diff options
Diffstat (limited to 'config-proxy/src/test/java/com')
-rw-r--r-- | config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServerTest.java | 2 | ||||
-rw-r--r-- | config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseHandlerTest.java | 5 | ||||
-rw-r--r-- | config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponsesTest.java | 3 | ||||
-rw-r--r-- | config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MockClientUpdater.java | 52 | ||||
-rw-r--r-- | config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MockConfigSource.java | 11 | ||||
-rw-r--r-- | config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MockConfigSourceClient.java | 5 | ||||
-rw-r--r-- | config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ProxyServerTest.java | 22 | ||||
-rw-r--r-- | config-proxy/src/test/java/com/yahoo/vespa/config/proxy/RpcConfigSourceClientTest.java (renamed from config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ClientUpdaterTest.java) | 12 |
8 files changed, 18 insertions, 94 deletions
diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServerTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServerTest.java index 48456d8ac23..b810c6c7e4c 100644 --- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServerTest.java +++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServerTest.java @@ -46,7 +46,7 @@ public class ConfigProxyRpcServerTest { @Test public void basic() { - ProxyServer proxy = ProxyServer.createTestServer(new MockConfigSource(new MockClientUpdater())); + ProxyServer proxy = ProxyServer.createTestServer(new MockConfigSource()); Spec spec = new Spec("localhost", 12345); ConfigProxyRpcServer server = new ConfigProxyRpcServer(proxy, new Supervisor(new Transport()), spec); assertThat(server.getSpec(), is(spec)); diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseHandlerTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseHandlerTest.java index 3ac1af6c4d8..af83a86db41 100644 --- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseHandlerTest.java +++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponseHandlerTest.java @@ -14,7 +14,7 @@ import static org.junit.Assert.assertThat; */ public class DelayedResponseHandlerTest { - private final MockConfigSource source = new MockConfigSource(new MockClientUpdater()); + private final MockConfigSource source = new MockConfigSource(); @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder(); @@ -28,8 +28,7 @@ public class DelayedResponseHandlerTest { @Test public void basic() { ConfigTester tester = new ConfigTester(); - ConfigProxyStatistics statistics = new ConfigProxyStatistics(); - DelayedResponses delayedResponses = new DelayedResponses(statistics); + DelayedResponses delayedResponses = new DelayedResponses(); final MockRpcServer mockRpcServer = new MockRpcServer(); final MemoryCache memoryCache = new MemoryCache(); memoryCache.update(ConfigTester.fooConfig); diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponsesTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponsesTest.java index 4ea5f796ff5..3f960d2c37c 100644 --- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponsesTest.java +++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/DelayedResponsesTest.java @@ -8,14 +8,13 @@ import static org.junit.Assert.assertThat; /** * @author hmusum - * @since 5.1.9 */ public class DelayedResponsesTest { @Test public void basic() throws InterruptedException { ConfigTester tester = new ConfigTester(); - DelayedResponses responses = new DelayedResponses(new ConfigProxyStatistics()); + DelayedResponses responses = new DelayedResponses(); DelayedResponse delayedResponse = new DelayedResponse(tester.createRequest("foo", "id", "bar", 10)); responses.add(delayedResponse); diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MockClientUpdater.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MockClientUpdater.java deleted file mode 100644 index f399d1bb085..00000000000 --- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MockClientUpdater.java +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.config.proxy; - -import com.yahoo.vespa.config.ConfigKey; -import com.yahoo.vespa.config.RawConfig; - -import java.time.Duration; -import java.time.Instant; - -class MockClientUpdater extends ClientUpdater { - private RawConfig lastConfig; - - MockClientUpdater() { - this(new ConfigProxyStatistics()); - } - - private MockClientUpdater(ConfigProxyStatistics statistics) { - super(new MockRpcServer(), statistics, new DelayedResponses(statistics)); - } - - @Override - public synchronized void updateSubscribers(RawConfig newConfig) { - lastConfig = newConfig; - } - - synchronized RawConfig getLastConfig() { - return lastConfig; - } - - long waitForConfigGeneration(ConfigKey<?> configKey, long expectedGeneration) { - Instant end = Instant.now().plus(Duration.ofSeconds(60)); - RawConfig lastConfig; - do { - lastConfig = getLastConfig(); - System.out.println("config=" + lastConfig + (lastConfig == null ? "" : ",generation=" + lastConfig.getGeneration())); - if (lastConfig != null && lastConfig.getKey().equals(configKey) && - lastConfig.getGeneration() == expectedGeneration) { - break; - } else { - try { - Thread.sleep(10); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - } - } while (Instant.now().isBefore(end)); - - if (lastConfig == null || ! lastConfig.getKey().equals(configKey) || lastConfig.getGeneration() != expectedGeneration) - throw new RuntimeException("Did not get config " + configKey + " with generation " + expectedGeneration); - return lastConfig.getGeneration(); - } -} diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MockConfigSource.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MockConfigSource.java index 2b26996fbdc..3457cbcf576 100644 --- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MockConfigSource.java +++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MockConfigSource.java @@ -5,7 +5,6 @@ import com.yahoo.config.subscription.ConfigSourceSet; import com.yahoo.vespa.config.ConfigKey; import com.yahoo.vespa.config.RawConfig; -import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Set; @@ -15,20 +14,12 @@ import java.util.Set; * source. * * @author hmusum - * @since 5.1.10 */ class MockConfigSource extends ConfigSourceSet { private final HashMap<ConfigKey<?>, RawConfig> backing = new HashMap<>(); - private final ClientUpdater clientUpdater; - MockConfigSource(ClientUpdater clientUpdater) { - this.clientUpdater = clientUpdater; - } - - MockConfigSource put(ConfigKey<?> key, RawConfig config) { + void put(ConfigKey<?> key, RawConfig config) { backing.put(key, config); - clientUpdater.updateSubscribers(config); - return this; } RawConfig getConfig(ConfigKey<?> key) { diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MockConfigSourceClient.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MockConfigSourceClient.java index 5a15ade6968..963c922d5b5 100644 --- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MockConfigSourceClient.java +++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/MockConfigSourceClient.java @@ -51,4 +51,9 @@ public class MockConfigSourceClient implements ConfigSourceClient{ public List<String> getSourceConnections() { return Collections.singletonList("N/A"); } + + @Override + public void updateSubscribers(RawConfig config) { + + } } diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ProxyServerTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ProxyServerTest.java index 19732e4b5b5..9d6d0ca2a39 100644 --- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ProxyServerTest.java +++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ProxyServerTest.java @@ -21,8 +21,7 @@ import static org.junit.Assert.*; public class ProxyServerTest { private final MemoryCache memoryCache = new MemoryCache(); - private MockClientUpdater clientUpdater = new MockClientUpdater(); - private final MockConfigSource source = new MockConfigSource(clientUpdater); + private final MockConfigSource source = new MockConfigSource(); private MockConfigSourceClient client = new MockConfigSourceClient(source, memoryCache); private final ConfigProxyStatistics statistics = new ConfigProxyStatistics(); private ProxyServer proxy; @@ -227,25 +226,6 @@ public class ProxyServerTest { } @Test - public void testReconfigurationAsClient() { - long generation = 1; - RawConfig fooConfig = ConfigTester.fooConfig; - source.put(fooConfig.getKey(), fooConfig); - - clientUpdater.waitForConfigGeneration(fooConfig.getKey(), generation); - assertThat(clientUpdater.getLastConfig(), is(fooConfig)); - - // Update payload in config - generation++; - final ConfigPayload payload = ConfigTester.createConfigPayload("bar", "value2"); - RawConfig fooConfig2 = createConfigWithNextConfigGeneration(fooConfig, 0, Payload.from(payload)); - source.put(fooConfig2.getKey(), fooConfig2); - - clientUpdater.waitForConfigGeneration(fooConfig2.getKey(), generation); - assertFalse(clientUpdater.getLastConfig().equals(fooConfig)); - } - - @Test public void testReadingSystemProperties() { ProxyServer.Properties properties = ProxyServer.getSystemProperties(); assertThat(properties.eventInterval, is(ConfigProxyStatistics.defaultEventInterval)); diff --git a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ClientUpdaterTest.java b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/RpcConfigSourceClientTest.java index 25140afd4cc..7f762955b92 100644 --- a/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ClientUpdaterTest.java +++ b/config-proxy/src/test/java/com/yahoo/vespa/config/proxy/RpcConfigSourceClientTest.java @@ -15,12 +15,12 @@ import static org.junit.Assert.assertEquals; /** * @author hmusum */ -public class ClientUpdaterTest { +public class RpcConfigSourceClientTest { private MockRpcServer rpcServer; private ConfigProxyStatistics statistics; private DelayedResponses delayedResponses; - private ClientUpdater clientUpdater; + private RpcConfigSourceClient rpcConfigSourceClient; @Rule public TemporaryFolder tempFolder = new TemporaryFolder(); @@ -30,8 +30,10 @@ public class ClientUpdaterTest { public void setup() { rpcServer = new MockRpcServer(); statistics = new ConfigProxyStatistics(); - delayedResponses = new DelayedResponses(statistics); - clientUpdater = new ClientUpdater(rpcServer, statistics, delayedResponses); + delayedResponses = new DelayedResponses(); + rpcConfigSourceClient = + new RpcConfigSourceClient(rpcServer, new MockConfigSource(), statistics, + new MemoryCache(), ProxyServer.defaultTimingValues(), delayedResponses); } @Test @@ -103,7 +105,7 @@ public class ClientUpdaterTest { } private void configUpdatedSendResponse(RawConfig config) { - clientUpdater.updateSubscribers(config); + rpcConfigSourceClient.updateSubscribers(config); } private RawConfig createConfigWithNextConfigGeneration(RawConfig config) { |