Return-Path: X-Original-To: apmail-brooklyn-commits-archive@minotaur.apache.org Delivered-To: apmail-brooklyn-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4226517E0D for ; Tue, 14 Oct 2014 10:05:19 +0000 (UTC) Received: (qmail 50916 invoked by uid 500); 14 Oct 2014 10:05:19 -0000 Delivered-To: apmail-brooklyn-commits-archive@brooklyn.apache.org Received: (qmail 50894 invoked by uid 500); 14 Oct 2014 10:05:19 -0000 Mailing-List: contact commits-help@brooklyn.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@brooklyn.incubator.apache.org Delivered-To: mailing list commits@brooklyn.incubator.apache.org Received: (qmail 50885 invoked by uid 99); 14 Oct 2014 10:05:19 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Oct 2014 10:05:19 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 14 Oct 2014 10:04:55 +0000 Received: (qmail 49227 invoked by uid 99); 14 Oct 2014 10:04:52 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 Oct 2014 10:04:52 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 1E2F6915FBA; Tue, 14 Oct 2014 10:04:52 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: richard@apache.org To: commits@brooklyn.incubator.apache.org Date: Tue, 14 Oct 2014 10:05:02 -0000 Message-Id: In-Reply-To: <639b39df2d094d2597b0301448995719@git.apache.org> References: <639b39df2d094d2597b0301448995719@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [12/16] git commit: Tidy MonitIntegrationTest, and comment why failing X-Virus-Checked: Checked by ClamAV on apache.org Tidy MonitIntegrationTest, and comment why failing Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/a78edf21 Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/a78edf21 Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/a78edf21 Branch: refs/heads/master Commit: a78edf215b43c894335c655827a7c49e563d5de0 Parents: f7c7330 Author: Aled Sage Authored: Mon Oct 13 21:31:04 2014 +0100 Committer: Aled Sage Committed: Mon Oct 13 21:31:04 2014 +0100 ---------------------------------------------------------------------- .../monitoring/monit/MonitIntegrationTest.java | 116 ++++++++----------- 1 file changed, 49 insertions(+), 67 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/a78edf21/software/monitoring/src/test/java/brooklyn/entity/monitoring/monit/MonitIntegrationTest.java ---------------------------------------------------------------------- diff --git a/software/monitoring/src/test/java/brooklyn/entity/monitoring/monit/MonitIntegrationTest.java b/software/monitoring/src/test/java/brooklyn/entity/monitoring/monit/MonitIntegrationTest.java index aaf246a..258440d 100644 --- a/software/monitoring/src/test/java/brooklyn/entity/monitoring/monit/MonitIntegrationTest.java +++ b/software/monitoring/src/test/java/brooklyn/entity/monitoring/monit/MonitIntegrationTest.java @@ -22,8 +22,17 @@ import static brooklyn.util.JavaGroovyEquivalents.elvis; import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotEquals; -import brooklyn.config.BrooklynProperties; -import brooklyn.entity.basic.ApplicationBuilder; +import java.io.File; +import java.io.IOException; +import java.nio.charset.Charset; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.Test; + +import brooklyn.entity.BrooklynAppLiveTestSupport; import brooklyn.entity.basic.Entities; import brooklyn.entity.basic.SameServerEntity; import brooklyn.entity.basic.SoftwareProcess; @@ -31,66 +40,60 @@ import brooklyn.entity.database.mysql.MySqlNode; import brooklyn.entity.proxying.EntitySpec; import brooklyn.event.basic.DependentConfiguration; import brooklyn.location.basic.LocalhostMachineProvisioningLocation; -import brooklyn.management.ManagementContext; -import brooklyn.management.internal.LocalManagementContext; import brooklyn.test.Asserts; -import brooklyn.test.entity.TestApplication; +import brooklyn.test.EntityTestUtils; + import com.google.common.base.Function; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.io.Files; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; -import java.io.File; -import java.io.IOException; -import java.nio.charset.Charset; -import java.util.Map; -public class MonitIntegrationTest { +public class MonitIntegrationTest extends BrooklynAppLiveTestSupport { + + /* + * FIXME Has the monit node output changed? Now it is listing 'cron' as well as system. + * It keeps reporting "Does" rather than "Running" as the status. + * Should we be getting the rest of the line after "status" (and trimming), rather than + * just the first word? + + input=The Monit daemon 5.9 uptime: 0m + Process 'cron' + status Does not exist + monitoring status Monitored + data collected Mon, 13 Oct 2014 21:27:01 + System 'aleds-macbook-pro.local' + status Running + monitoring status Monitored + load average [5.16] [4.73] [4.45] + cpu 7.1%us 5.7%sy + memory usage 11.6 GB [72.3%] + swap usage 3.0 GB [74.7%] + data collected Mon, 13 Oct 2014 21:27:01 + + */ private static final Logger LOG = LoggerFactory.getLogger(MonitIntegrationTest.class); - protected BrooklynProperties brooklynProperties; - protected ManagementContext managementContext; - protected TestApplication app; - - @BeforeMethod(alwaysRun = true) - public void setUp() { - brooklynProperties = BrooklynProperties.Factory.newDefault(); - managementContext = new LocalManagementContext(brooklynProperties); - app = ApplicationBuilder.newManagedApp(TestApplication.class, managementContext); - } + LocalhostMachineProvisioningLocation loc; - @AfterMethod(alwaysRun = true) - public void ensureShutDown() { - if (app != null) { - Entities.destroyAll(managementContext); - app = null; - } + @BeforeMethod(alwaysRun=true) + public void setUp() throws Exception { + super.setUp(); + loc = app.newLocalhostProvisioningLocation(); } @Test(groups = "Integration") public void test_localhost() throws InterruptedException { final MonitNode monitNode = app.createAndManageChild(EntitySpec.create(MonitNode.class) .configure(MonitNode.CONTROL_FILE_URL, "classpath:///brooklyn/entity/monitoring/monit/monit.monitrc")); - LocalhostMachineProvisioningLocation location = new LocalhostMachineProvisioningLocation(); - app.start(ImmutableSet.of(location)); + app.start(ImmutableSet.of(loc)); LOG.info("Monit started"); - Asserts.succeedsEventually(new Runnable() { - @Override - public void run() { - assertEquals(monitNode.getAttribute(MonitNode.MONIT_TARGET_PROCESS_STATUS), "Running"); - } - }); + EntityTestUtils.assertAttributeEqualsEventually(monitNode, MonitNode.MONIT_TARGET_PROCESS_STATUS, "Running"); } @Test(groups = "Integration") public void test_monitorMySql() throws InterruptedException { SameServerEntity sameServerEntity = app.createAndManageChild(EntitySpec.create(SameServerEntity.class)); - LocalhostMachineProvisioningLocation location = new LocalhostMachineProvisioningLocation(); MySqlNode mySqlNode = sameServerEntity.addChild(EntitySpec.create(MySqlNode.class)); Entities.manage(mySqlNode); Function> controlFileSubstitutionsFunction = new Function>() { @@ -104,16 +107,9 @@ public class MonitIntegrationTest { SoftwareProcess.PID_FILE, controlFileSubstitutionsFunction)); final MonitNode monitNode = sameServerEntity.addChild(monitSpec); Entities.manage(monitNode); - app.start(ImmutableSet.of(location)); + app.start(ImmutableSet.of(loc)); LOG.info("Monit and MySQL started"); - Asserts.succeedsEventually(new Runnable() { - @Override - public void run() { - String targetStatus = monitNode.getAttribute(MonitNode.MONIT_TARGET_PROCESS_STATUS); - LOG.debug("MonitNode target status: {}", targetStatus); - assertEquals(elvis(targetStatus, ""), "Running"); - } - }); + EntityTestUtils.assertAttributeEqualsEventually(monitNode, MonitNode.MONIT_TARGET_PROCESS_STATUS, "Running"); mySqlNode.stop(); Asserts.succeedsEventually(new Runnable() { @Override @@ -124,14 +120,7 @@ public class MonitIntegrationTest { } }); mySqlNode.restart(); - Asserts.succeedsEventually(new Runnable() { - @Override - public void run() { - String targetStatus = monitNode.getAttribute(MonitNode.MONIT_TARGET_PROCESS_STATUS); - LOG.debug("MonitNode target status: {}", targetStatus); - assertEquals(elvis(targetStatus, ""), "Running"); - } - }); + EntityTestUtils.assertAttributeEqualsEventually(monitNode, MonitNode.MONIT_TARGET_PROCESS_STATUS, "Running"); } @Test(groups = "Integration") @@ -145,7 +134,6 @@ public class MonitIntegrationTest { final String mySqlVersion = MySqlNode.SUGGESTED_VERSION.getDefaultValue(); SameServerEntity sameServerEntity = app.createAndManageChild(EntitySpec.create(SameServerEntity.class)); - LocalhostMachineProvisioningLocation location = new LocalhostMachineProvisioningLocation(); final MySqlNode mySqlNode = sameServerEntity.addChild(EntitySpec.create(MySqlNode.class) .configure(MySqlNode.INSTALL_DIR, mySqlInstallDir) .configure(MySqlNode.RUN_DIR, mySqlRunDir) @@ -167,7 +155,7 @@ public class MonitIntegrationTest { SoftwareProcess.PID_FILE, controlFileSubstitutionsFunction)); final MonitNode monitNode = sameServerEntity.addChild(monitSpec); Entities.manage(monitNode); - app.start(ImmutableSet.of(location)); + app.start(ImmutableSet.of(loc)); LOG.info("Monit and MySQL started"); final String[] initialPid = {""}; Asserts.succeedsEventually(new Runnable() { @@ -185,14 +173,8 @@ public class MonitIntegrationTest { } }); mySqlNode.stop(); - Asserts.succeedsEventually(new Runnable() { - @Override - public void run() { - String targetStatus = monitNode.getAttribute(MonitNode.MONIT_TARGET_PROCESS_STATUS); - LOG.debug("MonitNode target status: {}", targetStatus); - assertNotEquals(elvis(targetStatus, ""), "Running"); - } - }); + EntityTestUtils.assertAttributeEqualsEventually(monitNode, MonitNode.MONIT_TARGET_PROCESS_STATUS, "Running"); + // NOTE: Do not manually restart the mySqlNode, it should be restarted by monit Asserts.succeedsEventually(new Runnable() { @Override