Mercurial > stress-tester
changeset 921:5c94b8f2dc4b
AbstractWireMockTest dynamic port
author | Devel 2 |
---|---|
date | Thu, 26 Apr 2018 13:21:32 +0200 |
parents | 3a90f274cd0d |
children | ca0b914c317d |
files | stress-tester/src/test/java/com/passus/st/AbstractWireMockTest.java stress-tester/src/test/java/com/passus/st/client/http/HttpAsynchClientWorkerTest.java stress-tester/src/test/java/com/passus/st/client/http/HttpClientTest.java stress-tester/src/test/java/com/passus/st/client/http/HttpParallelClientWorkerTest.java stress-tester/src/test/java/com/passus/st/emitter/nio/NioEmitterTest.java stress-tester/src/test/java/com/passus/st/emitter/nio/NioEmitterWorker2Test.java |
diffstat | 6 files changed, 22 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/test/java/com/passus/st/AbstractWireMockTest.java Thu Apr 26 12:43:47 2018 +0200 +++ b/stress-tester/src/test/java/com/passus/st/AbstractWireMockTest.java Thu Apr 26 13:21:32 2018 +0200 @@ -12,7 +12,6 @@ */ public abstract class AbstractWireMockTest { - protected static final int PORT = 9999; protected static final String HOST = "127.0.0.1"; private WireMockServer wireMockServer; @@ -21,11 +20,21 @@ @BeforeClass public void beforeClass() { WireMockConfiguration config = WireMockConfiguration.wireMockConfig() - .port(PORT); + .dynamicPort(); wireMockServer = new WireMockServer(config); wireMockServer.start(); - WireMock.configureFor(HOST, PORT); - wireMock = new WireMock(HOST, PORT); + + int port = wireMockServer.port(); + WireMock.configureFor(HOST, port); + wireMock = new WireMock(HOST, port); + } + + protected int port() { + if(wireMockServer == null) { + return -1; + } + + return wireMockServer.port(); } @AfterMethod
--- a/stress-tester/src/test/java/com/passus/st/client/http/HttpAsynchClientWorkerTest.java Thu Apr 26 12:43:47 2018 +0200 +++ b/stress-tester/src/test/java/com/passus/st/client/http/HttpAsynchClientWorkerTest.java Thu Apr 26 13:21:32 2018 +0200 @@ -6,7 +6,6 @@ import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; import com.passus.commons.service.ServiceUtils; import com.passus.st.AbstractWireMockTest; -import com.passus.st.Log4jConfigurationFactory; import com.passus.st.client.Event; import com.passus.st.client.SessionEvent; import com.passus.st.client.SessionStatusEvent; @@ -55,7 +54,7 @@ List<Event> events = EventUtils.readEvents("pcap/http/http_req_resp.pcap", props); assertEquals(4, events.size()); - NioEmitter emitter = prepareEmitter("10.87.110.40:4214 -> " + HOST + ":" + PORT); + NioEmitter emitter = prepareEmitter("10.87.110.40:4214 -> " + HOST + ":" + port()); emitter.start(); TestHttpClientListener listner = new TestHttpClientListener();
--- a/stress-tester/src/test/java/com/passus/st/client/http/HttpClientTest.java Thu Apr 26 12:43:47 2018 +0200 +++ b/stress-tester/src/test/java/com/passus/st/client/http/HttpClientTest.java Thu Apr 26 13:21:32 2018 +0200 @@ -54,7 +54,7 @@ List<Event> events = EventUtils.readEvents("pcap/http/http_req_resp.pcap", props); assertEquals(4, events.size()); - NioEmitter emitter = prepareEmitter("10.87.110.40:4214 -> " + HOST + ":" + PORT); + NioEmitter emitter = prepareEmitter("10.87.110.40:4214 -> " + HOST + ":" + port()); emitter.start(); TestHttpClientListener listner = new TestHttpClientListener(); @@ -87,7 +87,7 @@ props.put("ports", "4214"); List<Event> events = EventUtils.readEvents("pcap/http/http_req_resp.pcap", props); - NioEmitter emitter = prepareEmitter("10.87.110.40:4214 -> " + HOST + ":" + PORT); + NioEmitter emitter = prepareEmitter("10.87.110.40:4214 -> " + HOST + ":" + port()); emitter.start(); HttpClient client = new HttpClient(emitter); @@ -121,7 +121,7 @@ SessionEvent sessionEvent = (SessionEvent) events.get(0); events.addFirst(new SessionStatusEvent(sessionEvent.getSessionInfo(), SessionStatusEvent.STATUS_ESTABLISHED)); - NioEmitter emitter = prepareEmitter("10.87.110.40:4214 -> " + HOST + ":" + PORT); + NioEmitter emitter = prepareEmitter("10.87.110.40:4214 -> " + HOST + ":" + port()); emitter.start(); TestHttpClientListener listener = new TestHttpClientListener();
--- a/stress-tester/src/test/java/com/passus/st/client/http/HttpParallelClientWorkerTest.java Thu Apr 26 12:43:47 2018 +0200 +++ b/stress-tester/src/test/java/com/passus/st/client/http/HttpParallelClientWorkerTest.java Thu Apr 26 13:21:32 2018 +0200 @@ -52,7 +52,7 @@ List<Event> events = EventUtils.readEvents("pcap/http/http_req_resp.pcap", props); assertEquals(4, events.size()); - NioEmitter emitter = prepareEmitter("10.87.110.40:4214 -> " + HOST + ":" + PORT); + NioEmitter emitter = prepareEmitter("10.87.110.40:4214 -> " + HOST + ":" + port()); emitter.start(); TestHttpClientListener listner = new TestHttpClientListener();
--- a/stress-tester/src/test/java/com/passus/st/emitter/nio/NioEmitterTest.java Thu Apr 26 12:43:47 2018 +0200 +++ b/stress-tester/src/test/java/com/passus/st/emitter/nio/NioEmitterTest.java Thu Apr 26 13:21:32 2018 +0200 @@ -54,7 +54,7 @@ NioEmitter emitter = new NioEmitter(); emitter.setMaxThreads(1); emitter.start(); - SessionInfo info = new SessionInfo("1.1.1.1", 5000, HOST, PORT); + SessionInfo info = new SessionInfo("1.1.1.1", 5000, HOST, port()); TestClientHandler handler = new TestClientHandler() { @Override @@ -88,7 +88,7 @@ NioEmitter emitter = new NioEmitter(); emitter.setMaxThreads(1); emitter.start(); - SessionInfo info = new SessionInfo("1.1.1.1", 5000, HOST, PORT); + SessionInfo info = new SessionInfo("1.1.1.1", 5000, HOST, port()); TestClientHandler handler = new TestClientHandler() {
--- a/stress-tester/src/test/java/com/passus/st/emitter/nio/NioEmitterWorker2Test.java Thu Apr 26 12:43:47 2018 +0200 +++ b/stress-tester/src/test/java/com/passus/st/emitter/nio/NioEmitterWorker2Test.java Thu Apr 26 13:21:32 2018 +0200 @@ -54,7 +54,7 @@ NioEmitter emitter = new NioEmitter(NioEmitterWorker2.class); emitter.setMaxThreads(1); emitter.start(); - SessionInfo info = new SessionInfo("1.1.1.1", 5000, HOST, PORT); + SessionInfo info = new SessionInfo("1.1.1.1", 5000, HOST, port()); TestClientHandler handler = new TestClientHandler() { @Override @@ -87,7 +87,7 @@ NioEmitter emitter = new NioEmitter(NioEmitterWorker2.class); emitter.setMaxThreads(1); emitter.start(); - SessionInfo info = new SessionInfo("1.1.1.1", 5000, HOST, PORT); + SessionInfo info = new SessionInfo("1.1.1.1", 5000, HOST, port()); TestClientHandler handler = new TestClientHandler() {