brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aleds...@apache.org
Subject [1/3] incubator-brooklyn git commit: BROOKLYN-102: Fix MongoDB rebind
Date Mon, 15 Dec 2014 23:58:16 GMT
Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master b3cea88cf -> 41a553e55


BROOKLYN-102: Fix MongoDB rebind

- Declare STATUS_BSON as transient, so won’t be persisted
  (because that value failed to rebind)


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/ad74b23b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/ad74b23b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/ad74b23b

Branch: refs/heads/master
Commit: ad74b23bc015ecabcdd77850b891fd3e2033c099
Parents: 327c227
Author: Aled Sage <aled.sage@gmail.com>
Authored: Mon Dec 15 17:37:10 2014 +0000
Committer: Aled Sage <aled.sage@gmail.com>
Committed: Mon Dec 15 21:15:49 2014 +0000

----------------------------------------------------------------------
 .../entity/nosql/mongodb/MongoDBServer.java     |  7 ++-
 .../mongodb/MongoDBRebindIntegrationTest.java   | 60 ++++++++++++++++++++
 2 files changed, 65 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ad74b23b/software/nosql/src/main/java/brooklyn/entity/nosql/mongodb/MongoDBServer.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/brooklyn/entity/nosql/mongodb/MongoDBServer.java
b/software/nosql/src/main/java/brooklyn/entity/nosql/mongodb/MongoDBServer.java
index 5f216ab..489b1a0 100644
--- a/software/nosql/src/main/java/brooklyn/entity/nosql/mongodb/MongoDBServer.java
+++ b/software/nosql/src/main/java/brooklyn/entity/nosql/mongodb/MongoDBServer.java
@@ -25,6 +25,7 @@ import brooklyn.config.ConfigKey;
 import brooklyn.entity.basic.ConfigKeys;
 import brooklyn.entity.proxying.ImplementedBy;
 import brooklyn.event.AttributeSensor;
+import brooklyn.event.AttributeSensor.SensorPersistenceMode;
 import brooklyn.event.basic.BasicConfigKey;
 import brooklyn.event.basic.PortAttributeSensorAndConfigKey;
 import brooklyn.event.basic.Sensors;
@@ -48,8 +49,10 @@ public interface MongoDBServer extends AbstractMongoDBServer {
     AttributeSensor<String> HTTP_INTERFACE_URL = Sensors.newStringSensor(
             "mongodb.server.http_interface", "URL of the server's HTTP console");
 
-    AttributeSensor<BasicBSONObject> STATUS_BSON = Sensors.newSensor(BasicBSONObject.class,
-            "mongodb.server.status.bson", "Server status (BSON/JSON map ojbect)");
+    AttributeSensor<BasicBSONObject> STATUS_BSON = Sensors.builder(BasicBSONObject.class,
"mongodb.server.status.bson")
+            .description("Server status (BSON/JSON map ojbect)")
+            .persistence(SensorPersistenceMode.NONE)
+            .build();
     
     AttributeSensor<Double> UPTIME_SECONDS = Sensors.newDoubleSensor(
             "mongodb.server.uptime", "Server uptime in seconds");

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ad74b23b/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBRebindIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBRebindIntegrationTest.java
b/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBRebindIntegrationTest.java
new file mode 100644
index 0000000..4789624
--- /dev/null
+++ b/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBRebindIntegrationTest.java
@@ -0,0 +1,60 @@
+/*
+ * 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 org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import brooklyn.entity.proxying.EntitySpec;
+import brooklyn.entity.rebind.RebindTestFixtureWithApp;
+import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
+import brooklyn.test.EntityTestUtils;
+
+import com.google.common.base.Predicates;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
+
+public class MongoDBRebindIntegrationTest extends RebindTestFixtureWithApp {
+
+    private LocalhostMachineProvisioningLocation loc;
+    
+    @BeforeMethod(alwaysRun=true)
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        loc = origApp.newLocalhostProvisioningLocation();
+    }
+
+    @Test(groups = {"Integration"})
+    public void testRebindMongoDb() throws Exception {
+        MongoDBServer origEntity = origApp.createAndManageChild(EntitySpec.create(MongoDBServer.class)
+                .configure("mongodbConfTemplateUrl", "classpath:///test-mongodb.conf"));
+        origApp.start(ImmutableList.of(loc));
+        EntityTestUtils.assertAttributeEventuallyNonNull(origEntity, MongoDBServer.STATUS_BSON);
+
+        // rebind
+        rebind();
+        final MongoDBServer newEntity = (MongoDBServer) Iterables.find(newApp.getChildren(),
Predicates.instanceOf(MongoDBServer.class));
+
+        // confirm effectors still work on entity
+        EntityTestUtils.assertAttributeEqualsEventually(newEntity, MongoDBServer.SERVICE_UP,
true);
+        newEntity.stop();
+        EntityTestUtils.assertAttributeEqualsEventually(newEntity, MongoDBServer.SERVICE_UP,
false);
+    }
+}


Mime
View raw message