You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2014/11/05 01:21:31 UTC
[1/8] git commit: Add comment to RebindCatalogEntityTest about failure
Repository: incubator-brooklyn
Updated Branches:
refs/heads/master 00b5a872b -> c398136f7
Add comment to RebindCatalogEntityTest about failure
- Non-deterministic failure seen once on jenkins
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/1a9636ac
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/1a9636ac
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/1a9636ac
Branch: refs/heads/master
Commit: 1a9636ac9e2eec4cfa6486320befe82fe2b0d8ca
Parents: 00b5a87
Author: Aled Sage <al...@gmail.com>
Authored: Tue Nov 4 22:31:17 2014 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Nov 4 22:31:17 2014 +0000
----------------------------------------------------------------------
.../java/brooklyn/entity/rebind/RebindCatalogEntityTest.java | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/1a9636ac/core/src/test/java/brooklyn/entity/rebind/RebindCatalogEntityTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/rebind/RebindCatalogEntityTest.java b/core/src/test/java/brooklyn/entity/rebind/RebindCatalogEntityTest.java
index eac2e35..2e3c621 100644
--- a/core/src/test/java/brooklyn/entity/rebind/RebindCatalogEntityTest.java
+++ b/core/src/test/java/brooklyn/entity/rebind/RebindCatalogEntityTest.java
@@ -42,6 +42,7 @@ import brooklyn.event.basic.Sensors;
import brooklyn.management.ha.ManagementNodeState;
import brooklyn.management.internal.LocalManagementContext;
import brooklyn.util.javalang.UrlClassLoader;
+import brooklyn.util.os.Os;
public class RebindCatalogEntityTest extends RebindTestFixture<StartableApplication> {
@@ -82,10 +83,7 @@ public class RebindCatalogEntityTest extends RebindTestFixture<StartableApplicat
super.setUp();
}
- // TODO Fails with an NPE trying to use:
- // managementContext.getCatalog().addToClasspath(url.toString())
- // classLoader = origManagementContext.getCatalog().getRootClassLoader();
- // appClazz = (Class<? extends AbstractApplication>) classLoader.loadClass(APP_CLASSNAME);
+ // TODO Failed in jenkins (once on 20141104, with invocationCount=100): mysensor was null post-rebind.
//
// Note: to test before/after behaviour (i.e. that we're really fixing what we think we are) then comment out the body of:
// AbstractMemento.injectTypeClass(Class)
[6/8] git commit: Extract portAvailable assertions to
NetworkingTestUtils
Posted by al...@apache.org.
Extract portAvailable assertions to NetworkingTestUtils
- Adds NetworkingTestUtils
- Cassandra assertions: if available, then log.info which ports were
checked.
Seeing strange errors in jenkins where this assertion passes, but
then it fails with RMI registry port seemingly not being available.
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/85d2f022
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/85d2f022
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/85d2f022
Branch: refs/heads/master
Commit: 85d2f0229b30ad49382cedbf4ba774ca9f291d35
Parents: 3eb8653
Author: Aled Sage <al...@gmail.com>
Authored: Tue Nov 4 23:22:49 2014 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Nov 4 23:24:01 2014 +0000
----------------------------------------------------------------------
.../cassandra/CassandraNodeIntegrationTest.java | 37 ++---------
.../java/brooklyn/test/NetworkingTestUtils.java | 68 ++++++++++++++++++++
2 files changed, 75 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/85d2f022/software/nosql/src/test/java/brooklyn/entity/nosql/cassandra/CassandraNodeIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/test/java/brooklyn/entity/nosql/cassandra/CassandraNodeIntegrationTest.java b/software/nosql/src/test/java/brooklyn/entity/nosql/cassandra/CassandraNodeIntegrationTest.java
index fc15c7d..4f780da 100644
--- a/software/nosql/src/test/java/brooklyn/entity/nosql/cassandra/CassandraNodeIntegrationTest.java
+++ b/software/nosql/src/test/java/brooklyn/entity/nosql/cassandra/CassandraNodeIntegrationTest.java
@@ -38,13 +38,10 @@ import brooklyn.entity.trait.Startable;
import brooklyn.event.basic.PortAttributeSensorAndConfigKey;
import brooklyn.test.Asserts;
import brooklyn.test.EntityTestUtils;
-import brooklyn.util.exceptions.Exceptions;
+import brooklyn.test.NetworkingTestUtils;
import brooklyn.util.math.MathPredicates;
-import brooklyn.util.net.Networking;
-import brooklyn.util.time.Duration;
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
/**
@@ -57,41 +54,21 @@ public class CassandraNodeIntegrationTest extends AbstractCassandraNodeTest {
private static final Logger LOG = LoggerFactory.getLogger(CassandraNodeIntegrationTest.class);
public static void assertCassandraPortsAvailableEventually() {
- // If we get into a TCP TIMED-WAIT state, it could take 4 minutes for the port to come available.
- // Could that be causing our integration tests to fail sometimes when run in the suite?!
- // Let's wait for the required ports in setup, rather than running+failing the test.
- Asserts.succeedsEventually(ImmutableMap.of("timeout", Duration.minutes(4)), new Runnable() {
- private boolean logged = false;
- public void run() {
- try {
- assertCassandraPortsAvailable();
- } catch (Throwable t) {
- if (!logged) {
- LOG.warn("Cassandra Port(s) not available; waiting for up to 4 minutes ("+Exceptions.getFirstInteresting(t)+")");
- logged = true;
- }
- throw Exceptions.propagate(t);
- }
- }});
- }
-
- public static void assertCassandraPortsAvailable() {
- for (Map.Entry<PortAttributeSensorAndConfigKey, Integer> entry : getCassandraDefaultPorts().entrySet()) {
- String errmsg = entry.getValue()+" not available for cassandra "+entry.getKey();
- assertTrue(Networking.isPortAvailable(entry.getValue()), errmsg);
- }
+ Map<String, Integer> ports = getCassandraDefaultPorts();
+ NetworkingTestUtils.assertPortsAvailableEventually(ports);
+ LOG.info("Confirmed Cassandra ports are available: "+ports);
}
- public static Map<PortAttributeSensorAndConfigKey, Integer> getCassandraDefaultPorts() {
+ public static Map<String, Integer> getCassandraDefaultPorts() {
List<PortAttributeSensorAndConfigKey> ports = ImmutableList.of(
CassandraNode.GOSSIP_PORT,
CassandraNode.SSL_GOSSIP_PORT,
CassandraNode.THRIFT_PORT,
CassandraNode.NATIVE_TRANSPORT_PORT,
CassandraNode.RMI_REGISTRY_PORT);
- Map<PortAttributeSensorAndConfigKey, Integer> result = Maps.newLinkedHashMap();
+ Map<String, Integer> result = Maps.newLinkedHashMap();
for (PortAttributeSensorAndConfigKey key : ports) {
- result.put(key, key.getConfigKey().getDefaultValue().iterator().next());
+ result.put(key.getName(), key.getConfigKey().getDefaultValue().iterator().next());
}
return result;
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/85d2f022/usage/test-support/src/main/java/brooklyn/test/NetworkingTestUtils.java
----------------------------------------------------------------------
diff --git a/usage/test-support/src/main/java/brooklyn/test/NetworkingTestUtils.java b/usage/test-support/src/main/java/brooklyn/test/NetworkingTestUtils.java
new file mode 100644
index 0000000..c55b4d3
--- /dev/null
+++ b/usage/test-support/src/main/java/brooklyn/test/NetworkingTestUtils.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software 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.
+ */
+package brooklyn.test;
+
+import static org.testng.Assert.assertTrue;
+
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import brooklyn.util.exceptions.Exceptions;
+import brooklyn.util.net.Networking;
+import brooklyn.util.time.Duration;
+
+import com.google.common.collect.ImmutableMap;
+
+public class NetworkingTestUtils {
+
+ private static final Logger LOG = LoggerFactory.getLogger(NetworkingTestUtils.class);
+
+ public static void assertPortsAvailableEventually(final Map<String, Integer> ports) {
+ // If we get into a TCP TIMED-WAIT state, it could take 4 minutes for the port to come available.
+ // Could that be causing our integration tests to fail sometimes when run in the suite?!
+ // Let's wait for the required ports in setup, rather than running+failing the test.
+ assertPortsAvailableEventually(ports, Duration.minutes(4));
+ }
+
+ public static void assertPortsAvailableEventually(final Map<String, Integer> ports, final Duration timeout) {
+ Asserts.succeedsEventually(ImmutableMap.of("timeout", Duration.minutes(4)), new Runnable() {
+ private boolean logged = false;
+ public void run() {
+ try {
+ assertPortsAvailable(ports);
+ } catch (Throwable t) {
+ if (!logged) {
+ LOG.warn("Port(s) not available; waiting for up to "+timeout+" ("+Exceptions.getFirstInteresting(t)+")");
+ logged = true;
+ }
+ throw Exceptions.propagate(t);
+ }
+ }});
+ LOG.debug("Ports are available: "+ports);
+ }
+
+ public static void assertPortsAvailable(final Map<String, Integer> ports) {
+ for (Map.Entry<String, Integer> entry : ports.entrySet()) {
+ String errmsg = "port "+entry.getValue()+" not available for "+entry.getKey();
+ assertTrue(Networking.isPortAvailable(entry.getValue()), errmsg);
+ }
+ }
+}
[8/8] git commit: This closes #300
Posted by al...@apache.org.
This closes #300
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/c398136f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/c398136f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/c398136f
Branch: refs/heads/master
Commit: c398136f77f66a7d8078b1510af5e2b3eb8fd33c
Parents: 00b5a87 2bf6c6b
Author: Aled Sage <al...@gmail.com>
Authored: Wed Nov 5 00:21:10 2014 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Wed Nov 5 00:21:10 2014 +0000
----------------------------------------------------------------------
.../util/task/DynamicSequentialTask.java | 50 ++++++++++----
.../entity/rebind/RebindCatalogEntityTest.java | 6 +-
.../java/brooklyn/entity/java/JmxSupport.java | 3 +-
.../monitoring/monit/MonitIntegrationTest.java | 28 ++++++--
.../monit/monitmysqlwithrestart.monitrc | 2 +-
.../cassandra/CassandraNodeIntegrationTest.java | 37 ++---------
.../NodeJsWebAppSimpleIntegrationTest.java | 19 ++----
.../test/entity/TestJavaWebAppEntityImpl.java | 2 +
.../java/brooklyn/test/NetworkingTestUtils.java | 68 ++++++++++++++++++++
9 files changed, 146 insertions(+), 69 deletions(-)
----------------------------------------------------------------------
[2/8] git commit: Fix MonitIntegrationTest
Posted by al...@apache.org.
Fix MonitIntegrationTest
- monitmysqlwithrestart.monitrc was previously hard-coding OS X!
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/00dd84c5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/00dd84c5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/00dd84c5
Branch: refs/heads/master
Commit: 00dd84c5b6dcd031ded199810160e10532470849
Parents: 1a9636a
Author: Aled Sage <al...@gmail.com>
Authored: Tue Nov 4 22:31:58 2014 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Nov 4 22:31:58 2014 +0000
----------------------------------------------------------------------
.../monitoring/monit/MonitIntegrationTest.java | 28 ++++++++++++++++----
.../monit/monitmysqlwithrestart.monitrc | 2 +-
2 files changed, 24 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/00dd84c5/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 6f8479c..94406a7 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
@@ -26,6 +26,7 @@ import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.Map;
+import java.util.concurrent.Callable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -40,6 +41,7 @@ import brooklyn.entity.basic.SoftwareProcess;
import brooklyn.entity.database.mysql.MySqlNode;
import brooklyn.entity.proxying.EntitySpec;
import brooklyn.event.basic.DependentConfiguration;
+import brooklyn.location.MachineDetails;
import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
import brooklyn.test.Asserts;
import brooklyn.test.EntityTestUtils;
@@ -76,7 +78,7 @@ public class MonitIntegrationTest extends BrooklynAppLiveTestSupport {
}
@Test(groups = "Integration")
- public void test_localhost() throws InterruptedException {
+ public void test_localhost() throws Exception {
final MonitNode monitNode = app.createAndManageChild(EntitySpec.create(MonitNode.class)
.configure(MonitNode.CONTROL_FILE_URL, "classpath:///brooklyn/entity/monitoring/monit/monit.monitrc"));
app.start(ImmutableSet.of(loc));
@@ -85,7 +87,7 @@ public class MonitIntegrationTest extends BrooklynAppLiveTestSupport {
}
@Test(groups = "Integration")
- public void test_monitorMySql() throws InterruptedException {
+ public void test_monitorMySql() throws Exception {
SameServerEntity sameServerEntity = app.createAndManageChild(EntitySpec.create(SameServerEntity.class));
MySqlNode mySqlNode = sameServerEntity.addChild(EntitySpec.create(MySqlNode.class));
Entities.manage(mySqlNode);
@@ -117,7 +119,21 @@ public class MonitIntegrationTest extends BrooklynAppLiveTestSupport {
}
@Test(groups = "Integration")
- public void test_monitorMySqlAutoRestart() throws InterruptedException {
+ public void test_monitorMySqlAutoRestart() throws Exception {
+ // This runs on localhost; free to obtain another machine with impunity.
+ final String osFlavor;
+ MachineDetails machineDetails = app.getExecutionContext().submit(new Callable<MachineDetails>() {
+ public MachineDetails call() throws Exception {
+ return loc.obtain().getMachineDetails();
+ }}).get();
+ if (machineDetails.getOsDetails().isMac()) {
+ osFlavor = "osx10.6-x86_64";
+ } else if (machineDetails.getOsDetails().isWindows()) {
+ throw new UnsupportedOperationException("Windows not supported for test_monitorMySqlAutoRestart");
+ } else {
+ osFlavor = "linux2.6-x86_64"; // assume 64 bit linux
+ }
+
// The monit node needs to know the installation and run directory of the mysql dir, so we need to specify it explicitly
File tempDir = Files.createTempDir();
tempDir.deleteOnExit();
@@ -138,10 +154,12 @@ public class MonitIntegrationTest extends BrooklynAppLiveTestSupport {
"targetPidFile", input,
"mySqlInstallDir", mySqlInstallDir,
"mySqlRunDir", mySqlRunDir,
- "mySqlVersion", mySqlVersion
+ "mySqlVersion", mySqlVersion,
+ "mySqlOsFlavor", osFlavor
);
}
};
+
EntitySpec<MonitNode> monitSpec = EntitySpec.create(MonitNode.class)
.configure(MonitNode.CONTROL_FILE_URL, "classpath:///brooklyn/entity/monitoring/monit/monitmysqlwithrestart.monitrc")
.configure(MonitNode.CONTROL_FILE_SUBSTITUTIONS, DependentConfiguration.valueWhenAttributeReady(mySqlNode,
@@ -182,7 +200,7 @@ public class MonitIntegrationTest extends BrooklynAppLiveTestSupport {
}
String targetStatus = monitNode.getAttribute(MonitNode.MONIT_TARGET_PROCESS_STATUS);
LOG.debug("MonitNode target status: {}", targetStatus);
- assertEquals(elvis(targetStatus, ""), "Running");
+ assertEquals(targetStatus, "Running");
}
});
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/00dd84c5/software/monitoring/src/test/resources/brooklyn/entity/monitoring/monit/monitmysqlwithrestart.monitrc
----------------------------------------------------------------------
diff --git a/software/monitoring/src/test/resources/brooklyn/entity/monitoring/monit/monitmysqlwithrestart.monitrc b/software/monitoring/src/test/resources/brooklyn/entity/monitoring/monit/monitmysqlwithrestart.monitrc
index 171fa71..ccd76dc 100644
--- a/software/monitoring/src/test/resources/brooklyn/entity/monitoring/monit/monitmysqlwithrestart.monitrc
+++ b/software/monitoring/src/test/resources/brooklyn/entity/monitoring/monit/monitmysqlwithrestart.monitrc
@@ -27,5 +27,5 @@ set logfile ${driver.runDir}/monit.log
check process mysqld with pidfile ${targetPidFile}
group database
mode active
- start program = "/bin/bash -c 'rm ${mySqlRunDir}/pid.txt ; ${mySqlInstallDir}/mysql-${mySqlVersion}-osx10.6-x86_64/bin/mysqld --defaults-file=${mySqlRunDir}/mymysql.cnf --user=root >> ${mySqlRunDir}/out.log 2>> ${mySqlRunDir}/err.log < /dev/null & echo $! > ${mySqlRunDir}/pid.txt'"
+ start program = "/bin/bash -c 'rm ${mySqlRunDir}/pid.txt ; ${mySqlInstallDir}/mysql-${mySqlVersion}-${mySqlOsFlavor}/bin/mysqld --defaults-file=${mySqlRunDir}/mymysql.cnf --user=root >> ${mySqlRunDir}/out.log 2>> ${mySqlRunDir}/err.log < /dev/null & echo $! > ${mySqlRunDir}/pid.txt'"
stop program = "/bin/bash -c 'kill -s SIGTERM $(cat ${mySqlRunDir}/pid.txt) ; kill -s KILL $(cat ${mySqlRunDir}/pid.txt) ; rm ${mySqlRunDir}/pid.txt'"
[7/8] git commit: Fix testTestJavaWebAppEntityStarts
Posted by al...@apache.org.
Fix testTestJavaWebAppEntityStarts
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/2bf6c6bd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/2bf6c6bd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/2bf6c6bd
Branch: refs/heads/master
Commit: 2bf6c6bd4940bf02e7413dece5695272e9ff12bd
Parents: 85d2f02
Author: Aled Sage <al...@gmail.com>
Authored: Wed Nov 5 00:18:24 2014 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Wed Nov 5 00:18:24 2014 +0000
----------------------------------------------------------------------
.../test/java/brooklyn/test/entity/TestJavaWebAppEntityImpl.java | 2 ++
1 file changed, 2 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2bf6c6bd/software/webapp/src/test/java/brooklyn/test/entity/TestJavaWebAppEntityImpl.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/test/entity/TestJavaWebAppEntityImpl.java b/software/webapp/src/test/java/brooklyn/test/entity/TestJavaWebAppEntityImpl.java
index ea7e440..579763d 100644
--- a/software/webapp/src/test/java/brooklyn/test/entity/TestJavaWebAppEntityImpl.java
+++ b/software/webapp/src/test/java/brooklyn/test/entity/TestJavaWebAppEntityImpl.java
@@ -51,6 +51,7 @@ public class TestJavaWebAppEntityImpl extends VanillaJavaAppImpl implements Test
public void start(java.util.Collection<? extends Location> locations) {
ServiceStateLogic.setExpectedState(entity(), Lifecycle.STARTING);
LOG.trace("Starting {}", this);
+ entity().setAttribute(SERVICE_PROCESS_IS_RUNNING, true);
entity().setAttribute(Attributes.SERVICE_UP, true);
ServiceStateLogic.setExpectedState(entity(), Lifecycle.RUNNING);
}
@@ -58,6 +59,7 @@ public class TestJavaWebAppEntityImpl extends VanillaJavaAppImpl implements Test
ServiceStateLogic.setExpectedState(entity(), Lifecycle.STOPPING);
LOG.trace("Stopping {}", this);
entity().setAttribute(Attributes.SERVICE_UP, false);
+ entity().setAttribute(SERVICE_PROCESS_IS_RUNNING, false);
ServiceStateLogic.setExpectedState(entity(), Lifecycle.STOPPED);
}
};
[5/8] git commit: On rmi registry port not available,
log what config said
Posted by al...@apache.org.
On rmi registry port not available, log what config said
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/3eb86535
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/3eb86535
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/3eb86535
Branch: refs/heads/master
Commit: 3eb86535f4b507c892a8912febf0574ec9851df7
Parents: 5f4cc2d
Author: Aled Sage <al...@gmail.com>
Authored: Tue Nov 4 23:06:58 2014 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Nov 4 23:06:58 2014 +0000
----------------------------------------------------------------------
software/base/src/main/java/brooklyn/entity/java/JmxSupport.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/3eb86535/software/base/src/main/java/brooklyn/entity/java/JmxSupport.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/java/JmxSupport.java b/software/base/src/main/java/brooklyn/entity/java/JmxSupport.java
index 88f76ea..0d93d02 100644
--- a/software/base/src/main/java/brooklyn/entity/java/JmxSupport.java
+++ b/software/base/src/main/java/brooklyn/entity/java/JmxSupport.java
@@ -269,7 +269,8 @@ public class JmxSupport implements UsesJmx {
switch (getJmxAgentMode()) {
case JMXMP_AND_RMI:
- result.put(JmxmpAgent.RMI_REGISTRY_PORT_PROPERTY, Preconditions.checkNotNull(entity.getAttribute(UsesJmx.RMI_REGISTRY_PORT), "registry port"));
+ Integer rmiRegistryPort = Preconditions.checkNotNull(entity.getAttribute(UsesJmx.RMI_REGISTRY_PORT), "registry port (config val %s)", entity.getConfig(UsesJmx.RMI_REGISTRY_PORT));
+ result.put(JmxmpAgent.RMI_REGISTRY_PORT_PROPERTY, rmiRegistryPort);
case JMXMP:
if (jmxRemotePort==null || jmxRemotePort<=0)
throw new IllegalStateException("Unsupported JMX port "+jmxRemotePort+" - when applying system properties ("+getJmxAgentMode()+" / "+getEntity()+")");
[4/8] git commit: DynamicSequentialTask: handle queue() when task
failed
Posted by al...@apache.org.
DynamicSequentialTask: handle queue() when task failed
- Previously, in NodeJs’s test detectFailureIfNodeJsBindToPort, it
would fail non-deterministically because of wrong exception being
propagated.
- If an error occurred in a sub-task, and then the main task’s thread
called queue(), that call would fail. That failure would be
propagated instead of the more interesting child exception.
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/5f4cc2d3
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/5f4cc2d3
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/5f4cc2d3
Branch: refs/heads/master
Commit: 5f4cc2d3b7c66b5dde0939d0e9a9aefb62f366cb
Parents: 467b9f7
Author: Aled Sage <al...@gmail.com>
Authored: Tue Nov 4 22:56:15 2014 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Nov 4 22:56:15 2014 +0000
----------------------------------------------------------------------
.../util/task/DynamicSequentialTask.java | 50 +++++++++++++++-----
1 file changed, 37 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/5f4cc2d3/core/src/main/java/brooklyn/util/task/DynamicSequentialTask.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/util/task/DynamicSequentialTask.java b/core/src/main/java/brooklyn/util/task/DynamicSequentialTask.java
index 34d8912..967c831 100644
--- a/core/src/main/java/brooklyn/util/task/DynamicSequentialTask.java
+++ b/core/src/main/java/brooklyn/util/task/DynamicSequentialTask.java
@@ -113,7 +113,17 @@ public class DynamicSequentialTask<T> extends BasicTask<T> implements HasTaskChi
public static final FailureHandlingConfig SWALLOWING_CHILDREN_FAILURES = new FailureHandlingConfig(false, false, false, false, false, false);
}
-
+ public static class QueueAbortedException extends IllegalStateException {
+ private static final long serialVersionUID = -7569362887826818524L;
+
+ public QueueAbortedException(String msg) {
+ super(msg);
+ }
+ public QueueAbortedException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+ }
+
/**
* Constructs a new compound task containing the specified units of work.
*
@@ -139,7 +149,7 @@ public class DynamicSequentialTask<T> extends BasicTask<T> implements HasTaskChi
if (primaryFinished)
throw new IllegalStateException("Cannot add a task to "+this+" which is already finished (trying to add "+t+")");
if (secondaryQueueAborted)
- throw new IllegalStateException("Cannot add a task to "+this+" whose queue has been aborted (trying to add "+t+")");
+ throw new QueueAbortedException("Cannot add a task to "+this+" whose queue has been aborted (trying to add "+t+")");
secondaryJobsAll.add(t);
secondaryJobsRemaining.add(t);
BrooklynTaskTags.addTagsDynamically(t, ManagementContextInternal.SUB_TASK_TAG);
@@ -154,7 +164,7 @@ public class DynamicSequentialTask<T> extends BasicTask<T> implements HasTaskChi
}
public boolean cancel(boolean mayInterruptTask, boolean interruptPrimaryThread, boolean alsoCancelChildren) {
if (isDone()) return false;
- log.trace("cancelling {}", this);
+ if (log.isTraceEnabled()) log.trace("cancelling {}", this);
boolean cancel = super.cancel(mayInterruptTask);
if (alsoCancelChildren) {
for (Task<?> t: secondaryJobsAll)
@@ -163,7 +173,7 @@ public class DynamicSequentialTask<T> extends BasicTask<T> implements HasTaskChi
synchronized (jobTransitionLock) {
if (primaryThread!=null) {
if (interruptPrimaryThread) {
- log.trace("cancelling {} - interrupting", this);
+ if (log.isTraceEnabled()) log.trace("cancelling {} - interrupting", this);
primaryThread.interrupt();
}
cancel = true;
@@ -231,6 +241,7 @@ public class DynamicSequentialTask<T> extends BasicTask<T> implements HasTaskChi
@SuppressWarnings("unchecked")
@Override
public T call() throws Exception {
+
synchronized (jobTransitionLock) {
primaryStarted = true;
primaryThread = Thread.currentThread();
@@ -318,15 +329,24 @@ public class DynamicSequentialTask<T> extends BasicTask<T> implements HasTaskChi
submitBackgroundInheritingContext(secondaryJobMaster);
T result = null;
- Throwable error=null;
- boolean errorIsFromChild=false;
+ Throwable error = null;
+ Throwable uninterestingSelfError = null;
+ boolean errorIsFromChild = false;
try {
- log.trace("calling primary job for {}", this);
+ if (log.isTraceEnabled()) log.trace("calling primary job for {}", this);
if (primaryJob!=null) result = primaryJob.call();
} catch (Throwable selfException) {
Exceptions.propagateIfFatal(selfException);
- error = selfException;
- errorIsFromChild = false;
+ if (Exceptions.getFirstThrowableOfType(selfException, QueueAbortedException.class) != null) {
+ // Error was caused by the task already having failed, and this thread calling queue() to try
+ // to queue more work. The underlying cause will be much more interesting.
+ // Without this special catch, we record error = "Cannot add a task to ... whose queue has been aborted",
+ // which gets propagated instead of the more interesting child exception.
+ uninterestingSelfError = selfException;
+ } else {
+ error = selfException;
+ errorIsFromChild = false;
+ }
if (failureHandlingConfig.abortSecondaryQueueOnPrimaryFailure) {
if (log.isDebugEnabled())
log.debug("Secondary job queue for "+DynamicSequentialTask.this+" aborting with "+secondaryJobsRemaining.size()+" remaining, due to error in primary task: "+selfException);
@@ -345,7 +365,7 @@ public class DynamicSequentialTask<T> extends BasicTask<T> implements HasTaskChi
}
} finally {
try {
- log.trace("cleaning up for {}", this);
+ if (log.isTraceEnabled()) log.trace("cleaning up for {}", this);
synchronized (jobTransitionLock) {
// semaphore might be nicer here (aled notes as it is this is a little hard to read)
primaryThread = null;
@@ -353,7 +373,7 @@ public class DynamicSequentialTask<T> extends BasicTask<T> implements HasTaskChi
jobTransitionLock.notifyAll();
}
if (!isCancelled() && !Thread.currentThread().isInterrupted()) {
- log.trace("waiting for secondaries for {}", this);
+ if (log.isTraceEnabled()) log.trace("waiting for secondaries for {}", this);
// wait on tasks sequentially so that blocking information is more interesting
DynamicTasks.waitForLast();
List<Object> result2 = secondaryJobMaster.get();
@@ -367,12 +387,16 @@ public class DynamicSequentialTask<T> extends BasicTask<T> implements HasTaskChi
error = childException;
errorIsFromChild = true;
} else {
- log.debug("Parent task "+this+" ignoring child error ("+childException+") in presence of our own error ("+error+")");
+ if (log.isDebugEnabled()) log.debug("Parent task "+this+" ignoring child error ("+childException+") in presence of our own error ("+error+")");
}
}
}
- if (error!=null)
+ if (error!=null) {
handleException(error, errorIsFromChild);
+ }
+ if (uninterestingSelfError != null) {
+ handleException(uninterestingSelfError, false);
+ }
return result;
}
[3/8] git commit: NodeJs: test tidy
Posted by al...@apache.org.
NodeJs: test tidy
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/467b9f7a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/467b9f7a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/467b9f7a
Branch: refs/heads/master
Commit: 467b9f7a685335d6b7134dba1a07b55b6c2ece09
Parents: 00dd84c
Author: Aled Sage <al...@gmail.com>
Authored: Tue Nov 4 22:33:40 2014 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Nov 4 22:33:40 2014 +0000
----------------------------------------------------------------------
.../NodeJsWebAppSimpleIntegrationTest.java | 19 ++++---------------
1 file changed, 4 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/467b9f7a/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSimpleIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSimpleIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSimpleIntegrationTest.java
index 010bea5..8f8aae9 100644
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSimpleIntegrationTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/webapp/nodejs/NodeJsWebAppSimpleIntegrationTest.java
@@ -25,17 +25,14 @@ import java.net.ServerSocket;
import java.util.Iterator;
import org.jclouds.util.Throwables2;
-import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import brooklyn.entity.basic.Entities;
+import brooklyn.entity.BrooklynAppLiveTestSupport;
import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.location.LocationSpec;
import brooklyn.location.PortRange;
import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
import brooklyn.location.basic.PortRanges;
-import brooklyn.test.entity.TestApplication;
import brooklyn.util.net.Networking;
import com.google.common.collect.ImmutableList;
@@ -43,12 +40,10 @@ import com.google.common.collect.ImmutableList;
/**
* This tests the operation of the {@link NodeJsWebAppService} entity.
*/
-public class NodeJsWebAppSimpleIntegrationTest {
+public class NodeJsWebAppSimpleIntegrationTest extends BrooklynAppLiveTestSupport {
private static PortRange DEFAULT_PORT_RANGE = PortRanges.fromString("3000-3099");
- private TestApplication app;
- private NodeJsWebAppService nodejs;
private int httpPort;
@BeforeMethod(alwaysRun=true)
@@ -63,19 +58,13 @@ public class NodeJsWebAppSimpleIntegrationTest {
fail("someone is already listening on ports "+DEFAULT_PORT_RANGE+"; tests assume that port is free on localhost");
}
- @AfterMethod(alwaysRun=true)
- public void tearDown() throws Exception {
- if (app != null) Entities.destroyAll(app.getManagementContext());
- }
-
@Test(groups="Integration")
public void detectFailureIfNodeJsBindToPort() throws Exception {
ServerSocket listener = new ServerSocket(httpPort);
try {
- app = TestApplication.Factory.newManagedInstanceForTests();
- nodejs = app.createAndManageChild(EntitySpec.create(NodeJsWebAppService.class).configure("httpPort", httpPort));
+ LocalhostMachineProvisioningLocation loc = app.newLocalhostProvisioningLocation();
+ NodeJsWebAppService nodejs = app.createAndManageChild(EntitySpec.create(NodeJsWebAppService.class).configure("httpPort", httpPort));
try {
- LocalhostMachineProvisioningLocation loc = app.getManagementContext().getLocationManager().createLocation(LocationSpec.create(LocalhostMachineProvisioningLocation.class));
nodejs.start(ImmutableList.of(loc));
fail("Should have thrown start-exception");
} catch (Exception e) {