diff options
author | gjoranv <gv@verizonmedia.com> | 2021-07-05 12:17:03 +0200 |
---|---|---|
committer | gjoranv <gv@verizonmedia.com> | 2021-07-05 12:17:18 +0200 |
commit | e2b4284cc36081747c13f121df3a84646faeda50 (patch) | |
tree | cf737aa5c9558613ad0b7aec9d13fb6265212774 /config-proxy/src/test/java/com/yahoo | |
parent | 82ef508085200f50b40e87a907dc592227ac7609 (diff) |
Reuse client and server to speed up test.
- From ~11.5 to ~3.5 sec
Diffstat (limited to 'config-proxy/src/test/java/com/yahoo')
-rw-r--r-- | config-proxy/src/test/java/com/yahoo/vespa/config/proxy/ConfigProxyRpcServerTest.java | 33 |
1 files changed, 22 insertions, 11 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 29bd38ea891..628e1c013e6 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 @@ -11,8 +11,8 @@ import com.yahoo.jrt.Supervisor; import com.yahoo.jrt.Target; import com.yahoo.jrt.Transport; import com.yahoo.vespa.config.RawConfig; -import org.junit.After; -import org.junit.Before; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; @@ -32,24 +32,29 @@ public class ConfigProxyRpcServerTest { private static final String hostname = "localhost"; private static final int port = 12345; private static final String configSourceAddress = "tcp/" + hostname + ":" + port; - private TestServer server; - private TestClient client; + private static TestServer server; + private static TestClient client; @Rule public TemporaryFolder temporaryFolder = new TemporaryFolder(); - @Before - public void setup() throws ListenFailedException { + @BeforeClass + public static void setup() throws ListenFailedException { server = new TestServer(); client = new TestClient(server.listenPort()); } - @After - public void teardown() { + @AfterClass + public static void teardown() { client.close(); server.close(); } + private static void reset() throws ListenFailedException { + teardown(); + setup(); + } + @Test public void basic() { ProxyServer proxy = createTestServer(new MockConfigSource()); @@ -75,7 +80,9 @@ public class ConfigProxyRpcServerTest { * Tests listCachedConfig RPC command */ @Test - public void testRpcMethodListCachedConfig() { + public void testRpcMethodListCachedConfig() throws ListenFailedException { + reset(); + Request req = new Request("listCachedConfig"); client.invoke(req); @@ -129,7 +136,9 @@ public class ConfigProxyRpcServerTest { * Tests printStatistics RPC command */ @Test - public void testRpcMethodListSourceConnections() { + public void testRpcMethodListSourceConnections() throws ListenFailedException { + reset(); + Request req = new Request("listSourceConnections"); client.invoke(req); @@ -218,7 +227,9 @@ public class ConfigProxyRpcServerTest { * Tests updateSources RPC command */ @Test - public void testRpcMethodUpdateSources() { + public void testRpcMethodUpdateSources() throws ListenFailedException { + reset(); + Request req = new Request("updateSources"); String spec1 = "tcp/a:19070"; String spec2 = "tcp/b:19070"; |