You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2015/08/18 13:00:58 UTC
[43/64] incubator-brooklyn git commit: brooklyn-software-messaging:
add org.apache package prefix
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c14fef53/software/messaging/src/test/java/org/apache/brooklyn/entity/messaging/zookeeper/ZooKeeperEc2LiveTest.java
----------------------------------------------------------------------
diff --git a/software/messaging/src/test/java/org/apache/brooklyn/entity/messaging/zookeeper/ZooKeeperEc2LiveTest.java b/software/messaging/src/test/java/org/apache/brooklyn/entity/messaging/zookeeper/ZooKeeperEc2LiveTest.java
new file mode 100644
index 0000000..c905f38
--- /dev/null
+++ b/software/messaging/src/test/java/org/apache/brooklyn/entity/messaging/zookeeper/ZooKeeperEc2LiveTest.java
@@ -0,0 +1,48 @@
+/*
+ * 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 org.apache.brooklyn.entity.messaging.zookeeper;
+
+import org.apache.brooklyn.api.entity.proxying.EntitySpec;
+import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.test.EntityTestUtils;
+import org.testng.annotations.Test;
+
+import brooklyn.entity.AbstractEc2LiveTest;
+import brooklyn.entity.basic.Entities;
+import brooklyn.entity.trait.Startable;
+import org.apache.brooklyn.entity.zookeeper.ZooKeeperNode;
+
+import com.google.common.collect.ImmutableList;
+
+public class ZooKeeperEc2LiveTest extends AbstractEc2LiveTest {
+
+ /**
+ * Test that can install, start and use a Zookeeper instance.
+ */
+ @Override
+ protected void doTest(Location loc) throws Exception {
+ ZooKeeperNode zookeeper = app.createAndManageChild(EntitySpec.create(ZooKeeperNode.class).configure("jmxPort", "31001+"));
+ app.start(ImmutableList.of(loc));
+ Entities.dumpInfo(zookeeper);
+ EntityTestUtils.assertAttributeEqualsEventually(zookeeper, Startable.SERVICE_UP, true);
+ }
+
+ @Test(enabled=false)
+ public void testDummy() {} // Convince testng IDE integration that this really does have test methods
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c14fef53/software/messaging/src/test/java/org/apache/brooklyn/entity/messaging/zookeeper/ZooKeeperEnsembleLiveTest.java
----------------------------------------------------------------------
diff --git a/software/messaging/src/test/java/org/apache/brooklyn/entity/messaging/zookeeper/ZooKeeperEnsembleLiveTest.java b/software/messaging/src/test/java/org/apache/brooklyn/entity/messaging/zookeeper/ZooKeeperEnsembleLiveTest.java
new file mode 100644
index 0000000..c4ca441
--- /dev/null
+++ b/software/messaging/src/test/java/org/apache/brooklyn/entity/messaging/zookeeper/ZooKeeperEnsembleLiveTest.java
@@ -0,0 +1,127 @@
+/*
+ * 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 org.apache.brooklyn.entity.messaging.zookeeper;
+
+import brooklyn.entity.basic.ApplicationBuilder;
+import brooklyn.entity.basic.Attributes;
+import brooklyn.entity.basic.Entities;
+import brooklyn.entity.trait.Startable;
+import org.apache.brooklyn.entity.zookeeper.ZooKeeperEnsemble;
+import org.apache.brooklyn.entity.zookeeper.ZooKeeperNode;
+
+import com.google.common.base.Throwables;
+import com.google.common.collect.ImmutableList;
+import com.google.common.util.concurrent.Uninterruptibles;
+
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.api.entity.proxying.EntitySpec;
+import org.apache.brooklyn.api.location.Location;
+import org.apache.brooklyn.test.EntityTestUtils;
+import org.apache.brooklyn.test.entity.TestApplication;
+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.net.Socket;
+import java.util.concurrent.TimeUnit;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+/**
+ * A live test of the {@link org.apache.brooklyn.entity.zookeeper.ZooKeeperEnsemble} entity.
+ *
+ * Tests that a 3 node cluster can be started on Amazon EC2 and data written on one {@link org.apache.brooklyn.entity.zookeeper.ZooKeeperEnsemble}
+ * can be read from another, using the Astyanax API.
+ */
+public class ZooKeeperEnsembleLiveTest {
+
+ private static final Logger log = LoggerFactory.getLogger(ZooKeeperEnsembleLiveTest.class);
+
+ private String provider =
+ "gce-europe-west1";
+// "aws-ec2:eu-west-1";
+// "named:hpcloud-compute-at";
+// "localhost";
+
+ protected TestApplication app;
+ protected Location testLocation;
+ protected ZooKeeperEnsemble cluster;
+
+ @BeforeMethod(alwaysRun = true)
+ public void setup() {
+ app = ApplicationBuilder.newManagedApp(TestApplication.class);
+ testLocation = app.getManagementContext().getLocationRegistry().resolve(provider);
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void shutdown() {
+ Entities.destroyAll(app.getManagementContext());
+ }
+
+ /**
+ * Test that a two node cluster starts up and allows access through both nodes.
+ */
+ @Test(groups = "Live")
+ public void testStartUpConnectAndResize() throws Exception {
+ try {
+ cluster = app.createAndManageChild(EntitySpec.create(ZooKeeperEnsemble.class)
+ .configure("initialSize", 3)
+ .configure("clusterName", "ZooKeeperEnsembleLiveTest"));
+ assertEquals(cluster.getCurrentSize().intValue(), 0);
+
+ app.start(ImmutableList.of(testLocation));
+
+ EntityTestUtils.assertAttributeEqualsEventually(cluster, ZooKeeperEnsemble.GROUP_SIZE, 3);
+ Entities.dumpInfo(app);
+
+ EntityTestUtils.assertAttributeEqualsEventually(cluster, Startable.SERVICE_UP, true);
+ for(Entity zkNode : cluster.getMembers()) {
+ assertTrue(isSocketOpen((ZooKeeperNode) zkNode));
+ }
+ cluster.resize(1);
+ EntityTestUtils.assertAttributeEqualsEventually(cluster, ZooKeeperEnsemble.GROUP_SIZE, 1);
+ Entities.dumpInfo(app);
+ EntityTestUtils.assertAttributeEqualsEventually(cluster, Startable.SERVICE_UP, true);
+ for (Entity zkNode : cluster.getMembers()) {
+ assertTrue(isSocketOpen((ZooKeeperNode) zkNode));
+ }
+ } catch (Throwable e) {
+ throw Throwables.propagate(e);
+ }
+ }
+
+ protected static boolean isSocketOpen(ZooKeeperNode node) {
+ int attempt = 0, maxAttempts = 20;
+ while(attempt < maxAttempts) {
+ try {
+ Socket s = new Socket(node.getAttribute(Attributes.HOSTNAME), node.getZookeeperPort());
+ s.close();
+ return true;
+ } catch (Exception e) {
+ attempt++;
+ }
+ Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS);
+ }
+ return false;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c14fef53/usage/launcher/src/test/resources/opengamma-cluster.yaml
----------------------------------------------------------------------
diff --git a/usage/launcher/src/test/resources/opengamma-cluster.yaml b/usage/launcher/src/test/resources/opengamma-cluster.yaml
index ebb5c35..a532f41 100644
--- a/usage/launcher/src/test/resources/opengamma-cluster.yaml
+++ b/usage/launcher/src/test/resources/opengamma-cluster.yaml
@@ -28,7 +28,7 @@ services:
attributes:
postgresql:
sql: io/cloudsoft/opengamma/config/create-brooklyn-db.sql
- - type: brooklyn.entity.messaging.activemq.ActiveMQBroker
+ - type: org.apache.brooklyn.entity.messaging.activemq.ActiveMQBroker
id: og-amq
- type: Fabric
id: web-fabric
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/c14fef53/usage/launcher/src/test/resources/storm-blueprint.yaml
----------------------------------------------------------------------
diff --git a/usage/launcher/src/test/resources/storm-blueprint.yaml b/usage/launcher/src/test/resources/storm-blueprint.yaml
index 47e7af5..8271c1a 100644
--- a/usage/launcher/src/test/resources/storm-blueprint.yaml
+++ b/usage/launcher/src/test/resources/storm-blueprint.yaml
@@ -19,7 +19,7 @@
name: Storm Sample App
location: aws-ec2:us-east-1
services:
-- type: brooklyn.entity.messaging.storm.StormDeployment
+- type: org.apache.brooklyn.entity.messaging.storm.StormDeployment
name: Storm Deployment
brooklyn.config:
storm.supervisors.count: 5