modules/common/cassandra-ccm/cassandra-ccm-core/pom.xml | 1 modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/bin/cassandra | 3 modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/rhq.cassandra-env.sh | 247 ---------- modules/common/cassandra-installer/src/main/java/org/rhq/storage/installer/StorageInstaller.java | 77 ++- modules/common/cassandra-installer/src/test/java/org/rhq/storage/installer/StorageInstallerTest.java | 93 +++ 5 files changed, 163 insertions(+), 258 deletions(-)
New commits: commit 656cc6066250f46ff51e16230c0f7c8263f55435 Author: John Sanda jsanda@redhat.com Date: Fri Jul 19 13:43:46 2013 -0400
[BZ 983226] fixing upgrade regression introduced by use of cassandra-jvm.properties
This commit removes cassandra-env.sh from our Cassandra distro since we are no longer using that script. The storage installer upgrade has been cleaned up some so that it will get the jmx port from cassandra-env.sh for 4.8 installs and then update cassandra-jvm.properties.
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/pom.xml b/modules/common/cassandra-ccm/cassandra-ccm-core/pom.xml index 42f6c8b..2bde394 100644 --- a/modules/common/cassandra-ccm/cassandra-ccm-core/pom.xml +++ b/modules/common/cassandra-ccm/cassandra-ccm-core/pom.xml @@ -171,6 +171,7 @@ <move file="${project.build.outputDirectory}/cassandra/bin/cassandra" todir="${cassandra.dir}/bin"/> <delete dir="${project.build.outputDirectory}/cassandra"/> <delete dir="${cassandra.dir}/javadoc"/> + <delete file="${cassandra.dir}/conf/cassandra-env.sh"/>
<zip basedir="${cassandra.dir}" destfile="${cassandra.distro.zip}"/> <delete dir="${cassandra.dir}"/> diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/bin/cassandra b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/bin/cassandra index 742d9c0..ddbc099 100755 --- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/bin/cassandra +++ b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/bin/cassandra @@ -106,8 +106,7 @@ if [ -z "$CASSANDRA_CONF" -o -z "$CLASSPATH" ]; then exit 1 fi
-if [ -f "$CASSANDRA_CONF/cassandra-env.sh" ]; then - #. "$CASSANDRA_CONF/cassandra-env.sh" +if [ -f "$CASSANDRA_CONF/cassandra-jvm.properties" ]; then . "$CASSANDRA_CONF/cassandra-jvm.properties" fi
diff --git a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/rhq.cassandra-env.sh b/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/rhq.cassandra-env.sh deleted file mode 100644 index 99b3128..0000000 --- a/modules/common/cassandra-ccm/cassandra-ccm-core/src/main/bundle/cassandra/conf/rhq.cassandra-env.sh +++ /dev/null @@ -1,247 +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. - -calculate_heap_sizes() -{ - case "`uname`" in - Linux) - system_memory_in_mb=`free -m | awk '/Mem:/ {print $2}'` - system_cpu_cores=`egrep -c 'processor([[:space:]]+):.*' /proc/cpuinfo` - ;; - FreeBSD) - system_memory_in_bytes=`sysctl hw.physmem | awk '{print $2}'` - system_memory_in_mb=`expr $system_memory_in_bytes / 1024 / 1024` - system_cpu_cores=`sysctl hw.ncpu | awk '{print $2}'` - ;; - SunOS) - system_memory_in_mb=`prtconf | awk '/Memory size:/ {print $3}'` - system_cpu_cores=`psrinfo | wc -l` - ;; - Darwin) - system_memory_in_bytes=`sysctl hw.memsize | awk '{print $2}'` - system_memory_in_mb=`expr $system_memory_in_bytes / 1024 / 1024` - system_cpu_cores=`sysctl hw.ncpu | awk '{print $2}'` - ;; - *) - # assume reasonable defaults for e.g. a modern desktop or - # cheap server - system_memory_in_mb="2048" - system_cpu_cores="2" - ;; - esac - - # some systems like the raspberry pi don't report cores, use at least 1 - if [ "$system_cpu_cores" -lt "1" ] - then - system_cpu_cores="1" - fi - - # set max heap size based on the following - # max(min(1/2 ram, 1024MB), min(1/4 ram, 8GB)) - # calculate 1/2 ram and cap to 1024MB - # calculate 1/4 ram and cap to 8192MB - # pick the max - half_system_memory_in_mb=`expr $system_memory_in_mb / 2` - quarter_system_memory_in_mb=`expr $half_system_memory_in_mb / 2` - if [ "$half_system_memory_in_mb" -gt "1024" ] - then - half_system_memory_in_mb="1024" - fi - if [ "$quarter_system_memory_in_mb" -gt "8192" ] - then - quarter_system_memory_in_mb="8192" - fi - if [ "$half_system_memory_in_mb" -gt "$quarter_system_memory_in_mb" ] - then - max_heap_size_in_mb="$half_system_memory_in_mb" - else - max_heap_size_in_mb="$quarter_system_memory_in_mb" - fi - MAX_HEAP_SIZE="${max_heap_size_in_mb}M" - - # Young gen: min(max_sensible_per_modern_cpu_core * num_cores, 1/4 * heap size) - max_sensible_yg_per_core_in_mb="100" - max_sensible_yg_in_mb=`expr $max_sensible_yg_per_core_in_mb "*" $system_cpu_cores` - - desired_yg_in_mb=`expr $max_heap_size_in_mb / 4` - - if [ "$desired_yg_in_mb" -gt "$max_sensible_yg_in_mb" ] - then - HEAP_NEWSIZE="${max_sensible_yg_in_mb}M" - else - HEAP_NEWSIZE="${desired_yg_in_mb}M" - fi -} - -# Determine the sort of JVM we'll be running on. - -java_ver_output=`"${JAVA:-java}" -version 2>&1` - -jvmver=`echo "$java_ver_output" | awk -F'"' 'NR==1 {print $2}'` -JVM_VERSION=${jvmver%_*} -JVM_PATCH_VERSION=${jvmver#*_} - -jvm=`echo "$java_ver_output" | awk 'NR==2 {print $1}'` -case "$jvm" in - OpenJDK) - JVM_VENDOR=OpenJDK - # this will be "64-Bit" or "32-Bit" - JVM_ARCH=`echo "$java_ver_output" | awk 'NR==3 {print $2}'` - ;; - "Java(TM)") - JVM_VENDOR=Oracle - # this will be "64-Bit" or "32-Bit" - JVM_ARCH=`echo "$java_ver_output" | awk 'NR==3 {print $3}'` - ;; - *) - # Help fill in other JVM values - JVM_VENDOR=other - JVM_ARCH=unknown - ;; -esac - - -# Override these to set the amount of memory to allocate to the JVM at -# start-up. For production use you may wish to adjust this for your -# environment. MAX_HEAP_SIZE is the total amount of memory dedicated -# to the Java heap; HEAP_NEWSIZE refers to the size of the young -# generation. Both MAX_HEAP_SIZE and HEAP_NEWSIZE should be either set -# or not (if you set one, set the other). -# -# The main trade-off for the young generation is that the larger it -# is, the longer GC pause times will be. The shorter it is, the more -# expensive GC will be (usually). -# -# The example HEAP_NEWSIZE assumes a modern 8-core+ machine for decent pause -# times. If in doubt, and if you do not particularly want to tweak, go with -# 100 MB per physical CPU core. - -#MAX_HEAP_SIZE="4G" -#HEAP_NEWSIZE="800M" - -if [ "x$MAX_HEAP_SIZE" = "x" ] && [ "x$HEAP_NEWSIZE" = "x" ]; then - calculate_heap_sizes -else - if [ "x$MAX_HEAP_SIZE" = "x" ] || [ "x$HEAP_NEWSIZE" = "x" ]; then - echo "please set or unset MAX_HEAP_SIZE and HEAP_NEWSIZE in pairs (see cassandra-env.sh)" - exit 1 - fi -fi - -# Specifies the default port over which Cassandra will be available for -# JMX connections. -JMX_PORT="${rhq.cassandra.jmx.port}" - - -# Here we create the arguments that will get passed to the jvm when -# starting cassandra. - -# enable assertions. disabling this in production will give a modest -# performance benefit (around 5%). -JVM_OPTS="$JVM_OPTS -ea" - -# add the jamm javaagent -if [ "$JVM_VENDOR" != "OpenJDK" -o "$JVM_VERSION" \> "1.6.0" ] \ - || [ "$JVM_VERSION" = "1.6.0" -a "$JVM_PATCH_VERSION" -ge 23 ] -then - JVM_OPTS="$JVM_OPTS -javaagent:$CASSANDRA_HOME/lib/jamm-0.2.5.jar" -fi - -# enable thread priorities, primarily so we can give periodic tasks -# a lower priority to avoid interfering with client workload -JVM_OPTS="$JVM_OPTS -XX:+UseThreadPriorities" -# allows lowering thread priority without being root. see -# http://tech.stolsvik.com/2010/01/linux-java-thread-priorities-workaround.htm... -JVM_OPTS="$JVM_OPTS -XX:ThreadPriorityPolicy=42" - -# min and max heap sizes should be set to the same value to avoid -# stop-the-world GC pauses during resize, and so that we can lock the -# heap in memory on startup to prevent any of it from being swapped -# out. -JVM_OPTS="$JVM_OPTS -Xms${rhq.cassandra.max.heap.size}" -JVM_OPTS="$JVM_OPTS -Xmx${rhq.cassandra.max.heap.size}" -JVM_OPTS="$JVM_OPTS -Xmn${rhq.cassandra.heap.new.size}" -JVM_OPTS="$JVM_OPTS -XX:+HeapDumpOnOutOfMemoryError" - -# set jvm HeapDumpPath with CASSANDRA_HEAPDUMP_DIR -if [ "x$CASSANDRA_HEAPDUMP_DIR" != "x" ]; then - JVM_OPTS="$JVM_OPTS -XX:HeapDumpPath=$CASSANDRA_HEAPDUMP_DIR/cassandra-`date +%s`-pid$$.hprof" -fi - - -startswith() { [ "${1#$2}" != "$1" ]; } - -if [ "`uname`" = "Linux" ] ; then - # reduce the per-thread stack size to minimize the impact of Thrift - # thread-per-client. (Best practice is for client connections to - # be pooled anyway.) Only do so on Linux where it is known to be - # supported. - # u34 and greater need 180k - JVM_OPTS="$JVM_OPTS -Xss${rhq.cassandra.stack.size}" -fi -echo "xss = $JVM_OPTS" - -# GC tuning options -JVM_OPTS="$JVM_OPTS -XX:+UseParNewGC" -JVM_OPTS="$JVM_OPTS -XX:+UseConcMarkSweepGC" -JVM_OPTS="$JVM_OPTS -XX:+CMSParallelRemarkEnabled" -JVM_OPTS="$JVM_OPTS -XX:SurvivorRatio=8" -JVM_OPTS="$JVM_OPTS -XX:MaxTenuringThreshold=1" -JVM_OPTS="$JVM_OPTS -XX:CMSInitiatingOccupancyFraction=75" -JVM_OPTS="$JVM_OPTS -XX:+UseCMSInitiatingOccupancyOnly" -JVM_OPTS="$JVM_OPTS -XX:+UseTLAB" -# note: bash evals '1.7.x' as > '1.7' so this is really a >= 1.7 jvm check -if [ "$JVM_VERSION" \> "1.7" ] ; then - JVM_OPTS="$JVM_OPTS -XX:+UseCondCardMark" -fi - -# GC logging options -- uncomment to enable -# JVM_OPTS="$JVM_OPTS -XX:+PrintGCDetails" -# JVM_OPTS="$JVM_OPTS -XX:+PrintGCDateStamps" -# JVM_OPTS="$JVM_OPTS -XX:+PrintHeapAtGC" -# JVM_OPTS="$JVM_OPTS -XX:+PrintTenuringDistribution" -# JVM_OPTS="$JVM_OPTS -XX:+PrintGCApplicationStoppedTime" -# JVM_OPTS="$JVM_OPTS -XX:+PrintPromotionFailure" -# JVM_OPTS="$JVM_OPTS -XX:PrintFLSStatistics=1" -# JVM_OPTS="$JVM_OPTS -Xloggc:/var/log/cassandra/gc-`date +%s`.log" -# If you are using JDK 6u34 7u2 or later you can enable GC log rotation -# don't stick the date in the log name if rotation is on. -# JVM_OPTS="$JVM_OPTS -Xloggc:/var/log/cassandra/gc.log" -# JVM_OPTS="$JVM_OPTS -XX:+UseGCLogFileRotation" -# JVM_OPTS="$JVM_OPTS -XX:NumberOfGCLogFiles=10" -# JVM_OPTS="$JVM_OPTS -XX:GCLogFileSize=10M" - -# uncomment to have Cassandra JVM listen for remote debuggers/profilers on port 1414 -# JVM_OPTS="$JVM_OPTS -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=1414" - -# Prefer binding to IPv4 network intefaces (when net.ipv6.bindv6only=1). See -# http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6342561 (short version: -# comment out this entry to enable IPv6 support). -JVM_OPTS="$JVM_OPTS -Djava.net.preferIPv4Stack=true" - -# jmx: metrics and administration interface -# -# add this if you're having trouble connecting: -# JVM_OPTS="$JVM_OPTS -Djava.rmi.server.hostname=<public name>" -# -# see -# https://blogs.oracle.com/jmxetc/entry/troubleshooting_connection_problems_in... -# for more on configuring JMX through firewalls, etc. (Short version: -# get it working with no firewall first.) -JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.port=$JMX_PORT" -JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.ssl=false" -JVM_OPTS="$JVM_OPTS -Dcom.sun.management.jmxremote.authenticate=false" -JVM_OPTS="$JVM_OPTS $JVM_EXTRA_OPTS" 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 63282e4..5c5ac4e 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 @@ -25,8 +25,10 @@
package org.rhq.storage.installer;
+import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; +import java.io.FileReader; import java.io.IOException; import java.net.InetAddress; import java.util.ArrayList; @@ -250,15 +252,32 @@ public class StorageInstaller { File oldConfDir = new File(existingStorageDir, "conf"); File newConfDir = new File(storageBasedir, "conf");
+ File cassandraEnvFile = new File(oldConfDir, "cassandra-env.sh"); + String cassandraYaml = "cassandra.yaml"; String cassandraJvmProps = "cassandra-jvm.properties"; File cassandraJvmPropsFile = new File(newConfDir, cassandraJvmProps); String log4j = "log4j-server.properties";
replaceFile(new File(oldConfDir, cassandraYaml), new File(newConfDir, cassandraYaml)); - replaceFile(new File(oldConfDir, cassandraJvmProps), cassandraJvmPropsFile); replaceFile(new File(oldConfDir, log4j), new File(newConfDir, log4j));
+ if (cassandraEnvFile.exists()) { + // Then this is an RHQ 4.8 install + jmxPort = parseJmxPortFromCassandrEnv(cassandraEnvFile); + Properties jvmProps = new Properties(); + jvmProps.load(new FileInputStream(cassandraJvmPropsFile)); + PropertiesFileUpdate propertiesUpdater = new PropertiesFileUpdate( + cassandraJvmPropsFile.getAbsolutePath()); + jvmProps.setProperty("jmx_port", Integer.toString(jmxPort)); + + propertiesUpdater.update(jvmProps); + + } else { + jmxPort = parseJmxPort(cassandraJvmPropsFile); + replaceFile(new File(oldConfDir, cassandraJvmProps), cassandraJvmPropsFile); + } + log.info("Finished installing RHQ Storage Node.");
log.info("Updating rhq-server.properties..."); @@ -268,8 +287,6 @@ public class StorageInstaller { Map<String, Object> config = (Map<String, Object>) yaml.load(new FileInputStream(yamlFile));
hostname = (String) config.get("listen_address"); - - jmxPort = parseJmxPort(cassandraJvmPropsFile); } else { if (cmdLine.hasOption("dir")) { File basedir = new File(cmdLine.getOptionValue("dir")); @@ -661,6 +678,60 @@ public class StorageInstaller { } }
+ private int parseJmxPortFromCassandrEnv(File cassandraEnvFile) { + Integer port = null; + if (isWindows()) { + // TODO + return defaultJmxPort; + } else { + BufferedReader reader = null; + try { + reader = new BufferedReader(new FileReader(cassandraEnvFile)); + String line = reader.readLine(); + + while (line != null) { + if (line.startsWith("JMX_PORT")) { + int startIndex = "JMX_PORT="".length(); + int endIndex = line.lastIndexOf("""); + + if (startIndex == -1 || endIndex == -1) { + log.error("Failed to parse the JMX port. Make sure that you have the JMX port defined on its " + + "own line as follows, JMX_PORT="<jmx-port>""); + throw new RuntimeException("Cannot determine JMX port"); + } + try { + port = Integer.parseInt(line.substring(startIndex, endIndex)); + } catch (NumberFormatException e) { + log.error("The JMX port must be an integer. [" + port + "] is an invalid value"); + throw new RuntimeException("The JMX port has an invalid value"); + } + return port; + } + line = reader.readLine(); + } + log.error("Failed to parse the JMX port. Make sure that you have the JMX port defined on its " + + "own line as follows, JMX_PORT="<jmx-port>""); + throw new RuntimeException("Cannot determine JMX port"); + } catch (IOException e) { + log.error("Failed to parse JMX port. There was an unexpected IO error", e); + throw new RuntimeException("Failed to parse JMX port due to IO error: " + e.getMessage()); + } finally { + try { + if (reader != null) { + reader.close(); + } + } catch (IOException e) { + if (log.isDebugEnabled()) { + log.debug("An error occurred closing the " + BufferedReader.class.getName() + " used to " + + "parse the JMX port", e); + } else { + log.warn("There was error closing the reader used to parse the JMX port: " + e.getMessage()); + } + } + } + } + } + private int parseJmxPort(File cassandraJvmOptsFile) { Integer port = null; if (isWindows()) { 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 index 3fd13c7..a7921c0 100644 --- 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 @@ -2,11 +2,13 @@ package org.rhq.storage.installer;
import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertTrue; import static org.testng.Assert.fail;
import java.io.File; import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.IOException; import java.lang.reflect.Method; import java.util.Properties; @@ -20,41 +22,53 @@ import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test;
import org.rhq.cassandra.CassandraClusterManager; +import org.rhq.core.util.MessageDigestGenerator; import org.rhq.core.util.file.FileUtil; +import org.rhq.core.util.stream.StreamUtil;
/** * @author John Sanda */ public class StorageInstallerTest {
+ private MessageDigestGenerator digestGenerator; + private File basedir;
+ private File serverDir; + private File storageDir;
private StorageInstaller installer;
@BeforeMethod public void initDirs(Method test) throws Exception { + digestGenerator = new MessageDigestGenerator(MessageDigestGenerator.SHA_256); + 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()); + serverDir = new File(basedir, "rhq-server");
- File serverPropsFile = new File(basedir, "rhq-server.properties"); + System.setProperty("rhq.server.basedir", serverDir.getAbsolutePath()); + + File serverPropsFile = new File(serverDir, "rhq-server.properties"); FileUtils.touch(serverPropsFile); System.setProperty("rhq.server.properties-file", serverPropsFile.getAbsolutePath());
- storageDir = new File(basedir, "rhq-storage"); + storageDir = new File(serverDir, "rhq-storage");
installer = new StorageInstaller(); }
@AfterMethod public void shutdownStorageNode() throws Exception { - CassandraClusterManager ccm = new CassandraClusterManager(); - ccm.killNode(storageDir); + if (FileUtils.getFile(storageDir, "bin", "cassandra.pid").exists()) { + CassandraClusterManager ccm = new CassandraClusterManager(); + ccm.killNode(storageDir); + } }
@Test @@ -97,6 +111,65 @@ public class StorageInstallerTest { assertTrue(savedCachesDir.exists(), "Expected to find saved_caches directory at " + savedCachesDir); }
+ @Test + public void upgradeFromRHQ48Install() throws Exception { + File rhq48ServerDir = new File(basedir, "rhq48-server"); + File rhq48StorageDir = new File(rhq48ServerDir, "rhq-storage"); + File rhq48StorageConfDir = new File(rhq48StorageDir, "conf"); + + File oldCassandraYamlFile = new File(rhq48StorageConfDir, "cassandra.yaml"); + File oldCassandraEnvFile = new File(rhq48StorageConfDir, "cassandra-env.sh"); + File oldLog4JFile = new File(rhq48StorageConfDir, "log4j-server.properties"); + + rhq48StorageConfDir.mkdirs(); + StreamUtil.copy(getClass().getResourceAsStream("/rhq48/storage/conf/cassandra.yaml"), + new FileOutputStream(oldCassandraYamlFile), true); + StreamUtil.copy(getClass().getResourceAsStream("/rhq48/storage/conf/cassandra-env.sh"), + new FileOutputStream(oldCassandraEnvFile)); + StreamUtil.copy(getClass().getResourceAsStream("/rhq48/storage/conf/log4j-server.properties"), + new FileOutputStream(oldLog4JFile)); + + CommandLineParser parser = new PosixParser(); + + String[] args = { + "--upgrade", rhq48ServerDir.getAbsolutePath(), + "--dir", storageDir.getAbsolutePath() + }; + + 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 upgrade"); + assertNodeIsRunning(); + + File binDir = new File(storageDir, "bin"); + assertTrue(binDir.exists(), "Expected to find bin directory at " + binDir); + + File libDir = new File(storageDir, "lib"); + assertTrue(libDir.exists(), "Expected to find lib directory at " + libDir); + + File confDir = new File(storageDir, "conf"); + assertTrue(confDir.exists(), "Expected to find conf directory at " + confDir); + + File newCassandraYamlFile = new File(confDir, "cassandra.yaml"); + assertEquals(sha256(oldCassandraYamlFile), sha256(newCassandraYamlFile), newCassandraYamlFile + + " does not match the original version"); + + File newLog4JFile = new File(confDir, "log4j-server.properties"); + assertEquals(sha256(oldLog4JFile), sha256(newLog4JFile), newLog4JFile + " does not match the original version"); + + assertFalse(new File(confDir, "cassandra-env.sh").exists(), "cassandra-env.sh should not be used after RHQ 4.8.0"); + + File cassandraJvmPropsFile = new File(confDir, "cassandra-jvm.properties"); + Properties properties = new Properties(); + properties.load(new FileInputStream(cassandraJvmPropsFile)); + + // If this check fails, make sure that the expected value matches the value in + // src/test/resources/rhq48/storage/conf/cassandra-env.sh + assertEquals(properties.getProperty("jmx_port"), "7399", "Failed to update the JMX port in " + + cassandraJvmPropsFile); + } + private void assertNodeIsRunning() { try { installer.verifyNodeIsUp("127.0.0.1", 7299, 3, 1000); @@ -106,7 +179,7 @@ public class StorageInstallerTest { }
private void assertRhqServerPropsUpdated() { - File serverPropsFile = new File(basedir, "rhq-server.properties"); + File serverPropsFile = new File(serverDir, "rhq-server.properties"); Properties properties = new Properties();
try { @@ -120,4 +193,12 @@ public class StorageInstallerTest { assertEquals(seeds, "127.0.0.1|7299|9142"); }
+ private String sha256(File file) { + try { + return digestGenerator.calcDigestString(file); + } catch (IOException e) { + throw new RuntimeException("Failed to calculate SHA-256 hash for " + file.getPath(), e); + } + } + }
rhq-commits@lists.fedorahosted.org