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/12/22 15:07:44 UTC
[5/7] incubator-brooklyn git commit: Add MongoDBRestartIntegrationTest
Add MongoDBRestartIntegrationTest
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/ba5edf98
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/ba5edf98
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/ba5edf98
Branch: refs/heads/master
Commit: ba5edf9893dc052aa28d34d54c9d1ebc2f3b9222
Parents: ccea3ec
Author: Aled Sage <al...@gmail.com>
Authored: Tue Dec 16 21:06:02 2014 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Tue Dec 16 22:53:15 2014 +0000
----------------------------------------------------------------------
.../mongodb/MongoDBRestartIntegrationTest.java | 88 ++++++++++++++++++++
1 file changed, 88 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ba5edf98/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBRestartIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBRestartIntegrationTest.java b/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBRestartIntegrationTest.java
new file mode 100644
index 0000000..c7376fe
--- /dev/null
+++ b/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBRestartIntegrationTest.java
@@ -0,0 +1,88 @@
+/*
+ * 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.entity.nosql.mongodb;
+
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.annotations.Test;
+
+import brooklyn.entity.BrooklynAppLiveTestSupport;
+import brooklyn.entity.Effector;
+import brooklyn.entity.basic.Entities;
+import brooklyn.entity.basic.Lifecycle;
+import brooklyn.entity.basic.ServiceStateLogic;
+import brooklyn.entity.basic.SoftwareProcess.RestartSoftwareParameters;
+import brooklyn.entity.basic.SoftwareProcess.StopSoftwareParameters;
+import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
+import brooklyn.test.EntityTestUtils;
+import brooklyn.util.collections.CollectionFunctionals;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Tests restart of the software *process* (as opposed to the VM).
+ */
+public class MongoDBRestartIntegrationTest extends BrooklynAppLiveTestSupport {
+
+ // TODO Remove duplication from TomcatServerRestartIntegrationTest and MySqlRestartIntegrationTest
+
+ @SuppressWarnings("unused")
+ private static final Logger LOG = LoggerFactory.getLogger(MongoDBRestartIntegrationTest.class);
+
+ @Test(groups="Integration")
+ public void testStopProcessAndRestart() throws Exception {
+ runStopProcessAndRestart(
+ MongoDBServer.RESTART,
+ ImmutableMap.of(RestartSoftwareParameters.RESTART_MACHINE.getName(), RestartSoftwareParameters.RestartMachineMode.FALSE));
+ }
+
+ @Test(groups="Integration")
+ public void testStopProcessAndStart() throws Exception {
+ runStopProcessAndRestart(
+ MongoDBServer.START,
+ ImmutableMap.of("locations", ImmutableList.of()));
+ }
+
+ protected void runStopProcessAndRestart(Effector<?> restartEffector, Map<String, ?> args) throws Exception {
+ LocalhostMachineProvisioningLocation loc = app.newLocalhostProvisioningLocation();
+ MongoDBServer entity = app.createAndManageChild(EntitySpec.create(MongoDBServer.class));
+ app.start(ImmutableList.of(loc));
+
+ Entities.invokeEffector(app, entity, MongoDBServer.STOP, ImmutableMap.of(
+ StopSoftwareParameters.STOP_MACHINE.getName(), false))
+ .get();
+ EntityTestUtils.assertAttributeEqualsEventually(entity, MongoDBServer.SERVICE_UP, false);
+ EntityTestUtils.assertAttributeEqualsEventually(entity, MongoDBServer.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED);
+ EntityTestUtils.assertAttributeEqualsEventually(entity, MongoDBServer.SERVICE_PROCESS_IS_RUNNING, false);
+ EntityTestUtils.assertAttributeEventually(entity, ServiceStateLogic.SERVICE_NOT_UP_INDICATORS, CollectionFunctionals.<String>mapSizeEquals(1));
+
+ Entities.invokeEffector(app, entity, restartEffector, args).get();
+ EntityTestUtils.assertAttributeEqualsEventually(entity, MongoDBServer.SERVICE_UP, true);
+ EntityTestUtils.assertAttributeEqualsEventually(entity, MongoDBServer.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
+ EntityTestUtils.assertAttributeEqualsEventually(entity, MongoDBServer.SERVICE_PROCESS_IS_RUNNING, true);
+ EntityTestUtils.assertAttributeEqualsEventually(entity, ServiceStateLogic.SERVICE_NOT_UP_INDICATORS, ImmutableMap.<String, Object>of());
+
+ EntityTestUtils.assertAttributeEqualsEventually(app, MongoDBServer.SERVICE_UP, true);
+ EntityTestUtils.assertAttributeEqualsEventually(app, MongoDBServer.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
+ }
+}