You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2015/08/18 13:01:09 UTC
[54/64] incubator-brooklyn git commit: brooklyn-software-database:
add org.apache package prefix
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ac1a7c09/software/database/src/test/java/brooklyn/entity/database/mysql/MySqlIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/database/src/test/java/brooklyn/entity/database/mysql/MySqlIntegrationTest.java b/software/database/src/test/java/brooklyn/entity/database/mysql/MySqlIntegrationTest.java
deleted file mode 100644
index 523cbda..0000000
--- a/software/database/src/test/java/brooklyn/entity/database/mysql/MySqlIntegrationTest.java
+++ /dev/null
@@ -1,106 +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.database.mysql;
-
-import java.io.File;
-
-import org.apache.brooklyn.api.entity.proxying.EntitySpec;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.BrooklynAppLiveTestSupport;
-import brooklyn.entity.database.VogellaExampleAccess;
-import org.apache.brooklyn.location.basic.LocalhostMachineProvisioningLocation;
-import brooklyn.util.collections.MutableMap;
-import brooklyn.util.net.Networking;
-import brooklyn.util.os.Os;
-
-import com.google.common.base.Joiner;
-import com.google.common.collect.ImmutableList;
-import com.google.common.io.Files;
-
-/**
- * Runs a slightly modified version of the popular Vogella MySQL tutorial,
- * from
- * http://www.vogella.de/articles/MySQLJava/article.html
- */
-public class MySqlIntegrationTest extends BrooklynAppLiveTestSupport {
-
- public static final Logger log = LoggerFactory.getLogger(MySqlIntegrationTest.class);
-
- // can start in AWS by running this -- or use brooklyn CLI/REST for most clouds, or programmatic/config for set of fixed IP machines
- static String hostname = Networking.getLocalHost().getHostName();
-
- // From http://www.vogella.de/articles/MySQLJava/article.html
- // Expects COMMENTS to be injected as the test.table.name config value, for VogellaExampleAccess to work.
- public static final String CREATION_SCRIPT = Joiner.on("\n").join(ImmutableList.of(
- "CREATE DATABASE feedback;",
- "CREATE USER 'sqluser'@'localhost' IDENTIFIED BY 'sqluserpw';",
- "GRANT USAGE ON *.* TO 'sqluser'@'localhost';",
- "GRANT ALL PRIVILEGES ON feedback.* TO 'sqluser'@'localhost';",
- "CREATE USER 'sqluser'@'%' IDENTIFIED BY 'sqluserpw';",
- "GRANT USAGE ON *.* TO 'sqluser'@'%';",
- "GRANT ALL PRIVILEGES ON feedback.* TO 'sqluser'@'%';",
- "CREATE USER 'sqluser'@'$hostname' IDENTIFIED BY 'sqluserpw';",
- "GRANT USAGE ON *.* TO 'sqluser'@'$hostname';",
- "GRANT ALL PRIVILEGES ON feedback.* TO 'sqluser'@'$hostname';",
- "FLUSH PRIVILEGES;",
- "USE feedback;",
- "CREATE TABLE ${config['test.table.name']} (",
- " id INT NOT NULL AUTO_INCREMENT,",
- " MYUSER VARCHAR(30) NOT NULL,",
- " EMAIL VARCHAR(30), ",
- " WEBPAGE VARCHAR(100) NOT NULL,",
- " DATUM DATE NOT NULL, ",
- " SUMMARY VARCHAR(40) NOT NULL,",
- " COMMENTS VARCHAR(400) NOT NULL,",
- " PRIMARY KEY (ID)",
- " );",
- "",
- "INSERT INTO ${config['test.table.name']} values (default, 'lars', 'myemail@gmail.com','http://www.vogella.de', '2009-09-14 10:33:11', 'Summary','My first comment' );"
- ));
-
- @Test(groups = {"Integration"})
- public void test_localhost() throws Exception {
- File dataDir = Files.createTempDir();
- try {
- MySqlNode mysql = app.createAndManageChild(EntitySpec.create(MySqlNode.class)
- .configure("mysql.server.conf", MutableMap.of("skip-name-resolve",""))
- .configure("creationScriptContents", CREATION_SCRIPT)
- .configure("dataDir", dataDir.getAbsolutePath())
- .configure("test.table.name", "COMMENTS")); // to ensure creation script is templated
- LocalhostMachineProvisioningLocation location = new LocalhostMachineProvisioningLocation();
-
- app.start(ImmutableList.of(location));;
- log.info("MySQL started");
-
- new VogellaExampleAccess("com.mysql.jdbc.Driver", mysql.getAttribute(MySqlNode.DATASTORE_URL)).readModifyAndRevertDataBase();
-
- log.info("Ran vogella MySQL example -- SUCCESS");
-
- // Ensure the data directory was successfully overridden.
- File mysqlSubdirFile = new File(dataDir, "mysql");
- Assert.assertTrue(mysqlSubdirFile.exists());
- } finally {
- Os.deleteRecursively(dataDir);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ac1a7c09/software/database/src/test/java/brooklyn/entity/database/mysql/MySqlLiveEc2Test.java
----------------------------------------------------------------------
diff --git a/software/database/src/test/java/brooklyn/entity/database/mysql/MySqlLiveEc2Test.java b/software/database/src/test/java/brooklyn/entity/database/mysql/MySqlLiveEc2Test.java
deleted file mode 100644
index c9d5e97..0000000
--- a/software/database/src/test/java/brooklyn/entity/database/mysql/MySqlLiveEc2Test.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 brooklyn.entity.database.mysql;
-
-import org.apache.brooklyn.api.entity.proxying.EntitySpec;
-import org.apache.brooklyn.api.location.Location;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.AbstractEc2LiveTest;
-import brooklyn.entity.database.DatastoreMixins.DatastoreCommon;
-import brooklyn.entity.database.VogellaExampleAccess;
-
-import com.google.common.collect.ImmutableList;
-
-@Test(groups = { "Live" })
-public class MySqlLiveEc2Test extends AbstractEc2LiveTest {
-
- @Override
- protected void doTest(Location loc) throws Exception {
- MySqlNode mysql = app.createAndManageChild(EntitySpec.create(MySqlNode.class)
- .configure(DatastoreCommon.CREATION_SCRIPT_CONTENTS, MySqlIntegrationTest.CREATION_SCRIPT)
- .configure("test.table.name", "COMMENTS"));
-
- app.start(ImmutableList.of(loc));
-
- new VogellaExampleAccess("com.mysql.jdbc.Driver", mysql.getAttribute(DatastoreCommon.DATASTORE_URL)).readModifyAndRevertDataBase();
- }
-
- @Override
- @Test(enabled=false, groups = "Live")
- public void test_Debian_7_2() throws Exception { } // Disabled because MySQl not available
-
- @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/ac1a7c09/software/database/src/test/java/brooklyn/entity/database/mysql/MySqlLiveGceTest.java
----------------------------------------------------------------------
diff --git a/software/database/src/test/java/brooklyn/entity/database/mysql/MySqlLiveGceTest.java b/software/database/src/test/java/brooklyn/entity/database/mysql/MySqlLiveGceTest.java
deleted file mode 100644
index f6322bd..0000000
--- a/software/database/src/test/java/brooklyn/entity/database/mysql/MySqlLiveGceTest.java
+++ /dev/null
@@ -1,49 +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.database.mysql;
-
-import org.apache.brooklyn.api.entity.proxying.EntitySpec;
-import org.apache.brooklyn.api.location.Location;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.AbstractGoogleComputeLiveTest;
-import brooklyn.entity.database.DatastoreMixins.DatastoreCommon;
-import brooklyn.entity.database.VogellaExampleAccess;
-
-import com.google.common.collect.ImmutableList;
-
-@Test(groups = { "Live" })
-public class MySqlLiveGceTest extends AbstractGoogleComputeLiveTest {
-
- @Override
- protected void doTest(Location loc) throws Exception {
- MySqlNode mysql = app.createAndManageChild(EntitySpec.create(MySqlNode.class)
- .configure(DatastoreCommon.CREATION_SCRIPT_CONTENTS, MySqlIntegrationTest.CREATION_SCRIPT)
- .configure("test.table.name", "COMMENTS"));
-
- app.start(ImmutableList.of(loc));
-
- new VogellaExampleAccess("com.mysql.jdbc.Driver", mysql.getAttribute(DatastoreCommon.DATASTORE_URL)).readModifyAndRevertDataBase();
- }
-
- @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/ac1a7c09/software/database/src/test/java/brooklyn/entity/database/mysql/MySqlLiveRackspaceTest.java
----------------------------------------------------------------------
diff --git a/software/database/src/test/java/brooklyn/entity/database/mysql/MySqlLiveRackspaceTest.java b/software/database/src/test/java/brooklyn/entity/database/mysql/MySqlLiveRackspaceTest.java
deleted file mode 100644
index 4175a7e..0000000
--- a/software/database/src/test/java/brooklyn/entity/database/mysql/MySqlLiveRackspaceTest.java
+++ /dev/null
@@ -1,107 +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.database.mysql;
-
-import java.util.Arrays;
-
-import org.apache.brooklyn.api.entity.proxying.EntitySpec;
-import org.testng.annotations.Test;
-
-import brooklyn.config.BrooklynProperties;
-import brooklyn.entity.database.DatastoreMixins.DatastoreCommon;
-import brooklyn.entity.database.VogellaExampleAccess;
-import org.apache.brooklyn.location.basic.SshMachineLocation;
-import org.apache.brooklyn.location.jclouds.JcloudsLocation;
-import brooklyn.util.net.Protocol;
-import brooklyn.util.ssh.IptablesCommands;
-import brooklyn.util.ssh.IptablesCommands.Chain;
-import brooklyn.util.ssh.IptablesCommands.Policy;
-
-import com.google.common.collect.ImmutableList;
-
-/**
- * The MySqlLiveTest installs MySQL on various operating systems like Ubuntu, CentOS, Red Hat etc. To make sure that
- * MySQL works like expected on these Operating Systems.
- */
-public class MySqlLiveRackspaceTest extends MySqlIntegrationTest {
- @Test(groups = {"Live"})
- public void test_Debian_6() throws Exception {
- test("Debian 6");
- }
-
- @Test(groups = {"Live"})
- public void test_Ubuntu_10_0() throws Exception {
- test("Ubuntu 10.0");
- }
-
- @Test(groups = {"Live", "Live-sanity"})
- public void test_Ubuntu_12_0() throws Exception {
- test("Ubuntu 12.0");
- }
-
- @Test(groups = {"Live"})
- public void test_Ubuntu_13() throws Exception {
- test("Ubuntu 13");
- }
-
- @Test(groups = {"Live"})
- public void test_CentOS_6() throws Exception {
- test("CentOS 6");
- }
-
- @Test(groups = {"Live"})
- public void test_CentOS_5() throws Exception {
- test("CentOS 5");
- }
-
- @Test(groups = {"Live"})
- public void test_Fedora() throws Exception {
- test("Fedora ");
- }
-
- @Test(groups = {"Live"})
- public void test_Red_Hat_Enterprise_Linux_6() throws Exception {
- test("Red Hat Enterprise Linux 6");
- }
-
- @Test(enabled=false, groups = {"Live"}) // only run this in MySqlIntegrationTest
- public void test_localhost() throws Exception {
- super.test_localhost();
- }
-
- public void test(String osRegex) throws Exception {
- MySqlNode mysql = app.createAndManageChild(EntitySpec.create(MySqlNode.class)
- .configure(DatastoreCommon.CREATION_SCRIPT_CONTENTS, CREATION_SCRIPT)
- .configure("test.table.name", "COMMENTS"));
-
- BrooklynProperties brooklynProperties = mgmt.getBrooklynProperties();
- brooklynProperties.put("brooklyn.location.jclouds.rackspace-cloudservers-uk.imageNameRegex", osRegex);
- brooklynProperties.remove("brooklyn.location.jclouds.rackspace-cloudservers-uk.image-id");
- brooklynProperties.remove("brooklyn.location.jclouds.rackspace-cloudservers-uk.imageId");
- brooklynProperties.put("brooklyn.location.jclouds.rackspace-cloudservers-uk.inboundPorts", Arrays.asList(22, 3306));
- JcloudsLocation jcloudsLocation = (JcloudsLocation) mgmt.getLocationRegistry().resolve("jclouds:rackspace-cloudservers-uk");
-
- app.start(ImmutableList.of(jcloudsLocation));
-
- SshMachineLocation l = (SshMachineLocation) mysql.getLocations().iterator().next();
- l.execCommands("add iptables rule", ImmutableList.of(IptablesCommands.insertIptablesRule(Chain.INPUT, Protocol.TCP, 3306, Policy.ACCEPT)));
-
- new VogellaExampleAccess("com.mysql.jdbc.Driver", mysql.getAttribute(DatastoreCommon.DATASTORE_URL)).readModifyAndRevertDataBase();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ac1a7c09/software/database/src/test/java/brooklyn/entity/database/mysql/MySqlRestartIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/database/src/test/java/brooklyn/entity/database/mysql/MySqlRestartIntegrationTest.java b/software/database/src/test/java/brooklyn/entity/database/mysql/MySqlRestartIntegrationTest.java
deleted file mode 100644
index ccc0e19..0000000
--- a/software/database/src/test/java/brooklyn/entity/database/mysql/MySqlRestartIntegrationTest.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.database.mysql;
-
-import org.apache.brooklyn.api.entity.proxying.EntitySpec;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.basic.AbstractSoftwareProcessRestartIntegrationTest;
-import brooklyn.entity.basic.SoftwareProcess;
-
-/**
- * Tests restart of the software *process* (as opposed to the VM).
- */
-@Test(groups="Integration")
-public class MySqlRestartIntegrationTest extends AbstractSoftwareProcessRestartIntegrationTest {
-
- @SuppressWarnings("unused")
- private static final Logger LOG = LoggerFactory.getLogger(MySqlRestartIntegrationTest.class);
-
- @Override
- protected EntitySpec<? extends SoftwareProcess> newEntitySpec() {
- return EntitySpec.create(MySqlNode.class);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ac1a7c09/software/database/src/test/java/brooklyn/entity/database/mysql/MysqlDockerLiveTest.java
----------------------------------------------------------------------
diff --git a/software/database/src/test/java/brooklyn/entity/database/mysql/MysqlDockerLiveTest.java b/software/database/src/test/java/brooklyn/entity/database/mysql/MysqlDockerLiveTest.java
deleted file mode 100644
index 0642dd6..0000000
--- a/software/database/src/test/java/brooklyn/entity/database/mysql/MysqlDockerLiveTest.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 brooklyn.entity.database.mysql;
-
-import brooklyn.entity.database.DatastoreMixins.DatastoreCommon;
-import brooklyn.entity.database.VogellaExampleAccess;
-import brooklyn.entity.software.AbstractDockerLiveTest;
-
-import com.google.common.collect.ImmutableList;
-
-import org.apache.brooklyn.api.entity.proxying.EntitySpec;
-import org.apache.brooklyn.api.location.Location;
-import org.testng.annotations.Test;
-
-public class MysqlDockerLiveTest extends AbstractDockerLiveTest {
-
- @Override
- protected void doTest(Location loc) throws Exception {
- MySqlNode mysql = app.createAndManageChild(EntitySpec.create(MySqlNode.class)
- .configure(DatastoreCommon.CREATION_SCRIPT_CONTENTS, MySqlIntegrationTest.CREATION_SCRIPT)
- .configure("test.table.name", "COMMENTS"));
-
- app.start(ImmutableList.of(loc));
-
- new VogellaExampleAccess("com.mysql.jdbc.Driver", mysql.getAttribute(DatastoreCommon.DATASTORE_URL))
- .readModifyAndRevertDataBase();
- }
-
- @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/ac1a7c09/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqDockerLiveTest.java
----------------------------------------------------------------------
diff --git a/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqDockerLiveTest.java b/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqDockerLiveTest.java
deleted file mode 100644
index 8b23415..0000000
--- a/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqDockerLiveTest.java
+++ /dev/null
@@ -1,46 +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.database.postgresql;
-
-import brooklyn.entity.database.DatastoreMixins.DatastoreCommon;
-import brooklyn.entity.database.VogellaExampleAccess;
-import brooklyn.entity.software.AbstractDockerLiveTest;
-
-import com.google.common.collect.ImmutableList;
-
-import org.apache.brooklyn.api.entity.proxying.EntitySpec;
-import org.apache.brooklyn.api.location.Location;
-import org.testng.annotations.Test;
-
-public class PostgreSqDockerLiveTest extends AbstractDockerLiveTest {
-
- @Override
- protected void doTest(Location loc) throws Exception {
- PostgreSqlNode psql = app.createAndManageChild(EntitySpec.create(PostgreSqlNode.class)
- .configure(DatastoreCommon.CREATION_SCRIPT_CONTENTS, PostgreSqlIntegrationTest.CREATION_SCRIPT));
-
- app.start(ImmutableList.of(loc));
-
- new VogellaExampleAccess("org.postgresql.Driver", psql.getAttribute(DatastoreCommon.DATASTORE_URL)).readModifyAndRevertDataBase();
- }
-
- @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/ac1a7c09/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlChefTest.java
----------------------------------------------------------------------
diff --git a/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlChefTest.java b/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlChefTest.java
deleted file mode 100644
index 36eb963..0000000
--- a/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlChefTest.java
+++ /dev/null
@@ -1,105 +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.database.postgresql;
-
-import java.util.Random;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.chef.ChefLiveTestSupport;
-import brooklyn.entity.database.DatastoreMixins.DatastoreCommon;
-import brooklyn.entity.database.VogellaExampleAccess;
-import brooklyn.entity.effector.EffectorTasks;
-import brooklyn.entity.software.SshEffectorTasks;
-
-import org.apache.brooklyn.api.location.PortRange;
-import org.apache.brooklyn.core.util.task.system.ProcessTaskWrapper;
-import org.apache.brooklyn.location.basic.PortRanges;
-import org.apache.brooklyn.location.basic.SshMachineLocation;
-
-import brooklyn.util.time.Duration;
-
-import com.google.common.collect.ImmutableList;
-
-/**
- * Tests Chef installation of PostgreSql. Requires chef-server (knife).
- * <p>
- * To be able to run repeatedly on the same box, you will need the patched version of the postgresql library,
- * at https://github.com/opscode-cookbooks/postgresql/pull/73 .
- *
- * @author alex
- *
- */
-public class PostgreSqlChefTest extends ChefLiveTestSupport {
-
- private static final Logger log = LoggerFactory.getLogger(PostgreSqlChefTest.class);
-
- PostgreSqlNode psql;
-
- @Test(groups="Live")
- public void testPostgresStartsAndStops() throws Exception {
- ChefLiveTestSupport.installBrooklynChefHostedConfig(app);
- psql = app.createAndManageChild(PostgreSqlSpecs.specChef());
-
- app.start(ImmutableList.of(targetLocation));
-
- Entities.submit(psql, SshEffectorTasks.ssh("ps aux | grep [p]ostgres").requiringExitCodeZero());
- SshMachineLocation targetMachine = EffectorTasks.getSshMachine(psql);
-
- psql.stop();
-
- try {
- // if host is still contactable ensure postgres is not running
- ProcessTaskWrapper<Integer> t = Entities.submit(app, SshEffectorTasks.ssh("ps aux | grep [p]ostgres").machine(targetMachine).allowingNonZeroExitCode());
- t.getTask().blockUntilEnded(Duration.TEN_SECONDS);
- if (!t.isDone())
- Assert.fail("Task not finished yet: "+t.getTask());
- Assert.assertNotEquals(t.get(), (Integer)0, "Task ended with code "+t.get()+"; output: "+t.getStdout() );
- } catch (Exception e) {
- // host has been killed, that is fine
- log.info("Machine "+targetMachine+" destroyed on stop (expected - "+e+")");
- }
- }
-
- @Test(groups="Live")
- public void testPostgresScriptAndAccess() throws Exception {
- ChefLiveTestSupport.installBrooklynChefHostedConfig(app);
- PortRange randomPort = PortRanges.fromString(String.format("%d+", 5420 + new Random().nextInt(10)));
- psql = app.createAndManageChild(PostgreSqlSpecs.specChef()
- .configure(DatastoreCommon.CREATION_SCRIPT_CONTENTS, PostgreSqlIntegrationTest.CREATION_SCRIPT)
- .configure(PostgreSqlNode.POSTGRESQL_PORT, randomPort)
- .configure(PostgreSqlNode.SHARED_MEMORY, "8MB")
- );
-
- app.start(ImmutableList.of(targetLocation));
-
- String url = psql.getAttribute(DatastoreCommon.DATASTORE_URL);
- log.info("Trying to connect to "+psql+" at "+url);
- Assert.assertNotNull(url);
- Assert.assertTrue(url.contains("542"));
-
- new VogellaExampleAccess("org.postgresql.Driver", url).readModifyAndRevertDataBase();
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ac1a7c09/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlEc2LiveTest.java
----------------------------------------------------------------------
diff --git a/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlEc2LiveTest.java b/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlEc2LiveTest.java
deleted file mode 100644
index 5eda573..0000000
--- a/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlEc2LiveTest.java
+++ /dev/null
@@ -1,54 +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.database.postgresql;
-
-import org.apache.brooklyn.api.entity.proxying.EntitySpec;
-import org.apache.brooklyn.api.location.Location;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.AbstractEc2LiveTest;
-import brooklyn.entity.database.DatastoreMixins.DatastoreCommon;
-import brooklyn.entity.database.VogellaExampleAccess;
-
-import com.google.common.collect.ImmutableList;
-
-public class PostgreSqlEc2LiveTest extends AbstractEc2LiveTest {
-
- @Override
- protected void doTest(Location loc) throws Exception {
- PostgreSqlNode psql = app.createAndManageChild(EntitySpec.create(PostgreSqlNode.class)
- .configure(DatastoreCommon.CREATION_SCRIPT_CONTENTS, PostgreSqlIntegrationTest.CREATION_SCRIPT));
-
- app.start(ImmutableList.of(loc));
-
- new VogellaExampleAccess("org.postgresql.Driver", psql.getAttribute(DatastoreCommon.DATASTORE_URL)).readModifyAndRevertDataBase();
- }
-
- @Override
- @Test(enabled=false, groups = "Live")
- public void test_Debian_6() throws Exception { } // Disabled because PostgreSql 9.1 not available
-
- @Override
- @Test(enabled=false, groups = "Live")
- public void test_Ubuntu_10_0() throws Exception { } // Disabled because PostgreSql 9.1 not available
-
- @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/ac1a7c09/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlGceLiveTest.java
----------------------------------------------------------------------
diff --git a/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlGceLiveTest.java b/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlGceLiveTest.java
deleted file mode 100644
index 70e44e0..0000000
--- a/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlGceLiveTest.java
+++ /dev/null
@@ -1,46 +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.database.postgresql;
-
-import org.apache.brooklyn.api.entity.proxying.EntitySpec;
-import org.apache.brooklyn.api.location.Location;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.AbstractGoogleComputeLiveTest;
-import brooklyn.entity.database.DatastoreMixins.DatastoreCommon;
-import brooklyn.entity.database.VogellaExampleAccess;
-
-import com.google.common.collect.ImmutableList;
-
-public class PostgreSqlGceLiveTest extends AbstractGoogleComputeLiveTest {
-
- @Override
- protected void doTest(Location loc) throws Exception {
- PostgreSqlNode psql = app.createAndManageChild(EntitySpec.create(PostgreSqlNode.class)
- .configure(DatastoreCommon.CREATION_SCRIPT_CONTENTS, PostgreSqlIntegrationTest.CREATION_SCRIPT));
-
- app.start(ImmutableList.of(loc));
-
- new VogellaExampleAccess("org.postgresql.Driver", psql.getAttribute(DatastoreCommon.DATASTORE_URL)).readModifyAndRevertDataBase();
- }
-
- @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/ac1a7c09/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlIntegrationTest.java b/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlIntegrationTest.java
deleted file mode 100644
index 7cb5863..0000000
--- a/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlIntegrationTest.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 brooklyn.entity.database.postgresql;
-
-import org.apache.brooklyn.api.entity.proxying.EntitySpec;
-import org.apache.brooklyn.api.management.ManagementContext;
-import org.apache.brooklyn.core.management.internal.LocalManagementContext;
-import org.apache.brooklyn.test.entity.TestApplication;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.config.BrooklynProperties;
-import brooklyn.entity.basic.ApplicationBuilder;
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.database.DatastoreMixins.DatastoreCommon;
-import brooklyn.entity.database.VogellaExampleAccess;
-
-import org.apache.brooklyn.location.basic.LocalhostMachineProvisioningLocation;
-
-import com.google.common.collect.ImmutableList;
-
-/**
- * Runs the popular Vogella MySQL tutorial against PostgreSQL
- * from
- * http://www.vogella.de/articles/MySQLJava/article.html
- */
-public class PostgreSqlIntegrationTest {
-
- public static final Logger log = LoggerFactory.getLogger(PostgreSqlIntegrationTest.class);
-
- protected BrooklynProperties brooklynProperties;
- protected ManagementContext managementContext;
- protected TestApplication tapp;
-
- @BeforeMethod(alwaysRun = true)
- public void setUp() {
- brooklynProperties = BrooklynProperties.Factory.newDefault();
- managementContext = new LocalManagementContext(brooklynProperties);
- tapp = ApplicationBuilder.newManagedApp(TestApplication.class, managementContext);
- }
-
- @AfterMethod(alwaysRun = true)
- public void ensureShutDown() {
- Entities.destroyAllCatching(managementContext);
- }
-
- //from http://www.vogella.de/articles/MySQLJava/article.html
- public static final String CREATION_SCRIPT =
- "CREATE USER sqluser WITH PASSWORD 'sqluserpw';\n" +
- "CREATE DATABASE feedback OWNER sqluser;\n" +
- "\\c feedback;\n" +
- "CREATE TABLE COMMENTS ( " +
- "id INT8 NOT NULL, " +
- "MYUSER VARCHAR(30) NOT NULL, " +
- "EMAIL VARCHAR(30), " +
- "WEBPAGE VARCHAR(100) NOT NULL, " +
- "DATUM DATE NOT NULL, " +
- "SUMMARY VARCHAR(40) NOT NULL, " +
- "COMMENTS VARCHAR(400) NOT NULL, " +
- "PRIMARY KEY (ID) " +
- ");\n" +
- "GRANT ALL ON comments TO sqluser;\n" +
- "INSERT INTO COMMENTS values (1, 'lars', 'myemail@gmail.com','http://www.vogella.de', '2009-09-14 10:33:11', 'Summary','My first comment' );";
-
- @Test(groups = "Integration")
- public void test_localhost() throws Exception {
- PostgreSqlNode pgsql = tapp.createAndManageChild(EntitySpec.create(PostgreSqlNode.class)
- .configure(DatastoreCommon.CREATION_SCRIPT_CONTENTS, CREATION_SCRIPT)
- .configure(PostgreSqlNode.MAX_CONNECTIONS, 10)
- .configure(PostgreSqlNode.SHARED_MEMORY, "512kB")); // Very low so kernel configuration not needed
-
- tapp.start(ImmutableList.of(new LocalhostMachineProvisioningLocation()));
- String url = pgsql.getAttribute(DatastoreCommon.DATASTORE_URL);
- log.info("PostgreSql started on "+url);
- new VogellaExampleAccess("org.postgresql.Driver", url).readModifyAndRevertDataBase();
- log.info("Ran vogella PostgreSql example -- SUCCESS");
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ac1a7c09/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlRackspaceLiveTest.java
----------------------------------------------------------------------
diff --git a/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlRackspaceLiveTest.java b/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlRackspaceLiveTest.java
deleted file mode 100644
index bd6abbf..0000000
--- a/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlRackspaceLiveTest.java
+++ /dev/null
@@ -1,108 +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.database.postgresql;
-
-import java.util.Arrays;
-
-import org.apache.brooklyn.api.entity.proxying.EntitySpec;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.database.DatastoreMixins.DatastoreCommon;
-import brooklyn.entity.database.VogellaExampleAccess;
-import org.apache.brooklyn.location.basic.PortRanges;
-import org.apache.brooklyn.location.basic.SshMachineLocation;
-import org.apache.brooklyn.location.jclouds.JcloudsLocation;
-import brooklyn.util.net.Protocol;
-import brooklyn.util.ssh.IptablesCommands;
-import brooklyn.util.ssh.IptablesCommands.Chain;
-import brooklyn.util.ssh.IptablesCommands.Policy;
-
-import com.google.common.collect.ImmutableList;
-
-/**
- * The PostgreSqlRackspaceLiveTest installs Postgresql on various operating systems like Ubuntu, CentOS, Red Hat etc. To
- * make sure that PostgreSql works like expected on these Operating Systems.
- */
-public class PostgreSqlRackspaceLiveTest extends PostgreSqlIntegrationTest {
- @Test(groups = "Live")
- public void test_Debian_6() throws Exception {
- test("Debian 6");
- }
-
- @Test(groups = "Live")
- public void test_Ubuntu_10_0() throws Exception {
- test("Ubuntu 10.0");
- }
-
- @Test(groups = "Live")
- public void test_Ubuntu_11_0() throws Exception {
- test("Ubuntu 11.0");
- }
-
- @Test(groups = "Live")
- public void test_Ubuntu_12_0() throws Exception {
- test("Ubuntu 12.0");
- }
-
- @Test(groups = "Live")
- public void test_CentOS_6_0() throws Exception {
- test("CentOS 6.0");
- }
-
- @Test(groups = "Live")
- public void test_CentOS_5_6() throws Exception {
- test("CentOS 5.6");
- }
-
- @Test(groups = "Live")
- public void test_Fedora_17() throws Exception {
- test("Fedora 17");
- }
-
- @Test(groups = "Live")
- public void test_Red_Hat_Enterprise_Linux_6() throws Exception {
- test("Red Hat Enterprise Linux 6");
- }
-
- @Test(groups = "Live")
- public void test_localhost() throws Exception {
- super.test_localhost();
- }
-
- public void test(String osRegex) throws Exception {
- PostgreSqlNode psql = tapp.createAndManageChild(EntitySpec.create(PostgreSqlNode.class)
- .configure(DatastoreCommon.CREATION_SCRIPT_CONTENTS, CREATION_SCRIPT)
- .configure(PostgreSqlNode.POSTGRESQL_PORT, PortRanges.fromInteger(5432))
- .configure(PostgreSqlNode.SHARED_MEMORY, "32MB"));
-
- brooklynProperties.put("brooklyn.location.jclouds.rackspace-cloudservers-uk.imageNameRegex", osRegex);
- brooklynProperties.remove("brooklyn.location.jclouds.rackspace-cloudservers-uk.image-id");
- brooklynProperties.remove("brooklyn.location.jclouds.rackspace-cloudservers-uk.imageId");
- brooklynProperties.put("brooklyn.location.jclouds.rackspace-cloudservers-uk.inboundPorts", Arrays.asList(22, 5432));
- JcloudsLocation jcloudsLocation = (JcloudsLocation) managementContext.getLocationRegistry().resolve("jclouds:rackspace-cloudservers-uk");
-
- tapp.start(ImmutableList.of(jcloudsLocation));
-
- SshMachineLocation l = (SshMachineLocation) psql.getLocations().iterator().next();
- l.execCommands("add iptables rule", ImmutableList.of(IptablesCommands.insertIptablesRule(Chain.INPUT, Protocol.TCP, 5432, Policy.ACCEPT)));
-
- String url = psql.getAttribute(DatastoreCommon.DATASTORE_URL);
- new VogellaExampleAccess("org.postgresql.Driver", url).readModifyAndRevertDataBase();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ac1a7c09/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlRebindIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlRebindIntegrationTest.java b/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlRebindIntegrationTest.java
deleted file mode 100644
index 8a00587..0000000
--- a/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlRebindIntegrationTest.java
+++ /dev/null
@@ -1,58 +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.database.postgresql;
-
-import org.apache.brooklyn.api.entity.proxying.EntitySpec;
-import org.apache.brooklyn.test.EntityTestUtils;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.rebind.RebindTestFixtureWithApp;
-import org.apache.brooklyn.location.basic.LocalhostMachineProvisioningLocation;
-
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-
-public class PostgreSqlRebindIntegrationTest extends RebindTestFixtureWithApp {
-
- private LocalhostMachineProvisioningLocation loc;
-
- @BeforeMethod(alwaysRun=true)
- @Override
- public void setUp() throws Exception {
- super.setUp();
- loc = origApp.newLocalhostProvisioningLocation();
- }
-
- @Test(groups = {"Integration"})
- public void testRebind() throws Exception {
- origApp.createAndManageChild(EntitySpec.create(PostgreSqlNode.class));
- origApp.start(ImmutableList.of(loc));
-
- // rebind
- rebind();
- final PostgreSqlNode newEntity = (PostgreSqlNode) Iterables.find(newApp.getChildren(), Predicates.instanceOf(PostgreSqlNode.class));
-
- // confirm effectors still work on entity
- EntityTestUtils.assertAttributeEqualsEventually(newEntity, PostgreSqlNode.SERVICE_UP, true);
- newEntity.stop();
- EntityTestUtils.assertAttributeEqualsEventually(newEntity, PostgreSqlNode.SERVICE_UP, false);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ac1a7c09/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlRestartIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlRestartIntegrationTest.java b/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlRestartIntegrationTest.java
deleted file mode 100644
index ba2ff29..0000000
--- a/software/database/src/test/java/brooklyn/entity/database/postgresql/PostgreSqlRestartIntegrationTest.java
+++ /dev/null
@@ -1,50 +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.database.postgresql;
-
-import org.apache.brooklyn.api.entity.proxying.EntitySpec;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.basic.AbstractSoftwareProcessRestartIntegrationTest;
-import brooklyn.entity.basic.SoftwareProcess;
-
-/**
- * Tests restart of the software *process* (as opposed to the VM).
- */
-@Test(groups="Integration")
-public class PostgreSqlRestartIntegrationTest extends AbstractSoftwareProcessRestartIntegrationTest {
-
- @SuppressWarnings("unused")
- private static final Logger LOG = LoggerFactory.getLogger(PostgreSqlRestartIntegrationTest.class);
-
- @Override
- protected EntitySpec<? extends SoftwareProcess> newEntitySpec() {
- return EntitySpec.create(PostgreSqlNode.class);
- }
-
- // TODO The second start() will fail because customize operations forbidden while there is existing data:
- // "If you want to create a new database system, either remove or empty".
- // I haven't checked whether it damaged the data in the database though!
- @Test(enabled=false, groups={"Integration", "WIP"})
- public void testStopProcessAndStart() throws Exception {
- super.testStopProcessAndStart();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ac1a7c09/software/database/src/test/java/brooklyn/entity/database/rubyrep/RubyRepEc2LiveTest.java
----------------------------------------------------------------------
diff --git a/software/database/src/test/java/brooklyn/entity/database/rubyrep/RubyRepEc2LiveTest.java b/software/database/src/test/java/brooklyn/entity/database/rubyrep/RubyRepEc2LiveTest.java
deleted file mode 100644
index c53db06..0000000
--- a/software/database/src/test/java/brooklyn/entity/database/rubyrep/RubyRepEc2LiveTest.java
+++ /dev/null
@@ -1,75 +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.database.rubyrep;
-
-import org.apache.brooklyn.api.entity.proxying.EntitySpec;
-import org.apache.brooklyn.api.location.Location;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.AbstractEc2LiveTest;
-import brooklyn.entity.database.DatastoreMixins.DatastoreCommon;
-import brooklyn.entity.database.postgresql.PostgreSqlIntegrationTest;
-import brooklyn.entity.database.postgresql.PostgreSqlNode;
-
-import org.apache.brooklyn.location.basic.PortRanges;
-
-public class RubyRepEc2LiveTest extends AbstractEc2LiveTest {
-
- @Override
- protected void doTest(Location loc) throws Exception {
- PostgreSqlNode db1 = app.createAndManageChild(EntitySpec.create(PostgreSqlNode.class)
- .configure(DatastoreCommon.CREATION_SCRIPT_CONTENTS, PostgreSqlIntegrationTest.CREATION_SCRIPT)
- .configure(PostgreSqlNode.POSTGRESQL_PORT, PortRanges.fromInteger(9111)));
-
- PostgreSqlNode db2 = app.createAndManageChild(EntitySpec.create(PostgreSqlNode.class)
- .configure(DatastoreCommon.CREATION_SCRIPT_CONTENTS, PostgreSqlIntegrationTest.CREATION_SCRIPT)
- .configure(PostgreSqlNode.POSTGRESQL_PORT, PortRanges.fromInteger(9111)));
-
- RubyRepIntegrationTest.startInLocation(app, db1, db2, loc);
- RubyRepIntegrationTest.testReplication(db1, db2);
- }
-
- @Override
- @Test(enabled=false, groups = "Live")
- public void test_Debian_6() throws Exception { } // Disabled because PostgreSql 9.1 not available
-
- @Override
- @Test(enabled=false, groups = "Live")
- public void test_Ubuntu_10_0() throws Exception { } // Disabled because PostgreSql 9.1 not available
-
- @Override
- @Test(enabled=false, groups = "Live")
- public void test_Debian_7_2() throws Exception { } // Diabling all except Ubuntu 12.0 temporarily
-
- @Override
- @Test(enabled=false, groups = "Live")
- public void test_CentOS_6_3() throws Exception { } // Diabling all except Ubuntu 12.0 temporarily
-
- @Override
- @Test(enabled=false, groups = "Live")
- public void test_CentOS_5() throws Exception { } // Diabling all except Ubuntu 12.0 temporarily
-
- @Override
- @Test(enabled=false, groups = "Live")
- public void test_Red_Hat_Enterprise_Linux_6() throws Exception { } // Diabling all except Ubuntu 12.0 temporarily
-
- @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/ac1a7c09/software/database/src/test/java/brooklyn/entity/database/rubyrep/RubyRepIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/database/src/test/java/brooklyn/entity/database/rubyrep/RubyRepIntegrationTest.java b/software/database/src/test/java/brooklyn/entity/database/rubyrep/RubyRepIntegrationTest.java
deleted file mode 100644
index 7028d1b..0000000
--- a/software/database/src/test/java/brooklyn/entity/database/rubyrep/RubyRepIntegrationTest.java
+++ /dev/null
@@ -1,191 +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.database.rubyrep;
-
-import static org.testng.Assert.assertEquals;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.brooklyn.api.entity.proxying.EntitySpec;
-import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.api.management.ManagementContext;
-import org.apache.brooklyn.core.management.internal.LocalManagementContext;
-import org.apache.brooklyn.test.entity.TestApplication;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.config.BrooklynProperties;
-import brooklyn.entity.basic.ApplicationBuilder;
-import brooklyn.entity.basic.Entities;
-import brooklyn.entity.database.DatastoreMixins.DatastoreCommon;
-import brooklyn.entity.database.VogellaExampleAccess;
-import brooklyn.entity.database.mysql.MySqlIntegrationTest;
-import brooklyn.entity.database.mysql.MySqlNode;
-import brooklyn.entity.database.postgresql.PostgreSqlIntegrationTest;
-import brooklyn.entity.database.postgresql.PostgreSqlNode;
-
-import org.apache.brooklyn.location.basic.LocalhostMachineProvisioningLocation;
-import org.apache.brooklyn.location.basic.PortRanges;
-
-public class RubyRepIntegrationTest {
-
- public static final Logger log = LoggerFactory.getLogger(RubyRepIntegrationTest.class);
- protected BrooklynProperties brooklynProperties;
- protected ManagementContext managementContext;
- protected TestApplication tapp;
-
- @BeforeMethod(alwaysRun = true)
- public void setUp() {
- brooklynProperties = BrooklynProperties.Factory.newDefault();
- managementContext = new LocalManagementContext(brooklynProperties);
- tapp = ApplicationBuilder.newManagedApp(TestApplication.class, managementContext);
- }
-
- @AfterMethod(alwaysRun = true)
- public void tearDown() {
- Entities.destroyAllCatching(managementContext);
- }
-
- @Test(groups = "Integration")
- public void test_localhost_mysql() throws Exception {
- MySqlNode db1 = tapp.createAndManageChild(EntitySpec.create(MySqlNode.class)
- .configure(DatastoreCommon.CREATION_SCRIPT_CONTENTS, MySqlIntegrationTest.CREATION_SCRIPT)
- .configure("test.table.name", "COMMENTS")
- .configure(MySqlNode.MYSQL_PORT, PortRanges.fromInteger(9111)));
-
- MySqlNode db2 = tapp.createAndManageChild(EntitySpec.create(MySqlNode.class)
- .configure(DatastoreCommon.CREATION_SCRIPT_CONTENTS, MySqlIntegrationTest.CREATION_SCRIPT)
- .configure("test.table.name", "COMMENTS")
- .configure(MySqlNode.MYSQL_PORT, PortRanges.fromInteger(9112)));
-
-
- startInLocation(tapp, db1, db2, new LocalhostMachineProvisioningLocation());
- testReplication(db1, db2);
- }
-
- /**
- * Altered to use a single postgresql server to avoid issues with shared memory limits
- */
- @Test(groups = {"Integration"})
- public void test_localhost_postgres() throws Exception {
- String createTwoDbsScript = PostgreSqlIntegrationTest.CREATION_SCRIPT +
- PostgreSqlIntegrationTest.CREATION_SCRIPT.replaceAll("CREATE USER.*", "").replaceAll(" feedback", " feedback1");
-
- PostgreSqlNode db1 = tapp.createAndManageChild(EntitySpec.create(PostgreSqlNode.class)
- .configure(DatastoreCommon.CREATION_SCRIPT_CONTENTS, createTwoDbsScript)
- .configure(PostgreSqlNode.POSTGRESQL_PORT, PortRanges.fromInteger(9113))
- .configure(PostgreSqlNode.MAX_CONNECTIONS, 10)
- .configure(PostgreSqlNode.SHARED_MEMORY, "512kB")); // Very low so kernel configuration not needed
-
- startInLocation(tapp, db1, "feedback", db1, "feedback1", new LocalhostMachineProvisioningLocation());
- testReplication(db1, "feedback", db1, "feedback1");
- }
-
- @Test(enabled = false, groups = "Integration") // TODO this doesn't appear to be supported by RubyRep
- public void test_localhost_postgres_mysql() throws Exception {
- PostgreSqlNode db1 = tapp.createAndManageChild(EntitySpec.create(PostgreSqlNode.class)
- .configure(DatastoreCommon.CREATION_SCRIPT_CONTENTS, PostgreSqlIntegrationTest.CREATION_SCRIPT)
- .configure(PostgreSqlNode.POSTGRESQL_PORT, PortRanges.fromInteger(9115))
- .configure(PostgreSqlNode.MAX_CONNECTIONS, 10)
- .configure(PostgreSqlNode.SHARED_MEMORY, "512kB")); // Very low so kernel configuration not needed
-
- MySqlNode db2 = tapp.createAndManageChild(EntitySpec.create(MySqlNode.class)
- .configure(DatastoreCommon.CREATION_SCRIPT_CONTENTS, MySqlIntegrationTest.CREATION_SCRIPT)
- .configure(MySqlNode.MYSQL_PORT, PortRanges.fromInteger(9116)));
-
- startInLocation(tapp, db1, db2, new LocalhostMachineProvisioningLocation());
- testReplication(db1, db2);
- }
-
- public static void startInLocation(TestApplication tapp, DatastoreCommon db1, DatastoreCommon db2, Location... locations) throws Exception {
- startInLocation(tapp, db1, "feedback", db2, "feedback", locations);
- }
-
- /**
- * Configures rubyrep to connect to the two databases and starts the app
- */
- public static void startInLocation(TestApplication tapp, DatastoreCommon db1, String dbName1, DatastoreCommon db2, String dbName2, Location... locations) throws Exception {
- tapp.createAndManageChild(EntitySpec.create(RubyRepNode.class)
- .configure("startupTimeout", 300)
- .configure("leftDatabase", db1)
- .configure("rightDatabase", db2)
- .configure("leftUsername", "sqluser")
- .configure("rightUsername", "sqluser")
- .configure("rightPassword", "sqluserpw")
- .configure("leftPassword", "sqluserpw")
- .configure("leftDatabaseName", dbName1)
- .configure("rightDatabaseName", dbName2)
- .configure("replicationInterval", 1)
- );
-
- tapp.start(Arrays.asList(locations));
- }
-
- public static void testReplication(DatastoreCommon db1, DatastoreCommon db2) throws Exception {
- testReplication(db1, "feedback", db2, "feedback");
- }
-
- /**
- * Tests replication between the two databases by altering the first and checking the change is applied to the second
- */
- public static void testReplication(DatastoreCommon db1, String dbName1, DatastoreCommon db2, String dbName2) throws Exception {
- String db1Url = db1.getAttribute(DatastoreCommon.DATASTORE_URL);
- String db2Url = db2.getAttribute(DatastoreCommon.DATASTORE_URL);
-
- log.info("Testing replication between " + db1Url + " and " + db2Url);
-
- VogellaExampleAccess vea1 = new VogellaExampleAccess(db1 instanceof MySqlNode ? "com.mysql.jdbc.Driver" : "org.postgresql.Driver", db1Url, dbName1);
- VogellaExampleAccess vea2 = new VogellaExampleAccess(db2 instanceof MySqlNode ? "com.mysql.jdbc.Driver" : "org.postgresql.Driver", db2Url, dbName2);
-
- try {
- vea1.connect();
- List<List<String>> rs = vea1.readDataBase();
- assertEquals(rs.size(), 1);
-
- vea2.connect();
- rs = vea2.readDataBase();
- assertEquals(rs.size(), 1);
-
- log.info("Modifying left database");
- vea1.modifyDataBase();
-
- log.info("Reading left database");
- rs = vea1.readDataBase();
- assertEquals(rs.size(), 2);
-
- log.info("Reading right database");
- rs = vea2.readDataBase();
-
- for (int i = 0; i < 60 && rs.size() != 2; i++) {
- log.info("Sleeping for a second");
- Thread.sleep(1000);
- rs = vea2.readDataBase();
- }
-
- assertEquals(rs.size(), 2);
- } finally {
- vea1.close();
- vea2.close();
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ac1a7c09/software/database/src/test/java/brooklyn/entity/database/rubyrep/RubyRepRackspaceLiveTest.java
----------------------------------------------------------------------
diff --git a/software/database/src/test/java/brooklyn/entity/database/rubyrep/RubyRepRackspaceLiveTest.java b/software/database/src/test/java/brooklyn/entity/database/rubyrep/RubyRepRackspaceLiveTest.java
deleted file mode 100644
index 845dce7..0000000
--- a/software/database/src/test/java/brooklyn/entity/database/rubyrep/RubyRepRackspaceLiveTest.java
+++ /dev/null
@@ -1,130 +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.database.rubyrep;
-
-import java.util.Arrays;
-
-import org.apache.brooklyn.api.entity.proxying.EntitySpec;
-import org.apache.brooklyn.api.location.Location;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.database.DatastoreMixins.DatastoreCommon;
-import brooklyn.entity.database.postgresql.PostgreSqlIntegrationTest;
-import brooklyn.entity.database.postgresql.PostgreSqlNode;
-
-import org.apache.brooklyn.location.basic.PortRanges;
-import org.apache.brooklyn.location.basic.SshMachineLocation;
-
-import brooklyn.util.net.Protocol;
-import brooklyn.util.ssh.IptablesCommands;
-import brooklyn.util.ssh.IptablesCommands.Chain;
-import brooklyn.util.ssh.IptablesCommands.Policy;
-
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-
-/**
- * The RubyRepRackspaceLiveTest installs RubyRep on various operating systems like Ubuntu, CentOS, Red Hat etc. To make sure that
- * RubyRep and PostgreSql works like expected on these Operating Systems.
- */
-public class RubyRepRackspaceLiveTest extends RubyRepIntegrationTest {
-
- @Test(groups = "Live")
- public void test_Debian_6() throws Exception {
- test("Debian 6");
- }
-
- @Test(groups = "Live")
- public void test_Ubuntu_10_0() throws Exception {
- test("Ubuntu 10.0");
- }
-
- @Test(groups = "Live")
- public void test_Ubuntu_12_0() throws Exception {
- test("Ubuntu 12.0");
- }
-
- @Test(groups = "Live")
- public void test_Ubuntu_13() throws Exception {
- test("Ubuntu 13");
- }
-
- @Test(groups = "Live")
- public void test_CentOS_6() throws Exception {
- test("CentOS 6");
- }
-
- @Test(groups = "Live")
- public void test_CentOS_5() throws Exception {
- test("CentOS 5");
- }
-
- @Test(groups = "Live")
- public void test_Fedora() throws Exception {
- test("Fedora ");
- }
-
- @Test(groups = "Live")
- public void test_Red_Hat_Enterprise_Linux_6() throws Exception {
- test("Red Hat Enterprise Linux 6");
- }
-
- public void test(String osRegex) throws Exception {
- PostgreSqlNode db1 = tapp.createAndManageChild(EntitySpec.create(PostgreSqlNode.class)
- .configure(DatastoreCommon.CREATION_SCRIPT_CONTENTS, PostgreSqlIntegrationTest.CREATION_SCRIPT)
- .configure(PostgreSqlNode.POSTGRESQL_PORT, PortRanges.fromInteger(9111)));
- PostgreSqlNode db2 = tapp.createAndManageChild(EntitySpec.create(PostgreSqlNode.class)
- .configure(DatastoreCommon.CREATION_SCRIPT_CONTENTS, PostgreSqlIntegrationTest.CREATION_SCRIPT)
- .configure(PostgreSqlNode.POSTGRESQL_PORT, PortRanges.fromInteger(9111)));
-
- brooklynProperties.put("brooklyn.location.jclouds.rackspace-cloudservers-uk.imageNameRegex", osRegex);
- brooklynProperties.remove("brooklyn.location.jclouds.rackspace-cloudservers-uk.image-id");
- brooklynProperties.remove("brooklyn.location.jclouds.rackspace-cloudservers-uk.imageId");
- brooklynProperties.put("brooklyn.location.jclouds.rackspace-cloudservers-uk.inboundPorts", Arrays.asList(22, 9111));
- Location loc = managementContext.getLocationRegistry().resolve("jclouds:rackspace-cloudservers-uk");
-
- startInLocation(tapp, db1, db2, loc);
-
- //hack to get the port for mysql open; is the inbounds property not respected on rackspace??
- for (DatastoreCommon node : ImmutableSet.of(db1, db2)) {
- SshMachineLocation l = (SshMachineLocation) node.getLocations().iterator().next();
- l.execCommands("add iptables rule", ImmutableList.of(IptablesCommands.insertIptablesRule(Chain.INPUT, Protocol.TCP, 9111, Policy.ACCEPT)));
- }
-
- testReplication(db1, db2);
- }
-
- // disable inherited non-live tests
- @Test(enabled = false, groups = "Integration")
- public void test_localhost_mysql() throws Exception {
- super.test_localhost_mysql();
- }
-
- // disable inherited non-live tests
- @Test(enabled = false, groups = "Integration")
- public void test_localhost_postgres() throws Exception {
- super.test_localhost_postgres();
- }
-
- // disable inherited non-live tests
- @Test(enabled = false, groups = "Integration")
- public void test_localhost_postgres_mysql() throws Exception {
- super.test_localhost_postgres_mysql();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ac1a7c09/software/database/src/test/java/org/apache/brooklyn/entity/database/VogellaExampleAccess.java
----------------------------------------------------------------------
diff --git a/software/database/src/test/java/org/apache/brooklyn/entity/database/VogellaExampleAccess.java b/software/database/src/test/java/org/apache/brooklyn/entity/database/VogellaExampleAccess.java
new file mode 100644
index 0000000..6b5a6cb
--- /dev/null
+++ b/software/database/src/test/java/org/apache/brooklyn/entity/database/VogellaExampleAccess.java
@@ -0,0 +1,161 @@
+/*
+ * 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.database;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.Lists;
+
+import java.sql.*;
+import java.util.List;
+
+/**
+ * Basic JDBC Access test Class, based on the Vogella MySQL tutorial
+ * http://www.vogella.de/articles/MySQLJava/article.html
+ */
+public class VogellaExampleAccess {
+ public static final Logger log = LoggerFactory.getLogger(VogellaExampleAccess.class);
+
+ private Connection connect = null;
+ private Statement statement = null;
+ private final String url;
+ private final String dbName;
+
+ public VogellaExampleAccess(String driverClass, String url) throws ClassNotFoundException {
+ this(driverClass, url, "feedback");
+ }
+
+ public VogellaExampleAccess(String driverClass, String url, String dbName) throws ClassNotFoundException {
+ // This will load the JDBC driver, each DB has its own driver
+ Class.forName(driverClass);
+ this.url = url;
+ this.dbName = dbName;
+ }
+
+ public void readModifyAndRevertDataBase() throws Exception {
+ connect();
+ readDataBase();
+ modifyDataBase();
+ revertDatabase();
+ close();
+ }
+
+ public void connect() throws Exception {
+ try {
+ // Setup the connection with the DB
+ String jdbcUrl = "jdbc:" + url + dbName + "?" + "user=sqluser&password=sqluserpw";
+ log.info("Connecting to " + jdbcUrl);
+ connect = DriverManager.getConnection(jdbcUrl);
+
+ // Statements allow to issue SQL queries to the database
+ statement = connect.createStatement();
+ } catch (Exception ex) {
+ close();
+ throw ex;
+ }
+ }
+
+ public List<List<String>> readDataBase() throws Exception {
+ List<List<String>> results = Lists.newArrayList();
+ // Result set get the result of the SQL query
+ ResultSet resultSet = statement.executeQuery("SELECT myuser, webpage, datum, summary, COMMENTS from COMMENTS");
+ // ResultSet is initially before the first data set
+ while (resultSet.next()) {
+ List<String> row = Lists.newArrayList();
+ for (int i = 1; i <= resultSet.getMetaData().getColumnCount(); i++) {
+ row.add(resultSet.getObject(i).toString());
+ }
+ results.add(row);
+ }
+ // Should close resultsets
+ resultSet.close();
+ writeResultSet(results);
+ return results;
+ }
+
+ public void modifyDataBase() throws Exception {
+ // PreparedStatements can use variables and are more efficient
+ PreparedStatement preparedStatement = connect.prepareStatement("insert into COMMENTS values (?, ?, ?, ?, ? , ?, ?)");
+ // "myuser, webpage, datum, summary, COMMENTS from FEEDBACK.COMMENTS");
+ // Parameters start with 1
+ preparedStatement.setInt(1, 2);
+ preparedStatement.setString(2, "Test");
+ preparedStatement.setString(3, "TestEmail");
+ preparedStatement.setString(4, "TestWebpage");
+ preparedStatement.setDate(5, new Date(new java.util.Date().getTime()));
+ preparedStatement.setString(6, "TestSummary");
+ preparedStatement.setString(7, "TestComment");
+ preparedStatement.executeUpdate();
+
+ writeResultSet(readDataBase());
+ preparedStatement.close();
+ }
+
+ // Remove again the insert comment added by modifyDataBase()
+ public void revertDatabase() throws Exception {
+ PreparedStatement preparedStatement = connect
+ .prepareStatement("delete from COMMENTS where myuser= ? ; ");
+ preparedStatement.setString(1, "Test");
+ preparedStatement.executeUpdate();
+
+ ResultSet resultSet = statement.executeQuery("select * from COMMENTS");
+ writeMetaData(resultSet);
+ // Should close resultsets
+ resultSet.close();
+ }
+
+ private void writeMetaData(ResultSet resultSet) throws SQLException {
+ // Get some metadata from the database
+ log.info("The columns in the table are: ");
+
+ log.info("Table: " + resultSet.getMetaData().getTableName(1));
+ for (int i = 1; i <= resultSet.getMetaData().getColumnCount(); i++) {
+ log.info("Column " + i + " " + resultSet.getMetaData().getColumnName(i));
+ }
+ }
+
+ private void writeResultSet(List<List<String>> resultSet) throws SQLException {
+ for (List<String> row : resultSet) {
+ String user = row.get(0);
+ String website = row.get(1);
+ String date = row.get(2);
+ String summary = row.get(3);
+ String comment = row.get(4);
+ log.info("User: " + user);
+ log.info("Website: " + website);
+ log.info("Summary: " + summary);
+ log.info("Date: " + date);
+ log.info("Comment: " + comment);
+ }
+ }
+
+ // You should always close the statement and connection
+ public void close() throws Exception {
+ if (statement != null) {
+ statement.close();
+ statement = null;
+ }
+
+ if (connect != null) {
+ connect.close();
+ connect = null;
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ac1a7c09/software/database/src/test/java/org/apache/brooklyn/entity/database/crate/CrateNodeIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/database/src/test/java/org/apache/brooklyn/entity/database/crate/CrateNodeIntegrationTest.java b/software/database/src/test/java/org/apache/brooklyn/entity/database/crate/CrateNodeIntegrationTest.java
new file mode 100644
index 0000000..e91b4ad
--- /dev/null
+++ b/software/database/src/test/java/org/apache/brooklyn/entity/database/crate/CrateNodeIntegrationTest.java
@@ -0,0 +1,64 @@
+/*
+ * 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.database.crate;
+
+import static org.testng.Assert.assertFalse;
+
+import org.apache.brooklyn.api.entity.proxying.EntitySpec;
+import org.apache.brooklyn.test.EntityTestUtils;
+import org.apache.brooklyn.test.entity.TestApplication;
+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.ApplicationBuilder;
+import brooklyn.entity.basic.Entities;
+import brooklyn.entity.trait.Startable;
+import org.apache.brooklyn.location.basic.LocalhostMachineProvisioningLocation;
+
+public class CrateNodeIntegrationTest {
+
+ 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 {
+ CrateNode entity = app.createAndManageChild(EntitySpec.create(CrateNode.class));
+ app.start(ImmutableList.of(localhostProvisioningLocation));
+
+ EntityTestUtils.assertAttributeEqualsEventually(entity, Startable.SERVICE_UP, true);
+ EntityTestUtils.assertAttributeEventuallyNonNull(entity, CrateNode.SERVER_NAME);
+
+ entity.stop();
+ assertFalse(entity.getAttribute(Startable.SERVICE_UP));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ac1a7c09/software/database/src/test/java/org/apache/brooklyn/entity/database/mariadb/MariaDbIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/database/src/test/java/org/apache/brooklyn/entity/database/mariadb/MariaDbIntegrationTest.java b/software/database/src/test/java/org/apache/brooklyn/entity/database/mariadb/MariaDbIntegrationTest.java
new file mode 100644
index 0000000..8e846e1
--- /dev/null
+++ b/software/database/src/test/java/org/apache/brooklyn/entity/database/mariadb/MariaDbIntegrationTest.java
@@ -0,0 +1,125 @@
+/*
+ * 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.database.mariadb;
+
+import java.io.File;
+import java.net.InetAddress;
+
+import org.apache.brooklyn.api.entity.proxying.EntitySpec;
+import org.apache.brooklyn.api.management.ManagementContext;
+import org.apache.brooklyn.core.management.internal.LocalManagementContext;
+import org.apache.brooklyn.test.entity.TestApplication;
+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 brooklyn.config.BrooklynProperties;
+import brooklyn.entity.basic.ApplicationBuilder;
+import brooklyn.entity.basic.Entities;
+import org.apache.brooklyn.entity.database.DatastoreMixins.DatastoreCommon;
+import org.apache.brooklyn.entity.database.VogellaExampleAccess;
+import org.apache.brooklyn.location.basic.LocalhostMachineProvisioningLocation;
+import brooklyn.util.collections.MutableMap;
+import brooklyn.util.text.Strings;
+
+import com.google.common.collect.ImmutableList;
+
+/**
+ * Runs a slightly modified version of the popular Vogella MySQL tutorial,
+ * from
+ * http://www.vogella.de/articles/MySQLJava/article.html
+ */
+public class MariaDbIntegrationTest {
+
+ public static final Logger log = LoggerFactory.getLogger(MariaDbIntegrationTest.class);
+
+ protected BrooklynProperties brooklynProperties;
+ protected ManagementContext managementContext;
+ protected TestApplication tapp;
+ protected String hostname;
+
+ @BeforeMethod(alwaysRun = true)
+ public void setUp() throws Exception {
+ // can start in AWS by running this -- or use brooklyn CLI/REST for most clouds, or programmatic/config for set of fixed IP machines
+ hostname = InetAddress.getLocalHost().getHostName();
+
+ brooklynProperties = BrooklynProperties.Factory.newDefault();
+ managementContext = new LocalManagementContext(brooklynProperties);
+ tapp = ApplicationBuilder.newManagedApp(TestApplication.class, managementContext);
+ }
+
+ @AfterMethod(alwaysRun=true)
+ public void ensureShutDown() throws Exception {
+ Entities.destroyAllCatching(managementContext);
+ }
+
+ //from http://www.vogella.de/articles/MySQLJava/article.html
+ public static final String CREATION_SCRIPT =
+ "CREATE DATABASE feedback; " +
+ "CREATE USER 'sqluser'@'localhost' IDENTIFIED BY 'sqluserpw'; " +
+ "GRANT USAGE ON *.* TO 'sqluser'@'localhost'; " +
+ "GRANT ALL PRIVILEGES ON feedback.* TO 'sqluser'@'localhost'; " +
+ "CREATE USER 'sqluser'@'%' IDENTIFIED BY 'sqluserpw'; " +
+ "GRANT USAGE ON *.* TO 'sqluser'@'%'; " +
+ "GRANT ALL PRIVILEGES ON feedback.* TO 'sqluser'@'%'; " +
+ "CREATE USER 'sqluser'@'$hostname' IDENTIFIED BY 'sqluserpw'; " +
+ "GRANT USAGE ON *.* TO 'sqluser'@'$hostname'; " +
+ "GRANT ALL PRIVILEGES ON feedback.* TO 'sqluser'@'$hostname'; " +
+ "FLUSH PRIVILEGES; " +
+ "USE feedback; " +
+ "CREATE TABLE COMMENTS ( " +
+ "id INT NOT NULL AUTO_INCREMENT, " +
+ "MYUSER VARCHAR(30) NOT NULL, " +
+ "EMAIL VARCHAR(30), " +
+ "WEBPAGE VARCHAR(100) NOT NULL, " +
+ "DATUM DATE NOT NULL, " +
+ "SUMMARY VARCHAR(40) NOT NULL, " +
+ "COMMENTS VARCHAR(400) NOT NULL, " +
+ "PRIMARY KEY (ID) " +
+ "); " +
+ "INSERT INTO COMMENTS values (default, 'lars', 'myemail@gmail.com','http://www.vogella.de', '2009-09-14 10:33:11', 'Summary','My first comment' );";
+
+ @Test(groups = "Integration")
+ public void test_localhost() throws Exception {
+ String dataDir = "/tmp/mariadb-data-" + Strings.makeRandomId(8);
+ MariaDbNode mariadb = tapp.createAndManageChild(EntitySpec.create(MariaDbNode.class)
+ .configure(MariaDbNode.MARIADB_SERVER_CONF, MutableMap.<String, Object>of("skip-name-resolve",""))
+ .configure(DatastoreCommon.CREATION_SCRIPT_CONTENTS, CREATION_SCRIPT)
+ .configure(MariaDbNode.DATA_DIR, dataDir));
+ LocalhostMachineProvisioningLocation location = new LocalhostMachineProvisioningLocation();
+
+ tapp.start(ImmutableList.of(location));
+ log.info("MariaDB started");
+
+ new VogellaExampleAccess("com.mysql.jdbc.Driver", mariadb.getAttribute(DatastoreCommon.DATASTORE_URL)).readModifyAndRevertDataBase();
+
+ log.info("Ran vogella MySQL example -- SUCCESS");
+
+ // Ensure the data directory was successfully overridden.
+ File dataDirFile = new File(dataDir);
+ File mariadbSubdirFile = new File(dataDirFile, "mysql");
+ Assert.assertTrue(mariadbSubdirFile.exists());
+
+ // Clean up.
+ dataDirFile.delete();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/ac1a7c09/software/database/src/test/java/org/apache/brooklyn/entity/database/mariadb/MariaDbLiveEc2Test.java
----------------------------------------------------------------------
diff --git a/software/database/src/test/java/org/apache/brooklyn/entity/database/mariadb/MariaDbLiveEc2Test.java b/software/database/src/test/java/org/apache/brooklyn/entity/database/mariadb/MariaDbLiveEc2Test.java
new file mode 100644
index 0000000..6fbf43e
--- /dev/null
+++ b/software/database/src/test/java/org/apache/brooklyn/entity/database/mariadb/MariaDbLiveEc2Test.java
@@ -0,0 +1,57 @@
+/*
+ * 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.database.mariadb;
+
+import org.apache.brooklyn.api.entity.proxying.EntitySpec;
+import org.apache.brooklyn.api.location.Location;
+import org.testng.annotations.Test;
+
+import brooklyn.entity.AbstractEc2LiveTest;
+import org.apache.brooklyn.entity.database.DatastoreMixins.DatastoreCommon;
+import org.apache.brooklyn.entity.database.VogellaExampleAccess;
+
+import org.apache.brooklyn.location.jclouds.JcloudsLocation;
+
+import com.google.common.collect.ImmutableList;
+
+@Test(groups = { "Live" })
+public class MariaDbLiveEc2Test extends AbstractEc2LiveTest {
+
+ @Override
+ protected void doTest(Location loc) throws Exception {
+ // TODO For some CentOS VMs (e.g. in AWS 6.3, us-east-1/ami-a96b01c0), currently need to turn off iptables unfortunately.
+ // Should really just open the ports in iptables.
+ MariaDbNode mariadb = app.createAndManageChild(EntitySpec.create(MariaDbNode.class)
+ .configure(DatastoreCommon.CREATION_SCRIPT_CONTENTS, MariaDbIntegrationTest.CREATION_SCRIPT)
+ .configure(MariaDbNode.PROVISIONING_PROPERTIES.subKey(JcloudsLocation.STOP_IPTABLES.getName()), true));
+
+ app.start(ImmutableList.of(loc));
+
+ new VogellaExampleAccess("com.mysql.jdbc.Driver", mariadb.getAttribute(DatastoreCommon.DATASTORE_URL)).readModifyAndRevertDataBase();
+ }
+
+ @Override
+ @Test(enabled=false, groups = "Live")
+ public void test_Debian_7_2() throws Exception { } // Disabled because MariaDB not available
+
+ @Test(enabled=false)
+ public void testDummy() {} // Convince testng IDE integration that this really does have test methods
+
+}
+