You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2015/08/06 18:32:19 UTC
[05/26] incubator-brooklyn git commit: [BROOKLYN-162] Renaming of the
NoSQL packages
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d5cf5285/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBReplicaSetIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBReplicaSetIntegrationTest.java b/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBReplicaSetIntegrationTest.java
deleted file mode 100644
index 948a5c4..0000000
--- a/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBReplicaSetIntegrationTest.java
+++ /dev/null
@@ -1,206 +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 brooklyn.entity.nosql.mongodb;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNotEquals;
-import static org.testng.Assert.assertNotNull;
-
-import java.util.Collection;
-import java.util.concurrent.TimeUnit;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.BrooklynAppLiveTestSupport;
-import brooklyn.entity.Entity;
-import brooklyn.entity.group.DynamicCluster;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.entity.trait.Startable;
-import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
-import brooklyn.test.Asserts;
-import brooklyn.util.time.Duration;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.mongodb.DBObject;
-
-public class MongoDBReplicaSetIntegrationTest extends BrooklynAppLiveTestSupport {
-
- @SuppressWarnings("unused")
- private static final Logger log = LoggerFactory.getLogger(MongoDBReplicaSetIntegrationTest.class);
-
- private Collection<LocalhostMachineProvisioningLocation> locs;
-
- // Replica sets can take a while to start
- private static final Duration TIMEOUT = Duration.of(3, TimeUnit.MINUTES);
-
- @BeforeMethod(alwaysRun=true)
- @Override
- public void setUp() throws Exception {
- super.setUp();
- locs = ImmutableList.of(app.newLocalhostProvisioningLocation());
- }
-
- /**
- * Creates and starts a replica set, asserts it reaches the given size
- * and that the primary and secondaries are non-null.
- */
- private MongoDBReplicaSet makeAndStartReplicaSet(final Integer size, final String testDescription) {
- // Sets secondaryPreferred so we can read from slaves.
- final MongoDBReplicaSet replicaSet = app.createAndManageChild(EntitySpec.create(MongoDBReplicaSet.class)
- .configure(DynamicCluster.INITIAL_SIZE, size)
- .configure("replicaSetName", "test-rs-"+testDescription)
- .configure("memberSpec", EntitySpec.create(MongoDBServer.class)
- .configure("mongodbConfTemplateUrl", "classpath:///test-mongodb.conf")
- .configure("port", "27017+")));
- app.start(locs);
-
- Asserts.succeedsEventually(ImmutableMap.of("timeout", TIMEOUT), new Runnable() {
- @Override
- public void run() {
- assertEquals(replicaSet.getCurrentSize(), size);
- assertNotNull(replicaSet.getPrimary(), "replica set has no primary");
- assertEquals(replicaSet.getPrimary().getReplicaSet().getName(), "test-rs-"+testDescription+replicaSet.getId());
- assertEquals(replicaSet.getSecondaries().size(), size-1);
- }
- });
- return replicaSet;
- }
-
- @Test(groups = "Integration")
- public void testCanStartAndStopAReplicaSet() {
- final MongoDBReplicaSet replicaSet = makeAndStartReplicaSet(3, "can-start-and-stop");
- replicaSet.stop();
- assertFalse(replicaSet.getAttribute(Startable.SERVICE_UP));
- }
-
- @Test(groups = "Integration")
- public void testWriteToMasterAndReadFromSecondary() {
- final MongoDBReplicaSet replicaSet = makeAndStartReplicaSet(3, "master-write-secondary-read");
-
- // Test we can read a document written to the primary from all secondaries
- final String documentId = MongoDBTestHelper.insert(replicaSet.getPrimary(), "meaning-of-life", 42);
- Asserts.succeedsEventually(ImmutableMap.of("timeout", TIMEOUT), new Runnable() {
- @Override
- public void run() {
- assertEquals(replicaSet.getCurrentSize().intValue(), 3);
- for (MongoDBServer secondary : replicaSet.getSecondaries()) {
- DBObject docOut = MongoDBTestHelper.getById(secondary, documentId);
- assertEquals(docOut.get("meaning-of-life"), 42);
- }
- }
- });
- }
-
- @Test(groups = "Integration")
- public void testCanResizeAndReadFromNewInstances() {
- final MongoDBReplicaSet replicaSet = makeAndStartReplicaSet(3, "resize-and-read-from-secondaries");
-
- // Test we can a document written to the primary from all secondaries
- final String documentId = MongoDBTestHelper.insert(replicaSet.getPrimary(), "meaning-of-life", 42);
- Asserts.succeedsEventually(ImmutableMap.of("timeout", TIMEOUT), new Runnable() {
- @Override
- public void run() {
- assertEquals(replicaSet.getCurrentSize().intValue(), 3);
- for (MongoDBServer secondary : replicaSet.getSecondaries()) {
- DBObject docOut = MongoDBTestHelper.getById(secondary, documentId);
- assertEquals(docOut.get("meaning-of-life"), 42);
- }
- }
- });
-
- // Resize and confirm new members get data
- replicaSet.resize(5);
- Asserts.succeedsEventually(ImmutableMap.of("timeout", TIMEOUT), new Runnable() {
- @Override
- public void run() {
- assertEquals(replicaSet.getCurrentSize().intValue(), 5);
- Collection<MongoDBServer> secondaries = replicaSet.getSecondaries();
- assertEquals(secondaries.size(), 4);
- for (MongoDBServer secondary : secondaries) {
- DBObject docOut = MongoDBTestHelper.getById(secondary, documentId);
- assertEquals(docOut.get("meaning-of-life"), 42);
- }
- }
- });
-
- }
-
- @Test(groups = "Integration")
- public void testResizeToEvenNumberOfMembers() {
- final MongoDBReplicaSet replicaSet = makeAndStartReplicaSet(3, "resize-even-ignored");
- assertEquals(replicaSet.getCurrentSize().intValue(), 3);
- replicaSet.resize(4);
- Asserts.succeedsEventually(new Runnable() {
- @Override
- public void run() {
- assertEquals(replicaSet.getCurrentSize().intValue(), 4);
- }
- });
- }
-
- /**
- * Test replacing the primary succeeds. More interesting than replacing a secondary
- * because the removal of a primary must happen _through_ the primary. The flow is:
- * - Brooklyn removes the server from the set and stops it
- * - The remaining members of the set elect a new primary
- * - We remove the original primary from the new primary.
- */
- @Test(groups = "Integration")
- public void testReplacePrimary() {
- final MongoDBReplicaSet replicaSet = makeAndStartReplicaSet(3, "replace-primary");
- final MongoDBServer replaced = replicaSet.getPrimary();
- replicaSet.replaceMember(replaced.getId());
- Asserts.succeedsEventually(ImmutableMap.of("timeout", TIMEOUT), new Runnable() {
- @Override
- public void run() {
- assertEquals(replicaSet.getCurrentSize().intValue(), 3);
- for (Entity member : replicaSet.getMembers()) {
- assertNotEquals(member.getId(), replaced.getId());
- }
- assertNotNull(replicaSet.getPrimary());
- assertNotEquals(replicaSet.getPrimary().getId(), replaced.getId(), "Expected a new primary to have been elected");
- }
- });
- }
-
- @Test(groups = "Integration")
- public void testRemovePrimary() {
- final MongoDBReplicaSet replicaSet = makeAndStartReplicaSet(3, "remove-primary");
- final MongoDBServer removed = replicaSet.getPrimary();
-
- replicaSet.removeMember(removed);
- removed.stop();
- Asserts.succeedsEventually(ImmutableMap.of("timeout", TIMEOUT), new Runnable() {
- @Override
- public void run() {
- assertEquals(replicaSet.getCurrentSize().intValue(), 2);
- for (Entity member : replicaSet.getMembers()) {
- assertNotEquals(member.getId(), removed.getId());
- }
- assertNotNull(replicaSet.getPrimary());
- assertNotEquals(replicaSet.getPrimary().getId(), removed.getId(), "Expected a new primary to have been elected");
- }
- });
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d5cf5285/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBRestartIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBRestartIntegrationTest.java b/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBRestartIntegrationTest.java
deleted file mode 100644
index 3d21055..0000000
--- a/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBRestartIntegrationTest.java
+++ /dev/null
@@ -1,42 +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 brooklyn.entity.nosql.mongodb;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.basic.AbstractSoftwareProcessRestartIntegrationTest;
-import brooklyn.entity.basic.SoftwareProcess;
-import brooklyn.entity.proxying.EntitySpec;
-
-/**
- * Tests restart of the software *process* (as opposed to the VM).
- */
-@Test(groups="Integration")
-public class MongoDBRestartIntegrationTest extends AbstractSoftwareProcessRestartIntegrationTest {
-
- @SuppressWarnings("unused")
- private static final Logger LOG = LoggerFactory.getLogger(MongoDBRestartIntegrationTest.class);
-
- @Override
- protected EntitySpec<? extends SoftwareProcess> newEntitySpec() {
- return EntitySpec.create(MongoDBServer.class);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d5cf5285/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBSoftLayerLiveTest.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBSoftLayerLiveTest.java b/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBSoftLayerLiveTest.java
deleted file mode 100644
index 84620d7..0000000
--- a/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBSoftLayerLiveTest.java
+++ /dev/null
@@ -1,56 +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 brooklyn.entity.nosql.mongodb;
-
-import static org.testng.Assert.assertEquals;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.mongodb.DBObject;
-
-import brooklyn.entity.AbstractSoftlayerLiveTest;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.location.Location;
-import brooklyn.test.EntityTestUtils;
-
-public class MongoDBSoftLayerLiveTest extends AbstractSoftlayerLiveTest {
-
- @SuppressWarnings("unused")
- private static final Logger LOG = LoggerFactory.getLogger(MongoDBSoftLayerLiveTest.class);
-
- @Override
- protected void doTest(Location loc) throws Exception {
- MongoDBServer entity = app.createAndManageChild(EntitySpec.create(MongoDBServer.class)
- .configure("mongodbConfTemplateUrl", "classpath:///test-mongodb.conf"));
- app.start(ImmutableList.of(loc));
-
- EntityTestUtils.assertAttributeEqualsEventually(entity, MongoDBServer.SERVICE_UP, true);
-
- String id = MongoDBTestHelper.insert(entity, "hello", "world!");
- DBObject docOut = MongoDBTestHelper.getById(entity, id);
- assertEquals(docOut.get("hello"), "world!");
- }
-
- @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/d5cf5285/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBTestHelper.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBTestHelper.java b/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBTestHelper.java
deleted file mode 100644
index a5cf79d..0000000
--- a/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/MongoDBTestHelper.java
+++ /dev/null
@@ -1,124 +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 brooklyn.entity.nosql.mongodb;
-
-import java.net.UnknownHostException;
-import java.util.List;
-import java.util.Map;
-
-import org.bson.types.ObjectId;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Throwables;
-import com.google.common.net.HostAndPort;
-import com.mongodb.BasicDBObject;
-import com.mongodb.CommandResult;
-import com.mongodb.DB;
-import com.mongodb.DBCollection;
-import com.mongodb.DBObject;
-import com.mongodb.MongoClient;
-import com.mongodb.ReadPreference;
-
-import brooklyn.location.access.BrooklynAccessUtils;
-
-public class MongoDBTestHelper {
-
- private static final Logger LOG = LoggerFactory.getLogger(MongoDBTestHelper.class);
-
- private static final String TEST_DB = "brooklyn_test";
- private static final String TEST_COLLECTION = "test_collection";
- private static final String ADMIN_DB = "admin";
-
- /**
- * Inserts a new object with { key: value } at given server.
- * @return The new document's id
- */
- public static String insert(AbstractMongoDBServer entity, String key, Object value) {
- LOG.info("Inserting {}:{} at {}", new Object[]{key, value, entity});
- MongoClient mongoClient = clientForServer(entity);
- try {
- DB db = mongoClient.getDB(TEST_DB);
- DBCollection testCollection = db.getCollection(TEST_COLLECTION);
- BasicDBObject doc = new BasicDBObject(key, value);
- testCollection.insert(doc);
- ObjectId id = (ObjectId) doc.get("_id");
- return id.toString();
- } finally {
- mongoClient.close();
- }
- }
-
- /** @return The {@link DBObject} representing the object with the given id */
- public static DBObject getById(AbstractMongoDBServer entity, String id) {
- LOG.info("Getting {} from {}", new Object[]{id, entity});
- MongoClient mongoClient = clientForServer(entity);
- // Secondary preferred means the driver will let us read from secondaries too.
- mongoClient.setReadPreference(ReadPreference.secondaryPreferred());
- try {
- DB db = mongoClient.getDB(TEST_DB);
- DBCollection testCollection = db.getCollection(TEST_COLLECTION);
- return testCollection.findOne(new BasicDBObject("_id", new ObjectId(id)));
- } finally {
- mongoClient.close();
- }
- }
-
- public static List<String> getDatabaseNames(AbstractMongoDBServer entity) {
- LOG.info("Getting database names from {}", entity);
- MongoClient mongoClient = clientForServer(entity);
- try {
- return mongoClient.getDatabaseNames();
- } finally {
- mongoClient.close();
- }
- }
-
- public static boolean isConfigServer(AbstractMongoDBServer entity) {
- LOG.info("Checking if {} is a config server", entity);
- MongoClient mongoClient = clientForServer(entity);
- try {
- DB db = mongoClient.getDB(ADMIN_DB);
- CommandResult commandResult = db.command("getCmdLineOpts");
- Map<?, ?> parsedArgs = (Map<?, ?>)commandResult.get("parsed");
- if (parsedArgs == null) return false;
- Boolean configServer = (Boolean)parsedArgs.get("configsvr");
- if (configServer != null) {
- // v2.5 format
- return Boolean.TRUE.equals(configServer);
- } else {
- // v2.6 format
- String role = (String) ((Map)parsedArgs.get("sharding")).get("clusterRole");
- return "configsvr".equals(role);
- }
- } finally {
- mongoClient.close();
- }
- }
-
- private static MongoClient clientForServer(AbstractMongoDBServer server) {
- try {
- HostAndPort hap = BrooklynAccessUtils.getBrooklynAccessibleAddress(server, server.getAttribute(MongoDBServer.PORT));
- return new MongoClient(hap.getHostText(), hap.getPort());
- } catch (UnknownHostException e) {
- // Fail whatever test called this method.
- throw Throwables.propagate(e);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d5cf5285/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/ReplicaSetConfigTest.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/ReplicaSetConfigTest.java b/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/ReplicaSetConfigTest.java
deleted file mode 100644
index a35c893..0000000
--- a/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/ReplicaSetConfigTest.java
+++ /dev/null
@@ -1,239 +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 brooklyn.entity.nosql.mongodb;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotEquals;
-import static org.testng.Assert.assertTrue;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-
-import javax.annotation.Nullable;
-
-import org.bson.BSONObject;
-import org.bson.BasicBSONObject;
-import org.bson.types.BasicBSONList;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.collect.FluentIterable;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-import com.google.common.net.HostAndPort;
-
-public class ReplicaSetConfigTest {
-
- // true if object has key "votes" that is > 1
- static Predicate<BasicBSONObject> IS_VOTING_MEMBER = new Predicate<BasicBSONObject>() {
- @Override public boolean apply(@Nullable BasicBSONObject input) {
- return input != null && input.containsField("votes") && input.getInt("votes") > 0;
- }
- };
-
- private BasicBSONObject makeSetMember(Integer id, String host) {
- return new BasicBSONObject(ImmutableMap.of("_id", id, "host", host));
- }
-
- private BasicBSONObject makeSetConfig(String id, Integer version, BasicBSONObject... members) {
- BasicBSONList memberList = new BasicBSONList();
- memberList.addAll(Arrays.asList(members));
- return new BasicBSONObject(ImmutableMap.of("_id", id, "version", version, "members", memberList));
- }
-
- private BasicBSONObject makeSetWithNMembers(int n) {
- ReplicaSetConfig setConfig = ReplicaSetConfig.builder("replica-set-name");
- for (int i = 0; i < n; i++) {
- setConfig.member("host-"+i, i, i);
- }
- return setConfig.build();
- }
-
- private Collection<HostAndPort> votingMembersOfSet(BasicBSONObject config) {
- BasicBSONList membersObject = BasicBSONList.class.cast(config.get("members"));
- List<BasicBSONObject> members = Lists.newArrayList();
- for (Object object : membersObject) members.add(BasicBSONObject.class.cast(object));
- return FluentIterable.from(members)
- .filter(IS_VOTING_MEMBER)
- .transform(new Function<BasicBSONObject, HostAndPort>() {
- @Override public HostAndPort apply(BasicBSONObject input) {
- return HostAndPort.fromString(input.getString("host"));
- }
- })
- .toList();
- }
-
- private Collection<HostAndPort> nonVotingMembersOfSet(BasicBSONObject config) {
- BasicBSONList membersObject = BasicBSONList.class.cast(config.get("members"));
- List<BasicBSONObject> members = Lists.newArrayList();
- for (Object object : membersObject) members.add(BasicBSONObject.class.cast(object));
- return FluentIterable
- .from(members)
- .filter(Predicates.not(IS_VOTING_MEMBER))
- .transform(new Function<BasicBSONObject, HostAndPort>() {
- @Override public HostAndPort apply(BasicBSONObject input) {
- return HostAndPort.fromString(input.getString("host"));
- }
- })
- .toList();
- }
-
- @Test
- public void testCreateFromScratch() {
- BasicBSONObject config = ReplicaSetConfig.builder("rs")
- .member("host-a", 12345, 1)
- .member("host-b", 54321, 2)
- .build();
- assertEquals(config.get("_id"), "rs");
- assertEquals(config.getInt("version"), 1);
- assertTrue(config.get("members") instanceof BasicBSONList);
- BasicBSONList members = (BasicBSONList) config.get("members");
- assertEquals(members.size(), 2);
- }
-
- @Test
- public void testCreateFromExistingConfig() {
- // Replica set of one member
- int version = 44;
- BasicBSONObject config = makeSetConfig("replica-set-name", version, makeSetMember(33, "example.com:7777"));
-
- // Use existing set to add two more members
- BasicBSONObject newConfig = ReplicaSetConfig.fromExistingConfig(config)
- .member("foo", 8888, 34)
- .member("bar", 9999, 35)
- .build();
-
- assertEquals(newConfig.get("_id"), "replica-set-name");
- assertEquals(newConfig.get("version"), version + 1);
- BasicBSONList members = (BasicBSONList) newConfig.get("members");
- assertEquals(members.size(), 3);
-
- BSONObject original = (BSONObject) members.get(0);
- assertEquals(original.get("_id"), 33);
- assertEquals(original.get("host"), "example.com:7777");
-
- BSONObject second = (BSONObject) members.get(1);
- assertEquals(second.get("_id"), 34);
- assertEquals(second.get("host"), "foo:8888");
-
- BSONObject third = (BSONObject) members.get(2);
- assertEquals(third.get("_id"), 35);
- assertEquals(third.get("host"), "bar:9999");
- }
-
- @Test
- public void testRemoveMember() {
- int version = 44;
- BasicBSONObject config = makeSetConfig("replica-set-name", version,
- makeSetMember(33, "example.com:7777"),
- makeSetMember(34, "example.com:7778"));
-
- // Use existing set to add two more members
- BasicBSONObject newConfig = ReplicaSetConfig.fromExistingConfig(config)
- .remove("example.com", 7777)
- .build();
-
- assertEquals(newConfig.get("version"), version + 1);
- BasicBSONList members = (BasicBSONList) newConfig.get("members");
- assertEquals(members.size(), 1);
- assertEquals(BSONObject.class.cast(members.get(0)).get("host"), "example.com:7778");
-
- newConfig = ReplicaSetConfig.fromExistingConfig(newConfig)
- .remove("example.com", 7778)
- .build();
-
- members = (BasicBSONList) newConfig.get("members");
- assertTrue(members.isEmpty());
- }
-
- @Test
- public void testRemoveNonExistentMemberHasNoEffect() {
- BasicBSONObject config = makeSetConfig("replica-set-name", 1,
- makeSetMember(33, "example.com:7777"),
- makeSetMember(34, "example.com:7778"));
-
- BasicBSONList members = (BasicBSONList) config.get("members");
- assertEquals(members.size(), 2);
-
- BasicBSONObject altered = ReplicaSetConfig.fromExistingConfig(config)
- .remove("foo", 99)
- .build();
-
- members = (BasicBSONList) altered.get("members");
- assertEquals(members.size(), 2);
- }
-
- @Test
- public void testSetOfFourMembersHasThreeVoters() {
- BasicBSONObject config = makeSetWithNMembers(4);
- assertEquals(votingMembersOfSet(config).size(), 3, "Expected three voters in set with four members");
- assertEquals(nonVotingMembersOfSet(config).size(), 1, "Expected one non-voter in set with four members");
- }
-
- @Test
- public void testFourthServerOfFourIsGivenVoteWhenAnotherServerIsRemoved() {
- BasicBSONObject config = makeSetWithNMembers(4);
- HostAndPort toRemove = votingMembersOfSet(config).iterator().next();
-
- BasicBSONObject updated = ReplicaSetConfig.fromExistingConfig(config)
- .remove(toRemove)
- .build();
-
- assertEquals(votingMembersOfSet(updated).size(), 3);
- assertTrue(nonVotingMembersOfSet(updated).isEmpty());
-
- BasicBSONList newMembers = BasicBSONList.class.cast(updated.get("members"));
- for (Object object : newMembers) {
- BasicBSONObject member = BasicBSONObject.class.cast(object);
- HostAndPort memberHostAndPort = HostAndPort.fromString(member.getString("host"));
- assertNotEquals(memberHostAndPort, toRemove);
- }
- }
-
- @Test
- public void testMaximumNumberOfVotersIsLimited() {
- BasicBSONObject config = makeSetWithNMembers(ReplicaSetConfig.MAXIMUM_REPLICA_SET_SIZE);
- int voters = ReplicaSetConfig.MAXIMUM_VOTING_MEMBERS;
- int nonVoters = ReplicaSetConfig.MAXIMUM_REPLICA_SET_SIZE - voters;
- assertEquals(votingMembersOfSet(config).size(), voters, "Expected number of voters in max-size set to be " + voters);
- assertEquals(nonVotingMembersOfSet(config).size(), nonVoters, "Expected number of non-voters in max-size set to be " + nonVoters);
- }
-
- @Test(expectedExceptions = IllegalStateException.class)
- public void testMoreMembersThanMaximumAllowsRejected() {
- makeSetWithNMembers(ReplicaSetConfig.MAXIMUM_REPLICA_SET_SIZE + 1);
- }
-
- @Test
- public void testPrimaryGivenVoteWhenLastInMemberList() {
- BasicBSONObject config = ReplicaSetConfig.builder("rs")
- .member("host-a", 1, 1)
- .member("host-b", 2, 2)
- .member("host-c", 3, 3)
- .member("host-d", 4, 4)
- .primary(HostAndPort.fromParts("host-d", 4))
- .build();
- assertEquals(votingMembersOfSet(config).size(), 3);
- assertEquals(nonVotingMembersOfSet(config).size(), 1);
- assertTrue(votingMembersOfSet(config).contains(HostAndPort.fromParts("host-d", 4)));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d5cf5285/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/sharding/MongoDBConfigServerIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/sharding/MongoDBConfigServerIntegrationTest.java b/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/sharding/MongoDBConfigServerIntegrationTest.java
deleted file mode 100644
index 4aa8f69..0000000
--- a/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/sharding/MongoDBConfigServerIntegrationTest.java
+++ /dev/null
@@ -1,66 +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 brooklyn.entity.nosql.mongodb.sharding;
-
-import static org.testng.Assert.assertFalse;
-
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.basic.ApplicationBuilder;
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.nosql.mongodb.MongoDBServer;
-import brooklyn.entity.nosql.mongodb.MongoDBTestHelper;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.entity.trait.Startable;
-import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
-import brooklyn.test.Asserts;
-import brooklyn.test.EntityTestUtils;
-import brooklyn.test.entity.TestApplication;
-
-import com.google.common.collect.ImmutableList;
-
-public class MongoDBConfigServerIntegrationTest {
- private TestApplication app;
- private LocalhostMachineProvisioningLocation localhostProvisioningLocation;
-
- @BeforeMethod(alwaysRun=true)
- public void setUp() throws Exception {
- localhostProvisioningLocation = new LocalhostMachineProvisioningLocation();
- app = ApplicationBuilder.newManagedApp(TestApplication.class);
- }
-
- @AfterMethod(alwaysRun=true)
- public void tearDown() throws Exception {
- if (app != null) Entities.destroyAll(app.getManagementContext());
- }
-
- @Test(groups = "Integration")
- public void testCanStartAndStop() throws Exception {
- MongoDBConfigServer entity = app.createAndManageChild(EntitySpec.create(MongoDBConfigServer.class)
- .configure(MongoDBServer.MONGODB_CONF_TEMPLATE_URL, "classpath:///test-mongodb-configserver.conf"));
- app.start(ImmutableList.of(localhostProvisioningLocation));
-
- EntityTestUtils.assertAttributeEqualsEventually(entity, Startable.SERVICE_UP, true);
- Asserts.assertTrue(MongoDBTestHelper.isConfigServer(entity), "Server is not a config server");
- entity.stop();
- assertFalse(entity.getAttribute(Startable.SERVICE_UP));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d5cf5285/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/sharding/MongoDBShardedDeploymentEc2LiveTest.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/sharding/MongoDBShardedDeploymentEc2LiveTest.java b/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/sharding/MongoDBShardedDeploymentEc2LiveTest.java
deleted file mode 100644
index e85a3ef..0000000
--- a/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/sharding/MongoDBShardedDeploymentEc2LiveTest.java
+++ /dev/null
@@ -1,83 +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 brooklyn.entity.nosql.mongodb.sharding;
-
-import groovy.time.TimeDuration;
-
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.AbstractEc2LiveTest;
-import brooklyn.entity.Entity;
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.nosql.mongodb.MongoDBReplicaSet;
-import brooklyn.entity.nosql.mongodb.MongoDBServer;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.location.Location;
-import brooklyn.test.Asserts;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-
-/**
- * NOTE: These test will provision 9 machines in AWS, which can cause 'Request limit exceeded' and
- * 'Exhausted available authentication methods' exceptions, depending upon current AWS load. You can
- * mitigate this issue by adding the following lines to your brooklyn.properties:
- *
- * brooklyn.location.jclouds.machineCreateAttempts=3
- * brooklyn.jclouds.aws-ec2.maxConcurrentMachineCreations=5
- */
-@Test
-public class MongoDBShardedDeploymentEc2LiveTest extends AbstractEc2LiveTest {
-
- private static final Integer ROUTER_CLUSTER_SIZE = 2;
- private static final Integer REPLICASET_SIZE = 2;
- private static final Integer SHARD_CLUSTER_SIZE = 3;
- private static final TimeDuration TIMEOUT = new TimeDuration(0, 3, 0, 0);
-
- @Override
- protected void doTest(Location loc) throws Exception {
- final MongoDBShardedDeployment deployment = app.createAndManageChild(EntitySpec.create(MongoDBShardedDeployment.class)
- .configure(MongoDBShardedDeployment.INITIAL_ROUTER_CLUSTER_SIZE, ROUTER_CLUSTER_SIZE)
- .configure(MongoDBShardedDeployment.SHARD_REPLICASET_SIZE, REPLICASET_SIZE)
- .configure(MongoDBShardedDeployment.INITIAL_SHARD_CLUSTER_SIZE, SHARD_CLUSTER_SIZE)
- .configure(MongoDBShardedDeployment.MONGODB_REPLICA_SET_SPEC, EntitySpec.create(MongoDBReplicaSet.class)
- .configure(MongoDBServer.MONGODB_CONF_TEMPLATE_URL, "classpath:///test-mongodb.conf")
- .configure(MongoDBReplicaSet.MEMBER_SPEC, EntitySpec.create(MongoDBServer.class)))
- .configure(MongoDBShardedDeployment.MONGODB_ROUTER_SPEC, EntitySpec.create(MongoDBRouter.class)
- .configure(MongoDBConfigServer.MONGODB_CONF_TEMPLATE_URL, "classpath:///test-mongodb-router.conf"))
- .configure(MongoDBShardedDeployment.MONGODB_CONFIG_SERVER_SPEC, EntitySpec.create(MongoDBConfigServer.class)
- .configure(MongoDBConfigServer.MONGODB_CONF_TEMPLATE_URL, "classpath:///test-mongodb-configserver.conf")));
-
- app.start(ImmutableList.of(loc));
-
- Entities.dumpInfo(app);
-
- Asserts.succeedsEventually(ImmutableMap.of("timeout", TIMEOUT), new Runnable() {
- public void run() {
- Assert.assertEquals(deployment.getRouterCluster().getCurrentSize(), ROUTER_CLUSTER_SIZE);
- Assert.assertEquals(deployment.getShardCluster().getCurrentSize(), SHARD_CLUSTER_SIZE);
- Assert.assertEquals(deployment.getConfigCluster().getCurrentSize(), MongoDBShardedDeployment.CONFIG_CLUSTER_SIZE.getDefaultValue());
- for (Entity entity : deployment.getShardCluster().getMembers()) {
- Assert.assertEquals(((MongoDBReplicaSet) entity).getCurrentSize(), REPLICASET_SIZE);
- }
- }
- });
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d5cf5285/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/sharding/MongoDBShardedDeploymentIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/sharding/MongoDBShardedDeploymentIntegrationTest.java b/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/sharding/MongoDBShardedDeploymentIntegrationTest.java
deleted file mode 100644
index 9348431..0000000
--- a/software/nosql/src/test/java/brooklyn/entity/nosql/mongodb/sharding/MongoDBShardedDeploymentIntegrationTest.java
+++ /dev/null
@@ -1,129 +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 brooklyn.entity.nosql.mongodb.sharding;
-
-import org.testng.Assert;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.BrooklynAppLiveTestSupport;
-import brooklyn.entity.Entity;
-import brooklyn.entity.nosql.mongodb.AbstractMongoDBServer;
-import brooklyn.entity.nosql.mongodb.MongoDBReplicaSet;
-import brooklyn.entity.nosql.mongodb.MongoDBServer;
-import brooklyn.entity.nosql.mongodb.MongoDBTestHelper;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.entity.trait.Startable;
-import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
-import brooklyn.test.EntityTestUtils;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-import com.mongodb.DBObject;
-
-public class MongoDBShardedDeploymentIntegrationTest extends BrooklynAppLiveTestSupport {
-
- private static final Integer ROUTER_CLUSTER_SIZE = 2;
- private static final Integer REPLICASET_SIZE = 2;
- private static final Integer SHARD_CLUSTER_SIZE = 3;
-
- private LocalhostMachineProvisioningLocation localhostProvisioningLocation;
-
- @BeforeMethod(alwaysRun=true)
- public void setUp() throws Exception {
- super.setUp();
- localhostProvisioningLocation = app.newLocalhostProvisioningLocation();
- }
-
- private MongoDBShardedDeployment makeAndStartDeployment() {
- final MongoDBShardedDeployment deployment = app.createAndManageChild(EntitySpec.create(MongoDBShardedDeployment.class)
- .configure(MongoDBShardedDeployment.INITIAL_ROUTER_CLUSTER_SIZE, ROUTER_CLUSTER_SIZE)
- .configure(MongoDBShardedDeployment.SHARD_REPLICASET_SIZE, REPLICASET_SIZE)
- .configure(MongoDBShardedDeployment.INITIAL_SHARD_CLUSTER_SIZE, SHARD_CLUSTER_SIZE)
- .configure(MongoDBShardedDeployment.MONGODB_REPLICA_SET_SPEC, EntitySpec.create(MongoDBReplicaSet.class)
- .configure(MongoDBServer.MONGODB_CONF_TEMPLATE_URL, "classpath:///test-mongodb.conf")
- .configure(MongoDBReplicaSet.MEMBER_SPEC, EntitySpec.create(MongoDBServer.class)))
- .configure(MongoDBShardedDeployment.MONGODB_ROUTER_SPEC, EntitySpec.create(MongoDBRouter.class)
- .configure(MongoDBConfigServer.MONGODB_CONF_TEMPLATE_URL, "classpath:///test-mongodb-router.conf"))
- .configure(MongoDBShardedDeployment.MONGODB_CONFIG_SERVER_SPEC, EntitySpec.create(MongoDBConfigServer.class)
- .configure(MongoDBConfigServer.MONGODB_CONF_TEMPLATE_URL, "classpath:///test-mongodb-configserver.conf")));
- app.start(ImmutableList.of(localhostProvisioningLocation));
- EntityTestUtils.assertAttributeEqualsEventually(deployment, Startable.SERVICE_UP, true);
- return deployment;
- }
-
- @Test(groups = "Integration")
- public void testCanStartAndStopDeployment() {
- MongoDBShardedDeployment deployment = makeAndStartDeployment();
- deployment.stop();
- EntityTestUtils.assertAttributeEqualsEventually(deployment, Startable.SERVICE_UP, false);
- }
-
- @Test(groups = "Integration")
- public void testDeployedStructure() {
- MongoDBShardedDeployment deployment = makeAndStartDeployment();
- MongoDBConfigServerCluster configServers = deployment.getConfigCluster();
- MongoDBRouterCluster routers = deployment.getRouterCluster();
- MongoDBShardCluster shards = deployment.getShardCluster();
- Assert.assertNotNull(configServers);
- Assert.assertNotNull(routers);
- Assert.assertNotNull(shards);
- Assert.assertEquals(configServers.getCurrentSize(), MongoDBShardedDeployment.CONFIG_CLUSTER_SIZE.getDefaultValue());
- Assert.assertEquals(routers.getCurrentSize(), ROUTER_CLUSTER_SIZE);
- Assert.assertEquals(shards.getCurrentSize(), SHARD_CLUSTER_SIZE);
- for (Entity entity : deployment.getShardCluster().getMembers()) {
- Assert.assertEquals(((MongoDBReplicaSet)entity).getCurrentSize(), REPLICASET_SIZE);
- }
- for (Entity entity : configServers.getMembers()) {
- checkEntityTypeAndServiceUp(entity, MongoDBConfigServer.class);
- }
- for (Entity entity : routers.getMembers()) {
- checkEntityTypeAndServiceUp(entity, MongoDBRouter.class);
- }
- for (Entity entity : shards.getMembers()) {
- checkEntityTypeAndServiceUp(entity, MongoDBReplicaSet.class);
- }
- }
-
- @Test(groups = "Integration")
- private void testReadAndWriteDifferentRouters() {
- MongoDBShardedDeployment deployment = makeAndStartDeployment();
- EntityTestUtils.assertAttributeEqualsEventually(deployment, Startable.SERVICE_UP, true);
- MongoDBRouter router1 = (MongoDBRouter) Iterables.get(deployment.getRouterCluster().getMembers(), 0);
- MongoDBRouter router2 = (MongoDBRouter) Iterables.get(deployment.getRouterCluster().getMembers(), 1);
- EntityTestUtils.assertAttributeEqualsEventually(router1, Startable.SERVICE_UP, true);
- EntityTestUtils.assertAttributeEqualsEventually(router2, Startable.SERVICE_UP, true);
-
- String documentId = MongoDBTestHelper.insert(router1, "meaning-of-life", 42);
- DBObject docOut = MongoDBTestHelper.getById(router2, documentId);
- Assert.assertEquals(docOut.get("meaning-of-life"), 42);
-
- for (Entity entity : Iterables.filter(app.getManagementContext().getEntityManager().getEntitiesInApplication(app), AbstractMongoDBServer.class)) {
- EntityTestUtils.assertAttributeEqualsEventually(entity, Startable.SERVICE_UP, true);
- }
- }
-
- private void checkEntityTypeAndServiceUp(Entity entity, Class<? extends Entity> expectedClass) {
- Assert.assertNotNull(entity);
- Assert.assertTrue(expectedClass.isAssignableFrom(entity.getClass()), "expected: " + expectedClass
- + " on interfaces, found: " + entity.getClass().getInterfaces());
- EntityTestUtils.assertAttributeEqualsEventually(entity, Startable.SERVICE_UP, true);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d5cf5285/software/nosql/src/test/java/brooklyn/entity/nosql/redis/JedisSupport.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/test/java/brooklyn/entity/nosql/redis/JedisSupport.java b/software/nosql/src/test/java/brooklyn/entity/nosql/redis/JedisSupport.java
deleted file mode 100644
index fba0f59..0000000
--- a/software/nosql/src/test/java/brooklyn/entity/nosql/redis/JedisSupport.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 brooklyn.entity.nosql.redis;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-import redis.clients.jedis.Jedis;
-
-import com.google.common.base.Strings;
-
-/**
- * {@link RedisStore} testing using Jedis API.
- */
-public class JedisSupport {
- private static final String TEST_DATA = Strings.repeat("0123456789", 16);
-
- private RedisStore redis;
-
- public JedisSupport(RedisStore redis) {
- this.redis = redis;
- }
-
- /**
- * Exercise the {@link RedisStore} using the Jedis API.
- */
- public void redisTest() throws Exception {
- writeData("brooklyn", TEST_DATA);
- String result = readData("brooklyn");
- assertEquals(result, TEST_DATA);
- }
-
- public void writeData(String key, String val) throws Exception {
- Jedis client = getRedisClient(redis);
- try {
- client.set(key, val);
- } finally {
- client.disconnect();
- }
- }
-
- public String readData(String key) throws Exception {
- Jedis client = getRedisClient(redis);
- try {
- return client.get(key);
- } finally {
- client.disconnect();
- }
- }
-
- private Jedis getRedisClient(RedisStore redis) {
- int port = redis.getAttribute(RedisStore.REDIS_PORT);
- String host = redis.getAttribute(RedisStore.HOSTNAME);
- Jedis client = new Jedis(host, port);
- client.connect();
- assertTrue(client.isConnected());
- return client;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d5cf5285/software/nosql/src/test/java/brooklyn/entity/nosql/redis/RedisClusterIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/test/java/brooklyn/entity/nosql/redis/RedisClusterIntegrationTest.java b/software/nosql/src/test/java/brooklyn/entity/nosql/redis/RedisClusterIntegrationTest.java
deleted file mode 100644
index 7795bac..0000000
--- a/software/nosql/src/test/java/brooklyn/entity/nosql/redis/RedisClusterIntegrationTest.java
+++ /dev/null
@@ -1,109 +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 brooklyn.entity.nosql.redis;
-
-import static org.testng.Assert.assertEquals;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.concurrent.Callable;
-
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.basic.ApplicationBuilder;
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.group.DynamicCluster;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.entity.trait.Startable;
-import brooklyn.location.Location;
-import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
-import brooklyn.test.Asserts;
-import brooklyn.test.EntityTestUtils;
-import brooklyn.test.entity.TestApplication;
-
-import com.google.common.collect.ImmutableList;
-
-public class RedisClusterIntegrationTest {
-
- private TestApplication app;
- private Location loc;
- private RedisCluster cluster;
-
- @BeforeMethod(alwaysRun=true)
- public void setup() {
- app = ApplicationBuilder.newManagedApp(TestApplication.class);
- loc = new LocalhostMachineProvisioningLocation();
- }
-
- @AfterMethod(alwaysRun=true)
- public void shutdown() {
- if (app != null) Entities.destroyAll(app.getManagementContext());
- }
-
- @Test(groups = { "Integration" })
- public void testRedisClusterReplicates() throws Exception {
- final String key = "mykey";
- final String val = "1234567890";
-
- cluster = app.createAndManageChild(EntitySpec.create(RedisCluster.class)
- .configure(DynamicCluster.INITIAL_SIZE, 3));
- app.start(ImmutableList.of(loc));
-
- EntityTestUtils.assertAttributeEqualsEventually(cluster, Startable.SERVICE_UP, true);
-
- RedisStore master = cluster.getMaster();
- List<RedisSlave> slaves = ImmutableList.<RedisSlave>copyOf((Collection)cluster.getSlaves().getMembers());
-
- assertEquals(slaves.size(), 3);
-
- JedisSupport viaMaster = new JedisSupport(master);
- viaMaster.writeData(key, val);
- assertEquals(viaMaster.readData(key), val);
-
- for (RedisSlave slave : slaves) {
- final JedisSupport viaSlave = new JedisSupport(slave);
- Asserts.succeedsEventually(new Callable<Void>() {
- @Override public Void call() throws Exception {
- assertEquals(viaSlave.readData(key), val);
- return null;
- }});
- }
-
- // Check that stopping slave will not stop anything else
- // (it used to stop master because wasn't supplying port!)
- slaves.get(0).stop();
- EntityTestUtils.assertAttributeEqualsEventually(slaves.get(0), Startable.SERVICE_UP, false);
-
- assertEquals(master.getAttribute(Startable.SERVICE_UP), Boolean.TRUE);
- for (RedisSlave slave : slaves.subList(1, slaves.size())) {
- assertEquals(slave.getAttribute(Startable.SERVICE_UP), Boolean.TRUE);
- }
-
- // Check that stopping cluster will stop everything
- cluster.stop();
-
- EntityTestUtils.assertAttributeEqualsEventually(cluster, Startable.SERVICE_UP, false);
- assertEquals(master.getAttribute(Startable.SERVICE_UP), Boolean.FALSE);
- for (RedisSlave slave : slaves) {
- assertEquals(slave.getAttribute(Startable.SERVICE_UP), Boolean.FALSE);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d5cf5285/software/nosql/src/test/java/brooklyn/entity/nosql/redis/RedisEc2LiveTest.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/test/java/brooklyn/entity/nosql/redis/RedisEc2LiveTest.java b/software/nosql/src/test/java/brooklyn/entity/nosql/redis/RedisEc2LiveTest.java
deleted file mode 100644
index a7d1fac..0000000
--- a/software/nosql/src/test/java/brooklyn/entity/nosql/redis/RedisEc2LiveTest.java
+++ /dev/null
@@ -1,66 +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 brooklyn.entity.nosql.redis;
-
-import javax.annotation.Nullable;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.AbstractEc2LiveTest;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.location.Location;
-import brooklyn.test.EntityTestUtils;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableList;
-
-public class RedisEc2LiveTest extends AbstractEc2LiveTest {
-
- @SuppressWarnings("unused")
- private static final Logger LOG = LoggerFactory.getLogger(RedisEc2LiveTest.class);
-
- @Override
- protected void doTest(Location loc) throws Exception {
- RedisStore redis = app.createAndManageChild(EntitySpec.create(RedisStore.class));
- app.start(ImmutableList.of(loc));
- EntityTestUtils.assertAttributeEqualsEventually(redis, RedisStore.SERVICE_UP, true);
-
- JedisSupport support = new JedisSupport(redis);
- support.redisTest();
- // Confirm sensors are valid
- EntityTestUtils.assertPredicateEventuallyTrue(redis, new Predicate<RedisStore>() {
- @Override public boolean apply(@Nullable RedisStore input) {
- return input != null &&
- input.getAttribute(RedisStore.UPTIME) > 0 &&
- input.getAttribute(RedisStore.TOTAL_COMMANDS_PROCESSED) >= 0 &&
- input.getAttribute(RedisStore.TOTAL_CONNECTIONS_RECEIVED) >= 0 &&
- input.getAttribute(RedisStore.EXPIRED_KEYS) >= 0 &&
- input.getAttribute(RedisStore.EVICTED_KEYS) >= 0 &&
- input.getAttribute(RedisStore.KEYSPACE_HITS) >= 0 &&
- input.getAttribute(RedisStore.KEYSPACE_MISSES) >= 0;
- }
- });
-
- }
-
- @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/d5cf5285/software/nosql/src/test/java/brooklyn/entity/nosql/redis/RedisIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/test/java/brooklyn/entity/nosql/redis/RedisIntegrationTest.java b/software/nosql/src/test/java/brooklyn/entity/nosql/redis/RedisIntegrationTest.java
deleted file mode 100644
index 9ecf445..0000000
--- a/software/nosql/src/test/java/brooklyn/entity/nosql/redis/RedisIntegrationTest.java
+++ /dev/null
@@ -1,119 +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 brooklyn.entity.nosql.redis;
-
-import javax.annotation.Nullable;
-
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.entity.trait.Startable;
-import brooklyn.location.Location;
-import brooklyn.location.basic.PortRanges;
-import brooklyn.test.EntityTestUtils;
-import brooklyn.test.entity.TestApplication;
-import brooklyn.util.time.Duration;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-
-/**
- * Test the operation of the {@link RedisStore} class.
- */
-public class RedisIntegrationTest {
-
- private TestApplication app;
- private Location loc;
- private RedisStore redis;
-
- @BeforeMethod(alwaysRun=true)
- public void setup() {
- app = TestApplication.Factory.newManagedInstanceForTests();
- loc = app.newLocalhostProvisioningLocation();
- }
-
- @AfterMethod(alwaysRun=true)
- public void shutdown() {
- if (app != null) Entities.destroyAll(app.getManagementContext());
- }
-
- /**
- * Test that the server starts up and sets SERVICE_UP correctly.
- */
- @Test(groups = { "Integration" })
- public void canStartupAndShutdown() throws Exception {
- redis = app.createAndManageChild(EntitySpec.create(RedisStore.class));
- app.start(ImmutableList.of(loc));
-
- EntityTestUtils.assertAttributeEqualsEventually(redis, Startable.SERVICE_UP, true);
-
- redis.stop();
-
- EntityTestUtils.assertAttributeEqualsEventually(redis, Startable.SERVICE_UP, false);
- }
-
- /**
- * Test that a client can connect to the service.
- */
- @Test(groups = { "Integration" })
- public void testRedisConnection() throws Exception {
- redis = app.createAndManageChild(EntitySpec.create(RedisStore.class));
- app.start(ImmutableList.of(loc));
-
- EntityTestUtils.assertAttributeEqualsEventually(redis, Startable.SERVICE_UP, true);
-
- JedisSupport support = new JedisSupport(redis);
- support.redisTest();
- }
-
- /**
- * Test we get sensors from an instance on a non-default port
- */
- @Test(groups = { "Integration" })
- public void testNonStandardPort() throws Exception {
- redis = app.createAndManageChild(EntitySpec.create(RedisStore.class)
- .configure(RedisStore.REDIS_PORT, PortRanges.fromString("10000+")));
- app.start(ImmutableList.of(loc));
-
- EntityTestUtils.assertAttributeEqualsEventually(redis, Startable.SERVICE_UP, true);
- JedisSupport support = new JedisSupport(redis);
- support.redisTest();
-
- // Increase timeout because test was failing on jenkins sometimes. The log shows only one
- // call to `info server` (for obtaining uptime) which took 26 seconds; then 4 seconds later
- // this assert failed (with it checking every 500ms). The response did correctly contain
- // `uptime_in_seconds:27`.
- EntityTestUtils.assertPredicateEventuallyTrue(ImmutableMap.of("timeout", Duration.FIVE_MINUTES), redis, new Predicate<RedisStore>() {
- @Override public boolean apply(@Nullable RedisStore input) {
- return input != null &&
- input.getAttribute(RedisStore.UPTIME) > 0 &&
- input.getAttribute(RedisStore.TOTAL_COMMANDS_PROCESSED) >= 0 &&
- input.getAttribute(RedisStore.TOTAL_CONNECTIONS_RECEIVED) >= 0 &&
- input.getAttribute(RedisStore.EXPIRED_KEYS) >= 0 &&
- input.getAttribute(RedisStore.EVICTED_KEYS) >= 0 &&
- input.getAttribute(RedisStore.KEYSPACE_HITS) >= 0 &&
- input.getAttribute(RedisStore.KEYSPACE_MISSES) >= 0;
- }
- });
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d5cf5285/software/nosql/src/test/java/brooklyn/entity/nosql/riak/RiakClusterEc2LiveTest.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/test/java/brooklyn/entity/nosql/riak/RiakClusterEc2LiveTest.java b/software/nosql/src/test/java/brooklyn/entity/nosql/riak/RiakClusterEc2LiveTest.java
deleted file mode 100644
index 3f9e7d9..0000000
--- a/software/nosql/src/test/java/brooklyn/entity/nosql/riak/RiakClusterEc2LiveTest.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 brooklyn.entity.nosql.riak;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.AbstractEc2LiveTest;
-import brooklyn.entity.basic.Attributes;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.location.Location;
-import brooklyn.test.EntityTestUtils;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Iterables;
-
-public class RiakClusterEc2LiveTest extends AbstractEc2LiveTest {
- @SuppressWarnings("unused")
- private static final Logger LOG = LoggerFactory.getLogger(RiakNodeEc2LiveTest.class);
-
- @Override
- protected void doTest(Location loc) throws Exception {
- RiakCluster cluster = app.createAndManageChild(EntitySpec.create(RiakCluster.class)
- .configure(RiakCluster.INITIAL_SIZE, 3)
- .configure(RiakCluster.MEMBER_SPEC, EntitySpec.create(RiakNode.class)));
- app.start(ImmutableList.of(loc));
-
- EntityTestUtils.assertAttributeEqualsEventually(cluster, RiakNode.SERVICE_UP, true);
-
- RiakNode first = (RiakNode) Iterables.get(cluster.getMembers(), 0);
- RiakNode second = (RiakNode) Iterables.get(cluster.getMembers(), 1);
-
- assertNodesUpAndInCluster(first, second);
-
- EntityTestUtils.assertAttributeEqualsEventually(cluster, Attributes.SERVICE_UP, true);
- }
-
- private void assertNodesUpAndInCluster(final RiakNode... nodes) {
- for (final RiakNode node : nodes) {
- EntityTestUtils.assertAttributeEqualsEventually(node, RiakNode.SERVICE_UP, true);
- EntityTestUtils.assertAttributeEqualsEventually(node, RiakNode.RIAK_NODE_HAS_JOINED_CLUSTER, true);
- }
- }
-
- @Test(enabled = false)
- public void testDummy() {
- } // Convince TestNG IDE integration that this really does have test methods
-
-
- @Override
- public void test_Ubuntu_12_0() throws Exception {
- //Override to add the custom securityGroup for opening Riak ports.
- // Image: {id=us-east-1/ami-d0f89fb9, providerId=ami-d0f89fb9, name=ubuntu/images/ebs/ubuntu-precise-12.04-amd64-server-20130411.1, location={scope=REGION, id=us-east-1, description=us-east-1, parent=aws-ec2, iso3166Codes=[US-VA]}, os={family=ubuntu, arch=paravirtual, version=12.04, description=099720109477/ubuntu/images/ebs/ubuntu-precise-12.04-amd64-server-20130411.1, is64Bit=true}, description=099720109477/ubuntu/images/ebs/ubuntu-precise-12.04-amd64-server-20130411.1, version=20130411.1, status=AVAILABLE[available], loginUser=ubuntu, userMetadata={owner=099720109477, rootDeviceType=ebs, virtualizationType=paravirtual, hypervisor=xen}}
- runTest(ImmutableMap.of("imageId", "us-east-1/ami-d0f89fb9", "loginUser", "ubuntu", "hardwareId", SMALL_HARDWARE_ID, "securityGroups", "RiakSecurityGroup"));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d5cf5285/software/nosql/src/test/java/brooklyn/entity/nosql/riak/RiakNodeEc2LiveTest.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/test/java/brooklyn/entity/nosql/riak/RiakNodeEc2LiveTest.java b/software/nosql/src/test/java/brooklyn/entity/nosql/riak/RiakNodeEc2LiveTest.java
deleted file mode 100644
index b3a2005..0000000
--- a/software/nosql/src/test/java/brooklyn/entity/nosql/riak/RiakNodeEc2LiveTest.java
+++ /dev/null
@@ -1,51 +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 brooklyn.entity.nosql.riak;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-
-import brooklyn.entity.AbstractEc2LiveTest;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.location.Location;
-import brooklyn.test.EntityTestUtils;
-
-public class RiakNodeEc2LiveTest extends AbstractEc2LiveTest {
-
- @SuppressWarnings("unused")
- private static final Logger LOG = LoggerFactory.getLogger(RiakNodeEc2LiveTest.class);
-
- @Override
- protected void doTest(Location loc) throws Exception {
- RiakNode entity = app.createAndManageChild(EntitySpec.create(RiakNode.class));
- app.start(ImmutableList.of(loc));
-
- EntityTestUtils.assertAttributeEqualsEventually(entity, RiakNode.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/d5cf5285/software/nosql/src/test/java/brooklyn/entity/nosql/riak/RiakNodeGoogleComputeLiveTest.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/test/java/brooklyn/entity/nosql/riak/RiakNodeGoogleComputeLiveTest.java b/software/nosql/src/test/java/brooklyn/entity/nosql/riak/RiakNodeGoogleComputeLiveTest.java
deleted file mode 100644
index a2cc46e..0000000
--- a/software/nosql/src/test/java/brooklyn/entity/nosql/riak/RiakNodeGoogleComputeLiveTest.java
+++ /dev/null
@@ -1,62 +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 brooklyn.entity.nosql.riak;
-
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-
-import brooklyn.entity.AbstractGoogleComputeLiveTest;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.location.Location;
-import brooklyn.test.EntityTestUtils;
-
-public class RiakNodeGoogleComputeLiveTest extends AbstractGoogleComputeLiveTest {
- @Override
- protected void doTest(Location loc) throws Exception {
- RiakCluster cluster = app.createAndManageChild(EntitySpec.create(RiakCluster.class)
- .configure(RiakCluster.INITIAL_SIZE, 2)
- .configure(RiakCluster.MEMBER_SPEC, EntitySpec.create(RiakNode.class)));
- app.start(ImmutableList.of(loc));
-
- EntityTestUtils.assertAttributeEqualsEventually(cluster, RiakCluster.SERVICE_UP, true);
-
- RiakNode first = (RiakNode) Iterables.get(cluster.getMembers(), 0);
- RiakNode second = (RiakNode) Iterables.get(cluster.getMembers(), 1);
-
- EntityTestUtils.assertAttributeEqualsEventually(first, RiakNode.SERVICE_UP, true);
- EntityTestUtils.assertAttributeEqualsEventually(second, RiakNode.SERVICE_UP, true);
-
- EntityTestUtils.assertAttributeEqualsEventually(first, RiakNode.RIAK_NODE_HAS_JOINED_CLUSTER, true);
- EntityTestUtils.assertAttributeEqualsEventually(second, RiakNode.RIAK_NODE_HAS_JOINED_CLUSTER, true);
-
- }
-
- @Test(groups = {"Live"})
- @Override
- public void test_DefaultImage() throws Exception {
- super.test_DefaultImage();
- }
-
- @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/d5cf5285/software/nosql/src/test/java/brooklyn/entity/nosql/riak/RiakNodeIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/test/java/brooklyn/entity/nosql/riak/RiakNodeIntegrationTest.java b/software/nosql/src/test/java/brooklyn/entity/nosql/riak/RiakNodeIntegrationTest.java
deleted file mode 100644
index 002739c..0000000
--- a/software/nosql/src/test/java/brooklyn/entity/nosql/riak/RiakNodeIntegrationTest.java
+++ /dev/null
@@ -1,64 +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 brooklyn.entity.nosql.riak;
-
-import static org.testng.Assert.assertFalse;
-
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.entity.trait.Startable;
-import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
-import brooklyn.test.EntityTestUtils;
-import brooklyn.test.entity.TestApplication;
-
-public class RiakNodeIntegrationTest {
-
- private TestApplication app;
- private LocalhostMachineProvisioningLocation localhostProvisioningLocation;
-
- @BeforeMethod(alwaysRun = true)
- public void setUp() throws Exception {
- localhostProvisioningLocation = new LocalhostMachineProvisioningLocation();
- app = TestApplication.Factory.newManagedInstanceForTests();
- }
-
- @AfterMethod(alwaysRun = true)
- public void tearDown() throws Exception {
- if (app != null) Entities.destroyAll(app.getManagementContext());
- }
-
-
- @Test(groups = "Integration")
- public void testCanStartAndStop() throws Exception {
- RiakNode entity = app.createAndManageChild(EntitySpec.create(RiakNode.class)
- .configure(RiakNode.SUGGESTED_VERSION, "2.1.1"));
- app.start(ImmutableList.of(localhostProvisioningLocation));
-
- EntityTestUtils.assertAttributeEqualsEventually(entity, Startable.SERVICE_UP, true);
- entity.stop();
- assertFalse(entity.getAttribute(Startable.SERVICE_UP));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d5cf5285/software/nosql/src/test/java/brooklyn/entity/nosql/riak/RiakNodeSoftlayerLiveTest.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/test/java/brooklyn/entity/nosql/riak/RiakNodeSoftlayerLiveTest.java b/software/nosql/src/test/java/brooklyn/entity/nosql/riak/RiakNodeSoftlayerLiveTest.java
deleted file mode 100644
index 123ef7f..0000000
--- a/software/nosql/src/test/java/brooklyn/entity/nosql/riak/RiakNodeSoftlayerLiveTest.java
+++ /dev/null
@@ -1,45 +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 brooklyn.entity.nosql.riak;
-
-import org.testng.annotations.BeforeMethod;
-
-import com.google.common.collect.ImmutableList;
-
-import brooklyn.entity.AbstractSoftlayerLiveTest;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.location.Location;
-import brooklyn.test.EntityTestUtils;
-
-public class RiakNodeSoftlayerLiveTest extends AbstractSoftlayerLiveTest {
-
- @BeforeMethod(alwaysRun=true)
- public void setUp() throws Exception {
- super.setUp();
- }
-
- @Override
- protected void doTest(Location loc) throws Exception {
- RiakNode entity = app.createAndManageChild(EntitySpec.create(RiakNode.class)
- .configure(RiakNode.SUGGESTED_VERSION, "2.1.1"));
- app.start(ImmutableList.of(loc));
-
- EntityTestUtils.assertAttributeEqualsEventually(entity, RiakNode.SERVICE_UP, true);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d5cf5285/software/nosql/src/test/java/brooklyn/entity/nosql/solr/AbstractSolrServerTest.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/test/java/brooklyn/entity/nosql/solr/AbstractSolrServerTest.java b/software/nosql/src/test/java/brooklyn/entity/nosql/solr/AbstractSolrServerTest.java
deleted file mode 100644
index de77a32..0000000
--- a/software/nosql/src/test/java/brooklyn/entity/nosql/solr/AbstractSolrServerTest.java
+++ /dev/null
@@ -1,41 +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 brooklyn.entity.nosql.solr;
-
-import org.testng.annotations.BeforeMethod;
-
-import brooklyn.entity.BrooklynAppLiveTestSupport;
-import brooklyn.location.Location;
-
-/**
- * Solr test framework for integration and live tests.
- */
-public class AbstractSolrServerTest extends BrooklynAppLiveTestSupport {
-
- protected Location testLocation;
- protected SolrServer solr;
-
- @BeforeMethod(alwaysRun = true)
- @Override
- public void setUp() throws Exception {
- super.setUp();
- testLocation = app.newLocalhostProvisioningLocation();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d5cf5285/software/nosql/src/test/java/brooklyn/entity/nosql/solr/SolrJSupport.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/test/java/brooklyn/entity/nosql/solr/SolrJSupport.java b/software/nosql/src/test/java/brooklyn/entity/nosql/solr/SolrJSupport.java
deleted file mode 100644
index d8bbd81..0000000
--- a/software/nosql/src/test/java/brooklyn/entity/nosql/solr/SolrJSupport.java
+++ /dev/null
@@ -1,66 +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 brooklyn.entity.nosql.solr;
-
-import java.util.Map;
-
-import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.client.solrj.impl.HttpSolrServer;
-import org.apache.solr.common.SolrDocument;
-import org.apache.solr.common.SolrInputDocument;
-
-import brooklyn.entity.basic.Attributes;
-
-/**
- * Solr testing using SolrJ API.
- */
-public class SolrJSupport {
-
- private final HttpSolrServer server;
-
- public SolrJSupport(SolrServer node, String core) {
- this(node.getAttribute(Attributes.HOSTNAME), node.getSolrPort(), core);
- }
-
- public SolrJSupport(String hostname, int solrPort, String core) {
- server = new HttpSolrServer(String.format("http://%s:%d/solr/%s", hostname, solrPort, core));
- server.setMaxRetries(1);
- server.setConnectionTimeout(5000);
- server.setSoTimeout(5000);
- }
-
- public void commit() throws Exception {
- server.commit();
- }
-
- public void addDocument(Map<String, Object> fields) throws Exception {
- SolrInputDocument doc = new SolrInputDocument();
- for (String field : fields.keySet()) {
- doc.setField(field, fields.get(field));
- }
- server.add(doc, 100);
- }
-
- public Iterable<SolrDocument> getDocuments() throws Exception {
- SolrQuery solrQuery = new SolrQuery();
- solrQuery.setQuery("*:*");
-
- return server.query(solrQuery).getResults();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/d5cf5285/software/nosql/src/test/java/brooklyn/entity/nosql/solr/SolrServerEc2LiveTest.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/test/java/brooklyn/entity/nosql/solr/SolrServerEc2LiveTest.java b/software/nosql/src/test/java/brooklyn/entity/nosql/solr/SolrServerEc2LiveTest.java
deleted file mode 100644
index 59dcc61..0000000
--- a/software/nosql/src/test/java/brooklyn/entity/nosql/solr/SolrServerEc2LiveTest.java
+++ /dev/null
@@ -1,66 +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 brooklyn.entity.nosql.solr;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertTrue;
-
-import org.apache.solr.common.SolrDocument;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import brooklyn.entity.AbstractEc2LiveTest;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.entity.trait.Startable;
-import brooklyn.location.Location;
-import brooklyn.test.EntityTestUtils;
-import brooklyn.util.collections.MutableMap;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Iterables;
-
-public class SolrServerEc2LiveTest extends AbstractEc2LiveTest {
-
- private static final Logger log = LoggerFactory.getLogger(SolrServerEc2LiveTest.class);
-
- @Override
- protected void doTest(Location loc) throws Exception {
- log.info("Testing Solr on {}", loc);
-
- SolrServer solr = app.createAndManageChild(EntitySpec.create(SolrServer.class)
- .configure(SolrServer.SOLR_CORE_CONFIG, ImmutableMap.of("example", "classpath://solr/example.tgz")));
- app.start(ImmutableList.of(loc));
-
- EntityTestUtils.assertAttributeEqualsEventually(solr, Startable.SERVICE_UP, true);
-
- SolrJSupport client = new SolrJSupport(solr, "example");
-
- Iterable<SolrDocument> results = client.getDocuments();
- assertTrue(Iterables.isEmpty(results));
-
- client.addDocument(MutableMap.<String, Object>of("id", "1", "description", "first"));
- client.addDocument(MutableMap.<String, Object>of("id", "2", "description", "second"));
- client.addDocument(MutableMap.<String, Object>of("id", "3", "description", "third"));
- client.commit();
-
- results = client.getDocuments();
- assertEquals(Iterables.size(results), 3);
- }
-}