diff options
author | Harald Musum <musum@yahoo-inc.com> | 2017-03-15 09:47:15 +0100 |
---|---|---|
committer | Harald Musum <musum@yahoo-inc.com> | 2017-03-15 09:47:15 +0100 |
commit | f118be72d4aa6fddada4757e85abe80e2d605969 (patch) | |
tree | 50a813c5572d18fe7033570800862bc3a292dc99 /config-proxy | |
parent | 409c5922b4a3d210c1d8872c236dc1d3c8e99366 (diff) |
Make sure to update generation before adding error config
Diffstat (limited to 'config-proxy')
-rw-r--r-- | config-proxy/src/test/java/com/yahoo/vespa/config/proxy/UpstreamConfigSubscriberTest.java | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/UpstreamConfigSubscriberTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/UpstreamConfigSubscriberTest.java index 4a6858cfb19..138c54a3a16 100644 --- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/UpstreamConfigSubscriberTest.java +++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/UpstreamConfigSubscriberTest.java @@ -10,12 +10,13 @@ import com.yahoo.vespa.config.util.ConfigUtils; import org.junit.*; import org.junit.rules.TemporaryFolder; +import java.time.Duration; +import java.time.Instant; import java.util.LinkedHashMap; import java.util.Map; import java.util.Optional; import static junit.framework.TestCase.assertNotNull; -import static junit.framework.TestCase.fail; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -81,6 +82,7 @@ public class UpstreamConfigSubscriberTest { sourceResponses.put(fooConfig.getKey(), fooConfig); // Create config with error based on fooConfig + generation++; ConfigPayload errorConfigPayload = new ConfigPayload(new Slime()); Payload errorPayload = Payload.from(errorConfigPayload); ConfigKey<?> errorConfigKey = new ConfigKey<>("error", fooConfig.getConfigId(), fooConfig.getNamespace()); @@ -92,7 +94,7 @@ public class UpstreamConfigSubscriberTest { UpstreamConfigSubscriber subscriber = createUpstreamConfigSubscriber(errorConfig); waitForConfigGeneration(clientUpdater, errorConfigKey, generation); RawConfig lastConfig = clientUpdater.getLastConfig(); - assertEquals(lastConfig, errorConfig); + assertEquals(errorConfig, lastConfig); assertThat(lastConfig.errorCode(), is(ErrorCode.UNKNOWN_DEFINITION)); subscriber.cancel(); } @@ -106,13 +108,11 @@ public class UpstreamConfigSubscriberTest { } private void waitForConfigGeneration(MockClientUpdater clientUpdater, ConfigKey<?> configKey, long expectedGeneration) { - int i = 0; + Instant end = Instant.now().plus(Duration.ofSeconds(60)); RawConfig lastConfig; do { lastConfig = clientUpdater.getLastConfig(); - if (lastConfig != null) { - System.out.println("i=" + i + ", config=" + lastConfig + ",generation=" + lastConfig.getGeneration()); - } + System.out.println("config=" + lastConfig + (lastConfig == null ? "" : ",generation=" + lastConfig.getGeneration())); if (lastConfig != null && lastConfig.getKey().equals(configKey) && lastConfig.getGeneration() == expectedGeneration) { break; @@ -120,11 +120,11 @@ public class UpstreamConfigSubscriberTest { try { Thread.sleep(10); } catch (InterruptedException e) { - fail(e.getMessage()); + throw new RuntimeException(e); } } - i++; - } while (i < 5000); + } while (Instant.now().isBefore(end)); + assertNotNull(lastConfig); assertThat(lastConfig.getGeneration(), is(expectedGeneration)); assertThat(lastConfig.getKey(), is(configKey)); |