From a2a6ae288622d7cec396084376735d1f77c09328 Mon Sep 17 00:00:00 2001 From: Alex Heneveld Date: Fri, 14 Sep 2018 23:38:36 +0100 Subject: [PATCH 1/2] speed up a ssh feed test, from 5s to 20ms --- .../mgmt/rebind/RebindHistoricSshCommandSensorTest.java | 8 ++++++-- .../core/mgmt/rebind/ssh-command-sensor-feed-a9ekg3cnu0 | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindHistoricSshCommandSensorTest.java b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindHistoricSshCommandSensorTest.java index 9c923260c7..cd56d656ef 100644 --- a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindHistoricSshCommandSensorTest.java +++ b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/RebindHistoricSshCommandSensorTest.java @@ -28,6 +28,8 @@ import org.apache.brooklyn.test.Asserts; import org.apache.brooklyn.util.core.internal.ssh.RecordingSshTool; import org.apache.brooklyn.util.core.internal.ssh.RecordingSshTool.ExecCmd; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; @@ -36,6 +38,7 @@ public class RebindHistoricSshCommandSensorTest extends AbstractRebindHistoricTest { + private static final Logger log = LoggerFactory.getLogger(RebindHistoricSshCommandSensorTest.class); private static final String BLACKHOLE_IP = "240.0.0.1"; @Override @@ -89,9 +92,10 @@ public void testSshFeed_2018_02() throws Exception { .configure("address", BLACKHOLE_IP) .configure(SshMachineLocation.SSH_TOOL_CLASS, RecordingSshTool.class.getName())); entity.addLocations(ImmutableList.of(recordingLocalhostMachine)); - + // odd, if this _class_ is run it waits the full period before running the feed; + // but if this _test_ is run on its own it runs immediately. + // reduced period to 20ms in persisted state and now it always runs immediately. ExecCmd cmd = Asserts.succeedsEventually(() -> RecordingSshTool.getLastExecCmd()); - assertTrue(cmd.commands.toString().contains("echo 'myval'"), "cmds="+cmd.commands); assertEquals(cmd.env.get("MY_ENV"), "myEnvVal", "env="+cmd.env); assertTrue(cmd.commands.toString().contains("/path/to/myexecutiondir"), "cmds="+cmd.commands); diff --git a/core/src/test/resources/org/apache/brooklyn/core/mgmt/rebind/ssh-command-sensor-feed-a9ekg3cnu0 b/core/src/test/resources/org/apache/brooklyn/core/mgmt/rebind/ssh-command-sensor-feed-a9ekg3cnu0 index 240ff30818..f0bb95f071 100644 --- a/core/src/test/resources/org/apache/brooklyn/core/mgmt/rebind/ssh-command-sensor-feed-a9ekg3cnu0 +++ b/core/src/test/resources/org/apache/brooklyn/core/mgmt/rebind/ssh-command-sensor-feed-a9ekg3cnu0 @@ -59,7 +59,7 @@ under the License. myconf String - 5s + 20ms echo 'myval' @@ -124,7 +124,7 @@ under the License. 0 - 5000 + 20 From de32889cb3fb2110f5e0b2821b31a8afbdbf9b15 Mon Sep 17 00:00:00 2001 From: Alex Heneveld Date: Sat, 15 Sep 2018 00:48:16 +0100 Subject: [PATCH 2/2] fix non-det test failure that looks for entity state changes it just wasn't always waiting on the initial value --- .../camp/brooklyn/VanillaSoftwareProcessYamlTest.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/VanillaSoftwareProcessYamlTest.java b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/VanillaSoftwareProcessYamlTest.java index 5a9a207cc7..f88fbcc992 100644 --- a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/VanillaSoftwareProcessYamlTest.java +++ b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/VanillaSoftwareProcessYamlTest.java @@ -143,6 +143,10 @@ public void testDisableSshPolling() throws Exception { RecordingSensorEventListener serviceUpListener = subscribe(entity, Attributes.SERVICE_UP); RecordingSensorEventListener serviceStateListener = subscribe(entity, Attributes.SERVICE_STATE_ACTUAL); + // ensure these get the initial values because test relies on that later + assertEventsEqualEventually(serviceStateListener, ImmutableList.of(Lifecycle.CREATED), true); + assertEventsEqualEventually(serviceUpListener, ImmutableList.of(false), true); + Task task = app.invoke(Startable.START, ImmutableMap.of()); // Should eventually poll for 'checkRunning', before reporting 'up' @@ -217,6 +221,10 @@ public void testAlternativeServiceUpPolling() throws Exception { RecordingSensorEventListener serviceUpListener = subscribe(entity, Attributes.SERVICE_UP); RecordingSensorEventListener serviceStateListener = subscribe(entity, Attributes.SERVICE_STATE_ACTUAL); + // ensure these get the initial values because test relies on that later + assertEventsEqualEventually(serviceStateListener, ImmutableList.of(Lifecycle.CREATED), true); + assertEventsEqualEventually(serviceUpListener, ImmutableList.of(false), true); + Task task = app.invoke(Startable.START, ImmutableMap.of()); // Should eventually poll for 'checkRunning', but just once immediately after doing launch etc