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 2016/02/01 18:47:43 UTC
[07/51] [abbrv] [partial] brooklyn-library git commit: move subdir
from incubator up a level as it is promoted to its own repo (first
non-incubator commit!)
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraDatacenterLiveTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraDatacenterLiveTest.java b/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraDatacenterLiveTest.java
deleted file mode 100644
index 7279f92..0000000
--- a/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraDatacenterLiveTest.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- * 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.nosql.cassandra;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-import java.math.BigInteger;
-import java.net.Socket;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.core.entity.Attributes;
-import org.apache.brooklyn.core.entity.Entities;
-import org.apache.brooklyn.core.entity.trait.Startable;
-import org.apache.brooklyn.core.test.BrooklynAppLiveTestSupport;
-import org.apache.brooklyn.entity.nosql.cassandra.AstyanaxSupport.AstyanaxSample;
-import org.apache.brooklyn.test.Asserts;
-import org.apache.brooklyn.test.EntityTestUtils;
-import org.apache.brooklyn.util.collections.MutableMap;
-import org.apache.brooklyn.util.text.Identifiers;
-import org.apache.brooklyn.util.time.Duration;
-import org.apache.brooklyn.util.time.Time;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import com.netflix.astyanax.AstyanaxContext;
-import com.netflix.astyanax.Cluster;
-import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
-
-/**
- * A live test of the {@link CassandraDatacenter} entity.
- *
- * Tests that a two node cluster can be started on Amazon EC2 and data written on one {@link CassandraNode}
- * can be read from another, using the Astyanax API.
- */
-public class CassandraDatacenterLiveTest extends BrooklynAppLiveTestSupport {
-
- private static final Logger log = LoggerFactory.getLogger(CassandraDatacenterLiveTest.class);
-
- private String provider =
- "aws-ec2:eu-west-1";
-// "rackspace-cloudservers-uk";
-// "named:hpcloud-compute-at";
-// "localhost";
-// "jcloudsByon:(provider=\"aws-ec2\",region=\"us-east-1\",user=\"aled\",hosts=\"i-6f374743,i-35324219,i-1135453d\")";
-
- protected Location testLocation;
- protected CassandraDatacenter cluster;
-
- @BeforeMethod(alwaysRun = true)
- @Override
- public void setUp() throws Exception {
- super.setUp();
- testLocation = mgmt.getLocationRegistry().resolve(provider);
- }
-
- @AfterMethod(alwaysRun=true)
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
- @Test(groups = "Live")
- public void testDatacenter() throws Exception {
- EntitySpec<CassandraDatacenter> spec = EntitySpec.create(CassandraDatacenter.class)
- .configure("initialSize", 2)
- .configure("clusterName", "CassandraClusterLiveTest");
- runCluster(spec, false);
- }
-
- @Test(groups = "Live")
- public void testDatacenterWithVnodes() throws Exception {
- EntitySpec<CassandraDatacenter> spec = EntitySpec.create(CassandraDatacenter.class)
- .configure("initialSize", 2)
- .configure(CassandraDatacenter.USE_VNODES, true)
- .configure("clusterName", "CassandraClusterLiveTest");
- runCluster(spec, true);
- }
-
- /*
- * TODO on some distros (e.g. CentOS?), it comes pre-installed with java 6. Installing java 7
- * didn't seem to be enough. I also had to set JAVA_HOME:
- * .configure("shell.env", MutableMap.of("JAVA_HOME", "/etc/alternatives/java_sdk_1.7.0"))
- * However, that would break other deployments such as on Ubuntu where JAVA_HOME would be different.
- *
- * TODO In AWS eu-west-1, with the default image choice (ami-ad2404da, ubuntu-trusty-14.04-amd64-server-20150908),
- * `apt-get install openjdk-8-jdk` failed with the error "Unable to locate package openjdk-8-jdk".
- * This meant Cassandra failed to start, because no Java was installed.
- */
- @Test(groups = "Live")
- public void testDatacenterWithVnodesVersion2() throws Exception {
- EntitySpec<CassandraDatacenter> spec = EntitySpec.create(CassandraDatacenter.class)
- .configure("initialSize", 2)
- .configure(CassandraNode.SUGGESTED_VERSION, "2.0.9")
- .configure(CassandraDatacenter.USE_VNODES, true)
- .configure("clusterName", "CassandraClusterLiveTest");
- runCluster(spec, true);
- }
-
- @Test(groups = {"Live", "Acceptance"}, invocationCount=10)
- public void testManyTimes() throws Exception {
- testDatacenter();
- }
-
- /**
- * Test a Cassandra Datacenter:
- * <ol>
- * <li>Create two node datacenter
- * <li>Confirm allows access via the Astyanax API through both nodes.
- * <li>Confirm can size
- * </ol>
- */
- protected void runCluster(EntitySpec<CassandraDatacenter> datacenterSpec, boolean usesVnodes) throws Exception {
- cluster = app.createAndManageChild(datacenterSpec);
- assertEquals(cluster.getCurrentSize().intValue(), 0);
-
- app.start(ImmutableList.of(testLocation));
-
- // Check cluster is up and healthy
- EntityTestUtils.assertAttributeEqualsEventually(cluster, CassandraDatacenter.GROUP_SIZE, 2);
- Entities.dumpInfo(app);
- List<CassandraNode> members = castToCassandraNodes(cluster.getMembers());
- assertNodesConsistent(members);
-
- if (usesVnodes) {
- assertVnodeTokensConsistent(members);
- } else {
- assertSingleTokenConsistent(members);
- }
-
- // Can connect via Astyanax
- checkConnectionRepeatedly(2, 5, members);
-
- // Resize
- cluster.resize(3);
- assertEquals(cluster.getMembers().size(), 3, "members="+cluster.getMembers());
- if (usesVnodes) {
- assertVnodeTokensConsistent(castToCassandraNodes(cluster.getMembers()));
- } else {
- assertSingleTokenConsistent(castToCassandraNodes(cluster.getMembers()));
- }
- checkConnectionRepeatedly(2, 5, cluster.getMembers());
- }
-
- protected static List<CassandraNode> castToCassandraNodes(Collection<? extends Entity> rawnodes) {
- final List<CassandraNode> nodes = Lists.newArrayList();
- for (Entity node : rawnodes) {
- nodes.add((CassandraNode) node);
- }
- return nodes;
- }
-
- protected static void assertNodesConsistent(final List<CassandraNode> nodes) {
- final Integer expectedLiveNodeCount = nodes.size();
- // may take some time to be consistent (with new thrift_latency checks on the node,
- // contactability should not be an issue, but consistency still might be)
- Asserts.succeedsEventually(MutableMap.of("timeout", Duration.TWO_MINUTES), new Runnable() {
- public void run() {
- for (Entity n : nodes) {
- CassandraNode node = (CassandraNode) n;
- EntityTestUtils.assertAttributeEquals(node, Startable.SERVICE_UP, true);
- String errmsg = "node="+node+"; hostname="+node.getAttribute(Attributes.HOSTNAME)+"; port="+node.getThriftPort();
- assertTrue(isSocketOpen(node), errmsg);
- assertTrue(areVersionsConsistent(node), errmsg);
- EntityTestUtils.assertAttributeEquals(node, CassandraNode.LIVE_NODE_COUNT, expectedLiveNodeCount);
- }
- }});
- }
-
- protected static void assertSingleTokenConsistent(final List<CassandraNode> nodes) {
- final int numNodes = nodes.size();
- Asserts.succeedsEventually(MutableMap.of("timeout", Duration.TWO_MINUTES), new Runnable() {
- public void run() {
- Set<BigInteger> alltokens = Sets.newLinkedHashSet();
- for (Entity node : nodes) {
- EntityTestUtils.assertAttributeEquals(node, Startable.SERVICE_UP, true);
- EntityTestUtils.assertConfigEquals(node, CassandraNode.NUM_TOKENS_PER_NODE, 1);
- EntityTestUtils.assertAttributeEquals(node, CassandraNode.PEERS, numNodes);
- Set<BigInteger> tokens = node.getAttribute(CassandraNode.TOKENS);
- assertNotNull(tokens);
- alltokens.addAll(tokens);
- }
- assertFalse(alltokens.contains(null), "tokens="+alltokens);
- assertEquals(alltokens.size(), numNodes);
- }});
- }
-
- protected static void assertVnodeTokensConsistent(final List<CassandraNode> nodes) {
- final int numNodes = nodes.size();
- final int tokensPerNode = Iterables.get(nodes, 0).getNumTokensPerNode();
-
- Asserts.succeedsEventually(MutableMap.of("timeout", Duration.TWO_MINUTES), new Runnable() {
- public void run() {
- Set<BigInteger> alltokens = Sets.newLinkedHashSet();
- for (Entity node : nodes) {
- EntityTestUtils.assertAttributeEquals(node, Startable.SERVICE_UP, true);
- EntityTestUtils.assertAttributeEquals(node, CassandraNode.PEERS, tokensPerNode*numNodes);
- EntityTestUtils.assertConfigEquals(node, CassandraNode.NUM_TOKENS_PER_NODE, 256);
- Set<BigInteger> tokens = node.getAttribute(CassandraNode.TOKENS);
- assertNotNull(tokens);
- assertEquals(tokens.size(), tokensPerNode, "tokens="+tokens);
- alltokens.addAll(tokens);
- }
- assertFalse(alltokens.contains(null));
- assertEquals(alltokens.size(), tokensPerNode*numNodes);
- }});
- }
-
- protected static void checkConnectionRepeatedly(int totalAttemptsAllowed, int numRetriesPerAttempt, Iterable<? extends Entity> nodes) throws Exception {
- int attemptNum = 0;
- while (true) {
- try {
- checkConnection(numRetriesPerAttempt, nodes);
- return;
- } catch (Exception e) {
- attemptNum++;
- if (attemptNum >= totalAttemptsAllowed) {
- log.warn("Cassandra not usable, "+attemptNum+" attempts; failing: "+e, e);
- throw e;
- }
- log.warn("Cassandra not usable (attempt "+attemptNum+" of "+totalAttemptsAllowed+"), trying again after delay: "+e, e);
- Time.sleep(Duration.TEN_SECONDS);
- }
- }
- }
-
- protected static void checkConnection(int numRetries, Iterable<? extends Entity> nodes) throws ConnectionException {
- CassandraNode first = (CassandraNode) Iterables.get(nodes, 0);
-
- // have been seeing intermittent SchemaDisagreementException errors on AWS, probably due to Astyanax / how we are using it
- // (confirmed that clocks are in sync)
- String uniqueName = Identifiers.makeRandomId(8);
- AstyanaxSample astyanaxFirst = AstyanaxSample.builder().node(first).columnFamilyName(uniqueName).build();
- Map<String, List<String>> versions;
- AstyanaxContext<Cluster> context = astyanaxFirst.newAstyanaxContextForCluster();
- try {
- versions = context.getEntity().describeSchemaVersions();
- } finally {
- context.shutdown();
- }
-
- log.info("Cassandra schema versions are: "+versions);
- if (versions.size() > 1) {
- Assert.fail("Inconsistent versions on Cassandra start: "+versions);
- }
- String keyspacePrefix = "BrooklynTests_"+Identifiers.makeRandomId(8);
-
- String keyspaceName = astyanaxFirst.writeData(keyspacePrefix, numRetries);
-
- for (Entity node : nodes) {
- AstyanaxSample astyanaxSecond = AstyanaxSample.builder().node((CassandraNode)node).columnFamilyName(uniqueName).build();
- astyanaxSecond.readData(keyspaceName, numRetries);
- }
- }
-
- protected static Boolean areVersionsConsistent(CassandraNode node) {
- AstyanaxContext<Cluster> context = null;
- try {
- context = new AstyanaxSample(node).newAstyanaxContextForCluster();
- Map<String, List<String>> v = context.getEntity().describeSchemaVersions();
- return v.size() == 1;
- } catch (Exception e) {
- return null;
- } finally {
- if (context != null) context.shutdown();
- }
- }
-
- protected static boolean isSocketOpen(CassandraNode node) {
- try {
- Socket s = new Socket(node.getAttribute(Attributes.HOSTNAME), node.getThriftPort());
- s.close();
- return true;
- } catch (Exception e) {
- return false;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraDatacenterRebindIntegrationTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraDatacenterRebindIntegrationTest.java b/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraDatacenterRebindIntegrationTest.java
deleted file mode 100644
index 89b03da..0000000
--- a/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraDatacenterRebindIntegrationTest.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * 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.nosql.cassandra;
-
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNotNull;
-
-import java.math.BigInteger;
-import java.util.Set;
-
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.core.entity.trait.Startable;
-import org.apache.brooklyn.core.mgmt.rebind.RebindOptions;
-import org.apache.brooklyn.core.mgmt.rebind.RebindTestFixtureWithApp;
-import org.apache.brooklyn.entity.proxy.nginx.NginxController;
-import org.apache.brooklyn.test.EntityTestUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
-
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-
-/**
- * Test the operation of the {@link NginxController} class.
- */
-public class CassandraDatacenterRebindIntegrationTest extends RebindTestFixtureWithApp {
- @SuppressWarnings("unused")
- private static final Logger LOG = LoggerFactory.getLogger(CassandraDatacenterRebindIntegrationTest.class);
-
- private LocalhostMachineProvisioningLocation localhostProvisioningLocation;
-
- @BeforeMethod(alwaysRun=true)
- public void setUp() throws Exception {
- CassandraNodeIntegrationTest.assertCassandraPortsAvailableEventually();
- super.setUp();
- localhostProvisioningLocation = origApp.newLocalhostProvisioningLocation();
- }
-
- @AfterMethod(alwaysRun=true)
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- CassandraNodeIntegrationTest.assertCassandraPortsAvailableEventually();
- }
-
- /**
- * Test that Brooklyn can rebind to a single node datacenter.
- */
- @Test(groups = "Integration")
- public void testRebindDatacenterOfSizeOne() throws Exception {
- CassandraDatacenter origDatacenter = origApp.createAndManageChild(EntitySpec.create(CassandraDatacenter.class)
- .configure("initialSize", 1));
-
- origApp.start(ImmutableList.of(localhostProvisioningLocation));
- CassandraNode origNode = (CassandraNode) Iterables.get(origDatacenter.getMembers(), 0);
-
- EntityTestUtils.assertAttributeEqualsEventually(origDatacenter, CassandraDatacenter.GROUP_SIZE, 1);
- CassandraDatacenterLiveTest.assertNodesConsistent(ImmutableList.of(origNode));
- CassandraDatacenterLiveTest.assertSingleTokenConsistent(ImmutableList.of(origNode));
- CassandraDatacenterLiveTest.checkConnectionRepeatedly(2, 5, ImmutableList.of(origNode));
- Set<BigInteger> origTokens = origNode.getAttribute(CassandraNode.TOKENS);
- assertNotNull(origTokens);
- assertFalse(origTokens.contains(null), "tokens="+origTokens);
-
- newApp = rebind(RebindOptions.create().terminateOrigManagementContext(true));
- final CassandraDatacenter newDatacenter = (CassandraDatacenter) Iterables.find(newApp.getChildren(), Predicates.instanceOf(CassandraDatacenter.class));
- final CassandraNode newNode = (CassandraNode) Iterables.find(newDatacenter.getMembers(), Predicates.instanceOf(CassandraNode.class));
-
- EntityTestUtils.assertAttributeEqualsEventually(newDatacenter, CassandraDatacenter.GROUP_SIZE, 1);
- EntityTestUtils.assertAttributeEqualsEventually(newNode, Startable.SERVICE_UP, true);
- EntityTestUtils.assertAttributeEqualsEventually(newNode, CassandraNode.TOKENS, origTokens);
- CassandraDatacenterLiveTest.assertNodesConsistent(ImmutableList.of(newNode));
- CassandraDatacenterLiveTest.assertSingleTokenConsistent(ImmutableList.of(newNode));
- CassandraDatacenterLiveTest.checkConnectionRepeatedly(2, 5, ImmutableList.of(newNode));
- }
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraDatacenterTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraDatacenterTest.java b/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraDatacenterTest.java
deleted file mode 100644
index 2c978b2..0000000
--- a/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraDatacenterTest.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * 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.nosql.cassandra;
-
-import static org.testng.Assert.assertEquals;
-
-import java.math.BigInteger;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.location.LocationSpec;
-import org.apache.brooklyn.core.entity.Attributes;
-import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
-import org.apache.brooklyn.entity.software.base.EmptySoftwareProcess;
-import org.apache.brooklyn.entity.software.base.EmptySoftwareProcessSshDriver;
-import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
-import org.apache.brooklyn.test.EntityTestUtils;
-import org.apache.brooklyn.util.core.ResourceUtils;
-import org.apache.brooklyn.util.core.text.TemplateProcessor;
-import org.apache.brooklyn.util.javalang.JavaClassNames;
-import org.apache.brooklyn.util.time.Duration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Sets;
-
-public class CassandraDatacenterTest extends BrooklynAppUnitTestSupport {
-
- private static final Logger log = LoggerFactory.getLogger(CassandraDatacenterTest.class);
-
- private LocalhostMachineProvisioningLocation loc;
- private CassandraDatacenter cluster;
-
- @BeforeMethod(alwaysRun=true)
- @Override
- public void setUp() throws Exception {
- super.setUp();
- loc = mgmt.getLocationManager().createLocation(LocationSpec.create(LocalhostMachineProvisioningLocation.class));
- }
-
- @Test
- public void testPopulatesInitialSeeds() throws Exception {
- cluster = app.createAndManageChild(EntitySpec.create(CassandraDatacenter.class)
- .configure(CassandraDatacenter.INITIAL_SIZE, 2)
- .configure(CassandraDatacenter.TOKEN_SHIFT, BigInteger.ZERO)
- .configure(CassandraDatacenter.DELAY_BEFORE_ADVERTISING_CLUSTER, Duration.ZERO)
- .configure(CassandraDatacenter.MEMBER_SPEC, EntitySpec.create(EmptySoftwareProcess.class)));
-
- app.start(ImmutableList.of(loc));
- EmptySoftwareProcess e1 = (EmptySoftwareProcess) Iterables.get(cluster.getMembers(), 0);
- EmptySoftwareProcess e2 = (EmptySoftwareProcess) Iterables.get(cluster.getMembers(), 1);
-
- EntityTestUtils.assertAttributeEqualsEventually(cluster, CassandraDatacenter.CURRENT_SEEDS, ImmutableSet.<Entity>of(e1, e2));
- }
-
- @Test(groups="Integration") // because takes approx 2 seconds
- public void testUpdatesSeedsOnFailuresAndAdditions() throws Exception {
- doTestUpdatesSeedsOnFailuresAndAdditions(true, false);
- }
-
- protected void doTestUpdatesSeedsOnFailuresAndAdditions(boolean fast, boolean checkSeedsConstantOnRejoining) throws Exception {
- cluster = app.createAndManageChild(EntitySpec.create(CassandraDatacenter.class)
- .configure(CassandraDatacenter.INITIAL_SIZE, 2)
- .configure(CassandraDatacenter.TOKEN_SHIFT, BigInteger.ZERO)
- .configure(CassandraDatacenter.DELAY_BEFORE_ADVERTISING_CLUSTER, Duration.ZERO)
- .configure(CassandraDatacenter.MEMBER_SPEC, EntitySpec.create(EmptySoftwareProcess.class)));
-
- app.start(ImmutableList.of(loc));
- EmptySoftwareProcess e1 = (EmptySoftwareProcess) Iterables.get(cluster.getMembers(), 0);
- EmptySoftwareProcess e2 = (EmptySoftwareProcess) Iterables.get(cluster.getMembers(), 1);
- EntityTestUtils.assertAttributeEqualsEventually(cluster, CassandraDatacenter.CURRENT_SEEDS, ImmutableSet.<Entity>of(e1, e2));
- log.debug("Test "+JavaClassNames.niceClassAndMethod()+", cluster "+cluster+" has "+cluster.getMembers()+"; e1="+e1+" e2="+e2);
-
- // calling the driver stop for this entity will cause SERVICE_UP to become false, and stay false
- // (and that's all it does, incidentally); if we just set the attribute it will become true on serviceUp sensor feed
- log.info("Simulating failure of cassandra node "+e1);
- ((EmptySoftwareProcess)e1).getDriver().stop();
- // not necessary, but speeds things up:
- if (fast)
- e1.sensors().set(Attributes.SERVICE_UP, false);
-
- EntityTestUtils.assertAttributeEqualsEventually(cluster, CassandraDatacenter.CURRENT_SEEDS, ImmutableSet.<Entity>of(e2));
-
- cluster.resize(3);
- EmptySoftwareProcess e3 = (EmptySoftwareProcess) Iterables.getOnlyElement(Sets.difference(ImmutableSet.copyOf(cluster.getMembers()), ImmutableSet.of(e1,e2)));
- log.debug("Test "+JavaClassNames.niceClassAndMethod()+", cluster "+cluster+" has "+cluster.getMembers()+"; e3="+e3);
- try {
- EntityTestUtils.assertAttributeEqualsEventually(cluster, CassandraDatacenter.CURRENT_SEEDS, ImmutableSet.<Entity>of(e2, e3));
- } finally {
- log.debug("Test "+JavaClassNames.niceClassAndMethod()+", cluster "+cluster+" has "+cluster.getMembers()+"; seeds "+cluster.getAttribute(CassandraDatacenter.CURRENT_SEEDS));
- }
-
- if (!checkSeedsConstantOnRejoining) {
- // cluster should not revert to e1+e2, simply because e1 has come back; but e1 should rejoin the group
- // (not that important, and waits for 1s, so only done as part of integration)
- ((EmptySoftwareProcessSshDriver)(((EmptySoftwareProcess)e1).getDriver())).launch();
- if (fast)
- e1.sensors().set(Attributes.SERVICE_UP, true);
- EntityTestUtils.assertAttributeEqualsEventually(e1, CassandraNode.SERVICE_UP, true);
- EntityTestUtils.assertAttributeEqualsContinually(cluster, CassandraDatacenter.CURRENT_SEEDS, ImmutableSet.<Entity>of(e2, e3));
- }
- }
-
- @Test
- public void testPopulatesInitialTokens() throws Exception {
- cluster = app.createAndManageChild(EntitySpec.create(CassandraDatacenter.class)
- .configure(CassandraDatacenter.INITIAL_SIZE, 2)
- .configure(CassandraDatacenter.TOKEN_SHIFT, BigInteger.ZERO)
- .configure(CassandraDatacenter.DELAY_BEFORE_ADVERTISING_CLUSTER, Duration.ZERO)
- .configure(CassandraDatacenter.MEMBER_SPEC, EntitySpec.create(EmptySoftwareProcess.class)));
-
- app.start(ImmutableList.of(loc));
-
- Set<BigInteger> tokens = Sets.newLinkedHashSet();
- for (Entity member : cluster.getMembers()) {
- Set<BigInteger > memberTokens = member.getConfig(CassandraNode.TOKENS);
- if (memberTokens != null) tokens.addAll(memberTokens);
- }
- assertEquals(tokens, ImmutableSet.of(new BigInteger("-9223372036854775808"), BigInteger.ZERO));
- }
-
- @Test
- public void testDoesNotPopulateInitialTokens() throws Exception {
- cluster = app.createAndManageChild(EntitySpec.create(CassandraDatacenter.class)
- .configure(CassandraDatacenter.INITIAL_SIZE, 2)
- .configure(CassandraDatacenter.USE_VNODES, true)
- .configure(CassandraDatacenter.DELAY_BEFORE_ADVERTISING_CLUSTER, Duration.ZERO)
- .configure(CassandraDatacenter.MEMBER_SPEC, EntitySpec.create(EmptySoftwareProcess.class)));
-
- app.start(ImmutableList.of(loc));
-
- Set<BigInteger> tokens = Sets.newLinkedHashSet();
- for (Entity member : cluster.getMembers()) {
- Set<BigInteger > memberTokens = member.getConfig(CassandraNode.TOKENS);
- if (memberTokens != null) tokens.addAll(memberTokens);
- }
- assertEquals(tokens, ImmutableSet.of());
- }
-
- public static class MockInputForTemplate {
- public BigInteger getToken() { return new BigInteger("-9223372036854775808"); }
- public String getTokensAsString() { return "" + getToken(); }
- public int getNumTokensPerNode() { return 1; }
- public String getSeeds() { return ""; }
- public int getGossipPort() { return 1234; }
- public int getSslGossipPort() { return 1234; }
- public int getThriftPort() { return 1234; }
- public int getNativeTransportPort() { return 1234; }
- public String getClusterName() { return "Mock"; }
- public String getEndpointSnitchName() { return ""; }
- public String getListenAddress() { return "0"; }
- public String getBroadcastAddress() { return "0"; }
- public String getRpcAddress() { return "0"; }
- public String getRunDir() { return "/tmp/mock"; }
- }
-
- @Test
- public void testBigIntegerFormattedCorrectly() {
- Map<String, Object> substitutions = ImmutableMap.<String, Object>builder()
- .put("entity", new MockInputForTemplate())
- .put("driver", new MockInputForTemplate())
- .build();
-
- String templatedUrl = CassandraNode.CASSANDRA_CONFIG_TEMPLATE_URL.getDefaultValue();
- String url = TemplateProcessor.processTemplateContents(templatedUrl, ImmutableMap.of("entity", ImmutableMap.of("majorMinorVersion", "1.2")));
- String templateContents = new ResourceUtils(this).getResourceAsString(url);
- String processedTemplate = TemplateProcessor.processTemplateContents(templateContents, substitutions);
- Assert.assertEquals(processedTemplate.indexOf("775,808"), -1);
- Assert.assertTrue(processedTemplate.indexOf("-9223372036854775808") > 0);
- }
-
- @Test(groups="Integration") // because takes approx 30 seconds
- public void testUpdatesSeedsFastishManyTimes() throws Exception {
- final int COUNT = 20;
- for (int i=0; i<COUNT; i++) {
- log.info("Test "+JavaClassNames.niceClassAndMethod()+", iteration "+(i+1)+" of "+COUNT);
- try {
- doTestUpdatesSeedsOnFailuresAndAdditions(true, true);
- tearDown();
- setUp();
- } catch (Exception e) {
- log.warn("Error in "+JavaClassNames.niceClassAndMethod()+", iteration "+(i+1)+" of "+COUNT, e);
- throw e;
- }
- }
- }
-
- @Test(groups="Integration") // because takes approx 5 seconds
- public void testUpdateSeedsSlowAndRejoining() throws Exception {
- final int COUNT = 1;
- for (int i=0; i<COUNT; i++) {
- log.info("Test "+JavaClassNames.niceClassAndMethod()+", iteration "+(i+1)+" of "+COUNT);
- doTestUpdatesSeedsOnFailuresAndAdditions(false, true);
- tearDown();
- setUp();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraFabricTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraFabricTest.java b/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraFabricTest.java
deleted file mode 100644
index f28ddc1..0000000
--- a/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraFabricTest.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * 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.nosql.cassandra;
-
-import static org.testng.Assert.assertEquals;
-
-import java.util.Collection;
-import java.util.Set;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.EntityLocal;
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.entity.ImplementedBy;
-import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.api.location.LocationSpec;
-import org.apache.brooklyn.core.entity.AbstractEntity;
-import org.apache.brooklyn.core.entity.Attributes;
-import org.apache.brooklyn.core.entity.EntityInternal;
-import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
-import org.apache.brooklyn.core.entity.lifecycle.ServiceStateLogic;
-import org.apache.brooklyn.core.entity.trait.Startable;
-import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
-import org.apache.brooklyn.entity.software.base.EmptySoftwareProcess;
-import org.apache.brooklyn.test.EntityTestUtils;
-import org.apache.brooklyn.util.time.Duration;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Sets;
-
-public class CassandraFabricTest extends BrooklynAppUnitTestSupport {
-
- private static final Logger log = LoggerFactory.getLogger(CassandraFabricTest.class);
-
- private LocalhostMachineProvisioningLocation loc1;
- private LocalhostMachineProvisioningLocation loc2;
- private CassandraFabric fabric;
-
- @BeforeMethod(alwaysRun=true)
- @Override
- public void setUp() throws Exception {
- super.setUp();
- loc1 = mgmt.getLocationManager().createLocation(LocationSpec.create(LocalhostMachineProvisioningLocation.class));
- loc2 = mgmt.getLocationManager().createLocation(LocationSpec.create(LocalhostMachineProvisioningLocation.class));
- }
-
- @Test
- public void testPopulatesInitialSeeds() throws Exception {
- fabric = app.createAndManageChild(EntitySpec.create(CassandraFabric.class)
- .configure(CassandraFabric.INITIAL_QUORUM_SIZE, 2)
- .configure(CassandraDatacenter.DELAY_BEFORE_ADVERTISING_CLUSTER, Duration.ZERO)
- .configure(CassandraFabric.MEMBER_SPEC, EntitySpec.create(CassandraDatacenter.class)
- .configure(CassandraDatacenter.INITIAL_SIZE, 2)
- .configure(CassandraDatacenter.MEMBER_SPEC, EntitySpec.create(EmptySoftwareProcess.class))));
-
- app.start(ImmutableList.of(loc1, loc2));
- CassandraDatacenter d1 = (CassandraDatacenter) Iterables.get(fabric.getMembers(), 0);
- CassandraDatacenter d2 = (CassandraDatacenter) Iterables.get(fabric.getMembers(), 1);
-
- final EmptySoftwareProcess d1a = (EmptySoftwareProcess) Iterables.get(d1.getMembers(), 0);
- final EmptySoftwareProcess d1b = (EmptySoftwareProcess) Iterables.get(d1.getMembers(), 1);
-
- final EmptySoftwareProcess d2a = (EmptySoftwareProcess) Iterables.get(d2.getMembers(), 0);
- final EmptySoftwareProcess d2b = (EmptySoftwareProcess) Iterables.get(d2.getMembers(), 1);
-
- Predicate<Set<Entity>> predicate = new Predicate<Set<Entity>>() {
- @Override public boolean apply(Set<Entity> input) {
- return input != null && input.size() >= 2 &&
- Sets.intersection(input, ImmutableSet.of(d1a, d1b)).size() == 1 &&
- Sets.intersection(input, ImmutableSet.of(d2a, d2b)).size() == 1;
- }
- };
- EntityTestUtils.assertAttributeEventually(fabric, CassandraFabric.CURRENT_SEEDS, predicate);
- EntityTestUtils.assertAttributeEventually(d1, CassandraDatacenter.CURRENT_SEEDS, predicate);
- EntityTestUtils.assertAttributeEventually(d2, CassandraDatacenter.CURRENT_SEEDS, predicate);
-
- Set<Entity> seeds = fabric.getAttribute(CassandraFabric.CURRENT_SEEDS);
- assertEquals(d1.getAttribute(CassandraDatacenter.CURRENT_SEEDS), seeds);
- assertEquals(d2.getAttribute(CassandraDatacenter.CURRENT_SEEDS), seeds);
- log.info("Seeds="+seeds);
- }
-
- @Test
- public void testPopulatesInitialSeedsWhenNodesOfOneClusterComeUpBeforeTheOtherCluster() throws Exception {
- fabric = app.createAndManageChild(EntitySpec.create(CassandraFabric.class)
- .configure(CassandraFabric.INITIAL_QUORUM_SIZE, 2)
- .configure(CassandraDatacenter.DELAY_BEFORE_ADVERTISING_CLUSTER, Duration.ZERO)
- .configure(CassandraFabric.MEMBER_SPEC, EntitySpec.create(CassandraDatacenter.class)
- .configure(CassandraDatacenter.INITIAL_SIZE, 2)
- .configure(CassandraDatacenter.MEMBER_SPEC, EntitySpec.create(DummyCassandraNode.class))));
-
- Thread t = new Thread() {
- public void run() {
- app.start(ImmutableList.of(loc1, loc2));
- }
- };
- t.start();
- try {
- EntityTestUtils.assertGroupSizeEqualsEventually(fabric, 2);
- CassandraDatacenter d1 = (CassandraDatacenter) Iterables.get(fabric.getMembers(), 0);
- CassandraDatacenter d2 = (CassandraDatacenter) Iterables.get(fabric.getMembers(), 1);
-
- EntityTestUtils.assertGroupSizeEqualsEventually(d1, 2);
- final DummyCassandraNode d1a = (DummyCassandraNode) Iterables.get(d1.getMembers(), 0);
- final DummyCassandraNode d1b = (DummyCassandraNode) Iterables.get(d1.getMembers(), 1);
-
- EntityTestUtils.assertGroupSizeEqualsEventually(d2, 2);
- final DummyCassandraNode d2a = (DummyCassandraNode) Iterables.get(d2.getMembers(), 0);
- final DummyCassandraNode d2b = (DummyCassandraNode) Iterables.get(d2.getMembers(), 1);
-
- d1a.sensors().set(Attributes.HOSTNAME, "d1a");
- d1b.sensors().set(Attributes.HOSTNAME, "d1b");
-
- Thread.sleep(1000);
- d2a.sensors().set(Attributes.HOSTNAME, "d2a");
- d2b.sensors().set(Attributes.HOSTNAME, "d2b");
-
- Predicate<Set<Entity>> predicate = new Predicate<Set<Entity>>() {
- @Override public boolean apply(Set<Entity> input) {
- return input != null && input.size() >= 2 &&
- Sets.intersection(input, ImmutableSet.of(d1a, d1b)).size() == 1 &&
- Sets.intersection(input, ImmutableSet.of(d2a, d2b)).size() == 1;
- }
- };
- EntityTestUtils.assertAttributeEventually(fabric, CassandraFabric.CURRENT_SEEDS, predicate);
- EntityTestUtils.assertAttributeEventually(d1, CassandraDatacenter.CURRENT_SEEDS, predicate);
- EntityTestUtils.assertAttributeEventually(d2, CassandraDatacenter.CURRENT_SEEDS, predicate);
-
- Set<Entity> seeds = fabric.getAttribute(CassandraFabric.CURRENT_SEEDS);
- assertEquals(d1.getAttribute(CassandraDatacenter.CURRENT_SEEDS), seeds);
- assertEquals(d2.getAttribute(CassandraDatacenter.CURRENT_SEEDS), seeds);
- log.info("Seeds="+seeds);
- } finally {
- log.info("Failed seeds; fabric="+fabric.getAttribute(CassandraFabric.CURRENT_SEEDS));
- t.interrupt();
- }
- }
-
-
- @ImplementedBy(DummyCassandraNodeImpl.class)
- public interface DummyCassandraNode extends Entity, Startable, EntityLocal, EntityInternal {
- }
-
- public static class DummyCassandraNodeImpl extends AbstractEntity implements DummyCassandraNode {
-
- @Override
- public void start(Collection<? extends Location> locations) {
- ServiceStateLogic.setExpectedState(this, Lifecycle.STARTING);
- }
-
- @Override
- public void stop() {
- ServiceStateLogic.setExpectedState(this, Lifecycle.STOPPING);
- }
-
- @Override
- public void restart() {
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNodeEc2LiveTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNodeEc2LiveTest.java b/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNodeEc2LiveTest.java
deleted file mode 100644
index c1b8b04..0000000
--- a/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNodeEc2LiveTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * 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.nosql.cassandra;
-
-import static org.testng.Assert.assertNotNull;
-
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.core.entity.Attributes;
-import org.apache.brooklyn.core.entity.EntityAsserts;
-import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
-import org.apache.brooklyn.core.location.cloud.CloudLocationConfig;
-import org.apache.brooklyn.entity.AbstractEc2LiveTest;
-import org.apache.brooklyn.entity.nosql.cassandra.AstyanaxSupport.AstyanaxSample;
-import org.apache.brooklyn.test.EntityTestUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-
-public class CassandraNodeEc2LiveTest extends AbstractEc2LiveTest {
-
- private static final Logger log = LoggerFactory.getLogger(CassandraNodeEc2LiveTest.class);
-
- @Override
- protected void doTest(Location loc) throws Exception {
- log.info("Testing Cassandra on {}", loc);
-
- CassandraNode cassandra = app.createAndManageChild(EntitySpec.create(CassandraNode.class)
- .configure("thriftPort", "9876+")
- .configure("clusterName", "TestCluster"));
- app.start(ImmutableList.of(loc));
-
- EntityTestUtils.assertAttributeEqualsEventually(cassandra, CassandraNode.SERVICE_UP, true);
-
- AstyanaxSample astyanax = new AstyanaxSample(cassandra);
- astyanax.astyanaxTest();
- }
-
- @Test(groups = {"Live"})
- public void testWithOnlyPort22() throws Exception {
- // CentOS-6.3-x86_64-GA-EBS-02-85586466-5b6c-4495-b580-14f72b4bcf51-ami-bb9af1d2.1
- jcloudsLocation = mgmt.getLocationRegistry().resolve(LOCATION_SPEC, ImmutableMap.of(
- "tags", ImmutableList.of(getClass().getName()),
- "imageId", "us-east-1/ami-a96b01c0",
- "hardwareId", SMALL_HARDWARE_ID));
-
- CassandraNode server = app.createAndManageChild(EntitySpec.create(CassandraNode.class)
- .configure(CassandraNode.PROVISIONING_PROPERTIES.subKey(CloudLocationConfig.INBOUND_PORTS.getName()), ImmutableList.of(22))
- .configure(CassandraNode.USE_JMX, false)
- .configure(CassandraNode.USE_THRIFT_MONITORING, false));
-
- app.start(ImmutableList.of(jcloudsLocation));
-
- EntityAsserts.assertAttributeEqualsEventually(server, Attributes.SERVICE_UP, true);
- EntityAsserts.assertAttributeEqualsEventually(server, Attributes.SERVICE_STATE_ACTUAL, Lifecycle.RUNNING);
-
- Integer port = server.getAttribute(CassandraNode.THRIFT_PORT);
- assertNotNull(port);
-
- assertViaSshLocalPortListeningEventually(server, port);
- }
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNodeIntegrationTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNodeIntegrationTest.java b/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNodeIntegrationTest.java
deleted file mode 100644
index 12edbe6..0000000
--- a/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNodeIntegrationTest.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * 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.nosql.cassandra;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.core.entity.Entities;
-import org.apache.brooklyn.core.entity.trait.Startable;
-import org.apache.brooklyn.core.sensor.PortAttributeSensorAndConfigKey;
-import org.apache.brooklyn.entity.nosql.cassandra.CassandraNode;
-import org.apache.brooklyn.entity.nosql.cassandra.AstyanaxSupport.AstyanaxSample;
-import org.apache.brooklyn.test.Asserts;
-import org.apache.brooklyn.test.EntityTestUtils;
-import org.apache.brooklyn.test.NetworkingTestUtils;
-import org.apache.brooklyn.util.math.MathPredicates;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Maps;
-
-/**
- * Cassandra integration tests.
- *
- * Test the operation of the {@link CassandraNode} class.
- */
-public class CassandraNodeIntegrationTest extends AbstractCassandraNodeTest {
-
- private static final Logger LOG = LoggerFactory.getLogger(CassandraNodeIntegrationTest.class);
-
- public static void assertCassandraPortsAvailableEventually() {
- Map<String, Integer> ports = getCassandraDefaultPorts();
- NetworkingTestUtils.assertPortsAvailableEventually(ports);
- LOG.info("Confirmed Cassandra ports are available: "+ports);
- }
-
- 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<String, Integer> result = Maps.newLinkedHashMap();
- for (PortAttributeSensorAndConfigKey key : ports) {
- result.put(key.getName(), key.getConfigKey().getDefaultValue().iterator().next());
- }
- return result;
- }
-
- @BeforeMethod(alwaysRun = true)
- @Override
- public void setUp() throws Exception {
- assertCassandraPortsAvailableEventually();
- super.setUp();
- }
-
- @AfterMethod(alwaysRun=true)
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- assertCassandraPortsAvailableEventually();
- }
-
- /**
- * Test that a node starts and sets SERVICE_UP correctly.
- */
- @Test(groups = "Integration")
- public void canStartupAndShutdown() {
- cassandra = app.createAndManageChild(EntitySpec.create(CassandraNode.class)
- .configure("jmxPort", "11099+")
- .configure("rmiRegistryPort", "19001+"));
- app.start(ImmutableList.of(testLocation));
-
- EntityTestUtils.assertAttributeEqualsEventually(cassandra, Startable.SERVICE_UP, true);
- Entities.dumpInfo(app);
-
- cassandra.stop();
-
- EntityTestUtils.assertAttributeEqualsEventually(cassandra, Startable.SERVICE_UP, false);
- }
-
- /**
- * Test that a keyspace and column family can be created and used with Astyanax client.
- */
- @Test(groups = "Integration")
- public void testConnection() throws Exception {
- cassandra = app.createAndManageChild(EntitySpec.create(CassandraNode.class)
- .configure("jmxPort", "11099+")
- .configure("rmiRegistryPort", "19001+")
- .configure("thriftPort", "9876+"));
- app.start(ImmutableList.of(testLocation));
-
- EntityTestUtils.assertAttributeEqualsEventually(cassandra, Startable.SERVICE_UP, true);
-
- AstyanaxSample astyanax = new AstyanaxSample(cassandra);
- astyanax.astyanaxTest();
- }
-
- /**
- * Cassandra v2 needs Java >= 1.7. If you have java 6 as the defult locally, then you can use
- * something like {@code .configure("shell.env", MutableMap.of("JAVA_HOME", "/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home"))}
- */
- @Test(groups = "Integration")
- public void testCassandraVersion2() throws Exception {
- // TODO In v2.0.10, the bin/cassandra script changed to add an additional check for JMX connectivity.
- // This causes cassandera script to hang for us (presumably due to the CLASSPATH/JVM_OPTS we're passing
- // in, regarding JMX agent).
- // See:
- // - https://issues.apache.org/jira/browse/CASSANDRA-7254
- // - https://github.com/apache/cassandra/blame/trunk/bin/cassandra#L211-216
-
- String version = "2.0.9";
- String majorMinorVersion = "2.0";
-
- cassandra = app.createAndManageChild(EntitySpec.create(CassandraNode.class)
- .configure(CassandraNode.SUGGESTED_VERSION, version)
- .configure(CassandraNode.NUM_TOKENS_PER_NODE, 256)
- .configure("jmxPort", "11099+")
- .configure("rmiRegistryPort", "19001+"));
- app.start(ImmutableList.of(testLocation));
-
- EntityTestUtils.assertAttributeEqualsEventually(cassandra, Startable.SERVICE_UP, true);
- Entities.dumpInfo(app);
-
- AstyanaxSample astyanax = new AstyanaxSample(cassandra);
- astyanax.astyanaxTest();
-
- assertEquals(cassandra.getMajorMinorVersion(), majorMinorVersion);
-
- Asserts.succeedsEventually(new Runnable() {
- @Override public void run() {
- assertNotNull(cassandra.getAttribute(CassandraNode.TOKENS));
- assertEquals(cassandra.getAttribute(CassandraNode.TOKENS).size(), 256, "tokens="+cassandra.getAttribute(CassandraNode.TOKENS));
-
- assertEquals(cassandra.getAttribute(CassandraNode.PEERS), (Integer)256);
- assertEquals(cassandra.getAttribute(CassandraNode.LIVE_NODE_COUNT), (Integer)1);
-
- assertTrue(cassandra.getAttribute(CassandraNode.SERVICE_UP_JMX));
- assertNotNull(cassandra.getAttribute(CassandraNode.THRIFT_PORT_LATENCY));
-
- assertNotNull(cassandra.getAttribute(CassandraNode.READ_PENDING));
- assertNotNull(cassandra.getAttribute(CassandraNode.READ_ACTIVE));
- EntityTestUtils.assertAttribute(cassandra, CassandraNode.READ_COMPLETED, MathPredicates.greaterThanOrEqual(1));
- assertNotNull(cassandra.getAttribute(CassandraNode.WRITE_PENDING));
- assertNotNull(cassandra.getAttribute(CassandraNode.WRITE_ACTIVE));
- EntityTestUtils.assertAttribute(cassandra, CassandraNode.WRITE_COMPLETED, MathPredicates.greaterThanOrEqual(1));
-
- assertNotNull(cassandra.getAttribute(CassandraNode.READS_PER_SECOND_LAST));
- assertNotNull(cassandra.getAttribute(CassandraNode.WRITES_PER_SECOND_LAST));
-
- assertNotNull(cassandra.getAttribute(CassandraNode.THRIFT_PORT_LATENCY_IN_WINDOW));
- assertNotNull(cassandra.getAttribute(CassandraNode.READS_PER_SECOND_IN_WINDOW));
- assertNotNull(cassandra.getAttribute(CassandraNode.WRITES_PER_SECOND_IN_WINDOW));
-
- // an example MXBean
- EntityTestUtils.assertAttribute(cassandra, CassandraNode.MAX_HEAP_MEMORY, MathPredicates.greaterThanOrEqual(1));
- }});
-
- cassandra.stop();
-
- EntityTestUtils.assertAttributeEqualsEventually(cassandra, Startable.SERVICE_UP, false);
- }
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNodeLiveTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNodeLiveTest.java b/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNodeLiveTest.java
deleted file mode 100644
index cf070bf..0000000
--- a/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/CassandraNodeLiveTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * 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.nosql.cassandra;
-
-import java.util.Map;
-
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.entity.nosql.cassandra.CassandraNode;
-import org.apache.brooklyn.entity.nosql.cassandra.AstyanaxSupport.AstyanaxSample;
-import org.apache.brooklyn.test.EntityTestUtils;
-import org.apache.brooklyn.util.collections.MutableMap;
-import org.apache.brooklyn.util.text.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-
-/**
- * Cassandra live tests.
- *
- * Test the operation of the {@link CassandraNode} class using the jclouds {@code rackspace-cloudservers-uk}
- * and {@code aws-ec2} providers, with different OS images. The tests use the {@link AstyanaxSupport#astyanaxTest()} method
- * to exercise the node, and will need to have {@code brooklyn.jclouds.provider.identity} and {@code .credential}
- * set, usually in the {@code .brooklyn/bropoklyn.properties} file.
- */
-public class CassandraNodeLiveTest extends AbstractCassandraNodeTest {
-
- private static final Logger log = LoggerFactory.getLogger(CassandraNodeLiveTest.class);
-
- @DataProvider(name = "virtualMachineData")
- public Object[][] provideVirtualMachineData() {
- return new Object[][] { // ImageId, Provider, Region, Description (for logging)
- new Object[] { "eu-west-1/ami-0307d674", "aws-ec2", "eu-west-1", "Ubuntu Server 14.04 LTS (HVM), SSD Volume Type" },
- new Object[] { "LON/f9b690bf-88eb-43c2-99cf-391f2558732e", "rackspace-cloudservers-uk", "", "Ubuntu 12.04 LTS (Precise Pangolin)" },
- new Object[] { "LON/a84b1592-6817-42da-a57c-3c13f3cfc1da", "rackspace-cloudservers-uk", "", "CentOS 6.5 (PVHVM)" },
- };
- }
-
- @Test(groups = "Live", dataProvider = "virtualMachineData")
- protected void testOperatingSystemProvider(String imageId, String provider, String region, String description) throws Exception {
- log.info("Testing Cassandra on {}{} using {} ({})", new Object[] { provider, Strings.isNonEmpty(region) ? ":" + region : "", description, imageId });
-
- Map<String, String> properties = MutableMap.of("imageId", imageId);
- testLocation = app.getManagementContext().getLocationRegistry()
- .resolve(provider + (Strings.isNonEmpty(region) ? ":" + region : ""), properties);
-
- cassandra = app.createAndManageChild(EntitySpec.create(CassandraNode.class)
- .configure("thriftPort", "9876+")
- .configure("clusterName", "TestCluster"));
- app.start(ImmutableList.of(testLocation));
- EntityTestUtils.assertAttributeEqualsEventually(cassandra, CassandraNode.SERVICE_UP, true);
-
- AstyanaxSample astyanax = new AstyanaxSample(cassandra);
- astyanax.astyanaxTest();
- }
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/NonNegTokenGeneratorTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/NonNegTokenGeneratorTest.java b/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/NonNegTokenGeneratorTest.java
deleted file mode 100644
index 281ae6d..0000000
--- a/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/NonNegTokenGeneratorTest.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * 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.nosql.cassandra;
-
-import static org.testng.Assert.assertEquals;
-
-import java.math.BigInteger;
-import java.util.List;
-
-import org.apache.brooklyn.entity.nosql.cassandra.TokenGenerators.AbstractTokenGenerator;
-import org.apache.brooklyn.entity.nosql.cassandra.TokenGenerators.NonNeg127TokenGenerator;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Lists;
-
-public class NonNegTokenGeneratorTest {
-
- public static final BigInteger C4_1 = new BigInteger("42535295865117307932921825928971026432");
- public static final BigInteger C4_2 = new BigInteger("85070591730234615865843651857942052864");
- public static final BigInteger C4_3 = new BigInteger("127605887595351923798765477786913079296");
-
- // TODO Expect this behaviour to change when we better support dynamically growing/shrinking.
- // In particular, the expected behaviour for testReturnsNullWhenClusterSizeUnknown
- // and testReturnsNullWhenGrowingClusterUnknownAmount will change.
-
- private AbstractTokenGenerator generator;
-
- @BeforeMethod(alwaysRun=true)
- public void setUp() throws Exception {
- generator = new NonNeg127TokenGenerator();
- }
-
- @Test
- public void testGetTokenForReplacementNode() {
- assertEquals(generator.getTokenForReplacementNode(BigInteger.ONE), BigInteger.ZERO);
- assertEquals(generator.getTokenForReplacementNode(BigInteger.ZERO), generator.max());
- assertEquals(generator.getTokenForReplacementNode(generator.max()), generator.max().subtract(BigInteger.ONE));
- }
-
- @Test
- public void testGeneratesInitialTokens() throws Exception {
- List<BigInteger> tokens = Lists.newArrayList();
- generator.growingCluster(4);
- for (int i = 0; i < 4; i++) {
- tokens.add(generator.newToken());
- }
-
- assertEquals(tokens, ImmutableList.of(
- BigInteger.ZERO,
- C4_1,
- C4_2,
- C4_3));
- }
-
- // Expect behaviour to be changed to better choose tokens for growing clusters
- // (but eg need to take into account how busy each node is!)
- @Test
- public void testGeneratesTokensForGrowingCluster() throws Exception {
- List<BigInteger> tokens = Lists.newArrayList();
- generator.growingCluster(4);
- for (int i = 0; i < 4; i++) {
- tokens.add(generator.newToken());
- }
- generator.growingCluster(1);
- assertEquals(generator.newToken(), C4_3.add(generator.max().add(BigInteger.ONE)).divide(BigInteger.valueOf(2)));
- generator.growingCluster(2);
- assertEquals(generator.newToken(), C4_1.divide(BigInteger.valueOf(2)));
- assertEquals(generator.newToken(), C4_2.add(C4_1).divide(BigInteger.valueOf(2)));
- }
-
- @Test
- public void testGeneratesTokensForGrowingClusterWhenInitialSizeIsOne() throws Exception {
- // initial size 1 has to do a special "average with ourself by half phase shift" computation
- List<BigInteger> tokens = Lists.newArrayList();
- generator.growingCluster(1);
- tokens.add(generator.newToken());
-
- generator.growingCluster(1);
- assertEquals(generator.newToken(), C4_2);
- generator.growingCluster(2);
- assertEquals(generator.newToken(), C4_3);
- assertEquals(generator.newToken(), C4_1);
- }
-
- @Test
- public void testReturnsNullWhenClusterSizeUnknown() throws Exception {
- assertEquals(generator.newToken(), null);
- }
-
- @Test
- public void testReturnsNullWhenGrowingClusterUnknownAmount() throws Exception {
- generator.growingCluster(4);
- for (int i = 0; i < 4; i++) {
- generator.newToken();
- }
- assertEquals(generator.newToken(), null);
- }
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/PosNegTokenGeneratorTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/PosNegTokenGeneratorTest.java b/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/PosNegTokenGeneratorTest.java
deleted file mode 100644
index e353f41..0000000
--- a/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/cassandra/PosNegTokenGeneratorTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * 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.nosql.cassandra;
-
-import static org.testng.Assert.assertEquals;
-
-import java.math.BigInteger;
-
-import org.apache.brooklyn.entity.nosql.cassandra.TokenGenerators.AbstractTokenGenerator;
-import org.apache.brooklyn.entity.nosql.cassandra.TokenGenerators.PosNeg63TokenGenerator;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-public class PosNegTokenGeneratorTest {
-
- // TODO Expect this behaviour to change when we better support dynamically growing/shrinking.
- // In particular, the expected behaviour for testReturnsNullWhenClusterSizeUnknown
- // and testReturnsNullWhenGrowingClusterUnknownAmount will change.
-
- private AbstractTokenGenerator generator;
-
- @BeforeMethod(alwaysRun=true)
- public void setUp() throws Exception {
- generator = new PosNeg63TokenGenerator();
- }
-
- @Test
- public void testGetTokenForReplacementNode() {
- assertEquals(generator.getTokenForReplacementNode(BigInteger.ONE), BigInteger.ZERO);
- assertEquals(generator.getTokenForReplacementNode(BigInteger.ZERO), BigInteger.ONE.negate());
- assertEquals(generator.getTokenForReplacementNode(generator.min()), generator.max());
- assertEquals(generator.getTokenForReplacementNode(generator.max()), generator.max().subtract(BigInteger.ONE));
- }
-
- @Test
- public void testGeneratesInitialTokens() throws Exception {
- generator.growingCluster(4);
- assertEquals(generator.newToken(), generator.min());
- assertEquals(generator.newToken(), generator.min().add(generator.range().divide(BigInteger.valueOf(4))));
- }
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/couchbase/CouchbaseOfflineTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/couchbase/CouchbaseOfflineTest.java b/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/couchbase/CouchbaseOfflineTest.java
deleted file mode 100644
index 0d684c1..0000000
--- a/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/couchbase/CouchbaseOfflineTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.nosql.couchbase;
-
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-import org.apache.brooklyn.core.entity.Entities;
-import org.apache.brooklyn.core.location.BasicOsDetails;
-import org.apache.brooklyn.core.location.BasicOsDetails.OsArchs;
-import org.apache.brooklyn.core.mgmt.internal.LocalManagementContext;
-import org.apache.brooklyn.core.test.entity.LocalManagementContextForTests;
-
-public class CouchbaseOfflineTest {
-
- private LocalManagementContext mgmt;
-
- @BeforeMethod
- public void setUp() {
- mgmt = LocalManagementContextForTests.newInstance();
- }
-
- @AfterMethod
- public void tearDown() {
- Entities.destroyAll(mgmt);
- }
-
- @Test
- public void testResolvingDownloadLinks() {
- checkOsTag("linux", OsArchs.I386, "unknown", true, "centos6.x86.rpm");
- checkOsTag("linux", OsArchs.I386, "unknown", false, "x86.rpm");
- checkOsTag("rhel", OsArchs.X_86_64, "6", true, "centos6.x86_64.rpm");
- checkOsTag("Ubuntu 14", OsArchs.X_86_64, "14.04", true, "ubuntu12.04_amd64.deb");
- checkOsTag("Ubuntu 14", OsArchs.X_86_64, "14.04", false, "x86_64.deb");
- checkOsTag("Debian 7up", OsArchs.I386, "7ish", true, "debian7_x86.deb");
- Assert.assertEquals(new CouchbaseNodeSshDriver.DownloadLinkSegmentComputer(null, true, "test").getOsTag(), "centos6.x86_64.rpm");
- Assert.assertEquals(new CouchbaseNodeSshDriver.DownloadLinkSegmentComputer(null, false, "test").getOsTag(), "x86_64.rpm");
- }
-
- protected void checkOsTag(String os, String arch, String version, boolean isV30, String expectedTag) {
- Assert.assertEquals(new CouchbaseNodeSshDriver.DownloadLinkSegmentComputer(new BasicOsDetails(os, arch, version), isV30, "test").getOsTag(), expectedTag);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/couchbase/CouchbaseSyncGatewayEc2LiveTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/couchbase/CouchbaseSyncGatewayEc2LiveTest.java b/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/couchbase/CouchbaseSyncGatewayEc2LiveTest.java
deleted file mode 100644
index 421dc85..0000000
--- a/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/couchbase/CouchbaseSyncGatewayEc2LiveTest.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * 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.nosql.couchbase;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.core.entity.trait.Startable;
-import org.apache.brooklyn.entity.AbstractEc2LiveTest;
-import org.apache.brooklyn.entity.group.DynamicCluster;
-import org.apache.brooklyn.test.EntityTestUtils;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-
-public class CouchbaseSyncGatewayEc2LiveTest extends AbstractEc2LiveTest {
-
- @Override
- protected void doTest(Location loc) throws Exception {
- CouchbaseCluster cluster = app.createAndManageChild(EntitySpec.create(CouchbaseCluster.class)
- .configure(CouchbaseNode.COUCHBASE_ADMIN_USERNAME, "Administrator")
- .configure(CouchbaseNode.COUCHBASE_ADMIN_PASSWORD, "Password")
- .configure(DynamicCluster.INITIAL_SIZE, 3)
- .configure(CouchbaseCluster.CREATE_BUCKETS, (List<Map<String,Object>>)ImmutableList.of(
- (Map<String,Object>)ImmutableMap.<String, Object>of(
- "bucket", "default",
- "bucket-ramsize", 100,
- "bucket-type", "couchbase",
- "bucket-port", 11211
- ),
- (Map<String,Object>)ImmutableMap.<String, Object>of(
- "bucket", "my_bucket",
- "bucket-ramsize", 100,
- "bucket-type", "couchbase",
- "bucket-port", 11223
- ),
- (Map<String,Object>)ImmutableMap.<String, Object>of(
- "bucket", "another",
- "bucket-ramsize", 100,
- "bucket-type", "couchbase",
- "bucket-port", 11224
- ))
- )
- );
- CouchbaseSyncGateway gateway = app.createAndManageChild(EntitySpec.create(CouchbaseSyncGateway.class)
- .configure(CouchbaseSyncGateway.COUCHBASE_SERVER, cluster)
- .configure(CouchbaseSyncGateway.COUCHBASE_SERVER_BUCKET, "my_bucket")
- );
-
- app.start(ImmutableList.of(loc));
-
- EntityTestUtils.assertAttributeEqualsEventually(gateway, Startable.SERVICE_UP, true);
- }
-
-
- // Supported operating systems
- @Test(groups = {"Live"})
- @Override
- public void test_Ubuntu_12_0() throws Exception {
- super.test_Ubuntu_12_0();
- }
-
- @Test(groups = {"Live"})
- @Override
- public void test_Red_Hat_Enterprise_Linux_6() throws Exception {
- super.test_Red_Hat_Enterprise_Linux_6();
- }
-
- @Test(groups = {"Live"})
- @Override
- public void test_CentOS_6_3() throws Exception {
- super.test_CentOS_6_3();
- }
-
- // Unsupported operating systems
-
- @Test(groups = {"Live"})
- @Override
- public void test_CentOS_5() throws Exception {
- // Unsupported
- // error: Failed dependencies:
- // libc.so.6(GLIBC_2.7)(64bit) is needed by couchbase-server-2.5.1-1083.x86_64
- // libcrypto.so.10()(64bit) is needed by couchbase-server-2.5.1-1083.x86_64
- // libreadline.so.6()(64bit) is needed by couchbase-server-2.5.1-1083.x86_64
- // libssl.so.10()(64bit) is needed by couchbase-server-2.5.1-1083.x86_64
- // libstdc++.so.6(GLIBCXX_3.4.10)(64bit) is needed by couchbase-server-2.5.1-1083.x86_64
- // libstdc++.so.6(GLIBCXX_3.4.11)(64bit) is needed by couchbase-server-2.5.1-1083.x86_64
- // libstdc++.so.6(GLIBCXX_3.4.9)(64bit) is needed by couchbase-server-2.5.1-1083.x86_64
- // libtinfo.so.5()(64bit) is needed by couchbase-server-2.5.1-1083.x86_64
- // openssl >= 1.0.0 is needed by couchbase-server-2.5.1-1083.x86_64
- // rpmlib(FileDigests) <= 4.6.0-1 is needed by couchbase-server-2.5.1-1083.x86_64
- // rpmlib(PayloadIsXz) <= 5.2-1 is needed by couchbase-server-2.5.1-1083.x86_64
- }
-
- @Test(groups = {"Live"})
- @Override
- public void test_Debian_6() throws Exception {
- // Unsupported
- }
-
- @Test(groups = {"Live"})
- @Override
- public void test_Debian_7_2() throws Exception {
- // Unsupported
- }
-
- @Test(groups = {"Live"})
- @Override
- public void test_Ubuntu_10_0() throws Exception {
- // Unsupported
- // Installing cannot proceed since the package 'libssl1*' is missing.
- // Please install libssl1* and try again.
- // $sudo apt-get install libssl1*
- //
- // Installing libssl1* doesn't fix the issue
- }
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/couchdb/AbstractCouchDBNodeTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/couchdb/AbstractCouchDBNodeTest.java b/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/couchdb/AbstractCouchDBNodeTest.java
deleted file mode 100644
index 22d4bc6..0000000
--- a/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/couchdb/AbstractCouchDBNodeTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.nosql.couchdb;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.core.entity.Entities;
-import org.apache.brooklyn.core.entity.factory.ApplicationBuilder;
-import org.apache.brooklyn.core.test.entity.TestApplication;
-import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
-
-/**
- * CouchDB test framework for integration and live tests.
- */
-public class AbstractCouchDBNodeTest {
-
- private static final Logger log = LoggerFactory.getLogger(AbstractCouchDBNodeTest.class);
-
- protected TestApplication app;
- protected Location testLocation;
- protected CouchDBNode couchdb;
-
- @BeforeMethod(alwaysRun = true)
- public void setup() throws Exception {
- app = ApplicationBuilder.newManagedApp(TestApplication.class);
- testLocation = new LocalhostMachineProvisioningLocation();
- // testLocation = app.managementContext.locationRegistry.resolve("named:test");
- }
-
- @AfterMethod(alwaysRun = true)
- public void shutdown() {
- Entities.destroyAll(app.getManagementContext());
- }
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/couchdb/CouchDBClusterLiveTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/couchdb/CouchDBClusterLiveTest.java b/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/couchdb/CouchDBClusterLiveTest.java
deleted file mode 100644
index cfa4ad3..0000000
--- a/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/couchdb/CouchDBClusterLiveTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * 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.nosql.couchdb;
-
-import static org.testng.Assert.assertEquals;
-
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.core.entity.Entities;
-import org.apache.brooklyn.core.entity.factory.ApplicationBuilder;
-import org.apache.brooklyn.core.entity.trait.Startable;
-import org.apache.brooklyn.core.test.entity.TestApplication;
-import org.apache.brooklyn.test.EntityTestUtils;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-
-/**
- * A live test of the {@link CouchDBCluster} entity.
- *
- * Tests that a two node cluster can be started on Amazon EC2 and data written on one {@link CouchDBNode}
- * can be read from another, using the Astyanax API.
- */
-public class CouchDBClusterLiveTest {
-
- // private String provider = "rackspace-cloudservers-uk";
- private String provider = "aws-ec2:eu-west-1";
-
- protected TestApplication app;
- protected Location testLocation;
- protected CouchDBCluster 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 via the Astyanax API through both nodes.
- */
- @Test(groups = "Live")
- public void canStartupAndShutdown() throws Exception {
- cluster = app.createAndManageChild(EntitySpec.create(CouchDBCluster.class)
- .configure("initialSize", 2)
- .configure("clusterName", "AmazonCluster"));
- assertEquals(cluster.getCurrentSize().intValue(), 0);
-
- app.start(ImmutableList.of(testLocation));
-
- EntityTestUtils.assertAttributeEqualsEventually(cluster, CouchDBCluster.GROUP_SIZE, 2);
- Entities.dumpInfo(app);
-
- CouchDBNode first = (CouchDBNode) Iterables.get(cluster.getMembers(), 0);
- CouchDBNode second = (CouchDBNode) Iterables.get(cluster.getMembers(), 1);
-
- EntityTestUtils.assertAttributeEqualsEventually(first, Startable.SERVICE_UP, true);
- EntityTestUtils.assertAttributeEqualsEventually(second, Startable.SERVICE_UP, true);
-
- JcouchdbSupport jcouchdbFirst = new JcouchdbSupport(first);
- JcouchdbSupport jcouchdbSecond = new JcouchdbSupport(second);
- jcouchdbFirst.jcouchdbTest();
- jcouchdbSecond.jcouchdbTest();
- }
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/couchdb/CouchDBNodeEc2LiveTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/couchdb/CouchDBNodeEc2LiveTest.java b/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/couchdb/CouchDBNodeEc2LiveTest.java
deleted file mode 100644
index 7534a96..0000000
--- a/brooklyn-library/software/nosql/src/test/java/org/apache/brooklyn/entity/nosql/couchdb/CouchDBNodeEc2LiveTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.nosql.couchdb;
-
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.core.entity.trait.Startable;
-import org.apache.brooklyn.entity.AbstractEc2LiveTest;
-import org.apache.brooklyn.test.EntityTestUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.collect.ImmutableList;
-
-public class CouchDBNodeEc2LiveTest extends AbstractEc2LiveTest {
-
- private static final Logger log = LoggerFactory.getLogger(CouchDBNodeEc2LiveTest.class);
-
- @Override
- protected void doTest(Location loc) throws Exception {
- log.info("Testing Cassandra on {}", loc);
-
- CouchDBNode couchdb = app.createAndManageChild(EntitySpec.create(CouchDBNode.class)
- .configure("httpPort", "8000+"));
- app.start(ImmutableList.of(loc));
-
- EntityTestUtils.assertAttributeEqualsEventually(couchdb, Startable.SERVICE_UP, true);
-
- JcouchdbSupport jcouchdb = new JcouchdbSupport(couchdb);
- jcouchdb.jcouchdbTest();
- }
-}