diff --git a/ngrinder-controller/src/test/java/org/ngrinder/perftest/service/PerfTestRunnableTest.java b/ngrinder-controller/src/test/java/org/ngrinder/perftest/service/PerfTestRunnableTest.java index 0502846d0c..742f4a7ecb 100644 --- a/ngrinder-controller/src/test/java/org/ngrinder/perftest/service/PerfTestRunnableTest.java +++ b/ngrinder-controller/src/test/java/org/ngrinder/perftest/service/PerfTestRunnableTest.java @@ -121,7 +121,6 @@ public void before() throws IOException { } @Test - @Ignore public void testDoTest() throws IOException { assertThat(agentService.getAllAttachedFreeApprovedAgents().size(), is(1)); perfTestRunnable.doStart(); @@ -135,8 +134,6 @@ public void testDoTest() throws IOException { assertThat(consoleManager.getConsoleInUse().size(), is(0)); } - private boolean ended = false; - @Test public void testStartConsole() throws IOException { // Get perf test @@ -168,7 +165,6 @@ public void onSamplingStarted() { @Override public void onSamplingEnded() { - ended = true; } @Override diff --git a/ngrinder-core/src/main/java/org/ngrinder/infra/AgentConfig.java b/ngrinder-core/src/main/java/org/ngrinder/infra/AgentConfig.java index 38b528d24d..f74c517415 100644 --- a/ngrinder-core/src/main/java/org/ngrinder/infra/AgentConfig.java +++ b/ngrinder-core/src/main/java/org/ngrinder/infra/AgentConfig.java @@ -41,6 +41,7 @@ import static org.ngrinder.common.util.ExceptionUtils.processException; import static org.ngrinder.common.util.NoOp.noOp; import static org.ngrinder.common.util.Preconditions.checkNotNull; +import static org.ngrinder.common.util.StringUtils.defaultIfBlank; /** * Spring component which is responsible to get the nGrinder config which is stored @@ -328,7 +329,7 @@ public void setControllerIP(String ip) { } public String getControllerIP() { - return defaultIfEmpty(controllerIP, NetworkUtils.getLocalHostAddress()); + return defaultIfBlank(controllerIP, NetworkUtils::getLocalHostAddress); } public int getControllerPort() { @@ -420,5 +421,15 @@ protected AgentHome resolveHome() { } return resolveHome; } + + @Override + public String getControllerHost() { + return "127.0.0.1"; + } + + @Override + public String getControllerIP() { + return "127.0.0.1"; + } } } diff --git a/ngrinder-core/src/test/java/net/grinder/AgentControllerTest.java b/ngrinder-core/src/test/java/net/grinder/AgentControllerTest.java index 56760c3ece..bed864b0c0 100644 --- a/ngrinder-core/src/test/java/net/grinder/AgentControllerTest.java +++ b/ngrinder-core/src/test/java/net/grinder/AgentControllerTest.java @@ -48,13 +48,15 @@ public void before() { final int freePort = getFreePort(); agentControllerServerDaemon = new AgentControllerServerDaemon(freePort); agentControllerServerDaemon.start(); + agentConfig1.setControllerPort(freePort); agentControllerDaemon = new AgentControllerDaemon(agentConfig1); - agentControllerDaemon.run(); + agentConfig2.setControllerPort(freePort); agentControllerDaemon2 = new AgentControllerDaemon(agentConfig2); agentControllerDaemon2.run(); + sleep(2000); // Validate if all agents are well-attached. @@ -172,7 +174,7 @@ public void testConsoleCommunicationSettingTimeout() throws GrinderProperties.Pe FileUtils.copyFileToDirectory( new File(this.getClass().getResource("/long-time-prepare-test.py").getFile()), - new File("./tmp/agent-home/tmp_1/file-store/_default/incoming") + new File("./tmp/agent-home/tmp_0/file-store/_default/incoming") ); URL scriptUrl = this.getClass().getResource("/long-time-prepare-test.properties"); @@ -180,17 +182,14 @@ public void testConsoleCommunicationSettingTimeout() throws GrinderProperties.Pe GrinderProperties properties = new GrinderProperties(scriptFile); properties.setAssociatedFile(new File("long-time-prepare-test.properties")); final MutableBoolean timeouted = new MutableBoolean(false); - console1.addListener(new SingleConsole.ConsoleShutdownListener() { - @Override - public void readyToStop(StopReason stopReason) { - // Notice: it couldn't distinguish between a script error or - // timed out of the keepalive connection. - System.out.println("The stop signal is received " + stopReason); - if (stopReason.equals(SCRIPT_ERROR)) { - timeouted.setValue(true); - } - } - }); + console1.addListener(stopReason -> { + // Notice: it couldn't distinguish between a script error or + // timed out of the keepalive connection. + System.out.println("The stop signal is received " + stopReason); + if (stopReason.equals(SCRIPT_ERROR)) { + timeouted.setValue(true); + } + }); console1.startTest(properties); for (int i = 0; i < 20; i++) { diff --git a/ngrinder-core/src/test/java/org/ngrinder/AbstractMultiGrinderTestBase.java b/ngrinder-core/src/test/java/org/ngrinder/AbstractMultiGrinderTestBase.java index da535f72ad..d5c1f7351e 100644 --- a/ngrinder-core/src/test/java/org/ngrinder/AbstractMultiGrinderTestBase.java +++ b/ngrinder-core/src/test/java/org/ngrinder/AbstractMultiGrinderTestBase.java @@ -43,13 +43,13 @@ abstract public class AbstractMultiGrinderTestBase { @Before public void agentInit() { - agentConfig1 = new AgentConfig.NullAgentConfig(1); + agentConfig1 = new AgentConfig.NullAgentConfig(0); agentConfig1.init(); agentConfig2 = new AgentConfig.NullAgentConfig(1); agentConfig2.init(); - agentConfig3 = new AgentConfig.NullAgentConfig(1); + agentConfig3 = new AgentConfig.NullAgentConfig(2); agentConfig3.init(); } diff --git a/ngrinder-core/src/test/java/org/ngrinder/infra/AgentConfigTest.java b/ngrinder-core/src/test/java/org/ngrinder/infra/AgentConfigTest.java index 3999ec07e3..6dbe946b3b 100644 --- a/ngrinder-core/src/test/java/org/ngrinder/infra/AgentConfigTest.java +++ b/ngrinder-core/src/test/java/org/ngrinder/infra/AgentConfigTest.java @@ -1,4 +1,4 @@ -/* +/* * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -9,13 +9,12 @@ * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and - * limitations under the License. + * limitations under the License. */ package org.ngrinder.infra; import org.apache.commons.io.FileUtils; -import org.junit.Ignore; import org.junit.Test; import java.io.File; @@ -36,7 +35,6 @@ public class AgentConfigTest { * @throws IOException */ @Test - @Ignore public void testAgentConfigInitialization() throws IOException { // Given AgentConfig config = new AgentConfig();