modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/CassandraClusterManager.java
| 2
modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
| 4
modules/common/cassandra-installer/src/test/java/org/rhq/storage/installer/StorageInstallerTest.java
| 123 ++++++++++
modules/common/cassandra-installer/src/test/resources/log4j.properties
| 41 +++
modules/common/cassandra-schema/pom.xml
| 6
modules/enterprise/server/server-metrics/pom.xml
| 12
modules/helpers/metrics-simulator/pom.xml
| 6
7 files changed, 173 insertions(+), 21 deletions(-)
New commits:
commit 165c9c9f8da7251c0000444f04161171a7d5794f
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jul 17 07:37:12 2013 -0400
need to make cassandra-ccm-core a direct dependency now
diff --git a/modules/helpers/metrics-simulator/pom.xml
b/modules/helpers/metrics-simulator/pom.xml
index a55afa5..0a06610 100644
--- a/modules/helpers/metrics-simulator/pom.xml
+++ b/modules/helpers/metrics-simulator/pom.xml
@@ -13,6 +13,12 @@
<dependencies>
<dependency>
<groupId>org.rhq</groupId>
+ <artifactId>rhq-cassandra-ccm-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.rhq</groupId>
<artifactId>rhq-cassandra-schema</artifactId>
<version>${project.version}</version>
</dependency>
commit fb59ea4fb09414875afcaa9543788e3cfc1b14f1
Author: John Sanda <jsanda(a)redhat.com>
Date: Wed Jul 17 07:35:22 2013 -0400
initial commit for StorageInstallerTest
This commit provides some initial test coverage for the storage installer. More
tests will be added to cover various error handling situations and upgrade
scenarios.
diff --git
a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/CassandraClusterManager.java
b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/CassandraClusterManager.java
index 7496d08..338ef3a 100644
---
a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/CassandraClusterManager.java
+++
b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/java/org/rhq/cassandra/CassandraClusterManager.java
@@ -303,7 +303,7 @@ public class CassandraClusterManager {
return nodeIds;
}
- private void killNode(File nodeDir) throws Exception {
+ public void killNode(File nodeDir) throws Exception {
long pid = getPid(nodeDir);
CLibrary.kill((int) pid, 9);
}
diff --git
a/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
b/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
index 2fec2dc..63282e4 100644
---
a/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
+++
b/modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java
@@ -485,7 +485,7 @@ public class StorageInstaller {
private PropertiesFileUpdate getServerProperties() {
String sysprop = System.getProperty("rhq.server.properties-file");
if (sysprop == null) {
- throw new RuntimeException("The required system property
[rhq.server.properties] is not defined.");
+ throw new RuntimeException("The required system property
[rhq.server.properties-file] is not defined.");
}
File file = new File(sysprop);
@@ -605,7 +605,7 @@ public class StorageInstaller {
return new File(binDir, "cassandra.pid").exists();
}
- private boolean verifyNodeIsUp(String address, int jmxPort, int retries, long
timeout) throws Exception {
+ boolean verifyNodeIsUp(String address, int jmxPort, int retries, long timeout) throws
Exception {
String url = "service:jmx:rmi:///jndi/rmi://" + address + ":"
+ jmxPort + "/jmxrmi";
JMXServiceURL serviceURL = new JMXServiceURL(url);
JMXConnector connector = null;
diff --git
a/modules/common/cassandra-installer/src/test/java/org/rhq/storage/installer/StorageInstallerTest.java
b/modules/common/cassandra-installer/src/test/java/org/rhq/storage/installer/StorageInstallerTest.java
new file mode 100644
index 0000000..3fd13c7
--- /dev/null
+++
b/modules/common/cassandra-installer/src/test/java/org/rhq/storage/installer/StorageInstallerTest.java
@@ -0,0 +1,123 @@
+package org.rhq.storage.installer;
+
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.util.Properties;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.PosixParser;
+import org.apache.commons.io.FileUtils;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import org.rhq.cassandra.CassandraClusterManager;
+import org.rhq.core.util.file.FileUtil;
+
+/**
+ * @author John Sanda
+ */
+public class StorageInstallerTest {
+
+ private File basedir;
+
+ private File storageDir;
+
+ private StorageInstaller installer;
+
+ @BeforeMethod
+ public void initDirs(Method test) throws Exception {
+ File dir = new File(getClass().getResource(".").toURI());
+ basedir = new File(dir, getClass().getSimpleName() + "/" +
test.getName());
+ FileUtil.purge(basedir, true);
+ basedir.mkdirs();
+
+ System.setProperty("rhq.server.basedir", basedir.getAbsolutePath());
+
+ File serverPropsFile = new File(basedir, "rhq-server.properties");
+ FileUtils.touch(serverPropsFile);
+ System.setProperty("rhq.server.properties-file",
serverPropsFile.getAbsolutePath());
+
+ storageDir = new File(basedir, "rhq-storage");
+
+ installer = new StorageInstaller();
+ }
+
+ @AfterMethod
+ public void shutdownStorageNode() throws Exception {
+ CassandraClusterManager ccm = new CassandraClusterManager();
+ ccm.killNode(storageDir);
+ }
+
+ @Test
+ public void performValidInstall() throws Exception {
+ CommandLineParser parser = new PosixParser();
+
+ String[] args = {
+ "--dir", storageDir.getAbsolutePath(),
+ "--commitlog", new File(storageDir,
"commit_log").getAbsolutePath(),
+ "--data", new File(storageDir,
"data").getAbsolutePath(),
+ "--saved-caches", new File(storageDir,
"saved_caches").getAbsolutePath(),
+ "--heap-size", "256M",
+ "--heap-new-size", "64M",
+ "--hostname", "127.0.0.1"
+ };
+
+ CommandLine cmdLine = parser.parse(installer.getOptions(), args);
+ int status = installer.run(cmdLine);
+
+ assertEquals(status, 0, "Expected to get back a status code of 0 for a
successful install");
+ assertNodeIsRunning();
+ assertRhqServerPropsUpdated();
+
+ File binDir = new File(storageDir, "bin");
+ assertTrue(binDir.exists(), "Expected to find bin directory at " +
binDir);
+
+ File confDir = new File(storageDir, "conf");
+ assertTrue(confDir.exists(), "Expected to find conf directory at " +
confDir);
+
+ File libDir = new File(storageDir, "lib");
+ assertTrue(libDir.exists(), "Expected to find lib directory at " +
libDir);
+
+ File commitLogDir = new File(storageDir, "commit_log");
+ assertTrue(commitLogDir.exists(), "Expected to find commit_log directory at
" + commitLogDir);
+
+ File dataDir = new File(storageDir, "data");
+ assertTrue(dataDir.exists(), "Expected to find data directory at " +
dataDir);
+
+ File savedCachesDir = new File(storageDir, "saved_caches");
+ assertTrue(savedCachesDir.exists(), "Expected to find saved_caches directory
at " + savedCachesDir);
+ }
+
+ private void assertNodeIsRunning() {
+ try {
+ installer.verifyNodeIsUp("127.0.0.1", 7299, 3, 1000);
+ } catch (Exception e) {
+ fail("Failed to verify that node is up", e);
+ }
+ }
+
+ private void assertRhqServerPropsUpdated() {
+ File serverPropsFile = new File(basedir, "rhq-server.properties");
+ Properties properties = new Properties();
+
+ try {
+ properties.load(new FileInputStream(serverPropsFile));
+ } catch (IOException e) {
+ fail("Failed to verify that " + serverPropsFile + " was
updated", e);
+ }
+
+ String seeds = properties.getProperty("rhq.cassandra.seeds");
+
+ assertEquals(seeds, "127.0.0.1|7299|9142");
+ }
+
+}
diff --git a/modules/common/cassandra-installer/src/test/resources/log4j.properties
b/modules/common/cassandra-installer/src/test/resources/log4j.properties
new file mode 100644
index 0000000..d56cc88
--- /dev/null
+++ b/modules/common/cassandra-installer/src/test/resources/log4j.properties
@@ -0,0 +1,41 @@
+#
+# /*
+# * RHQ Management Platform
+# * Copyright (C) 2005-2012 Red Hat, Inc.
+# * All rights reserved.
+# *
+# * This program is free software; you can redistribute it and/or modify
+# * it under the terms of the GNU General Public License, version 2, as
+# * published by the Free Software Foundation, and/or the GNU Lesser
+# * General Public License, version 2.1, also as published by the Free
+# * Software Foundation.
+# *
+# * This program is distributed in the hope that it will be useful,
+# * but WITHOUT ANY WARRANTY; without even the implied warranty of
+# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# * GNU General Public License and the GNU Lesser General Public License
+# * for more details.
+# *
+# * You should have received a copy of the GNU General Public License
+# * and the GNU Lesser General Public License along with this program;
+# * if not, write to the Free Software Foundation, Inc.,
+# * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+# */
+#
+
+log4j.rootCategory=WARN, FILE, CONSOLE
+
+log4j.appender.FILE=org.apache.log4j.DailyRollingFileAppender
+log4j.appender.FILE.DatePattern='.'yyyy-MM-dd
+log4j.appender.FILE.File=./target/test.log
+log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
+log4j.appender.FILE.layout.ConversionPattern=%d{ABSOLUTE} %-5p %c %m%n
+#log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
+log4j.appender.FILE.Append=false
+
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+#log4j.appender.CONSOLE.layout.ConversionPattern=%5p %d{HH:mm:ss,SSS} %m%n
+log4j.appender.CONSOLE.layout.ConversionPattern=%d{ABSOLUTE} %-5p %c %m%n
+
+log4j.logger.org.rhq=DEBUG
commit e798901b83e37cd267a2d11489664569918ef90d
Author: John Sanda <jsanda(a)redhat.com>
Date: Tue Jul 16 16:16:01 2013 -0400
cleaning up dependencies
diff --git a/modules/common/cassandra-schema/pom.xml
b/modules/common/cassandra-schema/pom.xml
index 8e3b44a..55dedb8 100644
--- a/modules/common/cassandra-schema/pom.xml
+++ b/modules/common/cassandra-schema/pom.xml
@@ -15,12 +15,6 @@
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>rhq-cassandra-ccm-core</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
<artifactId>rhq-cassandra-util</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/modules/enterprise/server/server-metrics/pom.xml
b/modules/enterprise/server/server-metrics/pom.xml
index 2245978..97496f7 100644
--- a/modules/enterprise/server/server-metrics/pom.xml
+++ b/modules/enterprise/server/server-metrics/pom.xml
@@ -47,18 +47,6 @@
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>rhq-cassandra-ccm-core</artifactId>
- <version>${project.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.apache.cassandra</groupId>
- <artifactId>cassandra-clientutil</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>${project.groupId}</groupId>
<artifactId>rhq-cassandra-ccm-testng</artifactId>
<version>${project.version}</version>
<scope>test</scope>