You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ak...@apache.org on 2016/08/05 04:46:16 UTC
[1/4] ignite git commit: IGNITE-3293 AWS bootstrap scripts patch for
Ignite-Cassandra - Fixes #794.
Repository: ignite
Updated Branches:
refs/heads/master 59fb5ef08 -> ee8ac73f2
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee8ac73f/modules/cassandra/src/test/bootstrap/aws/tests/tests-run.sh
----------------------------------------------------------------------
diff --git a/modules/cassandra/src/test/bootstrap/aws/tests/tests-run.sh b/modules/cassandra/src/test/bootstrap/aws/tests/tests-run.sh
deleted file mode 100644
index 74a769a..0000000
--- a/modules/cassandra/src/test/bootstrap/aws/tests/tests-run.sh
+++ /dev/null
@@ -1,715 +0,0 @@
-#!/bin/bash
-
-#
-# 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.
-#
-
-#profile=/home/ignite/.bash_profile
-profile=/root/.bash_profile
-
-. $profile
-
-terminate()
-{
- if [[ "$S3_TESTS_SUCCESS_URL" != */ ]]; then
- S3_TESTS_SUCCESS_URL=${S3_TESTS_SUCCESS_URL}/
- fi
-
- if [[ "$S3_TESTS_FAILURE_URL" != */ ]]; then
- S3_TESTS_FAILURE_URL=${S3_TESTS_FAILURE_URL}/
- fi
-
- msg=$HOST_NAME
-
- if [ -n "$1" ]; then
- echo "[ERROR] $1"
- echo "[ERROR]-----------------------------------------------------"
- echo "[ERROR] Tests execution failed"
- echo "[ERROR]-----------------------------------------------------"
- msg=$1
- reportFolder=${S3_TESTS_FAILURE_URL}${HOST_NAME}
- reportFile=$reportFolder/__error__
- else
- echo "[INFO]-----------------------------------------------------"
- echo "[INFO] Tests execution successfully completed"
- echo "[INFO]-----------------------------------------------------"
- reportFolder=${S3_TESTS_SUCCESS_URL}${HOST_NAME}
- reportFile=$reportFolder/__success__
- fi
-
- echo $msg > /opt/ignite-cassandra-tests/tests-result
-
- aws s3 rm --recursive $reportFolder
- if [ $? -ne 0 ]; then
- echo "[ERROR] Failed drop report folder: $reportFolder"
- fi
-
- if [ -d "/opt/ignite-cassandra-tests/logs" ]; then
- aws s3 sync --sse AES256 /opt/ignite-cassandra-tests/logs $reportFolder
- if [ $? -ne 0 ]; then
- echo "[ERROR] Failed to export tests logs to: $reportFolder"
- fi
- fi
-
- aws s3 cp --sse AES256 /opt/ignite-cassandra-tests/tests-result $reportFile
- if [ $? -ne 0 ]; then
- echo "[ERROR] Failed to report tests results to: $reportFile"
- fi
-
- aws s3 rm ${S3_TESTS_RUNNING_URL}${HOST_NAME}
- aws s3 rm ${S3_TESTS_WAITING_URL}${HOST_NAME}
-
- if [ "$FIRST_NODE" == "true" ]; then
- waitAllTestNodesCompleted
- removeFirstNodeLock
- reportScript=$(readlink -m $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/tests-report.sh)
- $reportScript
-
- if [ -n "$S3_LOGS_TRIGGER_URL" ]; then
- aws s3 cp --sse AES256 /opt/ignite-cassandra-tests/hostname $S3_LOGS_TRIGGER_URL
- if [ $? -ne 0 ]; then
- echo "[ERROR] Failed to trigger logs collection"
- fi
- fi
- fi
-
- rm -Rf /opt/ignite-cassandra-tests/tests-result /opt/ignite-cassandra-tests/hostname
-
- if [ -n "$1" ]; then
- exit 1
- fi
-
- exit 0
-}
-
-cleanupMetadata()
-{
- echo "[INFO] Running cleanup"
- aws s3 rm $S3_TESTS_SUMMARY_URL
- aws s3 rm --recursive $S3_TEST_NODES_DISCOVERY_URL
- aws s3 rm --recursive $S3_TESTS_RUNNING_URL
- aws s3 rm --recursive $S3_TESTS_WAITING_URL
- aws s3 rm --recursive $S3_TESTS_SUCCESS_URL
- aws s3 rm --recursive $S3_TESTS_FAILURE_URL
- echo "[INFO] Cleanup completed"
-}
-
-registerTestNode()
-{
- aws s3 cp --sse AES256 /opt/ignite-cassandra-tests/hostname ${S3_TEST_NODES_DISCOVERY_URL}${HOST_NAME}
- if [ $? -ne 0 ]; then
- terminate "Failed to create test node registration flag: ${S3_TEST_NODES_DISCOVERY_URL}${HOST_NAME}"
- fi
-}
-
-createRunningFlag()
-{
- aws s3 cp --sse AES256 /opt/ignite-cassandra-tests/hostname ${S3_TESTS_RUNNING_URL}${HOST_NAME}
- if [ $? -ne 0 ]; then
- terminate "Failed to create tests running flag: ${S3_TESTS_RUNNING_URL}${HOST_NAME}"
- fi
-}
-
-dropRunningFlag()
-{
- exists=$(aws s3 ls ${S3_TESTS_RUNNING_URL}${HOST_NAME})
- if [ -z "$exists" ]; then
- return 0
- fi
-
- aws s3 rm ${S3_TESTS_RUNNING_URL}${HOST_NAME}
- if [ $? -ne 0 ]; then
- terminate "Failed to drop tests running flag: ${S3_TESTS_RUNNING_URL}${HOST_NAME}"
- fi
-}
-
-createWaitingFlag()
-{
- aws s3 cp --sse AES256 /opt/ignite-cassandra-tests/hostname ${S3_TESTS_WAITING_URL}${HOST_NAME}
- if [ $? -ne 0 ]; then
- terminate "Failed to create tests waiting flag: ${S3_TESTS_WAITING_URL}${HOST_NAME}"
- fi
-}
-
-dropWaitingFlag()
-{
- exists=$(aws s3 ls ${S3_TESTS_WAITING_URL}${HOST_NAME})
- if [ -z "$exists" ]; then
- return 0
- fi
-
- aws s3 rm ${S3_TESTS_WAITING_URL}${HOST_NAME}
- if [ $? -ne 0 ]; then
- terminate "Failed to drop tests waiting flag: ${S3_TESTS_WAITING_URL}${HOST_NAME}"
- fi
-}
-
-dropTestsSummary()
-{
- exists=$(aws s3 ls $S3_TESTS_SUMMARY_URL)
- if [ -z "$exists" ]; then
- return 0
- fi
-
- aws s3 rm $S3_TESTS_SUMMARY_URL
- if [ $? -ne 0 ]; then
- terminate "Failed to drop tests summary info: $S3_TESTS_SUMMARY_URL"
- fi
-}
-
-validate()
-{
- if [ -z "$TESTS_TYPE" ]; then
- terminate "Tests type 'ignite' or 'cassandra' should be specified"
- fi
-
- if [ "$TESTS_TYPE" != "ignite" ] && [ "$TESTS_TYPE" != "cassandra" ]; then
- terminate "Incorrect tests type specified: $TESTS_TYPE"
- fi
-
- if [ -z "$S3_TESTS_SUCCESS_URL" ]; then
- terminate "Tests success URL doesn't specified"
- fi
-
- if [[ "$S3_TESTS_SUCCESS_URL" != */ ]]; then
- S3_TESTS_SUCCESS_URL=${S3_TESTS_SUCCESS_URL}/
- fi
-
- if [ -z "$S3_TESTS_FAILURE_URL" ]; then
- terminate "Tests failure URL doesn't specified"
- fi
-
- if [[ "$S3_TESTS_FAILURE_URL" != */ ]]; then
- S3_TESTS_FAILURE_URL=${S3_TESTS_FAILURE_URL}/
- fi
-
- if [ -z "$S3_TESTS_RUNNING_URL" ]; then
- terminate "Tests running URL doesn't specified"
- fi
-
- if [[ "$S3_TESTS_RUNNING_URL" != */ ]]; then
- S3_TESTS_RUNNING_URL=${S3_TESTS_RUNNING_URL}/
- fi
-
- if [ -z "$S3_TESTS_WAITING_URL" ]; then
- terminate "Tests waiting URL doesn't specified"
- fi
-
- if [[ "$S3_TESTS_WAITING_URL" != */ ]]; then
- S3_TESTS_WAITING_URL=${S3_TESTS_WAITING_URL}/
- fi
-
- if [ -z "$S3_IGNITE_SUCCESS_URL" ]; then
- terminate "Ignite success URL doesn't specified"
- fi
-
- if [[ "$S3_IGNITE_SUCCESS_URL" != */ ]]; then
- S3_IGNITE_SUCCESS_URL=${S3_IGNITE_SUCCESS_URL}/
- fi
-
- if [ -z "$S3_IGNITE_FAILURE_URL" ]; then
- terminate "Ignite failure URL doesn't specified"
- fi
-
- if [[ "$S3_IGNITE_FAILURE_URL" != */ ]]; then
- S3_IGNITE_FAILURE_URL=${S3_IGNITE_FAILURE_URL}/
- fi
-
- if [ -z "$S3_CASSANDRA_SUCCESS_URL" ]; then
- terminate "Cassandra success URL doesn't specified"
- fi
-
- if [[ "$S3_CASSANDRA_SUCCESS_URL" != */ ]]; then
- S3_CASSANDRA_SUCCESS_URL=${S3_CASSANDRA_SUCCESS_URL}/
- fi
-
- if [ -z "$S3_CASSANDRA_FAILURE_URL" ]; then
- terminate "Cassandra failure URL doesn't specified"
- fi
-
- if [[ "$S3_CASSANDRA_FAILURE_URL" != */ ]]; then
- S3_CASSANDRA_FAILURE_URL=${S3_CASSANDRA_FAILURE_URL}/
- fi
-
- if [ -z "$S3_TEST_NODES_DISCOVERY_URL" ]; then
- terminate "Tests S3 discovery URL doesn't specified"
- fi
-
- if [[ "$S3_TEST_NODES_DISCOVERY_URL" != */ ]]; then
- S3_TEST_NODES_DISCOVERY_URL=${S3_TEST_NODES_DISCOVERY_URL}/
- fi
-
- if [ -z "$S3_CASSANDRA_NODES_DISCOVERY_URL" ]; then
- terminate "Cassandra S3 discovery URL doesn't specified"
- fi
-
- if [[ "$S3_CASSANDRA_NODES_DISCOVERY_URL" != */ ]]; then
- S3_CASSANDRA_NODES_DISCOVERY_URL=${S3_CASSANDRA_NODES_DISCOVERY_URL}/
- fi
-
- if [ -z "$S3_IGNITE_NODES_DISCOVERY_URL" ]; then
- terminate "Ignite S3 discovery URL doesn't specified"
- fi
-
- if [[ "$S3_CASSANDRA_NODES_DISCOVERY_URL" != */ ]]; then
- S3_CASSANDRA_NODES_DISCOVERY_URL=${S3_CASSANDRA_NODES_DISCOVERY_URL}/
- fi
-
- if [ -z "$S3_IGNITE_NODES_DISCOVERY_URL" ]; then
- terminate "Ignite S3 discovery URL doesn't specified"
- fi
-
- if [[ "$S3_IGNITE_NODES_DISCOVERY_URL" != */ ]]; then
- S3_IGNITE_NODES_DISCOVERY_URL=${S3_IGNITE_NODES_DISCOVERY_URL}/
- fi
-}
-
-setupCassandraSeeds()
-{
- if [ $CASSANDRA_NODES_COUNT -eq 0 ]; then
- return 0
- fi
-
- CASSANDRA_SEEDS1=
- CASSANDRA_SEEDS2=
-
- echo "[INFO] Setting up Cassandra seeds"
-
- echo "[INFO] Looking for Cassandra seeds in: $S3_CASSANDRA_NODES_DISCOVERY_URL"
-
- startTime=$(date +%s)
-
- while true; do
- seeds=$(aws s3 ls $S3_CASSANDRA_NODES_DISCOVERY_URL | grep -v PRE | sed -r "s/^.* //g")
- if [ -n "$seeds" ]; then
- seeds=($seeds)
- length=${#seeds[@]}
-
- if [ $length -lt 4 ]; then
- seed1=${seeds[0]}
- seed2=${seeds[1]}
- seed3=${seeds[2]}
- else
- pos1=$(($RANDOM%$length))
- pos2=$(($RANDOM%$length))
- pos3=$(($RANDOM%$length))
- seed1=${seeds[${pos1}]}
- seed2=${seeds[${pos2}]}
- seed3=${seeds[${pos3}]}
- fi
-
- CASSANDRA_SEEDS1="<value>$seed1<\/value>"
- CASSANDRA_SEEDS2="$seed1"
-
- if [ "$seed2" != "$seed1" ] && [ -n "$seed2" ]; then
- CASSANDRA_SEEDS1="$CASSANDRA_SEEDS1<value>$seed2<\/value>"
- CASSANDRA_SEEDS2="${CASSANDRA_SEEDS2},$seed2"
- fi
-
- if [ "$seed3" != "$seed2" ] && [ "$seed3" != "$seed1" ] && [ -n "$seed3" ]; then
- CASSANDRA_SEEDS1="$CASSANDRA_SEEDS1<value>$seed3<\/value>"
- CASSANDRA_SEEDS2="${CASSANDRA_SEEDS2},$seed3"
- fi
-
- echo "[INFO] Using Cassandra seeds: $CASSANDRA_SEEDS2"
-
- echo "contact.points=$CASSANDRA_SEEDS2" > /opt/ignite-cassandra-tests/settings/org/apache/ignite/tests/cassandra/connection.properties
-
- cat /opt/ignite-cassandra-tests/bootstrap/aws/tests/ignite-cassandra-client-template.xml | sed -r "s/\\\$\{CASSANDRA_SEEDS\}/$CASSANDRA_SEEDS1/g" > /opt/ignite-cassandra-tests/bootstrap/aws/tests/ignite-cassandra-client-template1.xml
-
- return 0
- fi
-
- currentTime=$(date +%s)
- duration=$(( $currentTime-$startTime ))
- duration=$(( $duration/60 ))
-
- if [ $duration -gt $NODE_STARTUP_TIME ]; then
- terminate "${NODE_STARTUP_TIME}min timeout expired, but no Cassandra nodes is up and running"
- fi
-
- echo "[INFO] Waiting for the first Cassandra node to start and publish its seed, time passed ${duration}min"
-
- sleep 1m
- done
-}
-
-setupIgniteSeeds()
-{
- if [ $IGNITE_NODES_COUNT -eq 0 ]; then
- return 0
- fi
-
- echo "[INFO] Setting up Ignite seeds"
-
- echo "[INFO] Looking for Ignite seeds in: $S3_IGNITE_NODES_DISCOVERY_URL"
-
- startTime=$(date +%s)
-
- while true; do
- seeds=$(aws s3 ls $S3_IGNITE_NODES_DISCOVERY_URL | grep -v PRE | sed -r "s/^.* //g")
- if [ -n "$seeds" ]; then
- seeds=($seeds)
- length=${#seeds[@]}
-
- if [ $length -lt 4 ]; then
- seed1=${seeds[0]}
- seed2=${seeds[1]}
- seed3=${seeds[2]}
- else
- pos1=$(($RANDOM%$length))
- pos2=$(($RANDOM%$length))
- pos3=$(($RANDOM%$length))
- seed1=${seeds[${pos1}]}
- seed2=${seeds[${pos2}]}
- seed3=${seeds[${pos3}]}
- fi
-
- IGNITE_SEEDS="<value>$seed1<\/value>"
-
- if [ "$seed2" != "$seed1" ] && [ -n "$seed2" ]; then
- IGNITE_SEEDS="$IGNITE_SEEDS<value>$seed2<\/value>"
- fi
-
- if [ "$seed3" != "$seed2" ] && [ "$seed3" != "$seed1" ] && [ -n "$seed3" ]; then
- IGNITE_SEEDS="$IGNITE_SEEDS<value>$seed3<\/value>"
- fi
-
- echo "[INFO] Using Ignite seeds: $IGNITE_SEEDS"
-
- cat /opt/ignite-cassandra-tests/bootstrap/aws/tests/ignite-cassandra-client-template1.xml | sed -r "s/\\\$\{IGNITE_SEEDS\}/$IGNITE_SEEDS/g" > /opt/ignite-cassandra-tests/settings/org/apache/ignite/tests/persistence/primitive/ignite-remote-client-config.xml
- rm -f /opt/ignite-cassandra-tests/bootstrap/aws/tests/ignite-cassandra-client-template1.xml
-
- return 0
- fi
-
- currentTime=$(date +%s)
- duration=$(( $currentTime-$startTime ))
- duration=$(( $duration/60 ))
-
- if [ $duration -gt $NODE_STARTUP_TIME ]; then
- terminate "${NODE_STARTUP_TIME}min timeout expired, but no Ignite nodes is up and running"
- fi
-
- echo "[INFO] Waiting for the first Ignite node to start and publish its seed, time passed ${duration}min"
-
- sleep 1m
- done
-}
-
-tryToGetFirstNodeLock()
-{
- echo "[INFO] Trying to get first node lock"
-
- checkFirstNodeLockExist
- if [ $? -ne 0 ]; then
- return 1
- fi
-
- createFirstNodeLock
-
- sleep 5s
-
- rm -Rf /opt/ignite-cassandra-tests/first-node-lock
-
- aws s3 cp $S3_TESTS_FIRST_NODE_LOCK_URL /opt/ignite-cassandra-tests/first-node-lock
- if [ $? -ne 0 ]; then
- echo "[WARN] Failed to check just created first node lock"
- return 1
- fi
-
- first_host=$(cat /opt/ignite-cassandra-tests/first-node-lock)
-
- rm -f /opt/ignite-cassandra-tests/first-node-lock
-
- if [ "$first_host" != "$HOST_NAME" ]; then
- echo "[INFO] Node $first_host has discarded previously created first node lock"
- return 1
- fi
-
- echo "[INFO] Congratulations, got first node lock"
-
- return 0
-}
-
-checkFirstNodeLockExist()
-{
- echo "[INFO] Checking for the first node lock"
-
- lockExists=$(aws s3 ls $S3_TESTS_FIRST_NODE_LOCK_URL)
- if [ -n "$lockExists" ]; then
- echo "[INFO] First node lock already exists"
- return 1
- fi
-
- echo "[INFO] First node lock doesn't exist yet"
-
- return 0
-}
-
-createFirstNodeLock()
-{
- aws s3 cp --sse AES256 /opt/ignite-cassandra-tests/hostname $S3_TESTS_FIRST_NODE_LOCK_URL
- if [ $? -ne 0 ]; then
- terminate "Failed to create first node lock"
- fi
- echo "[INFO] Created first node lock"
-}
-
-removeFirstNodeLock()
-{
- exists=$(aws s3 ls $S3_TESTS_FIRST_NODE_LOCK_URL)
- if [ -z "$exists" ]; then
- return 0
- fi
-
- aws s3 rm $S3_TESTS_FIRST_NODE_LOCK_URL
- if [ $? -ne 0 ]; then
- echo "[ERROR] Failed to remove first node lock"
- return 1
- fi
-
- echo "[INFO] Removed first node lock"
-}
-
-waitAllIgniteNodesReady()
-{
- if [ $IGNITE_NODES_COUNT -eq 0 ]; then
- return 0
- fi
-
- echo "[INFO] Waiting for all $IGNITE_NODES_COUNT Ignite nodes up and running"
-
- while true; do
- successCount=$(aws s3 ls $S3_IGNITE_SUCCESS_URL | wc -l)
- failureCount=$(aws s3 ls $S3_IGNITE_FAILURE_URL | wc -l)
-
- if [ $successCount -ge $IGNITE_NODES_COUNT ]; then
- break
- fi
-
- if [ "$failureCount" != "0" ]; then
- terminate "$failureCount Ignite nodes are failed to start. Thus it doesn't make sense to run tests."
- fi
-
- echo "[INFO] Waiting extra 1min"
-
- sleep 1m
- done
-
- echo "[INFO] Congratulation, all $IGNITE_NODES_COUNT Ignite nodes are up and running"
-}
-
-waitAllCassandraNodesReady()
-{
- if [ $CASSANDRA_NODES_COUNT -eq 0 ]; then
- return 0
- fi
-
- echo "[INFO] Waiting for all $CASSANDRA_NODES_COUNT Cassandra nodes up and running"
-
- while true; do
- successCount=$(aws s3 ls $S3_CASSANDRA_SUCCESS_URL | wc -l)
- failureCount=$(aws s3 ls $S3_CASSANDRA_FAILURE_URL | wc -l)
-
- if [ $successCount -ge $CASSANDRA_NODES_COUNT ]; then
- break
- fi
-
- if [ "$failureCount" != "0" ]; then
- terminate "$failureCount Cassandra nodes are failed to start. Thus it doesn't make sense to run tests."
- fi
-
- echo "[INFO] Waiting extra 1min"
-
- sleep 1m
- done
-
- echo "[INFO] Congratulation, all $CASSANDRA_NODES_COUNT Cassandra nodes are up and running"
-}
-
-waitFirstTestNodeRegistered()
-{
- echo "[INFO] Waiting for the first test node to register"
-
- while true; do
- first_host=
-
- exists=$(aws s3 ls $S3_TESTS_FIRST_NODE_LOCK_URL)
- if [ -n "$exists" ]; then
- rm -Rf /opt/ignite-cassandra-tests/first-node-lock
-
- aws s3 cp $S3_TESTS_FIRST_NODE_LOCK_URL /opt/ignite-cassandra-tests/first-node-lock
- if [ $? -ne 0 ]; then
- terminate "Failed to check existing first node lock"
- fi
-
- first_host=$(cat /opt/ignite-cassandra-tests/first-node-lock)
-
- rm -Rf /opt/ignite-cassandra-tests/first-node-lock
- fi
-
- if [ -n "$first_host" ]; then
- exists=$(aws s3 ls ${S3_TEST_NODES_DISCOVERY_URL}${first_host})
- if [ -n "$exists" ]; then
- break
- fi
- fi
-
- echo "[INFO] Waiting extra 1min"
-
- sleep 1m
- done
-
- echo "[INFO] First test node registered"
-}
-
-waitAllTestNodesReady()
-{
- createWaitingFlag
-
- echo "[INFO] Waiting for all $TEST_NODES_COUNT test nodes up and running"
-
- while true; do
-
- nodesCount=$(aws s3 ls $S3_TEST_NODES_DISCOVERY_URL | wc -l)
-
- if [ $nodesCount -ge $TEST_NODES_COUNT ]; then
- break
- fi
-
- echo "[INFO] Waiting extra 1min"
-
- sleep 1m
- done
-
- echo "[INFO] Congratulation, all $TEST_NODES_COUNT test nodes are up and running"
-
- dropWaitingFlag
- createRunningFlag
-}
-
-waitAllTestNodesCompleted()
-{
- echo "[INFO] Waiting for all $TEST_NODES_COUNT test nodes to complete their tests"
-
- while true; do
- successCount=$(aws s3 ls $S3_TESTS_SUCCESS_URL | wc -l)
- failureCount=$(aws s3 ls $S3_TESTS_FAILURE_URL | wc -l)
- count=$(( $successCount+$failureCount ))
-
- if [ $count -ge $TEST_NODES_COUNT ]; then
- break
- fi
-
- echo "[INFO] Waiting extra 1min"
-
- sleep 1m
- done
-
- echo "[INFO] Congratulation, all $TEST_NODES_COUNT test nodes have completed their tests"
-}
-
-# Time (in minutes) to wait for Ignite/Cassandra node up and running and register it in S3
-NODE_STARTUP_TIME=10
-
-HOST_NAME=$(hostname -f | tr '[:upper:]' '[:lower:]')
-echo $HOST_NAME > /opt/ignite-cassandra-tests/hostname
-
-validate
-
-FIRST_NODE="false"
-
-tryToGetFirstNodeLock
-
-if [ $? -eq 0 ]; then
- FIRST_NODE="true"
-fi
-
-dropRunningFlag
-dropWaitingFlag
-
-echo "[INFO]-----------------------------------------------------------------"
-
-if [ "$FIRST_NODE" == "true" ]; then
- echo "[INFO] Running tests from first node"
- dropTestsSummary
-else
- echo "[INFO] Running tests"
-fi
-
-echo "[INFO]-----------------------------------------------------------------"
-echo "[INFO] Tests type: $TESTS_TYPE"
-echo "[INFO] Test nodes count: $TEST_NODES_COUNT"
-echo "[INFO] Ignite nodes count: $IGNITE_NODES_COUNT"
-echo "[INFO] Cassandra nodes count: $CASSANDRA_NODES_COUNT"
-echo "[INFO] Tests summary URL: $S3_TESTS_SUMMARY_URL"
-echo "[INFO] Tests first node lock URL: $S3_TESTS_FIRST_NODE_LOCK_URL"
-echo "[INFO] Tests package download URL: $TESTS_PACKAGE_DONLOAD_URL"
-echo "[INFO] Test node discovery URL: $S3_TEST_NODES_DISCOVERY_URL"
-echo "[INFO] Ignite node discovery URL: $S3_IGNITE_NODES_DISCOVERY_URL"
-echo "[INFO] Cassandra node discovery URL: $S3_CASSANDRA_NODES_DISCOVERY_URL"
-echo "[INFO] Tests running URL: $S3_TESTS_RUNNING_URL"
-echo "[INFO] Tests waiting URL: $S3_TESTS_WAITING_URL"
-echo "[INFO] Tests success URL: $S3_TESTS_SUCCESS_URL"
-echo "[INFO] Tests failure URL: $S3_TESTS_FAILURE_URL"
-echo "[INFO] Ignite success URL: $S3_IGNITE_SUCCESS_URL"
-echo "[INFO] Ignite failure URL: $S3_IGNITE_FAILURE_URL"
-echo "[INFO] Cassandra success URL: $S3_CASSANDRA_SUCCESS_URL"
-echo "[INFO] Cassandra failure URL: $S3_CASSANDRA_FAILURE_URL"
-echo "[INFO] Logs trigger URL: $S3_LOGS_TRIGGER_URL"
-echo "[INFO] JAVA_HOME: $JAVA_HOME"
-echo "[INFO] PATH: $PATH"
-echo "[INFO]-----------------------------------------------------------------"
-
-echo "admin.user=cassandra" > /opt/ignite-cassandra-tests/settings/org/apache/ignite/tests/cassandra/credentials.properties
-echo "admin.password=cassandra" >> /opt/ignite-cassandra-tests/settings/org/apache/ignite/tests/cassandra/credentials.properties
-echo "regular.user=cassandra" >> /opt/ignite-cassandra-tests/settings/org/apache/ignite/tests/cassandra/credentials.properties
-echo "regular.password=cassandra" >> /opt/ignite-cassandra-tests/settings/org/apache/ignite/tests/cassandra/credentials.properties
-
-waitAllCassandraNodesReady
-waitAllIgniteNodesReady
-
-setupCassandraSeeds
-setupIgniteSeeds
-
-if [ "$FIRST_NODE" != "true" ]; then
- waitFirstTestNodeRegistered
-else
- cleanupMetadata
-fi
-
-registerTestNode
-
-waitAllTestNodesReady
-
-cd /opt/ignite-cassandra-tests
-
-if [ "$TESTS_TYPE" == "ignite" ]; then
- echo "[INFO] Running Ignite load tests"
- ./ignite-load-tests.sh
- result=$?
-else
- echo "[INFO] Running Cassandra load tests"
- ./cassandra-load-tests.sh
- result=$?
-fi
-
-if [ $result -ne 0 ]; then
- terminate ""
-fi
-
-terminate
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee8ac73f/modules/cassandra/src/test/java/org/apache/ignite/tests/LoadTestsCassandraArtifactsCreator.java
----------------------------------------------------------------------
diff --git a/modules/cassandra/src/test/java/org/apache/ignite/tests/LoadTestsCassandraArtifactsCreator.java b/modules/cassandra/src/test/java/org/apache/ignite/tests/LoadTestsCassandraArtifactsCreator.java
new file mode 100644
index 0000000..4fdb96f
--- /dev/null
+++ b/modules/cassandra/src/test/java/org/apache/ignite/tests/LoadTestsCassandraArtifactsCreator.java
@@ -0,0 +1,104 @@
+/*
+ * 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.ignite.tests;
+
+import org.apache.ignite.cache.store.cassandra.persistence.KeyValuePersistenceSettings;
+import org.apache.ignite.tests.utils.CassandraHelper;
+import org.apache.ignite.tests.utils.TestsHelper;
+
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Recreates all required Cassandra database objects (keyspace, table, indexes) for load tests
+ */
+public class LoadTestsCassandraArtifactsCreator {
+ /**
+ * Recreates Cassandra artifacts required for load tests
+ * @param args not used
+ */
+ public static void main(String[] args) {
+ try {
+ System.out.println("[INFO] Recreating Cassandra artifacts (keyspace, table, indexes) for load tests");
+
+ KeyValuePersistenceSettings perSettings =
+ new KeyValuePersistenceSettings(TestsHelper.getLoadTestsPersistenceSettings());
+
+ System.out.println("[INFO] Dropping test keyspace: " + perSettings.getKeyspace());
+
+ try {
+ CassandraHelper.dropTestKeyspaces();
+ } catch (Throwable e) {
+ throw new RuntimeException("Failed to drop test keyspace: " + perSettings.getKeyspace(), e);
+ }
+
+ System.out.println("[INFO] Test keyspace '" + perSettings.getKeyspace() + "' was successfully dropped");
+
+ System.out.println("[INFO] Creating test keyspace: " + perSettings.getKeyspace());
+
+ try {
+ CassandraHelper.executeWithAdminCredentials(perSettings.getKeyspaceDDLStatement());
+ } catch (Throwable e) {
+ throw new RuntimeException("Failed to create test keyspace: " + perSettings.getKeyspace(), e);
+ }
+
+ System.out.println("[INFO] Test keyspace '" + perSettings.getKeyspace() + "' was successfully created");
+
+ System.out.println("[INFO] Creating test table: " + perSettings.getTable());
+
+ try {
+ CassandraHelper.executeWithAdminCredentials(perSettings.getTableDDLStatement());
+ } catch (Throwable e) {
+ throw new RuntimeException("Failed to create test table: " + perSettings.getTable(), e);
+ }
+
+ System.out.println("[INFO] Test table '" + perSettings.getTable() + "' was successfully created");
+
+ List<String> statements = perSettings.getIndexDDLStatements();
+ if (statements == null)
+ statements = new LinkedList<>();
+
+ for (String statement : statements) {
+ System.out.println("[INFO] Creating test table index:");
+ System.out.println(statement);
+
+ try {
+ CassandraHelper.executeWithAdminCredentials(statement);
+ } catch (Throwable e) {
+ throw new RuntimeException("Failed to create test table index", e);
+ }
+
+ System.out.println("[INFO] Test table index was successfully created");
+ }
+
+ System.out.println("[INFO] All required Cassandra artifacts were successfully recreated");
+ }
+ catch (Throwable e) {
+ System.out.println("[ERROR] Failed to recreate Cassandra artifacts");
+ e.printStackTrace(System.out);
+
+ if (e instanceof RuntimeException)
+ throw (RuntimeException)e;
+ else
+ throw new RuntimeException(e);
+ }
+ finally {
+ CassandraHelper.releaseCassandraResources();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee8ac73f/modules/cassandra/src/test/resources/org/apache/ignite/tests/cassandra/connection-settings.xml
----------------------------------------------------------------------
diff --git a/modules/cassandra/src/test/resources/org/apache/ignite/tests/cassandra/connection-settings.xml b/modules/cassandra/src/test/resources/org/apache/ignite/tests/cassandra/connection-settings.xml
index f7eb372..aec602e 100644
--- a/modules/cassandra/src/test/resources/org/apache/ignite/tests/cassandra/connection-settings.xml
+++ b/modules/cassandra/src/test/resources/org/apache/ignite/tests/cassandra/connection-settings.xml
@@ -26,7 +26,11 @@
<bean id="cassandraAdminCredentials" class="org.apache.ignite.tests.utils.CassandraAdminCredentials"/>
<bean id="cassandraRegularCredentials" class="org.apache.ignite.tests.utils.CassandraRegularCredentials"/>
- <bean id="loadBalancingPolicy" class="com.datastax.driver.core.policies.RoundRobinPolicy"/>
+ <bean id="loadBalancingPolicy" class="com.datastax.driver.core.policies.TokenAwarePolicy">
+ <constructor-arg type="com.datastax.driver.core.policies.LoadBalancingPolicy">
+ <bean class="com.datastax.driver.core.policies.RoundRobinPolicy"/>
+ </constructor-arg>
+ </bean>
<bean id="contactPoints" class="org.apache.ignite.tests.utils.CassandraHelper" factory-method="getContactPointsArray"/>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee8ac73f/modules/cassandra/src/test/resources/org/apache/ignite/tests/persistence/blob/ignite-config.xml
----------------------------------------------------------------------
diff --git a/modules/cassandra/src/test/resources/org/apache/ignite/tests/persistence/blob/ignite-config.xml b/modules/cassandra/src/test/resources/org/apache/ignite/tests/persistence/blob/ignite-config.xml
index 9aa5c84..fbf38e9 100644
--- a/modules/cassandra/src/test/resources/org/apache/ignite/tests/persistence/blob/ignite-config.xml
+++ b/modules/cassandra/src/test/resources/org/apache/ignite/tests/persistence/blob/ignite-config.xml
@@ -40,12 +40,6 @@
<bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="cacheConfiguration">
<list>
- <!-- Partitioned cache example configuration (Atomic mode). -->
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="atomicityMode" value="ATOMIC"/>
- <property name="backups" value="1"/>
- </bean>
-
<!-- Configuring persistence for "cache1" cache -->
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="cache1"/>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee8ac73f/modules/cassandra/src/test/resources/org/apache/ignite/tests/persistence/pojo/ignite-config.xml
----------------------------------------------------------------------
diff --git a/modules/cassandra/src/test/resources/org/apache/ignite/tests/persistence/pojo/ignite-config.xml b/modules/cassandra/src/test/resources/org/apache/ignite/tests/persistence/pojo/ignite-config.xml
index 8dcfffd..cc1e8a6 100644
--- a/modules/cassandra/src/test/resources/org/apache/ignite/tests/persistence/pojo/ignite-config.xml
+++ b/modules/cassandra/src/test/resources/org/apache/ignite/tests/persistence/pojo/ignite-config.xml
@@ -45,12 +45,6 @@
<bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="cacheConfiguration">
<list>
- <!-- Partitioned cache example configuration (Atomic mode). -->
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="atomicityMode" value="ATOMIC"/>
- <property name="backups" value="1"/>
- </bean>
-
<!-- Configuring persistence for "cache1" cache -->
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="cache1"/>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee8ac73f/modules/cassandra/src/test/resources/org/apache/ignite/tests/persistence/primitive/ignite-config.xml
----------------------------------------------------------------------
diff --git a/modules/cassandra/src/test/resources/org/apache/ignite/tests/persistence/primitive/ignite-config.xml b/modules/cassandra/src/test/resources/org/apache/ignite/tests/persistence/primitive/ignite-config.xml
index fb6b055..13e0922 100644
--- a/modules/cassandra/src/test/resources/org/apache/ignite/tests/persistence/primitive/ignite-config.xml
+++ b/modules/cassandra/src/test/resources/org/apache/ignite/tests/persistence/primitive/ignite-config.xml
@@ -40,12 +40,6 @@
<bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration">
<property name="cacheConfiguration">
<list>
- <!-- Partitioned cache example configuration (Atomic mode). -->
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="atomicityMode" value="ATOMIC"/>
- <property name="backups" value="1"/>
- </bean>
-
<!-- Configuring persistence for "cache1" cache -->
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="cache1"/>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee8ac73f/modules/cassandra/src/test/resources/org/apache/ignite/tests/persistence/primitive/ignite-remote-client-config.xml
----------------------------------------------------------------------
diff --git a/modules/cassandra/src/test/resources/org/apache/ignite/tests/persistence/primitive/ignite-remote-client-config.xml b/modules/cassandra/src/test/resources/org/apache/ignite/tests/persistence/primitive/ignite-remote-client-config.xml
index 50b2164..5b5bb59 100644
--- a/modules/cassandra/src/test/resources/org/apache/ignite/tests/persistence/primitive/ignite-remote-client-config.xml
+++ b/modules/cassandra/src/test/resources/org/apache/ignite/tests/persistence/primitive/ignite-remote-client-config.xml
@@ -24,7 +24,11 @@
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd">
- <bean id="loadBalancingPolicy" class="com.datastax.driver.core.policies.RoundRobinPolicy"/>
+ <bean id="loadBalancingPolicy" class="com.datastax.driver.core.policies.TokenAwarePolicy">
+ <constructor-arg type="com.datastax.driver.core.policies.LoadBalancingPolicy">
+ <bean class="com.datastax.driver.core.policies.RoundRobinPolicy"/>
+ </constructor-arg>
+ </bean>
<util:list id="contactPoints" value-type="java.lang.String">
<value>cassandra-node-1.abc.com</value>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee8ac73f/modules/cassandra/src/test/resources/org/apache/ignite/tests/persistence/primitive/ignite-remote-server-config.xml
----------------------------------------------------------------------
diff --git a/modules/cassandra/src/test/resources/org/apache/ignite/tests/persistence/primitive/ignite-remote-server-config.xml b/modules/cassandra/src/test/resources/org/apache/ignite/tests/persistence/primitive/ignite-remote-server-config.xml
index 1dc6f8a..8d71aec 100644
--- a/modules/cassandra/src/test/resources/org/apache/ignite/tests/persistence/primitive/ignite-remote-server-config.xml
+++ b/modules/cassandra/src/test/resources/org/apache/ignite/tests/persistence/primitive/ignite-remote-server-config.xml
@@ -25,7 +25,11 @@
http://www.springframework.org/schema/util/spring-util.xsd">
<!-- Cassandra connection settings -->
- <bean id="loadBalancingPolicy" class="com.datastax.driver.core.policies.RoundRobinPolicy"/>
+ <bean id="loadBalancingPolicy" class="com.datastax.driver.core.policies.TokenAwarePolicy">
+ <constructor-arg type="com.datastax.driver.core.policies.LoadBalancingPolicy">
+ <bean class="com.datastax.driver.core.policies.RoundRobinPolicy"/>
+ </constructor-arg>
+ </bean>
<util:list id="contactPoints" value-type="java.lang.String">
<value>cassandra-node-1.abc.com</value>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee8ac73f/modules/cassandra/src/test/scripts/recreate-cassandra-artifacts.bat
----------------------------------------------------------------------
diff --git a/modules/cassandra/src/test/scripts/recreate-cassandra-artifacts.bat b/modules/cassandra/src/test/scripts/recreate-cassandra-artifacts.bat
new file mode 100644
index 0000000..47b0a22
--- /dev/null
+++ b/modules/cassandra/src/test/scripts/recreate-cassandra-artifacts.bat
@@ -0,0 +1,39 @@
+echo off
+
+rem Licensed to the Apache Software Foundation (ASF) under one or more
+rem contributor license agreements. See the NOTICE file distributed with
+rem this work for additional information regarding copyright ownership.
+rem The ASF licenses this file to You under the Apache License, Version 2.0
+rem (the "License"); you may not use this file except in compliance with
+rem the License. You may obtain a copy of the License at
+rem
+rem http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem Unless required by applicable law or agreed to in writing, software
+rem distributed under the License is distributed on an "AS IS" BASIS,
+rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+rem See the License for the specific language governing permissions and
+rem limitations under the License.
+
+echo.
+
+set TESTS_CLASSPATH="%~dp0\lib*;%~dp0settings"
+
+call %~dp0jvm-opts.bat %*
+
+call java %JVM_OPTS% -cp "%TESTS_CLASSPATH%" "org.apache.ignite.tests.LoadTestsCassandraArtifactsCreator"
+
+if %errorLevel% NEQ 0 (
+ echo.
+ echo --------------------------------------------------------------------------------
+ echo [ERROR] Failed to recreate Cassandra artifacts
+ echo --------------------------------------------------------------------------------
+ echo.
+ exit /b %errorLevel%
+)
+
+echo.
+echo --------------------------------------------------------------------------------
+echo [INFO] Cassandra artifacts were successfully recreated
+echo --------------------------------------------------------------------------------
+echo.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee8ac73f/modules/cassandra/src/test/scripts/recreate-cassandra-artifacts.sh
----------------------------------------------------------------------
diff --git a/modules/cassandra/src/test/scripts/recreate-cassandra-artifacts.sh b/modules/cassandra/src/test/scripts/recreate-cassandra-artifacts.sh
new file mode 100644
index 0000000..b0f99be
--- /dev/null
+++ b/modules/cassandra/src/test/scripts/recreate-cassandra-artifacts.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+#
+# 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.
+#
+
+TESTS_ROOT=$(readlink -m $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ))
+TESTS_CLASSPATH="$TESTS_ROOT/lib/*:$TESTS_ROOT/settings"
+
+. $TESTS_ROOT/jvm-opt.sh $@
+
+java $JVM_OPTS -cp "$TESTS_CLASSPATH" "org.apache.ignite.tests.LoadTestsCassandraArtifactsCreator"
+
+if [ $? -ne 0 ]; then
+ echo
+ echo "--------------------------------------------------------------------------------"
+ echo "[ERROR] Failed to recreate Cassandra artifacts"
+ echo "--------------------------------------------------------------------------------"
+ echo
+ exit 1
+fi
+
+echo
+echo "--------------------------------------------------------------------------------"
+echo "[INFO] Cassandra artifacts were successfully recreated"
+echo "--------------------------------------------------------------------------------"
+echo
[2/4] ignite git commit: IGNITE-3293 AWS bootstrap scripts patch for
Ignite-Cassandra - Fixes #794.
Posted by ak...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee8ac73f/modules/cassandra/src/test/bootstrap/aws/ignite/ignite-cassandra-server-template.xml
----------------------------------------------------------------------
diff --git a/modules/cassandra/src/test/bootstrap/aws/ignite/ignite-cassandra-server-template.xml b/modules/cassandra/src/test/bootstrap/aws/ignite/ignite-cassandra-server-template.xml
index f85dcd9..03b3346 100644
--- a/modules/cassandra/src/test/bootstrap/aws/ignite/ignite-cassandra-server-template.xml
+++ b/modules/cassandra/src/test/bootstrap/aws/ignite/ignite-cassandra-server-template.xml
@@ -25,7 +25,11 @@
http://www.springframework.org/schema/util/spring-util.xsd">
<!-- Cassandra connection settings -->
- <bean id="loadBalancingPolicy" class="com.datastax.driver.core.policies.RoundRobinPolicy"/>
+ <bean id="loadBalancingPolicy" class="com.datastax.driver.core.policies.TokenAwarePolicy">
+ <constructor-arg type="com.datastax.driver.core.policies.LoadBalancingPolicy">
+ <bean class="com.datastax.driver.core.policies.RoundRobinPolicy"/>
+ </constructor-arg>
+ </bean>
<util:list id="contactPoints" value-type="java.lang.String">
${CASSANDRA_SEEDS}
@@ -108,15 +112,14 @@
<property name="cacheConfiguration">
<list>
- <!-- Partitioned cache example configuration (Atomic mode). -->
- <bean class="org.apache.ignite.configuration.CacheConfiguration">
- <property name="atomicityMode" value="ATOMIC"/>
- <property name="backups" value="1"/>
- </bean>
-
<!-- Configuring persistence for "cache1" cache -->
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="cache1"/>
+ <property name="startSize" value="1000000"/>
+ <property name="cacheMode" value="PARTITIONED"/>
+ <property name="backups" value="0"/>
+ <property name="offHeapMaxMemory" value="0"/>
+ <property name="swapEnabled" value="false"/>
<property name="readThrough" value="true"/>
<property name="writeThrough" value="true"/>
<property name="writeBehindEnabled" value="true"/>
@@ -131,6 +134,11 @@
<!-- Configuring persistence for "cache2" cache -->
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="cache2"/>
+ <property name="startSize" value="1000000"/>
+ <property name="cacheMode" value="PARTITIONED"/>
+ <property name="backups" value="0"/>
+ <property name="offHeapMaxMemory" value="0"/>
+ <property name="swapEnabled" value="false"/>
<property name="readThrough" value="true"/>
<property name="writeThrough" value="true"/>
<property name="writeBehindEnabled" value="true"/>
@@ -145,6 +153,11 @@
<!-- Configuring persistence for "cache3" cache -->
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="cache3"/>
+ <property name="startSize" value="1000000"/>
+ <property name="cacheMode" value="PARTITIONED"/>
+ <property name="backups" value="0"/>
+ <property name="offHeapMaxMemory" value="0"/>
+ <property name="swapEnabled" value="false"/>
<property name="readThrough" value="true"/>
<property name="writeThrough" value="true"/>
<property name="writeBehindEnabled" value="true"/>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee8ac73f/modules/cassandra/src/test/bootstrap/aws/ignite/ignite-env.sh
----------------------------------------------------------------------
diff --git a/modules/cassandra/src/test/bootstrap/aws/ignite/ignite-env.sh b/modules/cassandra/src/test/bootstrap/aws/ignite/ignite-env.sh
index e0643b7..bfe3371 100644
--- a/modules/cassandra/src/test/bootstrap/aws/ignite/ignite-env.sh
+++ b/modules/cassandra/src/test/bootstrap/aws/ignite/ignite-env.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
#
# Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,6 +17,10 @@
# limitations under the License.
#
+# -----------------------------------------------------------------------------------------------
+# Environment setup script from Ignite
+# -----------------------------------------------------------------------------------------------
+
JVM_OPTS="-Xms10g -Xmx10g -server -XX:+AggressiveOpts -XX:MaxMetaspaceSize=256m"
JVM_OPTS="$JVM_OPTS -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+UseTLAB -XX:NewSize=128m -XX:MaxNewSize=768m"
#JVM_OPTS="$JVM_OPTS -XX:MaxTenuringThreshold=0 -XX:SurvivorRatio=1024 -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=60"
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee8ac73f/modules/cassandra/src/test/bootstrap/aws/ignite/ignite-start.sh
----------------------------------------------------------------------
diff --git a/modules/cassandra/src/test/bootstrap/aws/ignite/ignite-start.sh b/modules/cassandra/src/test/bootstrap/aws/ignite/ignite-start.sh
index bb1ff0c..f2c1557 100644
--- a/modules/cassandra/src/test/bootstrap/aws/ignite/ignite-start.sh
+++ b/modules/cassandra/src/test/bootstrap/aws/ignite/ignite-start.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
#
# Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,380 +17,70 @@
# limitations under the License.
#
+# -----------------------------------------------------------------------------------------------
+# Script to start Ignite daemon (used by ignite-bootstrap.sh)
+# -----------------------------------------------------------------------------------------------
+
#profile=/home/ignite/.bash_profile
profile=/root/.bash_profile
. $profile
+. /opt/ignite-cassandra-tests/bootstrap/aws/common.sh "ignite"
-terminate()
-{
- if [[ "$S3_BOOTSTRAP_SUCCESS_URL" != */ ]]; then
- S3_BOOTSTRAP_SUCCESS_URL=${S3_BOOTSTRAP_SUCCESS_URL}/
- fi
-
- if [[ "$S3_BOOTSTRAP_FAILURE_URL" != */ ]]; then
- S3_BOOTSTRAP_FAILURE_URL=${S3_BOOTSTRAP_FAILURE_URL}/
- fi
-
- msg=$HOST_NAME
-
- if [ -n "$1" ]; then
- echo "[ERROR] $1"
- echo "[ERROR]-----------------------------------------------------"
- echo "[ERROR] Failed to start Ignite node"
- echo "[ERROR]-----------------------------------------------------"
- msg=$1
- reportFolder=${S3_BOOTSTRAP_FAILURE_URL}${HOST_NAME}
- reportFile=$reportFolder/__error__
- else
- echo "[INFO]-----------------------------------------------------"
- echo "[INFO] Ignite node successfully started"
- echo "[INFO]-----------------------------------------------------"
- reportFolder=${S3_BOOTSTRAP_SUCCESS_URL}${HOST_NAME}
- reportFile=$reportFolder/__success__
- fi
-
- echo $msg > /opt/ignite/start_result
-
- aws s3 rm --recursive $reportFolder
- if [ $? -ne 0 ]; then
- echo "[ERROR] Failed drop report folder: $reportFolder"
- fi
-
- if [ -d "/opt/ignite/work/log" ]; then
- aws s3 sync --sse AES256 /opt/ignite/work/log $reportFolder
- if [ $? -ne 0 ]; then
- echo "[ERROR] Failed to export Ignite logs to: $reportFolder"
- fi
- fi
-
- aws s3 cp --sse AES256 /opt/ignite/start_result $reportFile
- if [ $? -ne 0 ]; then
- echo "[ERROR] Failed to export node start result to: $reportFile"
- fi
-
- rm -f /opt/ignite/start_result /opt/ignite/join-lock /opt/ignite/remote-join-lock
-
- if [ -n "$1" ]; then
- exit 1
- fi
-
- exit 0
-}
-
-registerNode()
-{
- echo "[INFO] Registering Ignite node seed: ${S3_IGNITE_NODES_DISCOVERY_URL}$HOST_NAME"
-
- aws s3 cp --sse AES256 /opt/ignite/join-lock ${S3_IGNITE_NODES_DISCOVERY_URL}$HOST_NAME
- if [ $? -ne 0 ]; then
- terminate "Failed to register Ignite node seed: ${S3_IGNITE_NODES_DISCOVERY_URL}$HOST_NAME"
- fi
-
- echo "[INFO] Ignite node seed successfully registered"
-}
-
-unregisterNode()
-{
- echo "[INFO] Removing Ignite node registration from: ${S3_IGNITE_NODES_DISCOVERY_URL}$HOST_NAME"
- aws s3 rm ${S3_IGNITE_NODES_DISCOVERY_URL}$HOST_NAME
- echo "[INFO] Ignite node registration removed"
-}
-
-cleanupMetadata()
-{
- echo "[INFO] Running cleanup"
- aws s3 rm $S3_IGNITE_NODES_JOIN_LOCK_URL
- aws s3 rm --recursive $S3_IGNITE_NODES_DISCOVERY_URL
- aws s3 rm --recursive $S3_BOOTSTRAP_SUCCESS_URL
- aws s3 rm --recursive $S3_BOOTSTRAP_FAILURE_URL
- echo "[INFO] Cleanup completed"
-}
-
+# Setups Cassandra seeds for this Ignite node being able to connect to Cassandra.
+# Looks for the information in S3 about already up and running Cassandra cluster nodes.
setupCassandraSeeds()
{
- echo "[INFO] Setting up Cassandra seeds"
-
- echo "[INFO] Looking for Cassandra seeds in: $S3_CASSANDRA_NODES_DISCOVERY_URL"
-
- startTime=$(date +%s)
-
- while true; do
- seeds=$(aws s3 ls $S3_CASSANDRA_NODES_DISCOVERY_URL | grep -v PRE | sed -r "s/^.* //g")
- if [ -n "$seeds" ]; then
- seeds=($seeds)
- length=${#seeds[@]}
-
- if [ $length -lt 4 ]; then
- seed1=${seeds[0]}
- seed2=${seeds[1]}
- seed3=${seeds[2]}
- else
- pos1=$(($RANDOM%$length))
- pos2=$(($RANDOM%$length))
- pos3=$(($RANDOM%$length))
- seed1=${seeds[${pos1}]}
- seed2=${seeds[${pos2}]}
- seed3=${seeds[${pos3}]}
- fi
-
- CASSANDRA_SEEDS="<value>$seed1<\/value>"
-
- if [ "$seed2" != "$seed1" ] && [ -n "$seed2" ]; then
- CASSANDRA_SEEDS="$CASSANDRA_SEEDS<value>$seed2<\/value>"
- fi
-
- if [ "$seed3" != "$seed2" ] && [ "$seed3" != "$seed1" ] && [ -n "$seed3" ]; then
- CASSANDRA_SEEDS="$CASSANDRA_SEEDS<value>$seed3<\/value>"
- fi
-
- echo "[INFO] Using Cassandra seeds: $CASSANDRA_SEEDS"
+ setupClusterSeeds "cassandra" "true"
- cat /opt/ignite/config/ignite-cassandra-server-template.xml | sed -r "s/\\\$\{CASSANDRA_SEEDS\}/$CASSANDRA_SEEDS/g" > /opt/ignite/config/ignite-cassandra-server.xml
+ CLUSTER_SEEDS=($CLUSTER_SEEDS)
+ count=${#CLUSTER_SEEDS[@]}
- return 0
- fi
-
- currentTime=$(date +%s)
- duration=$(( $currentTime-$startTime ))
- duration=$(( $duration/60 ))
-
- if [ $duration -gt $NODE_STARTUP_TIME ]; then
- terminate "${NODE_STARTUP_TIME}min timeout expired, but no Cassandra nodes is up and running"
- fi
+ CASSANDRA_SEEDS=
- echo "[INFO] Waiting for the first Cassandra node to start and publish its seed, time passed ${duration}min"
+ for (( i=0; i<=$(( $count -1 )); i++ ))
+ do
+ seed=${CLUSTER_SEEDS[$i]}
+ CASSANDRA_SEEDS="${CASSANDRA_SEEDS}<value>$seed<\/value>"
+ done
- sleep 1m
- done
+ cat /opt/ignite/config/ignite-cassandra-server-template.xml | sed -r "s/\\\$\{CASSANDRA_SEEDS\}/$CASSANDRA_SEEDS/g" > /opt/ignite/config/ignite-cassandra-server.xml
}
+# Setups Ignite nodes which this EC2 Ignite node will use to send its metadata and join Ignite cluster
setupIgniteSeeds()
{
- echo "[INFO] Setting up Ignite seeds"
-
- if [ "$FIRST_NODE" == "true" ]; then
- IGNITE_SEEDS="<value>127.0.0.1:47500..47509<\/value>"
- echo "[INFO] Using localhost address as a seed for the first Ignite node: $IGNITE_SEEDS"
- aws s3 rm --recursive ${S3_IGNITE_NODES_DISCOVERY_URL::-1}
- if [ $? -ne 0 ]; then
- terminate "Failed to clean Ignite node discovery URL: $S3_IGNITE_NODES_DISCOVERY_URL"
- fi
-
- cat /opt/ignite/config/ignite-cassandra-server.xml | sed -r "s/\\\$\{IGNITE_SEEDS\}/$IGNITE_SEEDS/g" > /opt/ignite/config/ignite-cassandra-server1.xml
- mv -f /opt/ignite/config/ignite-cassandra-server1.xml /opt/ignite/config/ignite-cassandra-server.xml
+ if [ "$FIRST_NODE_LOCK" == "true" ]; then
+ echo "[INFO] Setting up Ignite seeds"
- return 0
- fi
+ CLUSTER_SEEDS="127.0.0.1:47500..47509"
- echo "[INFO] Looking for Ignite seeds in: $S3_IGNITE_NODES_DISCOVERY_URL"
-
- startTime=$(date +%s)
-
- while true; do
- seeds=$(aws s3 ls $S3_IGNITE_NODES_DISCOVERY_URL | grep -v PRE | sed -r "s/^.* //g")
- if [ -n "$seeds" ]; then
- seeds=($seeds)
- length=${#seeds[@]}
-
- if [ $length -lt 4 ]; then
- seed1=${seeds[0]}
- seed2=${seeds[1]}
- seed3=${seeds[2]}
- else
- pos1=$(($RANDOM%$length))
- pos2=$(($RANDOM%$length))
- pos3=$(($RANDOM%$length))
- seed1=${seeds[${pos1}]}
- seed2=${seeds[${pos2}]}
- seed3=${seeds[${pos3}]}
- fi
+ echo "[INFO] Using localhost address as a seed for the first Ignite node: $CLUSTER_SEEDS"
- IGNITE_SEEDS="<value>$seed1<\/value>"
-
- if [ "$seed2" != "$seed1" ] && [ -n "$seed2" ]; then
- IGNITE_SEEDS="$IGNITE_SEEDS<value>$seed2<\/value>"
- fi
-
- if [ "$seed3" != "$seed2" ] && [ "$seed3" != "$seed1" ] && [ -n "$seed3" ]; then
- IGNITE_SEEDS="$IGNITE_SEEDS<value>$seed3<\/value>"
- fi
-
- echo "[INFO] Using Ignite seeds: $IGNITE_SEEDS"
-
- cat /opt/ignite/config/ignite-cassandra-server.xml | sed -r "s/\\\$\{IGNITE_SEEDS\}/$IGNITE_SEEDS/g" > /opt/ignite/config/ignite-cassandra-server1.xml
- mv -f /opt/ignite/config/ignite-cassandra-server1.xml /opt/ignite/config/ignite-cassandra-server.xml
-
- return 0
- fi
-
- currentTime=$(date +%s)
- duration=$(( $currentTime-$startTime ))
- duration=$(( $duration/60 ))
-
- if [ $duration -gt $NODE_STARTUP_TIME ]; then
- terminate "${NODE_STARTUP_TIME}min timeout expired, but no Ignite nodes is up and running"
+ aws s3 rm --recursive ${S3_IGNITE_NODES_DISCOVERY::-1}
+ if [ $? -ne 0 ]; then
+ terminate "Failed to clean Ignite node discovery URL: $S3_IGNITE_NODES_DISCOVERY"
fi
-
- echo "[INFO] Waiting for the first Ignite node to start and publish its seed, time passed ${duration}min"
-
- sleep 1m
- done
-}
-
-tryToGetFirstNodeLock()
-{
- echo "[INFO] Trying to get first node lock"
-
- checkFirstNodeLockExist
- if [ $? -ne 0 ]; then
- return 1
- fi
-
- createFirstNodeLock
-
- sleep 5s
-
- rm -Rf /opt/ignite/first-node-lock
-
- aws s3 cp $S3_IGNITE_FIRST_NODE_LOCK_URL /opt/ignite/first-node-lock
- if [ $? -ne 0 ]; then
- echo "[WARN] Failed to check just created first node lock"
- return 1
- fi
-
- first_host=$(cat /opt/ignite/first-node-lock)
-
- rm -f /opt/ignite/first-node-lock
-
- if [ "$first_host" != "$HOST_NAME" ]; then
- echo "[INFO] Node $first_host has discarded previously created first node lock"
- return 1
- fi
-
- echo "[INFO] Congratulations, got first node lock"
-
- return 0
-}
-
-checkFirstNodeLockExist()
-{
- echo "[INFO] Checking for the first node lock"
-
- lockExists=$(aws s3 ls $S3_IGNITE_FIRST_NODE_LOCK_URL)
- if [ -n "$lockExists" ]; then
- echo "[INFO] First node lock already exists"
- return 1
- fi
-
- echo "[INFO] First node lock doesn't exist yet"
-
- return 0
-}
-
-createFirstNodeLock()
-{
- aws s3 cp --sse AES256 /opt/ignite/join-lock $S3_IGNITE_FIRST_NODE_LOCK_URL
- if [ $? -ne 0 ]; then
- terminate "Failed to create first node lock"
- fi
- echo "[INFO] Created first node lock"
-}
-
-removeFirstNodeLock()
-{
- aws s3 rm $S3_IGNITE_FIRST_NODE_LOCK_URL
- if [ $? -ne 0 ]; then
- terminate "Failed to remove first node lock"
- fi
- echo "[INFO] Removed first node lock"
-}
-
-tryToGetClusterJoinLock()
-{
- echo "[INFO] Trying to get cluster join lock"
-
- checkClusterJoinLockExist
- if [ $? -ne 0 ]; then
- return 1
- fi
-
- createClusterJoinLock
-
- sleep 5s
-
- rm -Rf /opt/ignite/remote-join-lock
-
- aws s3 cp $S3_IGNITE_NODES_JOIN_LOCK_URL /opt/ignite/remote-join-lock
- if [ $? -ne 0 ]; then
- echo "[WARN] Failed to check just created cluster join lock"
- return 1
- fi
-
- join_host=$(cat /opt/ignite/remote-join-lock)
-
- if [ "$join_host" != "$HOST_NAME" ]; then
- echo "[INFO] Node $first_host has discarded previously created cluster join lock"
- return 1
- fi
-
- echo "[INFO] Congratulations, got cluster join lock"
-
- return 0
-}
-
-checkClusterJoinLockExist()
-{
- echo "[INFO] Checking for the cluster join lock"
-
- lockExists=$(aws s3 ls $S3_IGNITE_NODES_JOIN_LOCK_URL)
- if [ -n "$lockExists" ]; then
- echo "[INFO] Cluster join lock already exists"
- return 1
- fi
-
- echo "[INFO] Cluster join lock doesn't exist"
-
- return 0
-}
-
-createClusterJoinLock()
-{
- aws s3 cp --sse AES256 /opt/ignite/join-lock $S3_IGNITE_NODES_JOIN_LOCK_URL
- if [ $? -ne 0 ]; then
- terminate "Failed to create cluster join lock"
+ else
+ setupClusterSeeds "ignite" "true"
fi
- echo "[INFO] Created cluster join lock"
-}
-removeClusterJoinLock()
-{
- aws s3 rm $S3_IGNITE_NODES_JOIN_LOCK_URL
- if [ $? -ne 0 ]; then
- terminate "Failed to remove cluster join lock"
- fi
- echo "[INFO] Removed cluster join lock"
-}
+ CLUSTER_SEEDS=($CLUSTER_SEEDS)
+ count=${#CLUSTER_SEEDS[@]}
-waitToJoinIgniteCluster()
-{
- echo "[INFO] Waiting to join Ignite cluster"
+ IGNITE_SEEDS=
- while true; do
- tryToGetClusterJoinLock
+ for (( i=0; i<=$(( $count -1 )); i++ ))
+ do
+ seed=${CLUSTER_SEEDS[$i]}
+ IGNITE_SEEDS="${IGNITE_SEEDS}<value>$seed<\/value>"
+ done
- if [ $? -ne 0 ]; then
- echo "[INFO] Another node is trying to join cluster. Waiting for extra 1min."
- sleep 1m
- else
- echo "[INFO]-------------------------------------------------------------"
- echo "[INFO] Congratulations, got lock to join Ignite cluster"
- echo "[INFO]-------------------------------------------------------------"
- break
- fi
- done
+ cat /opt/ignite/config/ignite-cassandra-server.xml | sed -r "s/\\\$\{IGNITE_SEEDS\}/$IGNITE_SEEDS/g" > /opt/ignite/config/ignite-cassandra-server1.xml
+ mv -f /opt/ignite/config/ignite-cassandra-server1.xml /opt/ignite/config/ignite-cassandra-server.xml
}
+# Checks status of Ignite daemon
checkIgniteStatus()
{
proc=$(ps -ef | grep java | grep "org.apache.ignite.startup.cmdline.CommandLineStartup")
@@ -419,52 +109,7 @@ checkIgniteStatus()
return 1
}
-waitFirstIgniteNodeRegistered()
-{
- echo "[INFO] Waiting for the first Ignite node to register"
-
- startTime=$(date +%s)
-
- while true; do
- first_host=
-
- exists=$(aws s3 ls $S3_IGNITE_FIRST_NODE_LOCK_URL)
- if [ -n "$exists" ]; then
- rm -Rf /opt/ignite/first-node-lock
-
- aws s3 cp $S3_IGNITE_FIRST_NODE_LOCK_URL /opt/ignite/first-node-lock
- if [ $? -ne 0 ]; then
- terminate "Failed to check existing first node lock"
- fi
-
- first_host=$(cat /opt/ignite/first-node-lock)
-
- rm -Rf /opt/ignite/first-node-lock
- fi
-
- if [ -n "$first_host" ]; then
- exists=$(aws s3 ls ${S3_IGNITE_NODES_DISCOVERY_URL}${first_host})
- if [ -n "$exists" ]; then
- break
- fi
- fi
-
- currentTime=$(date +%s)
- duration=$(( $currentTime-$startTime ))
- duration=$(( $duration/60 ))
-
- if [ $duration -gt $NODE_STARTUP_TIME ]; then
- terminate "${NODE_STARTUP_TIME}min timeout expired, but first Ignite node is still not up and running"
- fi
-
- echo "[INFO] Waiting extra 1min"
-
- sleep 1m
- done
-
- echo "[INFO] First Ignite node registered"
-}
-
+# Gracefully starts Ignite daemon and waits until it joins Ignite cluster
startIgnite()
{
echo "[INFO]-------------------------------------------------------------"
@@ -475,13 +120,13 @@ startIgnite()
setupCassandraSeeds
setupIgniteSeeds
- if [ "$FIRST_NODE" == "true" ]; then
- aws s3 rm --recursive ${S3_IGNITE_NODES_DISCOVERY_URL::-1}
+ waitToJoinCluster
+
+ if [ "$FIRST_NODE_LOCK" == "true" ]; then
+ aws s3 rm --recursive ${S3_IGNITE_NODES_DISCOVERY::-1}
if [ $? -ne 0 ]; then
- terminate "Failed to clean Ignite node discovery URL: $S3_IGNITE_NODES_DISCOVERY_URL"
+ terminate "Failed to clean Ignite node discovery URL: $S3_IGNITE_NODES_DISCOVERY"
fi
- else
- waitToJoinIgniteCluster
fi
proc=$(ps -ef | grep java | grep "org.apache.ignite.startup.cmdline.CommandLineStartup")
@@ -503,77 +148,46 @@ startIgnite()
START_ATTEMPT=$(( $START_ATTEMPT+1 ))
}
-# Time (in minutes) to wait for Ignite/Cassandra daemon up and running
-NODE_STARTUP_TIME=10
-
-# Number of attempts to start (not first) Ignite daemon
-NODE_START_ATTEMPTS=3
-
-HOST_NAME=$(hostname -f | tr '[:upper:]' '[:lower:]')
-echo $HOST_NAME > /opt/ignite/join-lock
+#######################################################################################################
START_ATTEMPT=0
-FIRST_NODE="false"
-
+# Cleans all the previous metadata about this EC2 node
unregisterNode
+# Tries to get first-node lock
tryToGetFirstNodeLock
-if [ $? -eq 0 ]; then
- FIRST_NODE="true"
-fi
-
echo "[INFO]-----------------------------------------------------------------"
-if [ "$FIRST_NODE" == "true" ]; then
+if [ "$FIRST_NODE_LOCK" == "true" ]; then
echo "[INFO] Starting first Ignite node"
else
echo "[INFO] Starting Ignite node"
fi
echo "[INFO]-----------------------------------------------------------------"
-echo "[INFO] Ignite nodes discovery URL: $S3_IGNITE_NODES_DISCOVERY_URL"
-echo "[INFO] Ignite first node lock URL: $S3_IGNITE_FIRST_NODE_LOCK_URL"
-echo "[INFO] Cassandra nodes discovery URL: $S3_CASSANDRA_NODES_DISCOVERY_URL"
-echo "[INFO] Start success URL: $S3_BOOTSTRAP_SUCCESS_URL"
-echo "[INFO] Start failure URL: $S3_BOOTSTRAP_FAILURE_URL"
-echo "[INFO] IGNITE_HOME: $IGNITE_HOME"
-echo "[INFO] JAVA_HOME: $JAVA_HOME"
-echo "[INFO] PATH: $PATH"
+printInstanceInfo
echo "[INFO]-----------------------------------------------------------------"
-if [ -z "$S3_CASSANDRA_NODES_DISCOVERY_URL" ]; then
- terminate "Cassandra S3 discovery URL doesn't specified"
-fi
-
-if [[ "$S3_CASSANDRA_NODES_DISCOVERY_URL" != */ ]]; then
- S3_CASSANDRA_NODES_DISCOVERY_URL=${S3_CASSANDRA_NODES_DISCOVERY_URL}/
-fi
-
-if [ -z "$S3_IGNITE_NODES_DISCOVERY_URL" ]; then
- terminate "Ignite S3 discovery URL doesn't specified"
-fi
-
-if [[ "$S3_IGNITE_NODES_DISCOVERY_URL" != */ ]]; then
- S3_IGNITE_NODES_DISCOVERY_URL=${S3_IGNITE_NODES_DISCOVERY_URL}/
-fi
-
-if [ "$FIRST_NODE" != "true" ]; then
- waitFirstIgniteNodeRegistered
+if [ "$FIRST_NODE_LOCK" != "true" ]; then
+ waitFirstClusterNodeRegistered "true"
else
cleanupMetadata
fi
+# Applies Ignite environment settings from ignite-env.sh
envScript=$(readlink -m $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/ignite-env.sh)
if [ -f "$envScript" ]; then
. $envScript
fi
+# Start Ignite daemon
startIgnite
startTime=$(date +%s)
+# Trying multiple attempts to start Ignite daemon
while true; do
proc=$(ps -ef | grep java | grep "org.apache.ignite.startup.cmdline.CommandLineStartup")
@@ -587,9 +201,9 @@ while true; do
echo $proc
echo "[INFO]-----------------------------------------------------"
- if [ "$FIRST_NODE" != "true" ]; then
- removeClusterJoinLock
- fi
+ # Once node joined the cluster we need to remove cluster-join lock
+ # to allow other EC2 nodes to acquire it and join cluster sequentially
+ removeClusterJoinLock
break
fi
@@ -598,33 +212,46 @@ while true; do
duration=$(( $currentTime-$startTime ))
duration=$(( $duration/60 ))
- if [ $duration -gt $NODE_STARTUP_TIME ]; then
- if [ "$FIRST_NODE" == "true" ]; then
- removeFirstNodeLock
- terminate "${NODE_STARTUP_TIME}min timeout expired, but first Ignite daemon is still not up and running"
+ if [ $duration -gt $SERVICE_STARTUP_TIME ]; then
+ if [ "$FIRST_NODE_LOCK" == "true" ]; then
+ # If the first node of Ignite cluster failed to start Ignite daemon in SERVICE_STARTUP_TIME min,
+ # we will not try any other attempts and just terminate with error. Terminate function itself, will
+ # take care about removing all the locks holding by this node.
+ terminate "${SERVICE_STARTUP_TIME}min timeout expired, but first Ignite daemon is still not up and running"
else
+ # If node isn't the first node of Ignite cluster and it failed to start we need to
+ # remove cluster-join lock to allow other EC2 nodes to acquire it
removeClusterJoinLock
- if [ $START_ATTEMPT -gt $NODE_START_ATTEMPTS ]; then
- terminate "${NODE_START_ATTEMPTS} attempts exceed, but Ignite daemon is still not up and running"
+ # If node failed all SERVICE_START_ATTEMPTS attempts to start Ignite daemon we will not
+ # try anymore and terminate with error
+ if [ $START_ATTEMPT -gt $SERVICE_START_ATTEMPTS ]; then
+ terminate "${SERVICE_START_ATTEMPTS} attempts exceed, but Ignite daemon is still not up and running"
fi
+ # New attempt to start Ignite daemon
startIgnite
fi
continue
fi
+ # Handling situation when Ignite daemon process abnormally terminated
if [ -z "$proc" ]; then
- if [ "$FIRST_NODE" == "true" ]; then
- removeFirstNodeLock
+ # If this is the first node of Ignite cluster just terminating with error
+ if [ "$FIRST_NODE_LOCK" == "true" ]; then
terminate "Failed to start Ignite daemon"
fi
+ # Remove cluster-join lock to allow other EC2 nodes to acquire it
removeClusterJoinLock
- echo "[WARN] Failed to start Ignite daemon. Sleeping for extra 1min"
- sleep 1m
+
+ echo "[WARN] Failed to start Ignite daemon. Sleeping for extra 30sec"
+ sleep 30s
+
+ # New attempt to start Ignite daemon
startIgnite
+
continue
fi
@@ -632,6 +259,8 @@ while true; do
sleep 30s
done
+# Once Ignite daemon successfully started we registering new Ignite node in S3
registerNode
+# Terminating script with zero exit code
terminate
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee8ac73f/modules/cassandra/src/test/bootstrap/aws/logs-collector.sh
----------------------------------------------------------------------
diff --git a/modules/cassandra/src/test/bootstrap/aws/logs-collector.sh b/modules/cassandra/src/test/bootstrap/aws/logs-collector.sh
index 73e3c2c..1634b89 100644
--- a/modules/cassandra/src/test/bootstrap/aws/logs-collector.sh
+++ b/modules/cassandra/src/test/bootstrap/aws/logs-collector.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
#
# Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,86 +17,157 @@
# limitations under the License.
#
-echo "[INFO] Running Logs collector service"
+# -----------------------------------------------------------------------------------------------
+# Logs collector daemon
+# -----------------------------------------------------------------------------------------------
+# Script is launched in background by all EC2 nodes of all clusters (Cassandra, Ignite, Tests) and
+# periodically (each 30 seconds) checks if specific S3 trigger file (specified by $S3_LOGS_TRIGGER_URL)
+# was created or its timestamp was changed. Such an event serve as a trigger for the script
+# to collect EC2 instance logs (from folder specified by $1) and upload them into specific
+# S3 folder (specified by $S3_LOGS_FOLDER).
+# -----------------------------------------------------------------------------------------------
+
+uploadLogs()
+{
+ if [ ! -d "$1" ]; then
+ echo "[INFO] Logs directory doesn't exist: $1"
+ return 0
+ fi
-if [ -z "$1" ]; then
- echo "[ERROR] Local logs directory doesn't specified"
- exit 1
-fi
+ echo "[INFO] Uploading logs from directory: $1"
-echo "[INFO] Local logs directory: $1"
+ dirList=$(ls $1 | head -1)
-if [ -z "$2" ]; then
- echo "[ERROR] S3 folder where to upload logs doesn't specified"
- exit 1
-fi
+ if [ -z "$dirList" ]; then
+ echo "[INFO] Directory is empty: $1"
+ fi
-echo "[INFO] S3 logs upload folder: $2"
+ for i in 0 9;
+ do
+ aws s3 sync --sse AES256 --delete "$1" "$S3_LOGS_FOLDER"
+ code=$?
-if [ -z "$3" ]; then
- echo "[ERROR] Logs collection S3 trigger URL doesn't specified"
- exit 1
-fi
+ if [ $code -eq 0 ]; then
+ echo "[INFO] Successfully uploaded logs from directory: $1"
+ return 0
+ fi
-echo "[INFO] Logs collection S3 trigger URL: $3"
+ echo "[WARN] Failed to upload logs from $i attempt, sleeping extra 30sec"
+ sleep 30s
+ done
-echo "--------------------------------------------------------------------"
+ echo "[ERROR] All 10 attempts to upload logs are failed for the directory: $1"
+}
-TRIGGER_STATE=
+createNewLogsSnapshot()
+{
+ rm -f ~/logs-collector.snapshot.new
-while true; do
- sleep 1m
+ for log_src in "$@"
+ do
+ if [ -d "$log_src" ] || [ -f "$log_src" ]; then
+ ls -alR $log_src >> ~/logs-collector.snapshot.new
- STATE=$(aws s3 ls $3)
+ fi
+ done
+}
- if [ -z "$STATE" ] || [ "$STATE" == "$TRIGGER_STATE" ]; then
- continue
+checkLogsChanged()
+{
+ createNewLogsSnapshot $@
+
+ if [ ! -f "~/logs-collector.snapshot" ]; then
+ return 1
fi
- TRIGGER_STATE=$STATE
+ diff "~/logs-collector.snapshot" "~/logs-collector.snapshot.new" > /dev/null
+
+ return $?
+}
- exists=
- if [ -d "$1" ]; then
- exists="true"
+updateLogsSnapshot()
+{
+ if [ ! -f "~/logs-collector.snapshot.new" ]; then
+ return 0
fi
- echo "[INFO] Uploading logs from $1 to $2"
+ rm -f "~/logs-collector.snapshot"
+ mv "~/logs-collector.snapshot.new" "~/logs-collector.snapshot"
+}
+
+collectLogs()
+{
+ createNewLogsSnapshot
+
+ rm -Rf ~/logs-collector-logs
+ mkdir -p ~/logs-collector-logs
+
+ for log_src in "$@"
+ do
+ if [ -f "$log_src" ]; then
+ echo "[INFO] Collecting log file: $log_src"
+ cp -f $log_src ~/logs-collector-logs
+ elif [ -d "$log_src" ]; then
+ echo "[INFO] Collecting logs from folder: $log_src"
+ cp -Rf $log_src ~/logs-collector-logs
+ fi
+ done
- if [ "$exists" != "true" ]; then
- echo "[INFO] Local logs directory $1 doesn't exist, thus there is nothing to upload"
- fi
+ uploadLogs ~/logs-collector-logs
- echo "--------------------------------------------------------------------"
+ rm -Rf ~/logs-collector-logs
- if [ "$exists" != "true" ]; then
- continue
- fi
+ updateLogsSnapshot
+}
- aws s3 sync --sse AES256 --delete "$1" "$2"
+echo "[INFO] Running Logs collector service"
- if [ $? -ne 0 ]; then
- echo "[ERROR] Failed to upload logs from $1 to $2 from first attempt"
- sleep 30s
+if [ -z "$1" ]; then
+ echo "[ERROR] Logs collection S3 trigger URL doesn't specified"
+ exit 1
+fi
+
+S3_LOGS_TRIGGER_URL=$1
+
+echo "[INFO] Logs collection S3 trigger URL: $S3_LOGS_TRIGGER_URL"
- aws s3 sync --sse AES256 --delete "$1" "$2"
+if [ -z "$2" ]; then
+ echo "[ERROR] S3 folder where to upload logs doesn't specified"
+ exit 1
+fi
- if [ $? -ne 0 ]; then
- echo "[ERROR] Failed to upload logs from $1 to $2 from second attempt"
- sleep 1m
+S3_LOGS_FOLDER=$2
- aws s3 sync --sse AES256 --delete "$1" "$2"
+echo "[INFO] S3 logs upload folder: $S3_LOGS_FOLDER"
- if [ $? -ne 0 ]; then
- echo "[ERROR] Failed to upload logs from $1 to $2 from third attempt"
- else
- echo "[INFO] Logs successfully uploaded from $1 to $2 from third attempt"
- fi
- else
- echo "[INFO] Logs successfully uploaded from $1 to $2 from second attempt"
+shift 2
+
+if [ -z "$1" ]; then
+ echo "[WARN] Local logs sources don't specified"
+else
+ echo "[INFO] Local logs sources: $@"
+fi
+
+echo "--------------------------------------------------------------------"
+
+TRIGGER_STATE=
+
+while true; do
+ sleep 30s
+
+ STATE=$(aws s3 ls $S3_LOGS_TRIGGER_URL)
+
+ if [ -z "$STATE" ] || [ "$STATE" == "$TRIGGER_STATE" ]; then
+ checkLogsChanged
+
+ if [ $? -eq 0 ]; then
+ continue
fi
- else
- echo "[INFO] Logs successfully uploaded from $1 to $2"
fi
+ TRIGGER_STATE=$STATE
+
+ collectLogs $@ /var/log/cloud-init.log /var/log/cloud-init-output.log
+
echo "--------------------------------------------------------------------"
done
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee8ac73f/modules/cassandra/src/test/bootstrap/aws/tests/ignite-cassandra-client-template.xml
----------------------------------------------------------------------
diff --git a/modules/cassandra/src/test/bootstrap/aws/tests/ignite-cassandra-client-template.xml b/modules/cassandra/src/test/bootstrap/aws/tests/ignite-cassandra-client-template.xml
index 53c33a2..77ffb9e 100644
--- a/modules/cassandra/src/test/bootstrap/aws/tests/ignite-cassandra-client-template.xml
+++ b/modules/cassandra/src/test/bootstrap/aws/tests/ignite-cassandra-client-template.xml
@@ -24,7 +24,11 @@
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd">
- <bean id="loadBalancingPolicy" class="com.datastax.driver.core.policies.RoundRobinPolicy"/>
+ <bean id="loadBalancingPolicy" class="com.datastax.driver.core.policies.TokenAwarePolicy">
+ <constructor-arg type="com.datastax.driver.core.policies.LoadBalancingPolicy">
+ <bean class="com.datastax.driver.core.policies.RoundRobinPolicy"/>
+ </constructor-arg>
+ </bean>
<util:list id="contactPoints" value-type="java.lang.String">
${CASSANDRA_SEEDS}
@@ -114,6 +118,11 @@
<!-- Configuring persistence for "cache1" cache -->
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="cache1"/>
+ <property name="startSize" value="1000000"/>
+ <property name="cacheMode" value="PARTITIONED"/>
+ <property name="backups" value="0"/>
+ <property name="offHeapMaxMemory" value="0"/>
+ <property name="swapEnabled" value="false"/>
<property name="readThrough" value="true"/>
<property name="writeThrough" value="true"/>
<property name="writeBehindEnabled" value="true"/>
@@ -128,6 +137,11 @@
<!-- Configuring persistence for "cache2" cache -->
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="cache2"/>
+ <property name="startSize" value="1000000"/>
+ <property name="cacheMode" value="PARTITIONED"/>
+ <property name="backups" value="0"/>
+ <property name="offHeapMaxMemory" value="0"/>
+ <property name="swapEnabled" value="false"/>
<property name="readThrough" value="true"/>
<property name="writeThrough" value="true"/>
<property name="writeBehindEnabled" value="true"/>
@@ -142,6 +156,11 @@
<!-- Configuring persistence for "cache3" cache -->
<bean class="org.apache.ignite.configuration.CacheConfiguration">
<property name="name" value="cache3"/>
+ <property name="startSize" value="1000000"/>
+ <property name="cacheMode" value="PARTITIONED"/>
+ <property name="backups" value="0"/>
+ <property name="offHeapMaxMemory" value="0"/>
+ <property name="swapEnabled" value="false"/>
<property name="readThrough" value="true"/>
<property name="writeThrough" value="true"/>
<property name="writeBehindEnabled" value="true"/>
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee8ac73f/modules/cassandra/src/test/bootstrap/aws/tests/tests-bootstrap.sh
----------------------------------------------------------------------
diff --git a/modules/cassandra/src/test/bootstrap/aws/tests/tests-bootstrap.sh b/modules/cassandra/src/test/bootstrap/aws/tests/tests-bootstrap.sh
index d00ddb6..8e6faff 100644
--- a/modules/cassandra/src/test/bootstrap/aws/tests/tests-bootstrap.sh
+++ b/modules/cassandra/src/test/bootstrap/aws/tests/tests-bootstrap.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
#
# Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,51 +17,31 @@
# limitations under the License.
#
+# -----------------------------------------------------------------------------------------------
+# Bootstrap script to spin up Tests cluster
+# -----------------------------------------------------------------------------------------------
+
+# URL to download AWS CLI tools
AWS_CLI_DOWNLOAD_URL=https://s3.amazonaws.com/aws-cli/awscli-bundle.zip
-S3_ROOT=s3://bucket/folder
-S3_DOWNLOADS=$S3_ROOT/test
-S3_SYSTEM=$S3_ROOT/test1
-
-TESTS_PACKAGE_DONLOAD_URL=$S3_DOWNLOADS/ignite-cassandra-tests-1.6.0-SNAPSHOT.zip
-TESTS_PACKAGE_ZIP=ignite-cassandra-tests-1.6.0-SNAPSHOT.zip
-TESTS_PACKAGE_UNZIP_DIR=ignite-cassandra-tests
-
-S3_LOGS_URL=$S3_SYSTEM/logs/t-logs
-S3_LOGS_TRIGGER_URL=$S3_SYSTEM/logs-trigger
-S3_IGNITE_NODES_DISCOVERY_URL=$S3_SYSTEM/i-discovery
-S3_CASSANDRA_NODES_DISCOVERY_URL=$S3_SYSTEM/c-discovery
-S3_TEST_NODES_DISCOVERY_URL=$S3_SYSTEM/t-discovery
-S3_TESTS_SUCCESS_URL=$S3_SYSTEM/t-success
-S3_TESTS_FAILURE_URL=$S3_SYSTEM/t-failure
-S3_TESTS_RUNNING_URL=$S3_SYSTEM/t-running
-S3_TESTS_WAITING_URL=$S3_SYSTEM/t-waiting
-S3_IGNITE_SUCCESS_URL=$S3_SYSTEM/i-success
-S3_IGNITE_FAILURE_URL=$S3_SYSTEM/i-failure
-S3_CASSANDRA_SUCCESS_URL=$S3_SYSTEM/c-success
-S3_CASSANDRA_FAILURE_URL=$S3_SYSTEM/c-failure
-S3_TESTS_FIRST_NODE_LOCK_URL=$S3_SYSTEM/t-first-node-lock
-S3_TESTS_SUMMARY_URL=$S3_SYSTEM/t-summary.zip
-
-INSTANCE_REGION=us-west-2
-INSTANCE_NAME_TAG=TEST-SERVER
-INSTANCE_OWNER_TAG=ignite@apache.org
-INSTANCE_PROJECT_TAG=ignite
-
-CASSANDRA_NODES_COUNT=50
-IGNITE_NODES_COUNT=30
-TEST_NODES_COUNT=30
-
-TESTS_TYPE="ignite"
+# URL to download JDK
+JDK_DOWNLOAD_URL=http://download.oracle.com/otn-pub/java/jdk/8u77-b03/jdk-8u77-linux-x64.tar.gz
+
+# URL to download Ignite-Cassandra tests package - you should previously package and upload it to this place
+TESTS_PACKAGE_DONLOAD_URL=s3://<bucket>/<folder>/ignite-cassandra-tests-<version>.zip
+# Terminates script execution and upload logs to S3
terminate()
{
- if [[ "$S3_TESTS_SUCCESS_URL" != */ ]]; then
- S3_TESTS_SUCCESS_URL=${S3_TESTS_SUCCESS_URL}/
+ SUCCESS_URL=$S3_TESTS_SUCCESS
+ FAILURE_URL=$S3_TESTS_FAILURE
+
+ if [ -n "$SUCCESS_URL" ] && [[ "$SUCCESS_URL" != */ ]]; then
+ SUCCESS_URL=${SUCCESS_URL}/
fi
- if [[ "$S3_TESTS_FAILURE_URL" != */ ]]; then
- S3_TESTS_FAILURE_URL=${S3_TESTS_FAILURE_URL}/
+ if [ -n "$FAILURE_URL" ] && [[ "$FAILURE_URL" != */ ]]; then
+ FAILURE_URL=${FAILURE_URL}/
fi
host_name=$(hostname -f | tr '[:upper:]' '[:lower:]')
@@ -73,13 +53,23 @@ terminate()
echo "[ERROR] Test node bootstrap failed"
echo "[ERROR]-----------------------------------------------------"
msg=$1
- reportFolder=${S3_TESTS_FAILURE_URL}${host_name}
+
+ if [ -z "$FAILURE_URL" ]; then
+ exit 1
+ fi
+
+ reportFolder=${FAILURE_URL}${host_name}
reportFile=$reportFolder/__error__
else
echo "[INFO]-----------------------------------------------------"
echo "[INFO] Test node bootstrap successfully completed"
echo "[INFO]-----------------------------------------------------"
- reportFolder=${S3_TESTS_SUCCESS_URL}${host_name}
+
+ if [ -z "$SUCCESS_URL" ]; then
+ exit 0
+ fi
+
+ reportFolder=${SUCCESS_URL}${host_name}
reportFile=$reportFolder/__success__
fi
@@ -87,7 +77,7 @@ terminate()
aws s3 rm --recursive $reportFolder
if [ $? -ne 0 ]; then
- echo "[ERROR] Failed drop report folder: $reportFolder"
+ echo "[ERROR] Failed to drop report folder: $reportFolder"
fi
aws s3 cp --sse AES256 /opt/bootstrap-result $reportFile
@@ -104,172 +94,67 @@ terminate()
exit 0
}
-tagInstance()
-{
- export EC2_HOME=/opt/aws/apitools/ec2
- export JAVA_HOME=/opt/jdk1.8.0_77
- export PATH=$JAVA_HOME/bin:$EC2_HOME/bin:$PATH
-
- INSTANCE_ID=$(curl http://169.254.169.254/latest/meta-data/instance-id)
- if [ $? -ne 0 ]; then
- terminate "Failed to get instance metadata to tag it"
- fi
-
- if [ -n "$INSTANCE_NAME_TAG" ]; then
- ec2-create-tags $INSTANCE_ID --tag Name=${INSTANCE_NAME_TAG} --region $INSTANCE_REGION
- if [ $code -ne 0 ]; then
- terminate "Failed to tag EC2 instance with: Name=${INSTANCE_NAME_TAG}"
- fi
- fi
-
- if [ -n "$INSTANCE_OWNER_TAG" ]; then
- ec2-create-tags $INSTANCE_ID --tag owner=${INSTANCE_OWNER_TAG} --region $INSTANCE_REGION
- if [ $code -ne 0 ]; then
- terminate "Failed to tag EC2 instance with: owner=${INSTANCE_OWNER_TAG}"
- fi
- fi
-
- if [ -n "$INSTANCE_PROJECT_TAG" ]; then
- ec2-create-tags $INSTANCE_ID --tag project=${INSTANCE_PROJECT_TAG} --region $INSTANCE_REGION
- if [ $code -ne 0 ]; then
- terminate "Failed to tag EC2 instance with: project=${INSTANCE_PROJECT_TAG}"
- fi
- fi
-}
-
+# Downloads specified package
downloadPackage()
{
echo "[INFO] Downloading $3 package from $1 into $2"
- if [[ "$1" == s3* ]]; then
- aws s3 cp $1 $2
-
- if [ $? -ne 0 ]; then
- echo "[WARN] Failed to download $3 package from first attempt"
- rm -Rf $2
- sleep 10s
-
- echo "[INFO] Trying second attempt to download $3 package"
+ for i in 0 9;
+ do
+ if [[ "$1" == s3* ]]; then
aws s3 cp $1 $2
+ code=$?
+ else
+ curl "$1" -o "$2"
+ code=$?
+ fi
- if [ $? -ne 0 ]; then
- echo "[WARN] Failed to download $3 package from second attempt"
- rm -Rf $2
- sleep 10s
-
- echo "[INFO] Trying third attempt to download $3 package"
- aws s3 cp $1 $2
-
- if [ $? -ne 0 ]; then
- terminate "All three attempts to download $3 package from $1 are failed"
- fi
- fi
+ if [ $code -eq 0 ]; then
+ echo "[INFO] $3 package successfully downloaded from $1 into $2"
+ return 0
fi
- else
- curl "$1" -o "$2"
- if [ $? -ne 0 ] && [ $? -ne 6 ]; then
- echo "[WARN] Failed to download $3 package from first attempt"
- rm -Rf $2
- sleep 10s
+ echo "[WARN] Failed to download $3 package from $i attempt, sleeping extra 5sec"
+ sleep 5s
+ done
- echo "[INFO] Trying second attempt to download $3 package"
- curl "$1" -o "$2"
+ terminate "All 10 attempts to download $3 package from $1 are failed"
+}
- if [ $? -ne 0 ] && [ $? -ne 6 ]; then
- echo "[WARN] Failed to download $3 package from second attempt"
- rm -Rf $2
- sleep 10s
+# Downloads and setup JDK
+setupJava()
+{
+ rm -Rf /opt/java /opt/jdk.tar.gz
- echo "[INFO] Trying third attempt to download $3 package"
- curl "$1" -o "$2"
+ echo "[INFO] Downloading 'jdk'"
+ wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "$JDK_DOWNLOAD_URL" -O /opt/jdk.tar.gz
+ if [ $? -ne 0 ]; then
+ terminate "Failed to download 'jdk'"
+ fi
- if [ $? -ne 0 ] && [ $? -ne 6 ]; then
- terminate "All three attempts to download $3 package from $1 are failed"
- fi
- fi
- fi
+ echo "[INFO] Untaring 'jdk'"
+ tar -xvzf /opt/jdk.tar.gz -C /opt
+ if [ $? -ne 0 ]; then
+ terminate "Failed to untar 'jdk'"
fi
- echo "[INFO] $3 package successfully downloaded from $1 into $2"
+ rm -Rf /opt/jdk.tar.gz
+
+ unzipDir=$(ls /opt | grep "jdk")
+ if [ "$unzipDir" != "java" ]; then
+ mv /opt/$unzipDir /opt/java
+ fi
}
-echo "[INFO]-----------------------------------------------------------------"
-echo "[INFO] Bootstrapping Tests node"
-echo "[INFO]-----------------------------------------------------------------"
-echo "[INFO] Tests type: $TESTS_TYPE"
-echo "[INFO] Test nodes count: $TEST_NODES_COUNT"
-echo "[INFO] Ignite nodes count: $IGNITE_NODES_COUNT"
-echo "[INFO] Cassandra nodes count: $CASSANDRA_NODES_COUNT"
-echo "[INFO] Tests summary URL: $S3_TESTS_SUMMARY_URL"
-echo "[INFO] Tests first node lock URL: $S3_TESTS_FIRST_NODE_LOCK_URL"
-echo "[INFO] Logs URL: $S3_LOGS_URL"
-echo "[INFO] Logs trigger URL: $S3_LOGS_TRIGGER_URL"
-echo "[INFO] Tests package download URL: $TESTS_PACKAGE_DONLOAD_URL"
-echo "[INFO] Test node discovery URL: $S3_TEST_NODES_DISCOVERY_URL"
-echo "[INFO] Ignite node discovery URL: $S3_IGNITE_NODES_DISCOVERY_URL"
-echo "[INFO] Cassandra node discovery URL: $S3_CASSANDRA_NODES_DISCOVERY_URL"
-echo "[INFO] Tests running URL: $S3_TESTS_RUNNING_URL"
-echo "[INFO] Tests waiting URL: $S3_TESTS_WAITING_URL"
-echo "[INFO] Tests success URL: $S3_TESTS_SUCCESS_URL"
-echo "[INFO] Tests failure URL: $S3_TESTS_FAILURE_URL"
-echo "[INFO] Ignite success URL: $S3_IGNITE_SUCCESS_URL"
-echo "[INFO] Ignite failure URL: $S3_IGNITE_FAILURE_URL"
-echo "[INFO] Cassandra success URL: $S3_CASSANDRA_SUCCESS_URL"
-echo "[INFO] Cassandra failure URL: $S3_CASSANDRA_FAILURE_URL"
-echo "[INFO]-----------------------------------------------------------------"
+# Downloads and setup AWS CLI
+setupAWSCLI()
+{
+ echo "[INFO] Installing 'awscli'"
+ pip install --upgrade awscli
+ if [ $? -eq 0 ]; then
+ return 0
+ fi
-echo "[INFO] Installing 'wget' package"
-yum -y install wget
-if [ $? -ne 0 ]; then
- terminate "Failed to install 'wget' package"
-fi
-
-echo "[INFO] Installing 'net-tools' package"
-yum -y install net-tools
-if [ $? -ne 0 ]; then
- terminate "Failed to install 'net-tools' package"
-fi
-
-echo "[INFO] Installing 'python' package"
-yum -y install python
-if [ $? -ne 0 ]; then
- terminate "Failed to install 'python' package"
-fi
-
-echo "[INFO] Installing 'unzip' package"
-yum -y install unzip
-if [ $? -ne 0 ]; then
- terminate "Failed to install 'unzip' package"
-fi
-
-rm -Rf /opt/jdk1.8.0_77 /opt/jdk-8u77-linux-x64.tar.gz
-
-echo "[INFO] Downloading 'jdk-8u77'"
-wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u77-b03/jdk-8u77-linux-x64.tar.gz" -O /opt/jdk-8u77-linux-x64.tar.gz
-if [ $? -ne 0 ]; then
- terminate "Failed to download 'jdk-8u77'"
-fi
-
-echo "[INFO] Unzipping 'jdk-8u77'"
-tar -xvzf /opt/jdk-8u77-linux-x64.tar.gz -C /opt
-if [ $? -ne 0 ]; then
- terminate "Failed to untar 'jdk-8u77'"
-fi
-
-rm -Rf /opt/jdk-8u77-linux-x64.tar.gz
-
-downloadPackage "https://bootstrap.pypa.io/get-pip.py" "/opt/get-pip.py" "get-pip.py"
-
-echo "[INFO] Installing 'pip'"
-python /opt/get-pip.py
-if [ $? -ne 0 ]; then
- terminate "Failed to install 'pip'"
-fi
-
-echo "[INFO] Installing 'awscli'"
-pip install --upgrade awscli
-if [ $? -ne 0 ]; then
echo "[ERROR] Failed to install 'awscli' using pip"
echo "[INFO] Trying to install awscli using zip archive"
echo "[INFO] Downloading awscli zip"
@@ -282,7 +167,7 @@ if [ $? -ne 0 ]; then
terminate "Failed to unzip awscli zip"
fi
- rm -fR /opt/awscli-bundle.zip
+ rm -Rf /opt/awscli-bundle.zip
echo "[INFO] Installing awscli"
/opt/awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
@@ -291,89 +176,142 @@ if [ $? -ne 0 ]; then
fi
echo "[INFO] Successfully installed awscli from zip archive"
-fi
+}
-tagInstance
+# Setup all the pre-requisites (packages, settings and etc.)
+setupPreRequisites()
+{
+ echo "[INFO] Installing 'wget' package"
+ yum -y install wget
+ if [ $? -ne 0 ]; then
+ terminate "Failed to install 'wget' package"
+ fi
-echo "[INFO] Creating 'ignite' group"
-exists=$(cat /etc/group | grep ignite)
-if [ -z "$exists" ]; then
- groupadd ignite
+ echo "[INFO] Installing 'net-tools' package"
+ yum -y install net-tools
if [ $? -ne 0 ]; then
- terminate "Failed to create 'ignite' group"
+ terminate "Failed to install 'net-tools' package"
fi
-fi
-echo "[INFO] Creating 'ignite' user"
-exists=$(cat /etc/passwd | grep ignite)
-if [ -z "$exists" ]; then
- useradd -g ignite ignite
+ echo "[INFO] Installing 'python' package"
+ yum -y install python
if [ $? -ne 0 ]; then
- terminate "Failed to create 'ignite' user"
+ terminate "Failed to install 'python' package"
fi
-fi
-downloadPackage "$TESTS_PACKAGE_DONLOAD_URL" "/opt/$TESTS_PACKAGE_ZIP" "Tests"
+ echo "[INFO] Installing 'unzip' package"
+ yum -y install unzip
+ if [ $? -ne 0 ]; then
+ terminate "Failed to install 'unzip' package"
+ fi
-unzip /opt/$TESTS_PACKAGE_ZIP -d /opt
-if [ $? -ne 0 ]; then
- terminate "Failed to unzip tests package: $TESTS_PACKAGE_DONLOAD_URL"
-fi
+ downloadPackage "https://bootstrap.pypa.io/get-pip.py" "/opt/get-pip.py" "get-pip.py"
-mv /opt/$TESTS_PACKAGE_UNZIP_DIR /opt/ignite-cassandra-tests
+ echo "[INFO] Installing 'pip'"
+ python /opt/get-pip.py
+ if [ $? -ne 0 ]; then
+ terminate "Failed to install 'pip'"
+ fi
+}
-if [ ! -f "/opt/ignite-cassandra-tests/cassandra-load-tests.sh" ]; then
- terminate "There are no cassandra-load-tests.sh in tests package"
-fi
+# Downloads and setup tests package
+setupTestsPackage()
+{
+ downloadPackage "$TESTS_PACKAGE_DONLOAD_URL" "/opt/ignite-cassandra-tests.zip" "Tests"
-if [ ! -f "/opt/ignite-cassandra-tests/ignite-load-tests.sh" ]; then
- terminate "There are no ignite-load-tests.sh in tests package"
-fi
+ rm -Rf /opt/ignite-cassandra-tests
-if [ ! -f "/opt/ignite-cassandra-tests/bootstrap/aws/tests/ignite-cassandra-client-template.xml" ]; then
- terminate "There are no ignite-cassandra-client-template.xml in tests package"
-fi
+ unzip /opt/ignite-cassandra-tests.zip -d /opt
+ if [ $? -ne 0 ]; then
+ terminate "Failed to unzip tests package"
+ fi
+
+ rm -f /opt/ignite-cassandra-tests.zip
+
+ unzipDir=$(ls /opt | grep "ignite-cassandra")
+ if [ "$unzipDir" != "ignite-cassandra-tests" ]; then
+ mv /opt/$unzipDir /opt/ignite-cassandra-tests
+ fi
+
+ find /opt/ignite-cassandra-tests -type f -name "*.sh" -exec chmod ug+x {} \;
+
+ . /opt/ignite-cassandra-tests/bootstrap/aws/common.sh "test"
-if [ ! -f "/opt/$TESTS_PACKAGE_UNZIP_DIR/bootstrap/aws/logs-collector.sh" ]; then
- terminate "There are no logs-collector.sh in tests package"
-fi
+ setupNTP
-chown -R ignite:ignite /opt/ignite-cassandra-tests
-find /opt/ignite-cassandra-tests -type f -name "*.sh" -exec chmod ug+x {} \;
+ echo "[INFO] Starting logs collector daemon"
-cp -f /opt/ignite-cassandra-tests/bootstrap/aws/logs-collector.sh /opt
-chown -R ignite:ignite /opt/logs-collector.sh
+ HOST_NAME=$(hostname -f | tr '[:upper:]' '[:lower:]')
+ /opt/ignite-cassandra-tests/bootstrap/aws/logs-collector.sh "$S3_LOGS_TRIGGER" "$S3_TESTS_LOGS/$HOST_NAME" "/opt/ignite-cassandra-tests/logs" > /opt/logs-collector.log &
-#profile=/home/ignite/.bash_profile
-profile=/root/.bash_profile
+ echo "[INFO] Logs collector daemon started: $!"
-echo "export JAVA_HOME=/opt/jdk1.8.0_77" >> $profile
-echo "export PATH=\$JAVA_HOME/bin:\IGNITE_HOME/bin:\$PATH" >> $profile
-echo "export TESTS_TYPE=$TESTS_TYPE" >> $profile
-echo "export S3_TESTS_SUMMARY_URL=$S3_TESTS_SUMMARY_URL" >> $profile
-echo "export S3_CASSANDRA_NODES_DISCOVERY_URL=$S3_CASSANDRA_NODES_DISCOVERY_URL" >> $profile
-echo "export S3_TEST_NODES_DISCOVERY_URL=$S3_TEST_NODES_DISCOVERY_URL" >> $profile
-echo "export S3_IGNITE_NODES_DISCOVERY_URL=$S3_IGNITE_NODES_DISCOVERY_URL" >> $profile
-echo "export S3_TESTS_RUNNING_URL=$S3_TESTS_RUNNING_URL" >> $profile
-echo "export S3_TESTS_WAITING_URL=$S3_TESTS_WAITING_URL" >> $profile
-echo "export S3_TESTS_SUCCESS_URL=$S3_TESTS_SUCCESS_URL" >> $profile
-echo "export S3_TESTS_FAILURE_URL=$S3_TESTS_FAILURE_URL" >> $profile
-echo "export S3_IGNITE_SUCCESS_URL=$S3_IGNITE_SUCCESS_URL" >> $profile
-echo "export S3_IGNITE_FAILURE_URL=$S3_IGNITE_FAILURE_URL" >> $profile
-echo "export S3_CASSANDRA_SUCCESS_URL=$S3_CASSANDRA_SUCCESS_URL" >> $profile
-echo "export S3_CASSANDRA_FAILURE_URL=$S3_CASSANDRA_FAILURE_URL" >> $profile
-echo "export S3_TESTS_FIRST_NODE_LOCK_URL=$S3_TESTS_FIRST_NODE_LOCK_URL" >> $profile
-echo "export CASSANDRA_NODES_COUNT=$CASSANDRA_NODES_COUNT" >> $profile
-echo "export IGNITE_NODES_COUNT=$IGNITE_NODES_COUNT" >> $profile
-echo "export TEST_NODES_COUNT=$TEST_NODES_COUNT" >> $profile
-echo "export S3_LOGS_TRIGGER_URL=$S3_LOGS_TRIGGER_URL" >> $profile
+ echo "----------------------------------------------------------------------------------------"
+ printInstanceInfo
+ echo "----------------------------------------------------------------------------------------"
+ tagInstance
+ bootstrapGangliaAgent "test" 8643
+
+ ###################################################
+ # Extra configuration specific only for test node #
+ ###################################################
+
+ echo "[INFO] Installing bc package"
+
+ yum -y install bc
+
+ if [ $? -ne 0 ]; then
+ terminate "Failed to install bc package"
+ fi
+
+ echo "[INFO] Installing zip package"
+
+ yum -y install zip
+
+ if [ $? -ne 0 ]; then
+ terminate "Failed to install zip package"
+ fi
+
+ echo "[INFO] Creating 'ignite' group"
+ exists=$(cat /etc/group | grep ignite)
+ if [ -z "$exists" ]; then
+ groupadd ignite
+ if [ $? -ne 0 ]; then
+ terminate "Failed to create 'ignite' group"
+ fi
+ fi
+
+ echo "[INFO] Creating 'ignite' user"
+ exists=$(cat /etc/passwd | grep ignite)
+ if [ -z "$exists" ]; then
+ useradd -g ignite ignite
+ if [ $? -ne 0 ]; then
+ terminate "Failed to create 'ignite' user"
+ fi
+ fi
+
+ mkdir -p /opt/ignite-cassandra-tests/logs
+ chown -R ignite:ignite /opt/ignite-cassandra-tests
+
+ echo "export JAVA_HOME=/opt/java" >> $1
+ echo "export PATH=\$JAVA_HOME/bin:\$PATH" >> $1
+}
+
+###################################################################################################################
+
+echo "[INFO]-----------------------------------------------------------------"
+echo "[INFO] Bootstrapping Tests node"
+echo "[INFO]-----------------------------------------------------------------"
-HOST_NAME=$(hostname -f | tr '[:upper:]' '[:lower:]')
+setupPreRequisites
+setupJava
+setupAWSCLI
+setupTestsPackage "/root/.bash_profile"
-/opt/logs-collector.sh "/opt/ignite-cassandra-tests/logs" "$S3_LOGS_URL/$HOST_NAME" "$S3_LOGS_TRIGGER_URL" > /opt/ignite-cassandra-tests/logs-collector.log &
+cmd="/opt/ignite-cassandra-tests/bootstrap/aws/tests/tests-manager.sh"
-cmd="/opt/ignite-cassandra-tests/bootstrap/aws/tests/tests-run.sh"
+#sudo -u ignite -g ignite sh -c "$cmd > /opt/ignite-cassandra-tests/tests-manager" &
-#sudo -u ignite -g ignite sh -c "$cmd | tee /opt/ignite-cassandra-tests/start.log"
+$cmd > /opt/ignite-cassandra-tests/logs/tests-manager.log &
-$cmd | tee /opt/ignite-cassandra-tests/start.log
\ No newline at end of file
+terminate
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee8ac73f/modules/cassandra/src/test/bootstrap/aws/tests/tests-manager.sh
----------------------------------------------------------------------
diff --git a/modules/cassandra/src/test/bootstrap/aws/tests/tests-manager.sh b/modules/cassandra/src/test/bootstrap/aws/tests/tests-manager.sh
new file mode 100644
index 0000000..c0f5d6b
--- /dev/null
+++ b/modules/cassandra/src/test/bootstrap/aws/tests/tests-manager.sh
@@ -0,0 +1,458 @@
+#!/bin/sh
+
+#
+# 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.
+#
+
+# -----------------------------------------------------------------------------------------------
+# Tests manager daemon
+# -----------------------------------------------------------------------------------------------
+# Script is launched in background by all nodes of Tests cluster and
+# periodically (each 30 seconds) checks if specific S3 trigger file was created or
+# its timestamp was changed. Such an event serve as a trigger for the script to start
+# preparing to run load tests.
+# -----------------------------------------------------------------------------------------------
+
+#profile=/home/ignite/.bash_profile
+profile=/root/.bash_profile
+
+. $profile
+. /opt/ignite-cassandra-tests/bootstrap/aws/common.sh "test"
+
+# Switch test node to IDLE state
+switchToIdleState()
+{
+ if [ "$NODE_STATE" != "IDLE" ]; then
+ echo "[INFO] Switching node to IDLE state"
+ dropStateFlag "$S3_TESTS_WAITING" "$S3_TESTS_PREPARING" "$S3_TESTS_RUNNING"
+ createStateFlag "$S3_TESTS_IDLE"
+ NODE_STATE="IDLE"
+ echo "[INFO] Node was switched to IDLE state"
+ fi
+}
+
+# Switch test node to PREPARING state
+switchToPreparingState()
+{
+ if [ "$NODE_STATE" != "PREPARING" ]; then
+ echo "[INFO] Switching node to PREPARING state"
+ dropStateFlag "$S3_TESTS_WAITING" "$S3_TESTS_IDLE" "$S3_TESTS_RUNNING"
+ createStateFlag "$S3_TESTS_PREPARING"
+ NODE_STATE="PREPARING"
+ echo "[INFO] Node was switched to PREPARING state"
+ fi
+}
+
+# Switch test node to WAITING state
+switchToWaitingState()
+{
+ if [ "$NODE_STATE" != "WAITING" ]; then
+ echo "[INFO] Switching node to WAITING state"
+ dropStateFlag "$S3_TESTS_IDLE" "$S3_TESTS_PREPARING" "$S3_TESTS_RUNNING"
+ createStateFlag "$S3_TESTS_WAITING"
+ NODE_STATE="WAITING"
+ echo "[INFO] Node was switched to WAITING state"
+ fi
+}
+
+# Switch test node to RUNNING state
+switchToRunningState()
+{
+ if [ "$NODE_STATE" != "RUNNING" ]; then
+ echo "[INFO] Switching node to RUNNING state"
+ dropStateFlag "$S3_TESTS_IDLE" "$S3_TESTS_PREPARING" "$S3_TESTS_WAITING"
+ createStateFlag "$S3_TESTS_RUNNING"
+ NODE_STATE="RUNNING"
+ echo "[INFO] Node was switched to RUNNING state"
+ fi
+}
+
+# Creates appropriate state flag for the node in S3
+createStateFlag()
+{
+ HOST_NAME=$(hostname -f | tr '[:upper:]' '[:lower:]')
+
+ aws s3 cp --sse AES256 /etc/hosts ${1}${HOST_NAME}
+ if [ $? -ne 0 ]; then
+ terminate "Failed to create state flag: ${1}${HOST_NAME}"
+ fi
+}
+
+# Drops appropriate state flag for the node in S3
+dropStateFlag()
+{
+ HOST_NAME=$(hostname -f | tr '[:upper:]' '[:lower:]')
+
+ for flagUrl in "$@"
+ do
+ exists=$(aws s3 ls ${flagUrl}${HOST_NAME})
+ if [ -n "$exists" ]; then
+ aws s3 rm ${flagUrl}${HOST_NAME}
+ if [ $? -ne 0 ]; then
+ terminate "Failed to drop state flag: ${flagUrl}${HOST_NAME}"
+ fi
+ fi
+ done
+}
+
+# Removes tests summary report from S3
+dropTestsSummary()
+{
+ exists=$(aws s3 ls $S3_TESTS_SUMMARY)
+ if [ -z "$exists" ]; then
+ return 0
+ fi
+
+ aws s3 rm $S3_TESTS_SUMMARY
+ if [ $? -ne 0 ]; then
+ terminate "Failed to drop tests summary info: $S3_TESTS_SUMMARY"
+ fi
+}
+
+# Recreate all the necessary Cassandra artifacts before running Load tests
+recreateCassandraArtifacts()
+{
+ /opt/ignite-cassandra-tests/recreate-cassandra-artifacts.sh
+ if [ $? -ne 0 ]; then
+ terminate "Failed to recreate Cassandra artifacts"
+ fi
+}
+
+# Setups Cassandra seeds for this Tests node being able to connect to Cassandra.
+# Looks for the information in S3 about already up and running Cassandra cluster nodes.
+setupCassandraSeeds()
+{
+ if [ $CASSANDRA_NODES_COUNT -eq 0 ]; then
+ return 0
+ fi
+
+ setupClusterSeeds "cassandra"
+
+ CASSANDRA_SEEDS1=$(echo $CLUSTER_SEEDS | sed -r "s/ /,/g")
+ CASSANDRA_SEEDS2=
+
+ CLUSTER_SEEDS=($CLUSTER_SEEDS)
+ count=${#CLUSTER_SEEDS[@]}
+
+ for (( i=0; i<=$(( $count -1 )); i++ ))
+ do
+ seed=${CLUSTER_SEEDS[$i]}
+ CASSANDRA_SEEDS2="${CASSANDRA_SEEDS2}<value>$seed<\/value>"
+ done
+
+ echo "[INFO] Using Cassandra seeds: $CASSANDRA_SEEDS1"
+
+ echo "contact.points=$CASSANDRA_SEEDS1" > /opt/ignite-cassandra-tests/settings/org/apache/ignite/tests/cassandra/connection.properties
+
+ cat /opt/ignite-cassandra-tests/bootstrap/aws/tests/ignite-cassandra-client-template.xml | sed -r "s/\\\$\{CASSANDRA_SEEDS\}/$CASSANDRA_SEEDS2/g" > /opt/ignite-cassandra-tests/bootstrap/aws/tests/ignite-cassandra-client-template1.xml
+}
+
+# Setups Ignite nodes for this Tests node being able to connect to Ignite.
+# Looks for the information in S3 about already up and running Cassandra cluster nodes.
+setupIgniteSeeds()
+{
+ if [ $IGNITE_NODES_COUNT -eq 0 ]; then
+ return 0
+ fi
+
+ setupClusterSeeds "ignite"
+
+ CLUSTER_SEEDS=($CLUSTER_SEEDS)
+ count=${#CLUSTER_SEEDS[@]}
+
+ IGNITE_SEEDS=
+
+ for (( i=0; i<=$(( $count -1 )); i++ ))
+ do
+ seed=${CLUSTER_SEEDS[$i]}
+ IGNITE_SEEDS="${IGNITE_SEEDS}<value>$seed<\/value>"
+ done
+
+ echo "[INFO] Using Ignite seeds: $IGNITE_SEEDS"
+
+ cat /opt/ignite-cassandra-tests/bootstrap/aws/tests/ignite-cassandra-client-template1.xml | sed -r "s/\\\$\{IGNITE_SEEDS\}/$IGNITE_SEEDS/g" > /opt/ignite-cassandra-tests/settings/org/apache/ignite/tests/persistence/primitive/ignite-remote-client-config.xml
+ rm -f /opt/ignite-cassandra-tests/bootstrap/aws/tests/ignite-cassandra-client-template1.xml
+}
+
+# Setups Cassandra credentials to connect to Cassandra cluster
+setupCassandraCredentials()
+{
+ echo "admin.user=cassandra" > /opt/ignite-cassandra-tests/settings/org/apache/ignite/tests/cassandra/credentials.properties
+ echo "admin.password=cassandra" >> /opt/ignite-cassandra-tests/settings/org/apache/ignite/tests/cassandra/credentials.properties
+ echo "regular.user=cassandra" >> /opt/ignite-cassandra-tests/settings/org/apache/ignite/tests/cassandra/credentials.properties
+ echo "regular.password=cassandra" >> /opt/ignite-cassandra-tests/settings/org/apache/ignite/tests/cassandra/credentials.properties
+}
+
+# Triggering first time tests execution for all nodes in the Tests cluster
+triggerFirstTimeTestsExecution()
+{
+ if [ -z "$TESTS_TYPE" ]; then
+ return 0
+ fi
+
+ tryToGetFirstNodeLock
+ if [ $? -ne 0 ]; then
+ return 0
+ fi
+
+ sleep 30s
+
+ echo "[INFO] Triggering first time tests execution"
+
+ echo "TESTS_TYPE=$TESTS_TYPE" > /opt/ignite-cassandra-tests/tests-trigger
+ echo "#--------------------------------------------------" >> /opt/ignite-cassandra-tests/tests-trigger
+ echo "" >> /opt/ignite-cassandra-tests/tests-trigger
+ cat /opt/ignite-cassandra-tests/settings/tests.properties >> /opt/ignite-cassandra-tests/tests-trigger
+
+ aws s3 cp --sse AES256 /opt/ignite-cassandra-tests/tests-trigger $S3_TESTS_TRIGGER
+ code=$?
+
+ rm -f /opt/ignite-cassandra-tests/tests-trigger
+
+ if [ $code -ne 0 ]; then
+ terminate "Failed to create tests trigger: $S3_TESTS_TRIGGER"
+ fi
+}
+
+# Cleans previously created logs from S3
+cleanPreviousLogs()
+{
+ for logFile in /opt/ignite-cassandra-tests/logs/*
+ do
+ managerLog=$(echo $logFile | grep "tests-manager")
+ if [ -z "$managerLog" ]; then
+ rm -Rf $logFile
+ fi
+ done
+
+ HOST_NAME=$(hostname -f | tr '[:upper:]' '[:lower:]')
+
+ aws s3 rm --recursive ${S3_TESTS_FAILURE}${HOST_NAME}
+ aws s3 rm --recursive ${S3_TESTS_SUCCESS}${HOST_NAME}
+}
+
+# Uploads tests logs to S3
+uploadTestsLogs()
+{
+ HOST_NAME=$(hostname -f | tr '[:upper:]' '[:lower:]')
+
+ if [ -f "/opt/ignite-cassandra-tests/logs/__success__" ]; then
+ logsFolder=${S3_TESTS_SUCCESS}${HOST_NAME}
+ else
+ logsFolder=${S3_TESTS_FAILURE}${HOST_NAME}
+ fi
+
+ aws s3 rm --recursive $logsFolder
+ if [ $? -ne 0 ]; then
+ echo "[ERROR] Failed to drop logs folder: $logsFolder"
+ fi
+
+ if [ -d "/opt/ignite-cassandra-tests/logs" ]; then
+ aws s3 sync --sse AES256 /opt/ignite-cassandra-tests/logs $logsFolder
+ if [ $? -ne 0 ]; then
+ echo "[ERROR] Failed to export tests logs to: $logsFolder"
+ fi
+ fi
+}
+
+# Runs tests-report.sh to prepare tests summary report
+buildTestsSummaryReport()
+{
+ reportScript=$(readlink -m $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/tests-report.sh)
+ $reportScript
+
+ if [ -n "$S3_LOGS_TRIGGER" ]; then
+ aws s3 cp --sse AES256 /etc/hosts $S3_LOGS_TRIGGER
+ if [ $? -ne 0 ]; then
+ echo "[ERROR] Failed to trigger logs collection"
+ fi
+ fi
+}
+
+# Running load tests
+runLoadTests()
+{
+ cd /opt/ignite-cassandra-tests
+
+ if [ "$TESTS_TYPE" == "ignite" ]; then
+ echo "[INFO] Running Ignite load tests"
+ ./ignite-load-tests.sh &
+ else
+ echo "[INFO] Running Cassandra load tests"
+ ./cassandra-load-tests.sh &
+ fi
+
+ testsJobId=$!
+
+ echo "[INFO] Tests job id: $testsJobId"
+
+ sleep 1m
+
+ LOGS_SNAPSHOT=$(ls -al /opt/ignite-cassandra-tests/logs)
+ LOGS_SNAPSHOT_TIME=$(date +%s)
+
+ TERMINATED=
+
+ # tests monitoring
+ while true; do
+ proc=$(ps -ef | grep java | grep "org.apache.ignite.tests")
+ if [ -z "$proc" ]; then
+ break
+ fi
+
+ NEW_LOGS_SNAPSHOT=$(ls -al /opt/ignite-cassandra-tests/logs)
+ NEW_LOGS_SNAPSHOT_TIME=$(date +%s)
+
+ # if logs state updated it means that tests are running and not stuck
+ if [ "$LOGS_SNAPSHOT" != "$NEW_LOGS_SNAPSHOT" ]; then
+ LOGS_SNAPSHOT=$NEW_LOGS_SNAPSHOT
+ LOGS_SNAPSHOT_TIME=$NEW_LOGS_SNAPSHOT_TIME
+ continue
+ fi
+
+ duration=$(( $NEW_LOGS_SNAPSHOT_TIME-$LOGS_SNAPSHOT_TIME ))
+ duration=$(( $duration/60 ))
+
+ # if logs wasn't updated during 5min it means that load tests stuck
+ if [ $duration -gt 5 ]; then
+ proc=($proc)
+ kill -9 ${proc[1]}
+ TERMINATED="true"
+ break
+ fi
+
+ echo "[INFO] Waiting extra 30sec for load tests to complete"
+
+ sleep 30s
+ done
+
+ rm -f /opt/ignite-cassandra-tests/logs/tests.properties
+ cp /opt/ignite-cassandra-tests/settings/tests.properties /opt/ignite-cassandra-tests/logs
+
+ if [ "$TERMINATED" == "true" ]; then
+ echo "[ERROR] Load tests stuck, tests process terminated"
+ echo "Load tests stuck, tests process terminated" > /opt/ignite-cassandra-tests/logs/__error__
+ return 0
+ fi
+
+ failed=
+ if [ "$TESTS_TYPE" == "cassandra" ]; then
+ failed=$(cat /opt/ignite-cassandra-tests/cassandra-load-tests.log | grep "load tests execution failed")
+ else
+ failed=$(cat /opt/ignite-cassandra-tests/ignite-load-tests.log | grep "load tests execution failed")
+ fi
+
+ if [ -n "$failed" ]; then
+ echo "[ERROR] Load tests execution failed"
+ echo "Load tests execution failed" > /opt/ignite-cassandra-tests/logs/__error__
+ else
+ echo "[INFO] Load tests execution successfully completed"
+ echo "Load tests execution successfully completed" > /opt/ignite-cassandra-tests/logs/__success__
+ fi
+}
+
+#######################################################################################################
+
+sleep 1m
+
+NODE_STATE=
+TRIGGER_STATE=
+
+printInstanceInfo
+setupCassandraCredentials
+switchToIdleState
+
+triggerFirstTimeTestsExecution
+
+registerNode
+
+while true; do
+ # switching state to IDLE
+ switchToIdleState
+
+ sleep 30s
+
+ NEW_TRIGGER_STATE=$(aws s3 ls $S3_TESTS_TRIGGER | xargs)
+ if [ -z "$NEW_TRIGGER_STATE" ] || [ "$NEW_TRIGGER_STATE" == "$TRIGGER_STATE" ]; then
+ continue
+ fi
+
+ echo "----------------------------------------------------------------------"
+ echo "[INFO] Tests trigger changed"
+ echo "----------------------------------------------------------------------"
+ echo "[INFO] Old trigger: $TRIGGER_STATE"
+ echo "----------------------------------------------------------------------"
+ echo "[INFO] New trigger: $NEW_TRIGGER_STATE"
+ echo "----------------------------------------------------------------------"
+
+ TRIGGER_STATE=$NEW_TRIGGER_STATE
+
+ aws s3 cp $S3_TESTS_TRIGGER /opt/ignite-cassandra-tests/tests-trigger
+ if [ $? -ne 0 ]; then
+ echo "[ERROR] Failed to download tests trigger info from: $S3_TESTS_TRIGGER"
+ continue
+ fi
+
+ TESTS_TYPE=$(cat /opt/ignite-cassandra-tests/tests-trigger | grep TESTS_TYPE | xargs | sed -r "s/TESTS_TYPE=//g")
+ if [ "$TESTS_TYPE" != "ignite" ] && [ "$TESTS_TYPE" != "cassandra" ]; then
+ rm -f /opt/ignite-cassandra-tests/tests-trigger
+ echo "[ERROR] Incorrect tests type specified in the trigger info: $S3_TESTS_TRIGGER"
+ continue
+ fi
+
+ rm -f /opt/ignite-cassandra-tests/settings/tests.properties
+ mv -f /opt/ignite-cassandra-tests/tests-trigger /opt/ignite-cassandra-tests/settings/tests.properties
+
+ waitAllTestNodesCompletedTests
+
+ # switching state to PREPARING
+ switchToPreparingState
+
+ waitAllClusterNodesReady "cassandra"
+ waitAllClusterNodesReady "ignite"
+ setupCassandraSeeds
+ setupIgniteSeeds
+
+ cleanPreviousLogs
+
+ tryToGetFirstNodeLock
+ if [ $? -eq 0 ]; then
+ dropTestsSummary
+ recreateCassandraArtifacts
+ fi
+
+ # switching state to WAITING
+ switchToWaitingState
+
+ waitAllClusterNodesReady "test"
+
+ if [ "$FIRST_NODE_LOCK" == "true" ]; then
+ aws s3 rm $S3_TESTS_TRIGGER
+ fi
+
+ # switching state to RUNNING
+ switchToRunningState
+
+ runLoadTests
+ uploadTestsLogs
+
+ tryToGetFirstNodeLock
+ if [ $? -eq 0 ]; then
+ waitAllTestNodesCompletedTests
+ buildTestsSummaryReport
+ removeFirstNodeLock
+ fi
+done
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee8ac73f/modules/cassandra/src/test/bootstrap/aws/tests/tests-report.sh
----------------------------------------------------------------------
diff --git a/modules/cassandra/src/test/bootstrap/aws/tests/tests-report.sh b/modules/cassandra/src/test/bootstrap/aws/tests/tests-report.sh
index 762dc6f..1576d57 100644
--- a/modules/cassandra/src/test/bootstrap/aws/tests/tests-report.sh
+++ b/modules/cassandra/src/test/bootstrap/aws/tests/tests-report.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
#
# Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,118 +17,20 @@
# limitations under the License.
#
+# -----------------------------------------------------------------------------------------------
+# Tests report builder
+# -----------------------------------------------------------------------------------------------
+# Script is used to analyze load tests logs collected from all 'Tests' cluster nodes and build
+# summary report
+# -----------------------------------------------------------------------------------------------
+
#profile=/home/ignite/.bash_profile
profile=/root/.bash_profile
. $profile
+. /opt/ignite-cassandra-tests/bootstrap/aws/common.sh "test"
-validate()
-{
- if [ -z "$TESTS_TYPE" ]; then
- terminate "Tests type 'ignite' or 'cassandra' should be specified"
- fi
-
- if [ "$TESTS_TYPE" != "ignite" ] && [ "$TESTS_TYPE" != "cassandra" ]; then
- terminate "Incorrect tests type specified: $TESTS_TYPE"
- fi
-
- if [ -z "$S3_TESTS_SUCCESS_URL" ]; then
- terminate "Tests success URL doesn't specified"
- fi
-
- if [[ "$S3_TESTS_SUCCESS_URL" != */ ]]; then
- S3_TESTS_SUCCESS_URL=${S3_TESTS_SUCCESS_URL}/
- fi
-
- if [ -z "$S3_TESTS_FAILURE_URL" ]; then
- terminate "Tests failure URL doesn't specified"
- fi
-
- if [[ "$S3_TESTS_FAILURE_URL" != */ ]]; then
- S3_TESTS_FAILURE_URL=${S3_TESTS_FAILURE_URL}/
- fi
-
- if [ -z "$S3_TESTS_RUNNING_URL" ]; then
- terminate "Tests running URL doesn't specified"
- fi
-
- if [[ "$S3_TESTS_RUNNING_URL" != */ ]]; then
- S3_TESTS_RUNNING_URL=${S3_TESTS_RUNNING_URL}/
- fi
-
- if [ -z "$S3_TESTS_WAITING_URL" ]; then
- terminate "Tests waiting URL doesn't specified"
- fi
-
- if [[ "$S3_TESTS_WAITING_URL" != */ ]]; then
- S3_TESTS_WAITING_URL=${S3_TESTS_WAITING_URL}/
- fi
-
- if [ -z "$S3_IGNITE_SUCCESS_URL" ]; then
- terminate "Ignite success URL doesn't specified"
- fi
-
- if [[ "$S3_IGNITE_SUCCESS_URL" != */ ]]; then
- S3_IGNITE_SUCCESS_URL=${S3_IGNITE_SUCCESS_URL}/
- fi
-
- if [ -z "$S3_IGNITE_FAILURE_URL" ]; then
- terminate "Ignite failure URL doesn't specified"
- fi
-
- if [[ "$S3_IGNITE_FAILURE_URL" != */ ]]; then
- S3_IGNITE_FAILURE_URL=${S3_IGNITE_FAILURE_URL}/
- fi
-
- if [ -z "$S3_CASSANDRA_SUCCESS_URL" ]; then
- terminate "Cassandra success URL doesn't specified"
- fi
-
- if [[ "$S3_CASSANDRA_SUCCESS_URL" != */ ]]; then
- S3_CASSANDRA_SUCCESS_URL=${S3_CASSANDRA_SUCCESS_URL}/
- fi
-
- if [ -z "$S3_CASSANDRA_FAILURE_URL" ]; then
- terminate "Cassandra failure URL doesn't specified"
- fi
-
- if [[ "$S3_CASSANDRA_FAILURE_URL" != */ ]]; then
- S3_CASSANDRA_FAILURE_URL=${S3_CASSANDRA_FAILURE_URL}/
- fi
-
- if [ -z "$S3_TEST_NODES_DISCOVERY_URL" ]; then
- terminate "Tests S3 discovery URL doesn't specified"
- fi
-
- if [[ "$S3_TEST_NODES_DISCOVERY_URL" != */ ]]; then
- S3_TEST_NODES_DISCOVERY_URL=${S3_TEST_NODES_DISCOVERY_URL}/
- fi
-
- if [ -z "$S3_CASSANDRA_NODES_DISCOVERY_URL" ]; then
- terminate "Cassandra S3 discovery URL doesn't specified"
- fi
-
- if [[ "$S3_CASSANDRA_NODES_DISCOVERY_URL" != */ ]]; then
- S3_CASSANDRA_NODES_DISCOVERY_URL=${S3_CASSANDRA_NODES_DISCOVERY_URL}/
- fi
-
- if [ -z "$S3_IGNITE_NODES_DISCOVERY_URL" ]; then
- terminate "Ignite S3 discovery URL doesn't specified"
- fi
-
- if [[ "$S3_CASSANDRA_NODES_DISCOVERY_URL" != */ ]]; then
- S3_CASSANDRA_NODES_DISCOVERY_URL=${S3_CASSANDRA_NODES_DISCOVERY_URL}/
- fi
-
- if [ -z "$S3_IGNITE_NODES_DISCOVERY_URL" ]; then
- terminate "Ignite S3 discovery URL doesn't specified"
- fi
-
- if [[ "$S3_IGNITE_NODES_DISCOVERY_URL" != */ ]]; then
- S3_IGNITE_NODES_DISCOVERY_URL=${S3_IGNITE_NODES_DISCOVERY_URL}/
- fi
-}
-
+# Building tests summary report
reportTestsSummary()
{
echo "[INFO] Preparing tests results summary"
@@ -145,8 +47,8 @@ reportTestsSummary()
mkdir -p $SUCCEED_NODES_DIR
mkdir -p $FAILED_NODES_DIR
- aws s3 ls $S3_TESTS_SUCCESS_URL | sed -r "s/PRE //g" | sed -r "s/ //g" | sed -r "s/\///g" > $SUCCEED_NODES_FILE
- aws s3 ls $S3_TESTS_FAILURE_URL | sed -r "s/PRE //g" | sed -r "s/ //g" | sed -r "s/\///g" > $FAILED_NODES_FILE
+ aws s3 ls $S3_TESTS_SUCCESS | sed -r "s/PRE //g" | sed -r "s/ //g" | sed -r "s/\///g" > $SUCCEED_NODES_FILE
+ aws s3 ls $S3_TESTS_FAILURE | sed -r "s/PRE //g" | sed -r "s/ //g" | sed -r "s/\///g" > $FAILED_NODES_FILE
succeedCount=$(cat $SUCCEED_NODES_FILE | wc -l)
failedCount=$(cat $FAILED_NODES_FILE | wc -l)
@@ -164,7 +66,7 @@ reportTestsSummary()
cat $SUCCEED_NODES_FILE >> $REPORT_FILE
echo "----------------------------------------------------------------------------------------------" >> $REPORT_FILE
- aws s3 sync --delete $S3_TESTS_SUCCESS_URL $SUCCEED_NODES_DIR
+ aws s3 sync --delete $S3_TESTS_SUCCESS $SUCCEED_NODES_DIR
if [ $? -ne 0 ]; then
echo "[ERROR] Failed to get succeed tests details"
else
@@ -178,7 +80,7 @@ reportTestsSummary()
cat $FAILED_NODES_FILE >> $REPORT_FILE
echo "----------------------------------------------------------------------------------------------" >> $REPORT_FILE
- aws sync --delete $S3_TESTS_FAILURE_URL $FAILED_NODES_DIR
+ aws sync --delete $S3_TESTS_FAILURE $FAILED_NODES_DIR
if [ $? -ne 0 ]; then
echo "[ERROR] Failed to get failed tests details"
else
@@ -204,34 +106,35 @@ reportTestsSummary()
return 1
fi
- aws s3 cp --sse AES256 $HOME/tests-summary.zip $S3_TESTS_SUMMARY_URL
+ aws s3 cp --sse AES256 $HOME/tests-summary.zip $S3_TESTS_SUMMARY
if [ $? -ne 0 ]; then
echo "-------------------------------------------------------------------------------------"
- echo "[ERROR] Failed to uploat tests summary archive to: $S3_TESTS_SUMMARY_URL"
+ echo "[ERROR] Failed to uploat tests summary archive to: $S3_TESTS_SUMMARY"
echo "-------------------------------------------------------------------------------------"
else
echo "-------------------------------------------------------------------------------------"
- echo "[INFO] Tests results summary uploaded to: $S3_TESTS_SUMMARY_URL"
+ echo "[INFO] Tests results summary uploaded to: $S3_TESTS_SUMMARY"
echo "-------------------------------------------------------------------------------------"
fi
rm -f $HOME/tests-summary.zip
}
+# Creates report for succeed tests
reportSucceedTestsStatistics()
{
- writeMsg=0
- writeErrors=0
- writeSpeed=0
- blkWriteMsg=0
- blkWriteErrors=0
- blkWriteSpeed=0
- readMsg=0
- readErrors=0
- readSpeed=0
- blkReadMsg=0
- blkReadErrors=0
- blkReadSpeed=0
+ writeMsg="0"
+ writeErrors="0"
+ writeSpeed="0"
+ blkWriteMsg="0"
+ blkWriteErrors="0"
+ blkWriteSpeed="0"
+ readMsg="0"
+ readErrors="0"
+ readSpeed="0"
+ blkReadMsg="0"
+ blkReadErrors="0"
+ blkReadSpeed="0"
writeErrNodes=
blkWriteErrNodes=
@@ -271,7 +174,7 @@ reportSucceedTestsStatistics()
cnt=$(cat $logFile | grep "^WRITE messages" | sed -r "s/WRITE messages: //g" | xargs)
if [ -n "$cnt" ]; then
- writeMsg=$(( $writeMsg+$cnt ))
+ writeMsg=$(bc <<< "$writeMsg + $cnt")
if [ $cnt -ne 0 ]; then
echo "[INFO] WRITE messages: $cnt"
else
@@ -292,7 +195,7 @@ reportSucceedTestsStatistics()
cnt=$(cat $logFile | grep "^WRITE errors" | sed -r "s/WRITE errors: //g" | sed -r "s/,.*//g" | xargs)
if [ -n "$cnt" ]; then
echo "[INFO] WRITE errors: $cnt"
- writeErrors=$(( $writeErrors+$cnt ))
+ writeErrors=$(bc <<< "$writeErrors + $cnt")
if [ $cnt -ne 0 ]; then
if [ -n "$writeErrNodes" ]; then
writeErrNodes="${writeErrNodes}, "
@@ -309,7 +212,7 @@ reportSucceedTestsStatistics()
cnt=$(cat $logFile | grep "^WRITE speed" | sed -r "s/WRITE speed: //g" | sed -r "s/ msg\/sec//g" | xargs)
if [ -n "$cnt" ]; then
- writeSpeed=$(( $writeSpeed+$cnt ))
+ writeSpeed=$(bc <<< "$writeSpeed + $cnt")
if [ $cnt -ne 0 ]; then
echo "[INFO] WRITE speed: $cnt msg/sec"
else
@@ -329,7 +232,7 @@ reportSucceedTestsStatistics()
cnt=$(cat $logFile | grep "^BULK_WRITE messages" | sed -r "s/BULK_WRITE messages: //g" | xargs)
if [ -n "$cnt" ]; then
- blkWriteMsg=$(( $blkWriteMsg+$cnt ))
+ blkWriteMsg=$(bc <<< "$blkWriteMsg + $cnt")
if [ $cnt -ne 0 ]; then
echo "[INFO] BULK_WRITE messages: $cnt"
else
@@ -349,7 +252,7 @@ reportSucceedTestsStatistics()
cnt=$(cat $logFile | grep "^BULK_WRITE errors" | sed -r "s/BULK_WRITE errors: //g" | sed -r "s/,.*//g" | xargs)
if [ -n "$cnt" ]; then
- blkWriteErrors=$(( $blkWriteErrors+$cnt ))
+ blkWriteErrors=$(bc <<< "$blkWriteErrors + $cnt")
echo "[INFO] BULK_WRITE errors: $cnt"
if [ $cnt -ne 0 ]; then
if [ -n "$blkWriteErrNodes" ]; then
@@ -367,7 +270,7 @@ reportSucceedTestsStatistics()
cnt=$(cat $logFile | grep "^BULK_WRITE speed" | sed -r "s/BULK_WRITE speed: //g" | sed -r "s/ msg\/sec//g" | xargs)
if [ -n "$cnt" ]; then
- blkWriteSpeed=$(( $blkWriteSpeed+$cnt ))
+ blkWriteSpeed=$(bc <<< "$blkWriteSpeed + $cnt")
if [ $cnt -ne 0 ]; then
echo "[INFO] BULK_WRITE speed: $cnt msg/sec"
else
@@ -387,7 +290,7 @@ reportSucceedTestsStatistics()
cnt=$(cat $logFile | grep "^READ messages" | sed -r "s/READ messages: //g" | xargs)
if [ -n "$cnt" ]; then
- readMsg=$(( $readMsg+$cnt ))
+ readMsg=$(bc <<< "$readMsg + $cnt")
if [ $cnt -ne 0 ]; then
echo "[INFO] READ messages: $cnt"
else
@@ -407,7 +310,7 @@ reportSucceedTestsStatistics()
cnt=$(cat $logFile | grep "^READ errors" | sed -r "s/READ errors: //g" | sed -r "s/,.*//g" | xargs)
if [ -n "$cnt" ]; then
- readErrors=$(( $readErrors+$cnt ))
+ readErrors=$(bc <<< "$readErrors + $cnt")
echo "[INFO] READ errors: $cnt"
if [ $cnt -ne 0 ]; then
if [ -n "$readErrNodes" ]; then
@@ -425,7 +328,7 @@ reportSucceedTestsStatistics()
cnt=$(cat $logFile | grep "^READ speed" | sed -r "s/READ speed: //g" | sed -r "s/ msg\/sec//g" | xargs)
if [ -n "$cnt" ]; then
- readSpeed=$(( $readSpeed+$cnt ))
+ readSpeed=$(bc <<< "$readSpeed + $cnt")
if [ $cnt -ne 0 ]; then
echo "[INFO] READ speed: $cnt msg/sec"
else
@@ -445,7 +348,7 @@ reportSucceedTestsStatistics()
cnt=$(cat $logFile | grep "^BULK_READ messages" | sed -r "s/BULK_READ messages: //g" | xargs)
if [ -n "$cnt" ]; then
- blkReadMsg=$(( $blkReadMsg+$cnt ))
+ blkReadMsg=$(bc <<< "$blkReadMsg + $cnt")
if [ $cnt -ne 0 ]; then
echo "[INFO] BULK_READ messages: $cnt"
else
@@ -465,7 +368,7 @@ reportSucceedTestsStatistics()
cnt=$(cat $logFile | grep "^BULK_READ errors" | sed -r "s/BULK_READ errors: //g" | sed -r "s/,.*//g" | xargs)
if [ -n "$cnt" ]; then
- blkReadErrors=$(( $blkReadErrors+$cnt ))
+ blkReadErrors=$(bc <<< "$blkReadErrors + $cnt")
echo "[INFO] BULK_READ errors: $cnt"
if [ $cnt -ne 0 ]; then
if [ -n "$blkReadErrNodes" ]; then
@@ -483,7 +386,7 @@ reportSucceedTestsStatistics()
cnt=$(cat $logFile | grep "^BULK_READ speed" | sed -r "s/BULK_READ speed: //g" | sed -r "s/ msg\/sec//g" | xargs)
if [ -n "$cnt" ]; then
- blkReadSpeed=$(( $blkReadSpeed+$cnt ))
+ blkReadSpeed=$(bc <<< "$blkReadSpeed + $cnt")
if [ $cnt -ne 0 ]; then
echo "[INFO] BULK_READ speed: $cnt msg/sec"
else
@@ -565,6 +468,7 @@ reportSucceedTestsStatistics()
rm -f $tmpFile
}
+# Creates report for failed tests
reportFailedTestsDetailes()
{
for dir in $2/*
@@ -586,5 +490,10 @@ reportFailedTestsDetailes()
done
}
-validate
+#######################################################################################################
+
+if [ "$TESTS_TYPE" != "ignite" ] && [ "$TESTS_TYPE" != "cassandra" ]; then
+ terminate "Incorrect tests type specified: $TESTS_TYPE"
+fi
+
reportTestsSummary
\ No newline at end of file
[3/4] ignite git commit: IGNITE-3293 AWS bootstrap scripts patch for
Ignite-Cassandra - Fixes #794.
Posted by ak...@apache.org.
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee8ac73f/modules/cassandra/src/test/bootstrap/aws/common.sh
----------------------------------------------------------------------
diff --git a/modules/cassandra/src/test/bootstrap/aws/common.sh b/modules/cassandra/src/test/bootstrap/aws/common.sh
new file mode 100644
index 0000000..6469e95
--- /dev/null
+++ b/modules/cassandra/src/test/bootstrap/aws/common.sh
@@ -0,0 +1,1481 @@
+#!/bin/sh
+
+#
+# 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.
+#
+
+# -----------------------------------------------------------------------------------------------
+# Common purpose functions used by bootstrap scripts
+# -----------------------------------------------------------------------------------------------
+
+# Validates values of the main environment variables specified in env.sh
+validate()
+{
+ if [ -n "$TESTS_TYPE" ] && [ "$TESTS_TYPE" != "ignite" ] && [ "$TESTS_TYPE" != "cassandra" ]; then
+ terminate "Incorrect tests type specified: $TESTS_TYPE"
+ fi
+
+ if [ -z "$S3_TESTS_NODES_DISCOVERY" ]; then
+ terminate "Tests discovery URL doesn't specified"
+ fi
+
+ if [[ "$S3_TESTS_NODES_DISCOVERY" != */ ]]; then
+ S3_TESTS_NODES_DISCOVERY=${S3_TESTS_NODES_DISCOVERY}/
+ fi
+
+ if [ -z "$S3_TESTS_SUCCESS" ]; then
+ terminate "Tests success URL doesn't specified"
+ fi
+
+ if [[ "$S3_TESTS_SUCCESS" != */ ]]; then
+ S3_TESTS_SUCCESS=${S3_TESTS_SUCCESS}/
+ fi
+
+ if [ -z "$S3_TESTS_FAILURE" ]; then
+ terminate "Tests failure URL doesn't specified"
+ fi
+
+ if [[ "$S3_TESTS_FAILURE" != */ ]]; then
+ S3_TESTS_FAILURE=${S3_TESTS_FAILURE}/
+ fi
+
+ if [ -z "$S3_TESTS_IDLE" ]; then
+ terminate "Tests idle URL doesn't specified"
+ fi
+
+ if [[ "$S3_TESTS_IDLE" != */ ]]; then
+ S3_TESTS_IDLE=${S3_TESTS_IDLE}/
+ fi
+
+ if [ -z "$S3_TESTS_PREPARING" ]; then
+ terminate "Tests preparing URL doesn't specified"
+ fi
+
+ if [[ "$S3_TESTS_PREPARING" != */ ]]; then
+ S3_TESTS_PREPARING=${S3_TESTS_PREPARING}/
+ fi
+
+ if [ -z "$S3_TESTS_RUNNING" ]; then
+ terminate "Tests running URL doesn't specified"
+ fi
+
+ if [[ "$S3_TESTS_RUNNING" != */ ]]; then
+ S3_TESTS_RUNNING=${S3_TESTS_RUNNING}/
+ fi
+
+ if [ -z "$S3_TESTS_WAITING" ]; then
+ terminate "Tests waiting URL doesn't specified"
+ fi
+
+ if [[ "$S3_TESTS_WAITING" != */ ]]; then
+ S3_TESTS_WAITING=${S3_TESTS_WAITING}/
+ fi
+
+ if [ -z "$S3_IGNITE_NODES_DISCOVERY" ]; then
+ terminate "Ignite discovery URL doesn't specified"
+ fi
+
+ if [[ "$S3_IGNITE_NODES_DISCOVERY" != */ ]]; then
+ S3_IGNITE_NODES_DISCOVERY=${S3_IGNITE_NODES_DISCOVERY}/
+ fi
+
+ if [ -z "$S3_IGNITE_BOOTSTRAP_SUCCESS" ]; then
+ terminate "Ignite success URL doesn't specified"
+ fi
+
+ if [[ "$S3_IGNITE_BOOTSTRAP_SUCCESS" != */ ]]; then
+ S3_IGNITE_BOOTSTRAP_SUCCESS=${S3_IGNITE_BOOTSTRAP_SUCCESS}/
+ fi
+
+ if [ -z "$S3_IGNITE_BOOTSTRAP_FAILURE" ]; then
+ terminate "Ignite failure URL doesn't specified"
+ fi
+
+ if [[ "$S3_IGNITE_BOOTSTRAP_FAILURE" != */ ]]; then
+ S3_IGNITE_BOOTSTRAP_FAILURE=${S3_IGNITE_BOOTSTRAP_FAILURE}/
+ fi
+
+ if [ -z "$S3_CASSANDRA_NODES_DISCOVERY" ]; then
+ terminate "Cassandra discovery URL doesn't specified"
+ fi
+
+ if [[ "$S3_CASSANDRA_NODES_DISCOVERY" != */ ]]; then
+ S3_CASSANDRA_NODES_DISCOVERY=${S3_CASSANDRA_NODES_DISCOVERY}/
+ fi
+
+ if [ -z "$S3_CASSANDRA_BOOTSTRAP_SUCCESS" ]; then
+ terminate "Cassandra success URL doesn't specified"
+ fi
+
+ if [[ "$S3_CASSANDRA_BOOTSTRAP_SUCCESS" != */ ]]; then
+ S3_CASSANDRA_BOOTSTRAP_SUCCESS=${S3_CASSANDRA_BOOTSTRAP_SUCCESS}/
+ fi
+
+ if [ -z "$S3_CASSANDRA_BOOTSTRAP_FAILURE" ]; then
+ terminate "Cassandra failure URL doesn't specified"
+ fi
+
+ if [[ "$S3_CASSANDRA_BOOTSTRAP_FAILURE" != */ ]]; then
+ S3_CASSANDRA_BOOTSTRAP_FAILURE=${S3_CASSANDRA_BOOTSTRAP_FAILURE}/
+ fi
+
+ if [ -z "$S3_GANGLIA_MASTER_DISCOVERY" ]; then
+ terminate "Ganglia master discovery URL doesn't specified"
+ fi
+
+ if [[ "$S3_GANGLIA_MASTER_DISCOVERY" != */ ]]; then
+ S3_GANGLIA_MASTER_DISCOVERY=${S3_GANGLIA_MASTER_DISCOVERY}/
+ fi
+
+ if [ -z "$S3_GANGLIA_BOOTSTRAP_SUCCESS" ]; then
+ terminate "Ganglia master success URL doesn't specified"
+ fi
+
+ if [[ "$S3_GANGLIA_BOOTSTRAP_SUCCESS" != */ ]]; then
+ S3_GANGLIA_BOOTSTRAP_SUCCESS=${S3_GANGLIA_BOOTSTRAP_SUCCESS}/
+ fi
+
+ if [ -z "$S3_GANGLIA_BOOTSTRAP_FAILURE" ]; then
+ terminate "Ganglia master failure URL doesn't specified"
+ fi
+
+ if [[ "$S3_GANGLIA_BOOTSTRAP_FAILURE" != */ ]]; then
+ S3_GANGLIA_BOOTSTRAP_FAILURE=${S3_GANGLIA_BOOTSTRAP_FAILURE}/
+ fi
+}
+
+# Prints EC2 instance info
+printInstanceInfo()
+{
+ if [ "$NODE_TYPE" == "cassandra" ]; then
+ echo "[INFO] Cassandra download URL: $CASSANDRA_DOWNLOAD_URL"
+ echo "[INFO] Tests package download URL: $TESTS_PACKAGE_DONLOAD_URL"
+ echo "[INFO] Ganglia Core download URL: $GANGLIA_CORE_DOWNLOAD_URL"
+ echo "[INFO] Ganglia Web download URL: $GANGLIA_WEB_DOWNLOAD_URL"
+ echo "[INFO] RRD download URL: $RRD_DOWNLOAD_URL"
+ echo "[INFO] Logs URL: $S3_CASSANDRA_LOGS"
+ echo "[INFO] Logs trigger URL: $S3_LOGS_TRIGGER"
+ echo "[INFO] Cassandra nodes discovery URL: $S3_CASSANDRA_NODES_DISCOVERY"
+ echo "[INFO] Ganglia master discovery URL: $S3_GANGLIA_MASTER_DISCOVERY"
+ echo "[INFO] Cassandra first node lock URL: $S3_CASSANDRA_FIRST_NODE_LOCK"
+ echo "[INFO] Cassandra nodes join lock URL: $S3_CASSANDRA_NODES_JOIN_LOCK"
+ echo "[INFO] Cassandra success URL: $S3_CASSANDRA_BOOTSTRAP_SUCCESS"
+ echo "[INFO] Cassandra failure URL: $S3_CASSANDRA_BOOTSTRAP_FAILURE"
+ fi
+
+ if [ "$NODE_TYPE" == "ignite" ]; then
+ echo "[INFO] Ignite download URL: $IGNITE_DOWNLOAD_URL"
+ echo "[INFO] Tests package download URL: $TESTS_PACKAGE_DONLOAD_URL"
+ echo "[INFO] Ganglia Core download URL: $GANGLIA_CORE_DOWNLOAD_URL"
+ echo "[INFO] Ganglia Web download URL: $GANGLIA_WEB_DOWNLOAD_URL"
+ echo "[INFO] RRD download URL: $RRD_DOWNLOAD_URL"
+ echo "[INFO] Logs URL: $S3_IGNITE_LOGS"
+ echo "[INFO] Logs trigger URL: $S3_LOGS_TRIGGER"
+ echo "[INFO] Ignite node discovery URL: $S3_IGNITE_NODES_DISCOVERY"
+ echo "[INFO] Cassandra node discovery URL: $S3_CASSANDRA_NODES_DISCOVERY"
+ echo "[INFO] Ganglia master discovery URL: $S3_GANGLIA_MASTER_DISCOVERY"
+ echo "[INFO] Ignite first node lock URL: $S3_IGNITE_FIRST_NODE_LOCK"
+ echo "[INFO] Ignite nodes join lock URL: $S3_IGNITE_NODES_JOIN_LOCK"
+ echo "[INFO] Ignite success URL: $S3_IGNITE_BOOTSTRAP_SUCCESS"
+ echo "[INFO] Ignite failure URL: $S3_IGNITE_BOOTSTRAP_FAILURE"
+ fi
+
+ if [ "$NODE_TYPE" == "test" ]; then
+ echo "[INFO] Tests type: $TESTS_TYPE"
+ echo "[INFO] Test nodes count: $TEST_NODES_COUNT"
+ echo "[INFO] Ignite nodes count: $IGNITE_NODES_COUNT"
+ echo "[INFO] Cassandra nodes count: $CASSANDRA_NODES_COUNT"
+ echo "[INFO] Tests summary URL: $S3_TESTS_SUMMARY"
+ echo "[INFO] ----------------------------------------------------"
+ echo "[INFO] Tests package download URL: $TESTS_PACKAGE_DONLOAD_URL"
+ echo "[INFO] Ganglia Core download URL: $GANGLIA_CORE_DOWNLOAD_URL"
+ echo "[INFO] Ganglia Web download URL: $GANGLIA_WEB_DOWNLOAD_URL"
+ echo "[INFO] RRD download URL: $RRD_DOWNLOAD_URL"
+ echo "[INFO] Logs URL: $S3_TESTS_LOGS"
+ echo "[INFO] Logs trigger URL: $S3_LOGS_TRIGGER"
+ echo "[INFO] Test node discovery URL: $S3_TESTS_NODES_DISCOVERY"
+ echo "[INFO] Ignite node discovery URL: $S3_IGNITE_NODES_DISCOVERY"
+ echo "[INFO] Cassandra node discovery URL: $S3_CASSANDRA_NODES_DISCOVERY"
+ echo "[INFO] Ganglia master discovery URL: $S3_GANGLIA_MASTER_DISCOVERY"
+ echo "[INFO] Tests trigger URL: $S3_TESTS_TRIGGER"
+ echo "[INFO] Tests idle URL: $S3_TESTS_IDLE"
+ echo "[INFO] Tests preparing URL: $S3_TESTS_PREPARING"
+ echo "[INFO] Tests waiting URL: $S3_TESTS_WAITING"
+ echo "[INFO] Tests running URL: $S3_TESTS_RUNNING"
+ echo "[INFO] Tests success URL: $S3_TESTS_SUCCESS"
+ echo "[INFO] Tests failure URL: $S3_TESTS_FAILURE"
+ echo "[INFO] Ignite success URL: $S3_IGNITE_BOOTSTRAP_SUCCESS"
+ echo "[INFO] Ignite failure URL: $S3_IGNITE_BOOTSTRAP_FAILURE"
+ echo "[INFO] Cassandra success URL: $S3_CASSANDRA_BOOTSTRAP_SUCCESS"
+ echo "[INFO] Cassandra failure URL: $S3_CASSANDRA_BOOTSTRAP_FAILURE"
+ fi
+
+ if [ "$NODE_TYPE" == "ganglia" ]; then
+ echo "[INFO] Ganglia Core download URL: $GANGLIA_CORE_DOWNLOAD_URL"
+ echo "[INFO] Ganglia Web download URL: $GANGLIA_WEB_DOWNLOAD_URL"
+ echo "[INFO] RRD download URL: $RRD_DOWNLOAD_URL"
+ echo "[INFO] Tests package download URL: $TESTS_PACKAGE_DONLOAD_URL"
+ echo "[INFO] Logs URL: $S3_GANGLIA_LOGS"
+ echo "[INFO] Logs trigger URL: $S3_LOGS_TRIGGER"
+ echo "[INFO] Ganglia master discovery URL: $S3_GANGLIA_MASTER_DISCOVERY"
+ echo "[INFO] Ganglia success URL: $S3_GANGLIA_BOOTSTRAP_SUCCESS"
+ echo "[INFO] Ganglia failure URL: $S3_GANGLIA_BOOTSTRAP_FAILURE"
+ fi
+}
+
+# Clone git repository
+gitClone()
+{
+ echo "[INFO] Cloning git repository $1 to $2"
+
+ rm -Rf $2
+
+ for i in 0 9;
+ do
+ git clone $1 $2
+
+ if [ $code -eq 0 ]; then
+ echo "[INFO] Git repository $1 was successfully cloned to $2"
+ return 0
+ fi
+
+ echo "[WARN] Failed to clone git repository $1 from $i attempt, sleeping extra 5sec"
+ rm -Rf $2
+ sleep 5s
+ done
+
+ terminate "All 10 attempts to clone git repository $1 are failed"
+}
+
+# Applies specified tag to EC2 instance
+createTag()
+{
+ if [ -z "$EC2_INSTANCE_REGION" ]; then
+ EC2_AVAIL_ZONE=`curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone`
+ EC2_INSTANCE_REGION="`echo \"$EC2_AVAIL_ZONE\" | sed -e 's:\([0-9][0-9]*\)[a-z]*\$:\\1:'`"
+ export EC2_INSTANCE_REGION
+ echo "[INFO] EC2 instance region: $EC2_INSTANCE_REGION"
+ fi
+
+ for i in 0 9;
+ do
+ aws ec2 create-tags --resources $1 --tags Key=$2,Value=$3 --region $EC2_INSTANCE_REGION
+ if [ $? -eq 0 ]; then
+ return 0
+ fi
+
+ echo "[WARN] $i attempt to tag EC2 instance $1 with $2=$3 is failed, sleeping extra 5sec"
+ sleep 5s
+ done
+
+ terminate "All 10 attempts to tag EC2 instance $1 with $2=$3 are failed"
+}
+
+# Applies 'owner', 'project' and 'Name' tags to EC2 instance
+tagInstance()
+{
+ export EC2_HOME=/opt/aws/apitools/ec2
+ export JAVA_HOME=/opt/java
+ export PATH=$JAVA_HOME/bin:$EC2_HOME/bin:$PATH
+
+ INSTANCE_ID=$(curl http://169.254.169.254/latest/meta-data/instance-id)
+ if [ $? -ne 0 ]; then
+ echo "[ERROR] Failed to get instance metadata to tag it"
+ exit 1
+ fi
+
+ INSTANCE_NAME=
+
+ if [ "$NODE_TYPE" == "cassandra" ]; then
+ INSTANCE_NAME=$EC2_CASSANDRA_TAG
+ elif [ "$NODE_TYPE" == "ignite" ]; then
+ INSTANCE_NAME=$EC2_IGNITE_TAG
+ elif [ "$NODE_TYPE" == "test" ]; then
+ INSTANCE_NAME=$EC2_TEST_TAG
+ elif [ "$NODE_TYPE" == "ganglia" ]; then
+ INSTANCE_NAME=$EC2_GANGLIA_TAG
+ fi
+
+ if [ -n "$INSTANCE_NAME" ]; then
+ createTag "$INSTANCE_ID" "Name" "${INSTANCE_NAME}"
+ fi
+
+ if [ -n "$EC2_OWNER_TAG" ]; then
+ createTag "$INSTANCE_ID" "owner" "${EC2_OWNER_TAG}"
+ fi
+
+ if [ -n "$EC2_PROJECT_TAG" ]; then
+ createTag "$INSTANCE_ID" "project" "${EC2_PROJECT_TAG}"
+ fi
+}
+
+# Sets NODE_TYPE env variable
+setNodeType()
+{
+ if [ -n "$1" ]; then
+ NEW_NODE_TYPE=$NODE_TYPE
+ NODE_TYPE=$1
+ else
+ NEW_NODE_TYPE=
+ fi
+}
+
+# Reverts NODE_TYPE env variable to previous value
+revertNodeType()
+{
+ if [ -n "$NEW_NODE_TYPE" ]; then
+ NODE_TYPE=$NEW_NODE_TYPE
+ NEW_NODE_TYPE=
+ fi
+}
+
+# Returns logs folder for the node (Cassandra, Ignite, Tests)
+getLocalLogsFolder()
+{
+ setNodeType $1
+
+ if [ "$NODE_TYPE" == "cassandra" ]; then
+ echo "/opt/cassandra/logs"
+ elif [ "$NODE_TYPE" == "ignite" ]; then
+ echo "/opt/ignite/work/log"
+ elif [ "$NODE_TYPE" == "test" ]; then
+ echo "/opt/ignite-cassandra-tests/logs"
+ elif [ "$NODE_TYPE" == "ganglia" ]; then
+ echo ""
+ fi
+
+ revertNodeType
+}
+
+# Returns S3 URL to discover this node
+getDiscoveryUrl()
+{
+ setNodeType $1
+
+ if [ "$NODE_TYPE" == "cassandra" ]; then
+ echo "$S3_CASSANDRA_NODES_DISCOVERY"
+ elif [ "$NODE_TYPE" == "ignite" ]; then
+ echo "$S3_IGNITE_NODES_DISCOVERY"
+ elif [ "$NODE_TYPE" == "test" ]; then
+ echo "$S3_TESTS_NODES_DISCOVERY"
+ elif [ "$NODE_TYPE" == "ganglia" ]; then
+ echo "$S3_GANGLIA_MASTER_DISCOVERY"
+ fi
+
+ revertNodeType
+}
+
+# Returns S3 URL used as a join lock, used by nodes to join cluster sequentially
+getJoinLockUrl()
+{
+ setNodeType $1
+
+ if [ "$NODE_TYPE" == "cassandra" ]; then
+ echo "$S3_CASSANDRA_NODES_JOIN_LOCK"
+ elif [ "$NODE_TYPE" == "ignite" ]; then
+ echo "$S3_IGNITE_NODES_JOIN_LOCK"
+ fi
+
+ revertNodeType
+}
+
+# Returns S3 URL used to select first node for the cluster. The first node is responsible
+# for doing all routine work (clean S3 logs/test results from previous execution) on cluster startup
+getFirstNodeLockUrl()
+{
+ setNodeType $1
+
+ if [ "$NODE_TYPE" == "cassandra" ]; then
+ echo "$S3_CASSANDRA_FIRST_NODE_LOCK"
+ elif [ "$NODE_TYPE" == "ignite" ]; then
+ echo "$S3_IGNITE_FIRST_NODE_LOCK"
+ elif [ "$NODE_TYPE" == "test" ]; then
+ echo "$S3_TESTS_FIRST_NODE_LOCK"
+ fi
+
+ revertNodeType
+}
+
+# Returns S3 success URL for the node - folder created in S3 in case node successfully started and containing node logs
+getSucessUrl()
+{
+ setNodeType $1
+
+ if [ "$NODE_TYPE" == "cassandra" ]; then
+ echo "$S3_CASSANDRA_BOOTSTRAP_SUCCESS"
+ elif [ "$NODE_TYPE" == "ignite" ]; then
+ echo "$S3_IGNITE_BOOTSTRAP_SUCCESS"
+ elif [ "$NODE_TYPE" == "test" ]; then
+ echo "$S3_TESTS_SUCCESS"
+ elif [ "$NODE_TYPE" == "ganglia" ]; then
+ echo "$S3_GANGLIA_BOOTSTRAP_SUCCESS"
+ fi
+
+ revertNodeType
+}
+
+# Returns S3 failure URL for the node - folder created in S3 in case node failed to start and containing node logs
+getFailureUrl()
+{
+ setNodeType $1
+
+ if [ "$NODE_TYPE" == "cassandra" ]; then
+ echo "$S3_CASSANDRA_BOOTSTRAP_FAILURE"
+ elif [ "$NODE_TYPE" == "ignite" ]; then
+ echo "$S3_IGNITE_BOOTSTRAP_FAILURE"
+ elif [ "$NODE_TYPE" == "test" ]; then
+ echo "$S3_TESTS_FAILURE"
+ elif [ "$NODE_TYPE" == "ganglia" ]; then
+ echo "$S3_GANGLIA_BOOTSTRAP_FAILURE"
+ fi
+
+ revertNodeType
+}
+
+# Terminates script execution, unregisters node and removes all the locks (join lock, first node lock) created by it
+terminate()
+{
+ SUCCESS_URL=$(getSucessUrl)
+ FAILURE_URL=$(getFailureUrl)
+
+ if [ -n "$SUCCESS_URL" ] && [[ "$SUCCESS_URL" != */ ]]; then
+ SUCCESS_URL=${SUCCESS_URL}/
+ fi
+
+ if [ -n "$FAILURE_URL" ] && [[ "$FAILURE_URL" != */ ]]; then
+ FAILURE_URL=${FAILURE_URL}/
+ fi
+
+ HOST_NAME=$(hostname -f | tr '[:upper:]' '[:lower:]')
+
+ msg=$HOST_NAME
+
+ if [ -n "$1" ]; then
+ echo "[ERROR] $1"
+ echo "[ERROR]-----------------------------------------------------"
+ echo "[ERROR] Failed to start $NODE_TYPE node"
+ echo "[ERROR]-----------------------------------------------------"
+ msg=$1
+ reportFolder=${FAILURE_URL}${HOST_NAME}
+ reportFile=$reportFolder/__error__
+ else
+ echo "[INFO]-----------------------------------------------------"
+ echo "[INFO] $NODE_TYPE node successfully started"
+ echo "[INFO]-----------------------------------------------------"
+ reportFolder=${SUCCESS_URL}${HOST_NAME}
+ reportFile=$reportFolder/__success__
+ fi
+
+ echo $msg > /opt/ignite-cassandra-tests/bootstrap/start_result
+
+ aws s3 rm --recursive $reportFolder
+ if [ $? -ne 0 ]; then
+ echo "[ERROR] Failed to drop report folder: $reportFolder"
+ fi
+
+ localLogs=$(getLocalLogsFolder)
+
+ if [ -d "$localLogs" ]; then
+ aws s3 sync --sse AES256 $localLogs $reportFolder
+ if [ $? -ne 0 ]; then
+ echo "[ERROR] Failed to export $NODE_TYPE logs to: $reportFolder"
+ fi
+ fi
+
+ aws s3 cp --sse AES256 /opt/ignite-cassandra-tests/bootstrap/start_result $reportFile
+ if [ $? -ne 0 ]; then
+ echo "[ERROR] Failed to export node start result to: $reportFile"
+ fi
+
+ rm -f /opt/ignite-cassandra-tests/bootstrap/start_result /opt/ignite-cassandra-tests/bootstrap/join-lock /opt/ignite-cassandra-tests/bootstrap/first-node-lock
+
+ removeClusterJoinLock
+
+ if [ "$NODE_TYPE" == "test" ]; then
+ aws s3 rm ${S3_TESTS_RUNNING}${HOST_NAME}
+ aws s3 rm ${S3_TESTS_WAITING}${HOST_NAME}
+ aws s3 rm ${S3_TESTS_IDLE}${HOST_NAME}
+ aws s3 rm ${S3_TESTS_PREPARING}${HOST_NAME}
+ unregisterNode
+ fi
+
+ if [ -n "$1" ]; then
+ removeFirstNodeLock
+ unregisterNode
+ exit 1
+ fi
+
+ exit 0
+}
+
+# Registers node by creating a file having node hostname inside specific folder in S3
+registerNode()
+{
+ DISCOVERY_URL=$(getDiscoveryUrl)
+ HOST_NAME=$(hostname -f | tr '[:upper:]' '[:lower:]')
+
+ echo "[INFO] Registering $NODE_TYPE node: ${DISCOVERY_URL}${HOST_NAME}"
+
+ aws s3 cp --sse AES256 /etc/hosts ${DISCOVERY_URL}${HOST_NAME}
+ if [ $? -ne 0 ]; then
+ terminate "Failed to register $NODE_TYPE node info in: ${DISCOVERY_URL}${HOST_NAME}"
+ fi
+
+ echo "[INFO] $NODE_TYPE node successfully registered"
+}
+
+# Unregisters node by removing a file having node hostname inside specific folder in S3
+unregisterNode()
+{
+ DISCOVERY_URL=$(getDiscoveryUrl)
+ HOST_NAME=$(hostname -f | tr '[:upper:]' '[:lower:]')
+
+ echo "[INFO] Removing $NODE_TYPE node registration from: ${DISCOVERY_URL}${HOST_NAME}"
+
+ exists=$(aws s3 ls ${DISCOVERY_URL}${HOST_NAME})
+
+ if [ -n "$exists" ]; then
+ aws s3 rm ${DISCOVERY_URL}${HOST_NAME}
+
+ if [ $? -ne 0 ]; then
+ echo "[ERROR] Failed to remove $NODE_TYPE node registration"
+ else
+ echo "[INFO] $NODE_TYPE node registration removed"
+ fi
+ else
+ echo "[INFO] Node registration actually haven't been previously created"
+ fi
+}
+
+# Cleans up all nodes metadata for particular cluster (Cassandra, Ignite, Tests). Performed only by the node acquired
+# first node lock.
+cleanupMetadata()
+{
+ DISCOVERY_URL=$(getDiscoveryUrl)
+ JOIN_LOCK_URL=$(getJoinLockUrl)
+ SUCCESS_URL=$(getSucessUrl)
+ FAILURE_URL=$(getFailureUrl)
+
+ echo "[INFO] Running metadata cleanup"
+
+ aws s3 rm $JOIN_LOCK_URL
+ aws s3 rm --recursive $DISCOVERY_URL
+ aws s3 rm --recursive $SUCCESS_URL
+ aws s3 rm --recursive $FAILURE_URL
+
+ echo "[INFO] Metadata cleanup completed"
+}
+
+# Tries to get first node lock for the node. Only one (first) node can have such lock and it will be responsible for
+# cleanup process when starting cluster
+tryToGetFirstNodeLock()
+{
+ if [ "$FIRST_NODE_LOCK" == "true" ]; then
+ return 0
+ fi
+
+ FIRST_NODE_LOCK_URL=$(getFirstNodeLockUrl)
+ HOST_NAME=$(hostname -f | tr '[:upper:]' '[:lower:]')
+
+ echo "[INFO] Trying to get first node lock: $FIRST_NODE_LOCK_URL"
+
+ checkFirstNodeLockExist $FIRST_NODE_LOCK_URL
+ if [ $? -ne 0 ]; then
+ return 1
+ fi
+
+ echo "$HOST_NAME" > /opt/ignite-cassandra-tests/bootstrap/first-node-lock
+
+ createFirstNodeLock $FIRST_NODE_LOCK_URL
+
+ sleep 5s
+
+ rm -Rf /opt/ignite-cassandra-tests/bootstrap/first-node-lock
+
+ aws s3 cp $FIRST_NODE_LOCK_URL /opt/ignite-cassandra-tests/bootstrap/first-node-lock
+ if [ $? -ne 0 ]; then
+ echo "[WARN] Failed to check just created first node lock"
+ return 1
+ fi
+
+ first_host=$(cat /opt/ignite-cassandra-tests/bootstrap/first-node-lock)
+
+ rm -f /opt/ignite-cassandra-tests/bootstrap/first-node-lock
+
+ if [ "$first_host" != "$HOST_NAME" ]; then
+ echo "[INFO] Node $first_host has discarded previously created first node lock"
+ return 1
+ fi
+
+ echo "[INFO] Congratulations, got first node lock"
+
+ FIRST_NODE_LOCK="true"
+
+ return 0
+}
+
+# Checks if first node lock already exists in S3
+checkFirstNodeLockExist()
+{
+ echo "[INFO] Checking for the first node lock: $1"
+
+ lockExists=$(aws s3 ls $1)
+ if [ -n "$lockExists" ]; then
+ echo "[INFO] First node lock already exists"
+ return 1
+ fi
+
+ echo "[INFO] First node lock doesn't exist"
+
+ return 0
+}
+
+# Creates first node lock in S3
+createFirstNodeLock()
+{
+ aws s3 cp --sse AES256 /opt/ignite-cassandra-tests/bootstrap/first-node-lock $1
+
+ if [ $? -ne 0 ]; then
+ terminate "Failed to create first node lock: $1"
+ fi
+
+ echo "[INFO] Created first node lock: $1"
+}
+
+# Removes first node lock from S3
+removeFirstNodeLock()
+{
+ if [ "$FIRST_NODE_LOCK" != "true" ]; then
+ return 0
+ fi
+
+ FIRST_NODE_LOCK_URL=$(getFirstNodeLockUrl)
+
+ echo "[INFO] Removing first node lock: $FIRST_NODE_LOCK_URL"
+
+ aws s3 rm $FIRST_NODE_LOCK_URL
+
+ if [ $? -ne 0 ]; then
+ terminate "Failed to remove first node lock: $FIRST_NODE_LOCK_URL"
+ fi
+
+ echo "[INFO] Removed first node lock: $FIRST_NODE_LOCK_URL"
+
+ FIRST_NODE_LOCK="false"
+}
+
+# Tries to get cluster join lock. Nodes use this lock to join a cluster sequentially.
+tryToGetClusterJoinLock()
+{
+ if [ "$JOIN_LOCK" == "true" ]; then
+ return 0
+ fi
+
+ JOIN_LOCK_URL=$(getJoinLockUrl)
+ HOST_NAME=$(hostname -f | tr '[:upper:]' '[:lower:]')
+
+ echo "[INFO] Trying to get cluster join lock"
+
+ checkClusterJoinLockExist $JOIN_LOCK_URL
+ if [ $? -ne 0 ]; then
+ return 1
+ fi
+
+ echo "$HOST_NAME" > /opt/ignite-cassandra-tests/bootstrap/join-lock
+
+ createClusterJoinLock $JOIN_LOCK_URL
+
+ sleep 5s
+
+ rm -Rf /opt/ignite-cassandra-tests/bootstrap/join-lock
+
+ aws s3 cp $JOIN_LOCK_URL /opt/ignite-cassandra-tests/bootstrap/join-lock
+ if [ $? -ne 0 ]; then
+ echo "[WARN] Failed to check just created cluster join lock"
+ return 1
+ fi
+
+ join_host=$(cat /opt/ignite-cassandra-tests/bootstrap/join-lock)
+
+ if [ "$join_host" != "$HOST_NAME" ]; then
+ echo "[INFO] Node $first_host has discarded previously created cluster join lock"
+ return 1
+ fi
+
+ echo "[INFO] Congratulations, got cluster join lock"
+
+ JOIN_LOCK="true"
+
+ return 0
+}
+
+# Checks if join lock already exists in S3
+checkClusterJoinLockExist()
+{
+ echo "[INFO] Checking for the cluster join lock: $1"
+
+ lockExists=$(aws s3 ls $1)
+ if [ -n "$lockExists" ]; then
+ echo "[INFO] Cluster join lock already exists"
+ return 1
+ fi
+
+ if [ "$NODE_TYPE" == "cassandra" ]; then
+ status=$(/opt/cassandra/bin/nodetool -h $CASSANDRA_SEED status)
+ leaving=$(echo $status | grep UL)
+ moving=$(echo $status | grep UM)
+ joining=$(echo $status | grep UJ)
+
+ if [ -n "$leaving" ] || [ -n "$moving" ] || [ -n "$joining" ]; then
+ echo "[INFO] Cluster join lock doesn't exist in S3, but some node still trying to join Cassandra cluster"
+ return 1
+ fi
+ fi
+
+ echo "[INFO] Cluster join lock doesn't exist"
+}
+
+# Creates join lock in S3
+createClusterJoinLock()
+{
+ aws s3 cp --sse AES256 /opt/ignite-cassandra-tests/bootstrap/join-lock $1
+
+ if [ $? -ne 0 ]; then
+ terminate "Failed to create cluster join lock: $1"
+ fi
+
+ echo "[INFO] Created cluster join lock: $1"
+}
+
+# Removes join lock
+removeClusterJoinLock()
+{
+ if [ "$JOIN_LOCK" != "true" ]; then
+ return 0
+ fi
+
+ JOIN_LOCK_URL=$(getJoinLockUrl)
+
+ echo "[INFO] Removing cluster join lock: $JOIN_LOCK_URL"
+
+ aws s3 rm $JOIN_LOCK_URL
+
+ if [ $? -ne 0 ]; then
+ terminate "Failed to remove cluster join lock: $JOIN_LOCK_URL"
+ fi
+
+ JOIN_LOCK="false"
+
+ echo "[INFO] Removed cluster join lock: $JOIN_LOCK_URL"
+}
+
+# Waits for the node to join cluster, periodically trying to acquire cluster join lock and exiting only when node
+# successfully acquired the lock. Such mechanism used by nodes to join cluster sequentially (limitation of Cassandra).
+waitToJoinCluster()
+{
+ echo "[INFO] Waiting to join $NODE_TYPE cluster"
+
+ while true; do
+ tryToGetClusterJoinLock
+
+ if [ $? -ne 0 ]; then
+ echo "[INFO] Another node is trying to join cluster. Waiting for extra 30sec."
+ sleep 30s
+ else
+ echo "[INFO]-------------------------------------------------------------"
+ echo "[INFO] Congratulations, got lock to join $NODE_TYPE cluster"
+ echo "[INFO]-------------------------------------------------------------"
+ break
+ fi
+ done
+}
+
+# Wait for the cluster to register at least one node in S3, so that all other nodes will use already existing nodes
+# to send them info about them and join the cluster
+setupClusterSeeds()
+{
+ if [ "$1" != "cassandra" ] && [ "$1" != "ignite" ] && [ "$1" != "test" ]; then
+ terminate "Incorrect cluster type specified '$1' to setup seeds"
+ fi
+
+ DISCOVERY_URL=$(getDiscoveryUrl $1)
+
+ echo "[INFO] Setting up $1 seeds"
+
+ echo "[INFO] Looking for $1 seeds in: $DISCOVERY_URL"
+
+ startTime=$(date +%s)
+
+ while true; do
+ seeds=$(aws s3 ls $DISCOVERY_URL | grep -v PRE | sed -r "s/^.* //g")
+ if [ -n "$seeds" ]; then
+ seeds=($seeds)
+ length=${#seeds[@]}
+
+ if [ $length -lt 4 ]; then
+ seed1=${seeds[0]}
+ seed2=${seeds[1]}
+ seed3=${seeds[2]}
+ else
+ pos1=$(($RANDOM%$length))
+ pos2=$(($RANDOM%$length))
+ pos3=$(($RANDOM%$length))
+ seed1=${seeds[${pos1}]}
+ seed2=${seeds[${pos2}]}
+ seed3=${seeds[${pos3}]}
+ fi
+
+ CLUSTER_SEEDS=$seed1
+
+ if [ "$seed2" != "$seed1" ] && [ -n "$seed2" ]; then
+ CLUSTER_SEEDS="$CLUSTER_SEEDS $seed2"
+ fi
+
+ if [ "$seed3" != "$seed2" ] && [ "$seed3" != "$seed1" ] && [ -n "$seed3" ]; then
+ CLUSTER_SEEDS="$CLUSTER_SEEDS $seed3"
+ fi
+
+ echo "[INFO] Using $1 seeds: $CLUSTER_SEEDS"
+
+ return 0
+ fi
+
+ currentTime=$(date +%s)
+ duration=$(( $currentTime-$startTime ))
+ duration=$(( $duration/60 ))
+
+ if [ "$2" == "true" ]; then
+ if [ $duration -gt $SERVICE_STARTUP_TIME ]; then
+ terminate "${SERVICE_STARTUP_TIME}min timeout expired, but first $1 node is still not up and running"
+ fi
+ fi
+
+ echo "[INFO] Waiting for the first $1 node to start and publish its seed, time passed ${duration}min"
+
+ sleep 30s
+ done
+}
+
+# Wait until first cluster node registered in S3
+waitFirstClusterNodeRegistered()
+{
+ DISCOVERY_URL=$(getDiscoveryUrl)
+
+ echo "[INFO] Waiting for the first $NODE_TYPE node to register in: $DISCOVERY_URL"
+
+ startTime=$(date +%s)
+
+ while true; do
+ exists=$(aws s3 ls $DISCOVERY_URL)
+ if [ -n "$exists" ]; then
+ break
+ fi
+
+ if [ "$1" == "true" ]; then
+ currentTime=$(date +%s)
+ duration=$(( $currentTime-$startTime ))
+ duration=$(( $duration/60 ))
+
+ if [ $duration -gt $SERVICE_STARTUP_TIME ]; then
+ terminate "${SERVICE_STARTUP_TIME}min timeout expired, but first $type node is still not up and running"
+ fi
+ fi
+
+ echo "[INFO] Waiting extra 30sec"
+
+ sleep 30s
+ done
+
+ echo "[INFO] First $type node registered"
+}
+
+# Waits until all cluster nodes successfully bootstrapped. In case of Tests cluster also waits until all nodes
+# switch to waiting state
+waitAllClusterNodesReady()
+{
+ if [ "$1" == "cassandra" ]; then
+ NODES_COUNT=$CASSANDRA_NODES_COUNT
+ elif [ "$1" == "ignite" ]; then
+ NODES_COUNT=$IGNITE_NODES_COUNT
+ elif [ "$1" == "test" ]; then
+ NODES_COUNT=$TEST_NODES_COUNT
+ else
+ terminate "Incorrect cluster type specified '$1' to wait for all nodes up and running"
+ fi
+
+ SUCCESS_URL=$(getSucessUrl $1)
+
+ if [ $NODES_COUNT -eq 0 ]; then
+ return 0
+ fi
+
+ echo "[INFO] Waiting for all $NODES_COUNT $1 nodes ready"
+
+ while true; do
+ if [ "$1" == "test" ]; then
+ count1=$(aws s3 ls $S3_TESTS_WAITING | wc -l)
+ count2=$(aws s3 ls $S3_TESTS_RUNNING | wc -l)
+ count=$(( $count1+$count2 ))
+ else
+ count=$(aws s3 ls $SUCCESS_URL | wc -l)
+ fi
+
+ if [ $count -ge $NODES_COUNT ]; then
+ break
+ fi
+
+ echo "[INFO] Waiting extra 30sec"
+
+ sleep 30s
+ done
+
+ sleep 30s
+
+ echo "[INFO] Congratulation, all $NODES_COUNT $1 nodes are ready"
+}
+
+# Wait untill all Tests cluster nodes completed their tests execution
+waitAllTestNodesCompletedTests()
+{
+ HOST_NAME=$(hostname -f | tr '[:upper:]' '[:lower:]')
+
+ echo "[INFO] Waiting for all $TEST_NODES_COUNT test nodes to complete their tests"
+
+ while true; do
+
+ count=$(aws s3 ls $S3_TESTS_RUNNING | grep -v $HOST_NAME | wc -l)
+
+ if [ $count -eq 0 ]; then
+ break
+ fi
+
+ echo "[INFO] Waiting extra 30sec"
+
+ sleep 30s
+ done
+
+ echo "[INFO] Congratulation, all $TEST_NODES_COUNT test nodes have completed their tests"
+}
+
+# Installs all required Ganglia packages
+installGangliaPackages()
+{
+ if [ "$1" == "master" ]; then
+ echo "[INFO] Installing Ganglia master required packages"
+ else
+ echo "[INFO] Installing Ganglia agent required packages"
+ fi
+
+ isAmazonLinux=$(cat "/etc/issue" | grep "Amazon Linux")
+
+ if [ -z "$isAmazonLinux" ]; then
+ setenforce 0
+
+ if [ $? -ne 0 ]; then
+ terminate "Failed to turn off SELinux"
+ fi
+
+ downloadPackage "$EPEL_DOWNLOAD_URL" "/opt/epel.rpm" "EPEL"
+
+ rpm -Uvh /opt/epel.rpm
+ if [ $? -ne 0 ]; then
+ terminate "Failed to setup EPEL repository"
+ fi
+
+ rm -f /opt/epel.rpm
+ fi
+
+ yum -y install apr-devel apr-util check-devel cairo-devel pango-devel pango \
+ libxml2-devel glib2-devel dbus-devel freetype-devel freetype \
+ libpng-devel libart_lgpl-devel fontconfig-devel gcc-c++ expat-devel \
+ python-devel libXrender-devel perl-devel perl-CPAN gettext git sysstat \
+ automake autoconf ltmain.sh pkg-config gperf libtool pcre-devel libconfuse-devel
+
+ if [ $? -ne 0 ]; then
+ terminate "Failed to install all Ganglia required packages"
+ fi
+
+ if [ "$1" == "master" ]; then
+ yum -y install httpd php php-devel php-pear
+
+ if [ $? -ne 0 ]; then
+ terminate "Failed to install all Ganglia required packages"
+ fi
+
+ if [ -z "$isAmazonLinux" ]; then
+ yum -y install liberation-sans-fonts
+
+ if [ $? -ne 0 ]; then
+ terminate "Failed to install liberation-sans-fonts package"
+ fi
+ fi
+ fi
+
+ if [ -z "$isAmazonLinux" ]; then
+ downloadPackage "$GPERF_DOWNLOAD_URL" "/opt/gperf.tar.gz" "gperf"
+
+ tar -xvzf /opt/gperf.tar.gz -C /opt
+ if [ $? -ne 0 ]; then
+ terminate "Failed to untar gperf tarball"
+ fi
+
+ rm -Rf /opt/gperf.tar.gz
+
+ unzipDir=$(ls /opt | grep "gperf")
+
+ if [ $? -ne 0 ]; then
+ terminate "Failed to update creation date to current for all files inside: /opt/$unzipDir"
+ fi
+
+ pushd /opt/$unzipDir
+
+ cat ./configure | sed -r "s/test \"\\\$2\" = conftest.file/test 1 = 1/g" > ./configure1
+ rm ./configure
+ mv ./configure1 ./configure
+ chmod a+x ./configure
+
+ ./configure
+ if [ $? -ne 0 ]; then
+ terminate "Failed to configure gperf"
+ fi
+
+ make
+ if [ $? -ne 0 ]; then
+ terminate "Failed to make gperf"
+ fi
+
+ make install
+ if [ $? -ne 0 ]; then
+ terminate "Failed to install gperf"
+ fi
+
+ echo "[INFO] gperf tool successfully installed"
+
+ popd
+ fi
+
+ echo "[INFO] Installing rrdtool"
+
+ downloadPackage "$RRD_DOWNLOAD_URL" "/opt/rrdtool.tar.gz" "rrdtool"
+
+ tar -xvzf /opt/rrdtool.tar.gz -C /opt
+ if [ $? -ne 0 ]; then
+ terminate "Failed to untar rrdtool tarball"
+ fi
+
+ rm -Rf /opt/rrdtool.tar.gz
+
+ unzipDir=$(ls /opt | grep "rrdtool")
+ if [ "$unzipDir" != "rrdtool" ]; then
+ mv /opt/$unzipDir /opt/rrdtool
+ fi
+
+ if [ $? -ne 0 ]; then
+ terminate "Failed to update creation date to current for all files inside: /opt/rrdtool"
+ fi
+
+ export PKG_CONFIG_PATH=/usr/lib/pkgconfig/
+
+ pushd /opt/rrdtool
+
+ cat ./configure | sed -r "s/test \"\\\$2\" = conftest.file/test 1 = 1/g" > ./configure1
+ rm ./configure
+ mv ./configure1 ./configure
+ chmod a+x ./configure
+
+ ./configure --prefix=/usr/local/rrdtool
+ if [ $? -ne 0 ]; then
+ terminate "Failed to configure rrdtool"
+ fi
+
+ make
+ if [ $? -ne 0 ]; then
+ terminate "Failed to make rrdtool"
+ fi
+
+ make install
+ if [ $? -ne 0 ]; then
+ terminate "Failed to install rrdtool"
+ fi
+
+ ln -s /usr/local/rrdtool/bin/rrdtool /usr/bin/rrdtool
+ mkdir -p /var/lib/ganglia/rrds
+
+ chown -R nobody:nobody /usr/local/rrdtool /var/lib/ganglia/rrds /usr/bin/rrdtool
+
+ rm -Rf /opt/rrdtool
+
+ popd
+
+ echo "[INFO] rrdtool successfully installed"
+
+ echo "[INFO] Installig ganglia-core"
+
+ gitClone $GANGLIA_CORE_DOWNLOAD_URL /opt/monitor-core
+
+ if [ $? -ne 0 ]; then
+ terminate "Failed to update creation date to current for all files inside: /opt/monitor-core"
+ fi
+
+ pushd /opt/monitor-core
+
+ git checkout efe9b5e5712ea74c04e3b15a06eb21900e18db40
+
+ ./bootstrap
+
+ if [ $? -ne 0 ]; then
+ terminate "Failed to prepare ganglia-core for compilation"
+ fi
+
+ cat ./configure | sed -r "s/test \"\\\$2\" = conftest.file/test 1 = 1/g" > ./configure1
+ rm ./configure
+ mv ./configure1 ./configure
+ chmod a+x ./configure
+
+ ./configure --with-gmetad --with-librrd=/usr/local/rrdtool
+
+ if [ $? -ne 0 ]; then
+ terminate "Failed to configure ganglia-core"
+ fi
+
+ make
+ if [ $? -ne 0 ]; then
+ terminate "Failed to make ganglia-core"
+ fi
+
+ make install
+ if [ $? -ne 0 ]; then
+ terminate "Failed to install ganglia-core"
+ fi
+
+ rm -Rf /opt/monitor-core
+
+ popd
+
+ echo "[INFO] ganglia-core successfully installed"
+
+ if [ "$1" != "master" ]; then
+ return 0
+ fi
+
+ echo "[INFO] Installing ganglia-web"
+
+ gitClone $GANGLIA_WEB_DOWNLOAD_URL /opt/web
+
+ if [ $? -ne 0 ]; then
+ terminate "Failed to update creation date to current for all files inside: /opt/web"
+ fi
+
+ cat /opt/web/Makefile | sed -r "s/GDESTDIR = \/usr\/share\/ganglia-webfrontend/GDESTDIR = \/opt\/ganglia-web/g" > /opt/web/Makefile1
+ cat /opt/web/Makefile1 | sed -r "s/GCONFDIR = \/etc\/ganglia-web/GCONFDIR = \/opt\/ganglia-web/g" > /opt/web/Makefile2
+ cat /opt/web/Makefile2 | sed -r "s/GWEB_STATEDIR = \/var\/lib\/ganglia-web/GWEB_STATEDIR = \/opt\/ganglia-web/g" > /opt/web/Makefile3
+ cat /opt/web/Makefile3 | sed -r "s/APACHE_USER = www-data/APACHE_USER = apache/g" > /opt/web/Makefile4
+
+ rm -f /opt/web/Makefile
+ cp /opt/web/Makefile4 /opt/web/Makefile
+ rm -f /opt/web/Makefile1 /opt/web/Makefile2 /opt/web/Makefile3 /opt/web/Makefile4
+
+ pushd /opt/web
+
+ git checkout f2b19c7cacfc8c51921be801b92f8ed0bd4901ae
+
+ make
+
+ if [ $? -ne 0 ]; then
+ terminate "Failed to make ganglia-web"
+ fi
+
+ make install
+
+ if [ $? -ne 0 ]; then
+ terminate "Failed to install ganglia-web"
+ fi
+
+ rm -Rf /opt/web
+
+ popd
+
+ echo "" >> /etc/httpd/conf/httpd.conf
+ echo "Alias /ganglia /opt/ganglia-web" >> /etc/httpd/conf/httpd.conf
+ echo "<Directory \"/opt/ganglia-web\">" >> /etc/httpd/conf/httpd.conf
+ echo " AllowOverride All" >> /etc/httpd/conf/httpd.conf
+ echo " Order allow,deny" >> /etc/httpd/conf/httpd.conf
+
+ if [ -z "$isAmazonLinux" ]; then
+ echo " Require all granted" >> /etc/httpd/conf/httpd.conf
+ fi
+
+ echo " Allow from all" >> /etc/httpd/conf/httpd.conf
+ echo " Deny from none" >> /etc/httpd/conf/httpd.conf
+ echo "</Directory>" >> /etc/httpd/conf/httpd.conf
+
+ echo "[INFO] ganglia-web successfully installed"
+}
+
+# Setup ntpd service
+setupNTP()
+{
+ echo "[INFO] Installing ntp package"
+
+ yum -y install ntp
+
+ if [ $? -ne 0 ]; then
+ terminate "Failed to install ntp package"
+ fi
+
+ echo "[INFO] Starting ntpd service"
+
+ service ntpd restart
+
+ if [ $? -ne 0 ]; then
+ terminate "Failed to restart ntpd service"
+ fi
+}
+
+# Installs and run Ganglia agent ('gmond' daemon)
+bootstrapGangliaAgent()
+{
+ echo "[INFO]-----------------------------------------------------------------"
+ echo "[INFO] Bootstrapping Ganglia agent"
+ echo "[INFO]-----------------------------------------------------------------"
+
+ installGangliaPackages
+
+ echo "[INFO] Running ganglia agent daemon to discover Ganglia master"
+
+ /opt/ignite-cassandra-tests/bootstrap/aws/ganglia/agent-start.sh $1 $2 > /opt/ganglia-agent.log &
+
+ echo "[INFO] Ganglia daemon job id: $!"
+}
+
+# Partitioning, formatting to ext4 and mounting all unpartitioned drives.
+# As a result env array MOUNT_POINTS provides all newly created mount points.
+mountUnpartitionedDrives()
+{
+ MOUNT_POINTS=
+
+ echo "[INFO] Mounting unpartitioned drives"
+
+ lsblk -V &> /dev/null
+
+ if [ $? -ne 0 ]; then
+ echo "[WARN] lsblk utility doesn't exist"
+ echo "[INFO] Installing util-linux-ng package"
+
+ yum -y install util-linux-ng
+
+ if [ $? -ne 0 ]; then
+ terminate "Failed to install util-linux-ng package"
+ fi
+ fi
+
+ parted -v &> /dev/null
+
+ if [ $? -ne 0 ]; then
+ echo "[WARN] parted utility doesn't exist"
+ echo "[INFO] Installing parted package"
+
+ yum -y install parted
+
+ if [ $? -ne 0 ]; then
+ terminate "Failed to install parted package"
+ fi
+ fi
+
+ drives=$(lsblk -io KNAME,TYPE | grep disk | sed -r "s/disk//g" | xargs)
+
+ echo "[INFO] Found HDDs: $drives"
+
+ unpartDrives=
+ partDrives=$(lsblk -io KNAME,TYPE | grep part | sed -r "s/[0-9]*//g" | sed -r "s/part//g" | xargs)
+
+ drives=($drives)
+ count=${#drives[@]}
+ iter=1
+
+ for (( i=0; i<=$(( $count -1 )); i++ ))
+ do
+ drive=${drives[$i]}
+
+ if [ -z "$drive" ]; then
+ continue
+ fi
+
+ isPartitioned=$(echo $partDrives | grep "$drive")
+
+ if [ -n "$isPartitioned" ]; then
+ continue
+ fi
+
+ echo "[INFO] Creating partition for the drive: $drive"
+
+ parted -s -a opt /dev/$drive mklabel gpt mkpart primary 0% 100%
+
+ if [ $? -ne 0 ]; then
+ terminate "Failed to create partition for the drive: $drive"
+ fi
+
+ partition=$(lsblk -io KNAME,TYPE | grep part | grep $drive | sed -r "s/part//g" | xargs)
+
+ echo "[INFO] Successfully created partition $partition for the drive: $drive"
+
+ echo "[INFO] Formatting partition /dev/$partition to ext4"
+
+ mkfs.ext4 -F -q /dev/$partition
+
+ if [ $? -ne 0 ]; then
+ terminate "Failed to format partition: /dev/$partition"
+ fi
+
+ echo "[INFO] Partition /dev/$partition was successfully formatted to ext4"
+
+ echo "[INFO] Mounting partition /dev/$partition to /storage$iter"
+
+ mkdir -p /storage$iter
+
+ if [ $? -ne 0 ]; then
+ terminate "Failed to create mount point directory: /storage$iter"
+ fi
+
+ echo "/dev/$partition /storage$iter ext4 defaults 1 1" >> /etc/fstab
+
+ mount /storage$iter
+
+ if [ $? -ne 0 ]; then
+ terminate "Failed to mount /storage$iter mount point for partition /dev/$partition"
+ fi
+
+ echo "[INFO] Partition /dev/$partition was successfully mounted to /storage$iter"
+
+ if [ -n "$MOUNT_POINTS" ]; then
+ MOUNT_POINTS="$MOUNT_POINTS "
+ fi
+
+ MOUNT_POINTS="${MOUNT_POINTS}/storage${iter}"
+
+ iter=$(($iter+1))
+ done
+
+ if [ -z "$MOUNT_POINTS" ]; then
+ echo "[INFO] All drives already have partitions created"
+ fi
+
+ MOUNT_POINTS=($MOUNT_POINTS)
+}
+
+# Creates storage directories for Cassandra: data files, commit log, saved caches.
+# As a result CASSANDRA_DATA_DIR, CASSANDRA_COMMITLOG_DIR, CASSANDRA_CACHES_DIR will point to appropriate directories.
+createCassandraStorageLayout()
+{
+ CASSANDRA_DATA_DIR=
+ CASSANDRA_COMMITLOG_DIR=
+ CASSANDRA_CACHES_DIR=
+
+ mountUnpartitionedDrives
+
+ echo "[INFO] Creating Cassandra storage layout"
+
+ count=${#MOUNT_POINTS[@]}
+
+ for (( i=0; i<=$(( $count -1 )); i++ ))
+ do
+ mountPoint=${MOUNT_POINTS[$i]}
+
+ if [ -z "$CASSANDRA_DATA_DIR" ]; then
+ CASSANDRA_DATA_DIR=$mountPoint
+ elif [ -z "$CASSANDRA_COMMITLOG_DIR" ]; then
+ CASSANDRA_COMMITLOG_DIR=$mountPoint
+ elif [ -z "$CASSANDRA_CACHES_DIR" ]; then
+ CASSANDRA_CACHES_DIR=$mountPoint
+ else
+ CASSANDRA_DATA_DIR="$CASSANDRA_DATA_DIR $mountPoint"
+ fi
+ done
+
+ if [ -z "$CASSANDRA_DATA_DIR" ]; then
+ CASSANDRA_DATA_DIR="/storage/cassandra/data"
+ else
+ CASSANDRA_DATA_DIR="$CASSANDRA_DATA_DIR/cassandra_data"
+ fi
+
+ if [ -z "$CASSANDRA_COMMITLOG_DIR" ]; then
+ CASSANDRA_COMMITLOG_DIR="/storage/cassandra/commitlog"
+ else
+ CASSANDRA_COMMITLOG_DIR="$CASSANDRA_COMMITLOG_DIR/cassandra_commitlog"
+ fi
+
+ if [ -z "$CASSANDRA_CACHES_DIR" ]; then
+ CASSANDRA_CACHES_DIR="/storage/cassandra/saved_caches"
+ else
+ CASSANDRA_CACHES_DIR="$CASSANDRA_CACHES_DIR/cassandra_caches"
+ fi
+
+ echo "[INFO] Cassandra data dir: $CASSANDRA_DATA_DIR"
+ echo "[INFO] Cassandra commit log dir: $CASSANDRA_COMMITLOG_DIR"
+ echo "[INFO] Cassandra saved caches dir: $CASSANDRA_CACHES_DIR"
+
+ dirs=("$CASSANDRA_DATA_DIR $CASSANDRA_COMMITLOG_DIR $CASSANDRA_CACHES_DIR")
+
+ count=${#dirs[@]}
+
+ for (( i=0; i<=$(( $count -1 )); i++ ))
+ do
+ directory=${dirs[$i]}
+
+ mkdir -p $directory
+
+ if [ $? -ne 0 ]; then
+ terminate "Failed to create directory: $directory"
+ fi
+
+ chown -R cassandra:cassandra $directory
+
+ if [ $? -ne 0 ]; then
+ terminate "Failed to assign cassandra:cassandra as an owner of directory $directory"
+ fi
+ done
+
+ DATA_DIR_SPEC="\n"
+
+ dirs=($CASSANDRA_DATA_DIR)
+
+ count=${#dirs[@]}
+
+ for (( i=0; i<=$(( $count -1 )); i++ ))
+ do
+ dataDir=${dirs[$i]}
+ DATA_DIR_SPEC="${DATA_DIR_SPEC} - ${dataDir}\n"
+ done
+
+ CASSANDRA_DATA_DIR=$(echo $DATA_DIR_SPEC | sed -r "s/\//\\\\\//g")
+ CASSANDRA_COMMITLOG_DIR=$(echo $CASSANDRA_COMMITLOG_DIR | sed -r "s/\//\\\\\//g")
+ CASSANDRA_CACHES_DIR=$(echo $CASSANDRA_CACHES_DIR | sed -r "s/\//\\\\\//g")
+}
+
+# Attaches environment configuration settings
+. $( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/env.sh
+
+# Validates environment settings
+validate
+
+# Validates node type of EC2 instance
+if [ "$1" != "cassandra" ] && [ "$1" != "ignite" ] && [ "$1" != "test" ] && [ "$1" != "ganglia" ]; then
+ echo "[ERROR] Unsupported node type specified: $1"
+ exit 1
+fi
+
+# Sets node type of EC2 instance
+export NODE_TYPE=$1
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee8ac73f/modules/cassandra/src/test/bootstrap/aws/env.sh
----------------------------------------------------------------------
diff --git a/modules/cassandra/src/test/bootstrap/aws/env.sh b/modules/cassandra/src/test/bootstrap/aws/env.sh
new file mode 100644
index 0000000..aff4694
--- /dev/null
+++ b/modules/cassandra/src/test/bootstrap/aws/env.sh
@@ -0,0 +1,113 @@
+#!/bin/sh
+
+#
+# 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.
+#
+
+# -----------------------------------------------------------------------------------------------
+# This file specifies environment specific settings to bootstrap required infrastructure for:
+# -----------------------------------------------------------------------------------------------
+#
+# 1) Cassandra cluster
+# 2) Ignite cluster
+# 3) Tests cluster
+# 4) Ganglia agents to be installed on each clusters machine
+# 5) Ganglia master to collect metrics from agent and show graphs on Ganglia Web dashboard
+#
+# -----------------------------------------------------------------------------------------------
+
+# EC2 tagging related settings
+export EC2_OWNER_TAG=ignite@apache.org
+export EC2_PROJECT_TAG=ignite
+export EC2_CASSANDRA_TAG=CASSANDRA
+export EC2_IGNITE_TAG=IGNITE
+export EC2_TEST_TAG=TEST
+export EC2_GANGLIA_TAG=GANGLIA
+
+# Tests summary settings
+export CASSANDRA_NODES_COUNT=3
+export IGNITE_NODES_COUNT=3
+export TEST_NODES_COUNT=2
+export TESTS_TYPE="ignite"
+
+# Time (in minutes) to wait for Cassandra/Ignite node up and running and register it in S3
+export SERVICE_STARTUP_TIME=10
+
+# Number of attempts to start Cassandra/Ignite daemon
+export SERVICE_START_ATTEMPTS=3
+
+# Root S3 folder
+export S3_ROOT=s3://<bucket>/<folder>
+
+# S3 folder for downloads. You should put here ignite load tests jar archive
+# (you can also download here other required artifacts like Cassandra, Ignite and etc)
+export S3_DOWNLOADS=$S3_ROOT/test
+
+# S3 root system folders where to store all infrastructure info
+export S3_SYSTEM=$S3_ROOT/test1
+
+# S3 system folders to store cluster specific info
+export S3_CASSANDRA_SYSTEM=$S3_SYSTEM/cassandra
+export S3_IGNITE_SYSTEM=$S3_SYSTEM/ignite
+export S3_TESTS_SYSTEM=$S3_SYSTEM/tests
+export S3_GANGLIA_SYSTEM=$S3_SYSTEM/ganglia
+
+# Logs related settings
+export S3_LOGS_TRIGGER=$S3_SYSTEM/logs-trigger
+export S3_LOGS_ROOT=$S3_SYSTEM/logs
+export S3_CASSANDRA_LOGS=$S3_LOGS_ROOT/cassandra
+export S3_IGNITE_LOGS=$S3_LOGS_ROOT/ignite
+export S3_TESTS_LOGS=$S3_LOGS_ROOT/tests
+export S3_GANGLIA_LOGS=$S3_LOGS_ROOT/ganglia
+
+# Cassandra related settings
+export CASSANDRA_DOWNLOAD_URL=http://archive.apache.org/dist/cassandra/3.5/apache-cassandra-3.5-bin.tar.gz
+export S3_CASSANDRA_BOOTSTRAP_SUCCESS=$S3_CASSANDRA_SYSTEM/success
+export S3_CASSANDRA_BOOTSTRAP_FAILURE=$S3_CASSANDRA_SYSTEM/failure
+export S3_CASSANDRA_NODES_DISCOVERY=$S3_CASSANDRA_SYSTEM/discovery
+export S3_CASSANDRA_FIRST_NODE_LOCK=$S3_CASSANDRA_SYSTEM/first-node-lock
+export S3_CASSANDRA_NODES_JOIN_LOCK=$S3_CASSANDRA_SYSTEM/join-lock
+
+# Ignite related settings
+export IGNITE_DOWNLOAD_URL=$S3_DOWNLOADS/apache-ignite-fabric-1.7.0-SNAPSHOT-bin.zip
+export S3_IGNITE_BOOTSTRAP_SUCCESS=$S3_IGNITE_SYSTEM/success
+export S3_IGNITE_BOOTSTRAP_FAILURE=$S3_IGNITE_SYSTEM/failure
+export S3_IGNITE_NODES_DISCOVERY=$S3_IGNITE_SYSTEM/discovery
+export S3_IGNITE_FIRST_NODE_LOCK=$S3_IGNITE_SYSTEM/first-node-lock
+export S3_IGNITE_NODES_JOIN_LOCK=$S3_IGNITE_SYSTEM/i-join-lock
+
+# Tests related settings
+export TESTS_PACKAGE_DONLOAD_URL=$S3_DOWNLOADS/ignite-cassandra-tests-1.7.0-SNAPSHOT.zip
+export S3_TESTS_TRIGGER=$S3_SYSTEM/tests-trigger
+export S3_TESTS_NODES_DISCOVERY=$S3_TESTS_SYSTEM/discovery
+export S3_TESTS_SUCCESS=$S3_TESTS_SYSTEM/success
+export S3_TESTS_FAILURE=$S3_TESTS_SYSTEM/failure
+export S3_TESTS_IDLE=$S3_TESTS_SYSTEM/idle
+export S3_TESTS_PREPARING=$S3_TESTS_SYSTEM/preparing
+export S3_TESTS_WAITING=$S3_TESTS_SYSTEM/waiting
+export S3_TESTS_RUNNING=$S3_TESTS_SYSTEM/running
+export S3_TESTS_FIRST_NODE_LOCK=$S3_TESTS_SYSTEM/first-node-lock
+export S3_TESTS_SUMMARY=$S3_SYSTEM/t-summary.zip
+
+# Ganglia related settings
+export GANGLIA_CORE_DOWNLOAD_URL=https://github.com/ganglia/monitor-core.git
+export GANGLIA_WEB_DOWNLOAD_URL=https://github.com/ganglia/ganglia-web.git
+export RRD_DOWNLOAD_URL=http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.3.1.tar.gz
+export GPERF_DOWNLOAD_URL=http://ftp.gnu.org/gnu/gperf/gperf-3.0.3.tar.gz
+export EPEL_DOWNLOAD_URL=https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
+export S3_GANGLIA_BOOTSTRAP_SUCCESS=$S3_GANGLIA_SYSTEM/success
+export S3_GANGLIA_BOOTSTRAP_FAILURE=$S3_GANGLIA_SYSTEM/failure
+export S3_GANGLIA_MASTER_DISCOVERY=$S3_GANGLIA_SYSTEM/discovery
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee8ac73f/modules/cassandra/src/test/bootstrap/aws/ganglia/agent-start.sh
----------------------------------------------------------------------
diff --git a/modules/cassandra/src/test/bootstrap/aws/ganglia/agent-start.sh b/modules/cassandra/src/test/bootstrap/aws/ganglia/agent-start.sh
new file mode 100644
index 0000000..8e49c18
--- /dev/null
+++ b/modules/cassandra/src/test/bootstrap/aws/ganglia/agent-start.sh
@@ -0,0 +1,75 @@
+#!/bin/sh
+
+#
+# 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.
+#
+
+# -----------------------------------------------------------------------------------------------
+# Script to start Ganglia agent on EC2 node (used by agent-bootstrap.sh)
+# -----------------------------------------------------------------------------------------------
+
+. /opt/ignite-cassandra-tests/bootstrap/aws/common.sh "ganglia"
+
+echo "[INFO] Running Ganglia agent discovery daemon for '$1' cluster using $2 port"
+
+# Waiting for the Ganglia master node up and running
+waitFirstClusterNodeRegistered
+
+DISCOVERY_URL=$(getDiscoveryUrl)
+
+masterNode=$(aws s3 ls $DISCOVERY_URL | head -1)
+masterNode=($masterNode)
+masterNode=${masterNode[3]}
+masterNode=$(echo $masterNode | xargs)
+
+if [ $? -ne 0 ] || [ -z "$masterNode" ]; then
+ echo "[ERROR] Failed to get Ganglia master node from: $DISCOVERY_URL"
+fi
+
+echo "[INFO] Got Ganglia master node: $masterNode"
+
+echo "[INFO] Creating gmond config file"
+
+/usr/local/sbin/gmond --default_config > /opt/gmond-default.conf
+
+cat /opt/gmond-default.conf | sed -r "s/deaf = no/deaf = yes/g" | \
+sed -r "s/name = \"unspecified\"/name = \"$1\"/g" | \
+sed -r "s/#bind_hostname/bind_hostname/g" | \
+sed "0,/mcast_join = 239.2.11.71/s/mcast_join = 239.2.11.71/host = $masterNode/g" | \
+sed -r "s/mcast_join = 239.2.11.71//g" | sed -r "s/bind = 239.2.11.71//g" | \
+sed -r "s/port = 8649/port = $2/g" | sed -r "s/retry_bind = true//g" > /opt/gmond.conf
+
+echo "[INFO] Running gmond daemon to report to gmetad on $masterNode"
+
+/usr/local/sbin/gmond --conf=/opt/gmond.conf -p /opt/gmond.pid
+
+sleep 2s
+
+if [ ! -f "/opt/gmond.pid" ]; then
+ echo "[ERROR] Failed to start gmond daemon, pid file doesn't exist"
+ exit 1
+fi
+
+pid=$(cat /opt/gmond.pid)
+
+echo "[INFO] gmond daemon started, pid=$pid"
+
+exists=$(ps $pid | grep gmond)
+
+if [ -z "$exists" ]; then
+ echo "[ERROR] gmond daemon abnormally terminated"
+ exit 1
+fi
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee8ac73f/modules/cassandra/src/test/bootstrap/aws/ganglia/ganglia-bootstrap.sh
----------------------------------------------------------------------
diff --git a/modules/cassandra/src/test/bootstrap/aws/ganglia/ganglia-bootstrap.sh b/modules/cassandra/src/test/bootstrap/aws/ganglia/ganglia-bootstrap.sh
new file mode 100644
index 0000000..15fa044
--- /dev/null
+++ b/modules/cassandra/src/test/bootstrap/aws/ganglia/ganglia-bootstrap.sh
@@ -0,0 +1,417 @@
+#!/bin/sh
+
+#
+# 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.
+#
+
+# -----------------------------------------------------------------------------------------------
+# Bootstrap script to spin up Ganglia master
+# -----------------------------------------------------------------------------------------------
+
+# URL to download AWS CLI tools
+AWS_CLI_DOWNLOAD_URL=https://s3.amazonaws.com/aws-cli/awscli-bundle.zip
+
+# URL to download JDK
+JDK_DOWNLOAD_URL=http://download.oracle.com/otn-pub/java/jdk/8u77-b03/jdk-8u77-linux-x64.tar.gz
+
+# URL to download Ignite-Cassandra tests package - you should previously package and upload it to this place
+TESTS_PACKAGE_DONLOAD_URL=s3://<bucket>/<folder>/ignite-cassandra-tests-<version>.zip
+
+# Terminates script execution and upload logs to S3
+terminate()
+{
+ SUCCESS_URL=$S3_GANGLIA_BOOTSTRAP_SUCCESS
+ FAILURE_URL=$S3_GANGLIA_BOOTSTRAP_FAILURE
+
+ if [ -n "$SUCCESS_URL" ] && [[ "$SUCCESS_URL" != */ ]]; then
+ SUCCESS_URL=${SUCCESS_URL}/
+ fi
+
+ if [ -n "$FAILURE_URL" ] && [[ "$FAILURE_URL" != */ ]]; then
+ FAILURE_URL=${FAILURE_URL}/
+ fi
+
+ host_name=$(hostname -f | tr '[:upper:]' '[:lower:]')
+ msg=$host_name
+
+ if [ -n "$1" ]; then
+ echo "[ERROR] $1"
+ echo "[ERROR]-----------------------------------------------------"
+ echo "[ERROR] Ganglia master node bootstrap failed"
+ echo "[ERROR]-----------------------------------------------------"
+ msg=$1
+
+ if [ -z "$FAILURE_URL" ]; then
+ exit 1
+ fi
+
+ reportFolder=${FAILURE_URL}${host_name}
+ reportFile=$reportFolder/__error__
+ else
+ echo "[INFO]-----------------------------------------------------"
+ echo "[INFO] Ganglia master node bootstrap successfully completed"
+ echo "[INFO]-----------------------------------------------------"
+
+ if [ -z "$SUCCESS_URL" ]; then
+ exit 0
+ fi
+
+ reportFolder=${SUCCESS_URL}${host_name}
+ reportFile=$reportFolder/__success__
+ fi
+
+ echo $msg > /opt/bootstrap-result
+
+ aws s3 rm --recursive $reportFolder
+ if [ $? -ne 0 ]; then
+ echo "[ERROR] Failed to drop report folder: $reportFolder"
+ fi
+
+ aws s3 cp --sse AES256 /opt/bootstrap-result $reportFile
+ if [ $? -ne 0 ]; then
+ echo "[ERROR] Failed to report bootstrap result to: $reportFile"
+ fi
+
+ rm -f /opt/bootstrap-result
+
+ if [ -n "$1" ]; then
+ exit 1
+ fi
+
+ exit 0
+}
+
+# Downloads specified package
+downloadPackage()
+{
+ echo "[INFO] Downloading $3 package from $1 into $2"
+
+ for i in 0 9;
+ do
+ if [[ "$1" == s3* ]]; then
+ aws s3 cp $1 $2
+ code=$?
+ else
+ curl "$1" -o "$2"
+ code=$?
+ fi
+
+ if [ $code -eq 0 ]; then
+ echo "[INFO] $3 package successfully downloaded from $1 into $2"
+ return 0
+ fi
+
+ echo "[WARN] Failed to download $3 package from $i attempt, sleeping extra 5sec"
+ sleep 5s
+ done
+
+ terminate "All 10 attempts to download $3 package from $1 are failed"
+}
+
+# Downloads and setup JDK
+setupJava()
+{
+ rm -Rf /opt/java /opt/jdk.tar.gz
+
+ echo "[INFO] Downloading 'jdk'"
+ wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "$JDK_DOWNLOAD_URL" -O /opt/jdk.tar.gz
+ if [ $? -ne 0 ]; then
+ terminate "Failed to download 'jdk'"
+ fi
+
+ echo "[INFO] Untaring 'jdk'"
+ tar -xvzf /opt/jdk.tar.gz -C /opt
+ if [ $? -ne 0 ]; then
+ terminate "Failed to untar 'jdk'"
+ fi
+
+ rm -Rf /opt/jdk.tar.gz
+
+ unzipDir=$(ls /opt | grep "jdk")
+ if [ "$unzipDir" != "java" ]; then
+ mv /opt/$unzipDir /opt/java
+ fi
+}
+
+# Downloads and setup AWS CLI
+setupAWSCLI()
+{
+ echo "[INFO] Installing 'awscli'"
+ pip install --upgrade awscli
+ if [ $? -eq 0 ]; then
+ return 0
+ fi
+
+ echo "[ERROR] Failed to install 'awscli' using pip"
+ echo "[INFO] Trying to install awscli using zip archive"
+ echo "[INFO] Downloading awscli zip"
+
+ downloadPackage "$AWS_CLI_DOWNLOAD_URL" "/opt/awscli-bundle.zip" "awscli"
+
+ echo "[INFO] Unzipping awscli zip"
+ unzip /opt/awscli-bundle.zip -d /opt
+ if [ $? -ne 0 ]; then
+ terminate "Failed to unzip awscli zip"
+ fi
+
+ rm -Rf /opt/awscli-bundle.zip
+
+ echo "[INFO] Installing awscli"
+ /opt/awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
+ if [ $? -ne 0 ]; then
+ terminate "Failed to install awscli"
+ fi
+
+ echo "[INFO] Successfully installed awscli from zip archive"
+}
+
+# Setup all the pre-requisites (packages, settings and etc.)
+setupPreRequisites()
+{
+ echo "[INFO] Installing 'wget' package"
+ yum -y install wget
+ if [ $? -ne 0 ]; then
+ terminate "Failed to install 'wget' package"
+ fi
+
+ echo "[INFO] Installing 'net-tools' package"
+ yum -y install net-tools
+ if [ $? -ne 0 ]; then
+ terminate "Failed to install 'net-tools' package"
+ fi
+
+ echo "[INFO] Installing 'python' package"
+ yum -y install python
+ if [ $? -ne 0 ]; then
+ terminate "Failed to install 'python' package"
+ fi
+
+ echo "[INFO] Installing 'unzip' package"
+ yum -y install unzip
+ if [ $? -ne 0 ]; then
+ terminate "Failed to install 'unzip' package"
+ fi
+
+ downloadPackage "https://bootstrap.pypa.io/get-pip.py" "/opt/get-pip.py" "get-pip.py"
+
+ echo "[INFO] Installing 'pip'"
+ python /opt/get-pip.py
+ if [ $? -ne 0 ]; then
+ terminate "Failed to install 'pip'"
+ fi
+}
+
+# Downloads and setup tests package
+setupTestsPackage()
+{
+ downloadPackage "$TESTS_PACKAGE_DONLOAD_URL" "/opt/ignite-cassandra-tests.zip" "Tests"
+
+ rm -Rf /opt/ignite-cassandra-tests
+
+ unzip /opt/ignite-cassandra-tests.zip -d /opt
+ if [ $? -ne 0 ]; then
+ terminate "Failed to unzip tests package"
+ fi
+
+ rm -f /opt/ignite-cassandra-tests.zip
+
+ unzipDir=$(ls /opt | grep "ignite-cassandra")
+ if [ "$unzipDir" != "ignite-cassandra-tests" ]; then
+ mv /opt/$unzipDir /opt/ignite-cassandra-tests
+ fi
+
+ find /opt/ignite-cassandra-tests -type f -name "*.sh" -exec chmod ug+x {} \;
+
+ . /opt/ignite-cassandra-tests/bootstrap/aws/common.sh "ganglia"
+
+ setupNTP
+
+ echo "[INFO] Starting logs collector daemon"
+
+ HOST_NAME=$(hostname -f | tr '[:upper:]' '[:lower:]')
+ /opt/ignite-cassandra-tests/bootstrap/aws/logs-collector.sh "$S3_LOGS_TRIGGER" "$S3_GANGLIA_LOGS/$HOST_NAME" "/var/log/httpd" > /opt/logs-collector.log &
+
+ echo "[INFO] Logs collector daemon started: $!"
+
+ echo "----------------------------------------------------------------------------------------"
+ printInstanceInfo
+ echo "----------------------------------------------------------------------------------------"
+ tagInstance
+}
+
+# Creates config file for 'gmond' damon working in receiver mode
+createGmondReceiverConfig()
+{
+ /usr/local/sbin/gmond --default_config > /opt/gmond-default.conf
+ if [ $? -ne 0 ]; then
+ terminate "Failed to create gmond default config in: /opt/gmond-default.txt"
+ fi
+
+ HOST_NAME=$(hostname -f | tr '[:upper:]' '[:lower:]')
+
+ cat /opt/gmond-default.conf | sed -r "s/mute = no/mute = yes/g" | \
+ sed -r "s/name = \"unspecified\"/name = \"$1\"/g" | \
+ sed -r "s/#bind_hostname/bind_hostname/g" | \
+ sed "0,/mcast_join = 239.2.11.71/s/mcast_join = 239.2.11.71/host = $HOST_NAME/g" | \
+ sed -r "s/mcast_join = 239.2.11.71//g" | sed -r "s/bind = 239.2.11.71//g" | \
+ sed -r "s/port = 8649/port = $2/g" | sed -r "s/retry_bind = true//g" > /opt/gmond-${1}.conf
+
+ chmod a+r /opt/gmond-${1}.conf
+
+ rm -f /opt/gmond-default.conf
+}
+
+# Creates config file for 'gmond' damon working in sender-receiver mode
+createGmondSenderReceiverConfig()
+{
+ /usr/local/sbin/gmond --default_config > /opt/gmond-default.conf
+ if [ $? -ne 0 ]; then
+ terminate "Failed to create gmond default config in: /opt/gmond-default.txt"
+ fi
+
+ HOST_NAME=$(hostname -f | tr '[:upper:]' '[:lower:]')
+
+ cat /opt/gmond-default.conf | sed -r "s/name = \"unspecified\"/name = \"$1\"/g" | \
+ sed -r "s/#bind_hostname/bind_hostname/g" | \
+ sed "0,/mcast_join = 239.2.11.71/s/mcast_join = 239.2.11.71/host = $HOST_NAME/g" | \
+ sed -r "s/mcast_join = 239.2.11.71//g" | sed -r "s/bind = 239.2.11.71//g" | \
+ sed -r "s/port = 8649/port = $2/g" | sed -r "s/retry_bind = true//g" > /opt/gmond-${1}.conf
+
+ chmod a+r /opt/gmond-${1}.conf
+
+ rm -f /opt/gmond-default.conf
+}
+
+# Downloads and setup Ganglia (and dependency) packages
+setupGangliaPackages()
+{
+ installGangliaPackages "master"
+
+ HOST_NAME=$(hostname -f | tr '[:upper:]' '[:lower:]')
+
+ echo "data_source \"cassandra\" ${HOST_NAME}:8641" > /opt/gmetad.conf
+ echo "data_source \"ignite\" ${HOST_NAME}:8642" >> /opt/gmetad.conf
+ echo "data_source \"test\" ${HOST_NAME}:8643" >> /opt/gmetad.conf
+ #echo "data_source \"ganglia\" ${HOST_NAME}:8644" >> /opt/gmetad.conf
+ echo "setuid_username \"nobody\"" >> /opt/gmetad.conf
+ echo "case_sensitive_hostnames 0" >> /opt/gmetad.conf
+
+ chmod a+r /opt/gmetad.conf
+
+ createGmondReceiverConfig cassandra 8641
+ createGmondReceiverConfig ignite 8642
+ createGmondReceiverConfig test 8643
+ #createGmondSenderReceiverConfig ganglia 8644
+}
+
+# Starts 'gmond' receiver damon
+startGmondReceiver()
+{
+ configFile=/opt/gmond-${1}.conf
+ pidFile=/opt/gmond-${1}.pid
+
+ echo "[INFO] Starting gmond receiver daemon for $1 cluster using config file: $configFile"
+
+ rm -f $pidFile
+
+ /usr/local/sbin/gmond --conf=$configFile --pid-file=$pidFile
+
+ sleep 2s
+
+ if [ ! -f "$pidFile" ]; then
+ terminate "Failed to start gmond daemon for $1 cluster, pid file doesn't exist"
+ fi
+
+ pid=$(cat $pidFile)
+
+ echo "[INFO] gmond daemon for $1 cluster started, pid=$pid"
+
+ exists=$(ps $pid | grep gmond)
+
+ if [ -z "$exists" ]; then
+ terminate "gmond daemon for $1 cluster abnormally terminated"
+ fi
+}
+
+# Starts 'gmetad' daemon
+startGmetadCollector()
+{
+ echo "[INFO] Starting gmetad daemon"
+
+ rm -f /opt/gmetad.pid
+
+ /usr/local/sbin/gmetad --conf=/opt/gmetad.conf --pid-file=/opt/gmetad.pid
+
+ sleep 2s
+
+ if [ ! -f "/opt/gmetad.pid" ]; then
+ terminate "Failed to start gmetad daemon, pid file doesn't exist"
+ fi
+
+ pid=$(cat /opt/gmetad.pid)
+
+ echo "[INFO] gmetad daemon started, pid=$pid"
+
+ exists=$(ps $pid | grep gmetad)
+
+ if [ -z "$exists" ]; then
+ terminate "gmetad daemon abnormally terminated"
+ fi
+}
+
+# Starts Apache 'httpd' service
+startHttpdService()
+{
+ echo "[INFO] Starting httpd service"
+
+ service httpd start
+
+ if [ $? -ne 0 ]; then
+ terminate "Failed to start httpd service"
+ fi
+
+ sleep 5s
+
+ exists=$(service httpd status | grep running)
+ if [ -z "$exists" ]; then
+ terminate "httpd service process terminated"
+ fi
+
+ echo "[INFO] httpd service successfully started"
+}
+
+###################################################################################################################
+
+echo "[INFO]-----------------------------------------------------------------"
+echo "[INFO] Bootstrapping Ganglia master server"
+echo "[INFO]-----------------------------------------------------------------"
+
+setupPreRequisites
+setupJava
+setupAWSCLI
+setupTestsPackage
+setupGangliaPackages
+
+registerNode
+
+startGmondReceiver cassandra
+startGmondReceiver ignite
+startGmondReceiver test
+#startGmondReceiver ganglia
+startGmetadCollector
+startHttpdService
+
+terminate
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee8ac73f/modules/cassandra/src/test/bootstrap/aws/ignite/ignite-bootstrap.sh
----------------------------------------------------------------------
diff --git a/modules/cassandra/src/test/bootstrap/aws/ignite/ignite-bootstrap.sh b/modules/cassandra/src/test/bootstrap/aws/ignite/ignite-bootstrap.sh
index a3a0601..7f97ea1 100644
--- a/modules/cassandra/src/test/bootstrap/aws/ignite/ignite-bootstrap.sh
+++ b/modules/cassandra/src/test/bootstrap/aws/ignite/ignite-bootstrap.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
#
# Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,42 +17,31 @@
# limitations under the License.
#
-AWS_CLI_DOWNLOAD_URL=https://s3.amazonaws.com/aws-cli/awscli-bundle.zip
-
-S3_ROOT=s3://bucket/folder
-S3_DOWNLOADS=$S3_ROOT/test
-S3_SYSTEM=$S3_ROOT/test1
-
-IGNITE_DOWNLOAD_URL=$S3_DOWNLOADS/apache-ignite-fabric-1.6.0-SNAPSHOT-bin.zip
-IGNITE_ZIP=apache-ignite-fabric-1.6.0-SNAPSHOT-bin.zip
-IGNITE_UNZIP_DIR=apache-ignite-fabric-1.6.0-SNAPSHOT-bin
+# -----------------------------------------------------------------------------------------------
+# Bootstrap script to spin up Ignite cluster
+# -----------------------------------------------------------------------------------------------
-TESTS_PACKAGE_DONLOAD_URL=$S3_DOWNLOADS/ignite-cassandra-tests-1.6.0-SNAPSHOT.zip
-TESTS_PACKAGE_ZIP=ignite-cassandra-tests-1.6.0-SNAPSHOT.zip
-TESTS_PACKAGE_UNZIP_DIR=ignite-cassandra-tests
+# URL to download AWS CLI tools
+AWS_CLI_DOWNLOAD_URL=https://s3.amazonaws.com/aws-cli/awscli-bundle.zip
-S3_LOGS_URL=$S3_SYSTEM/logs/i-logs
-S3_LOGS_TRIGGER_URL=$S3_SYSTEM/logs-trigger
-S3_BOOTSTRAP_SUCCESS_URL=$S3_SYSTEM/i-success
-S3_BOOTSTRAP_FAILURE_URL=$S3_SYSTEM/i-failure
-S3_CASSANDRA_NODES_DISCOVERY_URL=$S3_SYSTEM/c-discovery
-S3_IGNITE_NODES_DISCOVERY_URL=$S3_SYSTEM/i-discovery
-S3_IGNITE_FIRST_NODE_LOCK_URL=$S3_SYSTEM/i-first-node-lock
-S3_IGNITE_NODES_JOIN_LOCK_URL=$S3_SYSTEM/i-join-lock
+# URL to download JDK
+JDK_DOWNLOAD_URL=http://download.oracle.com/otn-pub/java/jdk/8u77-b03/jdk-8u77-linux-x64.tar.gz
-INSTANCE_REGION=us-west-2
-INSTANCE_NAME_TAG=IGNITE-SERVER
-INSTANCE_OWNER_TAG=ignite@apache.org
-INSTANCE_PROJECT_TAG=ignite
+# URL to download Ignite-Cassandra tests package - you should previously package and upload it to this place
+TESTS_PACKAGE_DONLOAD_URL=s3://<bucket>/<folder>/ignite-cassandra-tests-<version>.zip
+# Terminates script execution and upload logs to S3
terminate()
{
- if [[ "$S3_BOOTSTRAP_SUCCESS_URL" != */ ]]; then
- S3_BOOTSTRAP_SUCCESS_URL=${S3_BOOTSTRAP_SUCCESS_URL}/
+ SUCCESS_URL=$S3_IGNITE_BOOTSTRAP_SUCCESS
+ FAILURE_URL=$S3_IGNITE_BOOTSTRAP_FAILURE
+
+ if [ -n "$SUCCESS_URL" ] && [[ "$SUCCESS_URL" != */ ]]; then
+ SUCCESS_URL=${SUCCESS_URL}/
fi
- if [[ "$S3_BOOTSTRAP_FAILURE_URL" != */ ]]; then
- S3_BOOTSTRAP_FAILURE_URL=${S3_BOOTSTRAP_FAILURE_URL}/
+ if [ -n "$FAILURE_URL" ] && [[ "$FAILURE_URL" != */ ]]; then
+ FAILURE_URL=${FAILURE_URL}/
fi
host_name=$(hostname -f | tr '[:upper:]' '[:lower:]')
@@ -64,13 +53,23 @@ terminate()
echo "[ERROR] Ignite node bootstrap failed"
echo "[ERROR]-----------------------------------------------------"
msg=$1
- reportFolder=${S3_BOOTSTRAP_FAILURE_URL}${host_name}
+
+ if [ -z "$FAILURE_URL" ]; then
+ exit 1
+ fi
+
+ reportFolder=${FAILURE_URL}${host_name}
reportFile=$reportFolder/__error__
else
echo "[INFO]-----------------------------------------------------"
echo "[INFO] Ignite node bootstrap successfully completed"
echo "[INFO]-----------------------------------------------------"
- reportFolder=${S3_BOOTSTRAP_SUCCESS_URL}${host_name}
+
+ if [ -z "$SUCCESS_URL" ]; then
+ exit 0
+ fi
+
+ reportFolder=${SUCCESS_URL}${host_name}
reportFile=$reportFolder/__success__
fi
@@ -78,7 +77,7 @@ terminate()
aws s3 rm --recursive $reportFolder
if [ $? -ne 0 ]; then
- echo "[ERROR] Failed drop report folder: $reportFolder"
+ echo "[ERROR] Failed to drop report folder: $reportFolder"
fi
aws s3 cp --sse AES256 /opt/bootstrap-result $reportFile
@@ -95,170 +94,67 @@ terminate()
exit 0
}
-tagInstance()
-{
- export EC2_HOME=/opt/aws/apitools/ec2
- export JAVA_HOME=/opt/jdk1.8.0_77
- export PATH=$JAVA_HOME/bin:$EC2_HOME/bin:$PATH
-
- INSTANCE_ID=$(curl http://169.254.169.254/latest/meta-data/instance-id)
- if [ $? -ne 0 ]; then
- terminate "Failed to get instance metadata to tag it"
- fi
-
- if [ -n "$INSTANCE_NAME_TAG" ]; then
- ec2-create-tags $INSTANCE_ID --tag Name=${INSTANCE_NAME_TAG} --region $INSTANCE_REGION
- if [ $code -ne 0 ]; then
- terminate "Failed to tag EC2 instance with: Name=${INSTANCE_NAME_TAG}"
- fi
- fi
-
- if [ -n "$INSTANCE_OWNER_TAG" ]; then
- ec2-create-tags $INSTANCE_ID --tag owner=${INSTANCE_OWNER_TAG} --region $INSTANCE_REGION
- if [ $code -ne 0 ]; then
- terminate "Failed to tag EC2 instance with: owner=${INSTANCE_OWNER_TAG}"
- fi
- fi
-
- if [ -n "$INSTANCE_PROJECT_TAG" ]; then
- ec2-create-tags $INSTANCE_ID --tag project=${INSTANCE_PROJECT_TAG} --region $INSTANCE_REGION
- if [ $code -ne 0 ]; then
- terminate "Failed to tag EC2 instance with: project=${INSTANCE_PROJECT_TAG}"
- fi
- fi
-}
-
+# Downloads specified package
downloadPackage()
{
echo "[INFO] Downloading $3 package from $1 into $2"
- if [[ "$1" == s3* ]]; then
- aws s3 cp $1 $2
-
- if [ $? -ne 0 ]; then
- echo "[WARN] Failed to download $3 package from first attempt"
- rm -Rf $2
- sleep 10s
-
- echo "[INFO] Trying second attempt to download $3 package"
+ for i in 0 9;
+ do
+ if [[ "$1" == s3* ]]; then
aws s3 cp $1 $2
-
- if [ $? -ne 0 ]; then
- echo "[WARN] Failed to download $3 package from second attempt"
- rm -Rf $2
- sleep 10s
-
- echo "[INFO] Trying third attempt to download $3 package"
- aws s3 cp $1 $2
-
- if [ $? -ne 0 ]; then
- terminate "All three attempts to download $3 package from $1 are failed"
- fi
- fi
+ code=$?
+ else
+ curl "$1" -o "$2"
+ code=$?
fi
- else
- curl "$1" -o "$2"
- if [ $? -ne 0 ] && [ $? -ne 6 ]; then
- echo "[WARN] Failed to download $3 package from first attempt"
- rm -Rf $2
- sleep 10s
+ if [ $code -eq 0 ]; then
+ echo "[INFO] $3 package successfully downloaded from $1 into $2"
+ return 0
+ fi
- echo "[INFO] Trying second attempt to download $3 package"
- curl "$1" -o "$2"
+ echo "[WARN] Failed to download $3 package from $i attempt, sleeping extra 5sec"
+ sleep 5s
+ done
- if [ $? -ne 0 ] && [ $? -ne 6 ]; then
- echo "[WARN] Failed to download $3 package from second attempt"
- rm -Rf $2
- sleep 10s
+ terminate "All 10 attempts to download $3 package from $1 are failed"
+}
- echo "[INFO] Trying third attempt to download $3 package"
- curl "$1" -o "$2"
+# Downloads and setup JDK
+setupJava()
+{
+ rm -Rf /opt/java /opt/jdk.tar.gz
- if [ $? -ne 0 ] && [ $? -ne 6 ]; then
- terminate "All three attempts to download $3 package from $1 are failed"
- fi
- fi
- fi
+ echo "[INFO] Downloading 'jdk'"
+ wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "$JDK_DOWNLOAD_URL" -O /opt/jdk.tar.gz
+ if [ $? -ne 0 ]; then
+ terminate "Failed to download 'jdk'"
fi
- echo "[INFO] $3 package successfully downloaded from $1 into $2"
-}
+ echo "[INFO] Untaring 'jdk'"
+ tar -xvzf /opt/jdk.tar.gz -C /opt
+ if [ $? -ne 0 ]; then
+ terminate "Failed to untar 'jdk'"
+ fi
-if [[ "$S3_IGNITE_NODES_DISCOVERY_URL" != */ ]]; then
- S3_IGNITE_NODES_DISCOVERY_URL=${S3_IGNITE_NODES_DISCOVERY_URL}/
-fi
+ rm -Rf /opt/jdk.tar.gz
-if [[ "$S3_CASSANDRA_NODES_DISCOVERY_URL" != */ ]]; then
- S3_CASSANDRA_NODES_DISCOVERY_URL=${S3_CASSANDRA_NODES_DISCOVERY_URL}/
-fi
+ unzipDir=$(ls /opt | grep "jdk")
+ if [ "$unzipDir" != "java" ]; then
+ mv /opt/$unzipDir /opt/java
+ fi
+}
-echo "[INFO]-----------------------------------------------------------------"
-echo "[INFO] Bootstrapping Ignite node"
-echo "[INFO]-----------------------------------------------------------------"
-echo "[INFO] Ignite download URL: $IGNITE_DOWNLOAD_URL"
-echo "[INFO] Tests package download URL: $TESTS_PACKAGE_DONLOAD_URL"
-echo "[INFO] Logs URL: $S3_LOGS_URL"
-echo "[INFO] Logs trigger URL: $S3_LOGS_TRIGGER_URL"
-echo "[INFO] Ignite node discovery URL: $S3_IGNITE_NODES_DISCOVERY_URL"
-echo "[INFO] Ignite first node lock URL: $S3_IGNITE_FIRST_NODE_LOCK_URL"
-echo "[INFO] Ignite nodes join lock URL: $S3_IGNITE_NODES_JOIN_LOCK_URL"
-echo "[INFO] Cassandra node discovery URL: $S3_CASSANDRA_NODES_DISCOVERY_URL"
-echo "[INFO] Bootsrap success URL: $S3_BOOTSTRAP_SUCCESS_URL"
-echo "[INFO] Bootsrap failure URL: $S3_BOOTSTRAP_FAILURE_URL"
-echo "[INFO]-----------------------------------------------------------------"
+# Downloads and setup AWS CLI
+setupAWSCLI()
+{
+ echo "[INFO] Installing 'awscli'"
+ pip install --upgrade awscli
+ if [ $? -eq 0 ]; then
+ return 0
+ fi
-echo "[INFO] Installing 'wget' package"
-yum -y install wget
-if [ $? -ne 0 ]; then
- terminate "Failed to install 'wget' package"
-fi
-
-echo "[INFO] Installing 'net-tools' package"
-yum -y install net-tools
-if [ $? -ne 0 ]; then
- terminate "Failed to install 'net-tools' package"
-fi
-
-echo "[INFO] Installing 'python' package"
-yum -y install python
-if [ $? -ne 0 ]; then
- terminate "Failed to install 'python' package"
-fi
-
-echo "[INFO] Installing 'unzip' package"
-yum -y install unzip
-if [ $? -ne 0 ]; then
- terminate "Failed to install 'unzip' package"
-fi
-
-rm -Rf /opt/jdk1.8.0_77 /opt/jdk-8u77-linux-x64.tar.gz
-
-echo "[INFO] Downloading 'jdk-8u77'"
-wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u77-b03/jdk-8u77-linux-x64.tar.gz" -O /opt/jdk-8u77-linux-x64.tar.gz
-if [ $? -ne 0 ]; then
- terminate "Failed to download 'jdk-8u77'"
-fi
-
-echo "[INFO] Unzipping 'jdk-8u77'"
-tar -xvzf /opt/jdk-8u77-linux-x64.tar.gz -C /opt
-if [ $? -ne 0 ]; then
- terminate "Failed to untar 'jdk-8u77'"
-fi
-
-rm -Rf /opt/jdk-8u77-linux-x64.tar.gz
-
-downloadPackage "https://bootstrap.pypa.io/get-pip.py" "/opt/get-pip.py" "get-pip.py"
-
-echo "[INFO] Installing 'pip'"
-python /opt/get-pip.py
-if [ $? -ne 0 ]; then
- terminate "Failed to install 'pip'"
-fi
-
-echo "[INFO] Installing 'awscli'"
-pip install --upgrade awscli
-if [ $? -ne 0 ]; then
echo "[ERROR] Failed to install 'awscli' using pip"
echo "[INFO] Trying to install awscli using zip archive"
echo "[INFO] Downloading awscli zip"
@@ -271,7 +167,7 @@ if [ $? -ne 0 ]; then
terminate "Failed to unzip awscli zip"
fi
- rm -fR /opt/awscli-bundle.zip
+ rm -Rf /opt/awscli-bundle.zip
echo "[INFO] Installing awscli"
/opt/awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
@@ -280,105 +176,161 @@ if [ $? -ne 0 ]; then
fi
echo "[INFO] Successfully installed awscli from zip archive"
-fi
+}
+
+# Setup all the pre-requisites (packages, settings and etc.)
+setupPreRequisites()
+{
+ echo "[INFO] Installing 'wget' package"
+ yum -y install wget
+ if [ $? -ne 0 ]; then
+ terminate "Failed to install 'wget' package"
+ fi
+
+ echo "[INFO] Installing 'net-tools' package"
+ yum -y install net-tools
+ if [ $? -ne 0 ]; then
+ terminate "Failed to install 'net-tools' package"
+ fi
-tagInstance
+ echo "[INFO] Installing 'python' package"
+ yum -y install python
+ if [ $? -ne 0 ]; then
+ terminate "Failed to install 'python' package"
+ fi
-echo "[INFO] Creating 'ignite' group"
-exists=$(cat /etc/group | grep ignite)
-if [ -z "$exists" ]; then
- groupadd ignite
+ echo "[INFO] Installing 'unzip' package"
+ yum -y install unzip
if [ $? -ne 0 ]; then
- terminate "Failed to create 'ignite' group"
+ terminate "Failed to install 'unzip' package"
fi
-fi
-echo "[INFO] Creating 'ignite' user"
-exists=$(cat /etc/passwd | grep ignite)
-if [ -z "$exists" ]; then
- useradd -g ignite ignite
+ downloadPackage "https://bootstrap.pypa.io/get-pip.py" "/opt/get-pip.py" "get-pip.py"
+
+ echo "[INFO] Installing 'pip'"
+ python /opt/get-pip.py
if [ $? -ne 0 ]; then
- terminate "Failed to create 'ignite' user"
+ terminate "Failed to install 'pip'"
fi
-fi
+}
+
+# Downloads and setup tests package
+setupTestsPackage()
+{
+ downloadPackage "$TESTS_PACKAGE_DONLOAD_URL" "/opt/ignite-cassandra-tests.zip" "Tests"
-rm -Rf /opt/ignite /opt/$IGNITE_ZIP
+ rm -Rf /opt/ignite-cassandra-tests
-downloadPackage "$IGNITE_DOWNLOAD_URL" "/opt/$IGNITE_ZIP" "Ignite"
+ unzip /opt/ignite-cassandra-tests.zip -d /opt
+ if [ $? -ne 0 ]; then
+ terminate "Failed to unzip tests package"
+ fi
+
+ rm -f /opt/ignite-cassandra-tests.zip
-echo "[INFO] Unzipping Ignite package"
-unzip /opt/$IGNITE_ZIP -d /opt
-if [ $? -ne 0 ]; then
- terminate "Failed to unzip Ignite package"
-fi
+ unzipDir=$(ls /opt | grep "ignite-cassandra")
+ if [ "$unzipDir" != "ignite-cassandra-tests" ]; then
+ mv /opt/$unzipDir /opt/ignite-cassandra-tests
+ fi
-rm -Rf /opt/$IGNITE_ZIP /opt/ignite-start.sh /opt/ignite-env.sh /opt/ignite
-mv /opt/$IGNITE_UNZIP_DIR /opt/ignite
-chown -R ignite:ignite /opt/ignite
+ find /opt/ignite-cassandra-tests -type f -name "*.sh" -exec chmod ug+x {} \;
-downloadPackage "$TESTS_PACKAGE_DONLOAD_URL" "/opt/$TESTS_PACKAGE_ZIP" "Tests"
+ . /opt/ignite-cassandra-tests/bootstrap/aws/common.sh "ignite"
-unzip /opt/$TESTS_PACKAGE_ZIP -d /opt
-if [ $? -ne 0 ]; then
- terminate "Failed to unzip tests package: $TESTS_PACKAGE_DONLOAD_URL"
-fi
+ setupNTP
-chown -R ignite:ignite /opt/$TESTS_PACKAGE_UNZIP_DIR
-find /opt/$TESTS_PACKAGE_UNZIP_DIR -type f -name "*.sh" -exec chmod ug+x {} \;
+ echo "[INFO] Starting logs collector daemon"
-if [ ! -f "/opt/$TESTS_PACKAGE_UNZIP_DIR/bootstrap/aws/ignite/ignite-start.sh" ]; then
- terminate "There are no ignite-start.sh in tests package"
-fi
+ HOST_NAME=$(hostname -f | tr '[:upper:]' '[:lower:]')
+ /opt/ignite-cassandra-tests/bootstrap/aws/logs-collector.sh "$S3_LOGS_TRIGGER" "$S3_IGNITE_LOGS/$HOST_NAME" "/opt/ignite/work/log" "/opt/ignite/ignite-start.log" > /opt/logs-collector.log &
-if [ ! -f "/opt/$TESTS_PACKAGE_UNZIP_DIR/bootstrap/aws/ignite/ignite-cassandra-server-template.xml" ]; then
- terminate "There are no ignite-cassandra-server-template.xml in tests package"
-fi
+ echo "[INFO] Logs collector daemon started: $!"
-if [ ! -f "/opt/$TESTS_PACKAGE_UNZIP_DIR/bootstrap/aws/logs-collector.sh" ]; then
- terminate "There are no logs-collector.sh in tests package"
-fi
+ echo "----------------------------------------------------------------------------------------"
+ printInstanceInfo
+ echo "----------------------------------------------------------------------------------------"
+ tagInstance
+ bootstrapGangliaAgent "ignite" 8642
+}
-testsJar=$(find /opt/$TESTS_PACKAGE_UNZIP_DIR -type f -name "*.jar" | grep ignite-cassandra- | grep tests.jar)
-if [ -n "$testsJar" ]; then
- echo "[INFO] Coping tests jar $testsJar into /opt/ignite/libs/optional/ignite-cassandra"
- cp $testsJar /opt/ignite/libs/optional/ignite-cassandra
+# Downloads Ignite package
+downloadIgnite()
+{
+ downloadPackage "$IGNITE_DOWNLOAD_URL" "/opt/ignite.zip" "Ignite"
+
+ rm -Rf /opt/ignite
+
+ echo "[INFO] Unzipping Ignite package"
+ unzip /opt/ignite.zip -d /opt
if [ $? -ne 0 ]; then
- terminate "Failed copy $testsJar into /opt/ignite/libs/optional/ignite-cassandra"
+ terminate "Failed to unzip Ignite package"
fi
-fi
-mv -f /opt/$TESTS_PACKAGE_UNZIP_DIR/bootstrap/aws/ignite/ignite-start.sh /opt
-mv -f /opt/$TESTS_PACKAGE_UNZIP_DIR/bootstrap/aws/ignite/ignite-cassandra-server-template.xml /opt/ignite/config
-mv -f /opt/$TESTS_PACKAGE_UNZIP_DIR/bootstrap/aws/logs-collector.sh /opt
+ rm -f /opt/ignite.zip
-if [ -f "/opt/$TESTS_PACKAGE_UNZIP_DIR/bootstrap/aws/ignite/ignite-env.sh" ]; then
- mv -f /opt/$TESTS_PACKAGE_UNZIP_DIR/bootstrap/aws/ignite/ignite-env.sh /opt
- chown -R ignite:ignite /opt/ignite-env.sh
-fi
+ unzipDir=$(ls /opt | grep "ignite" | grep "apache")
+ if [ "$unzipDir" != "ignite" ]; then
+ mv /opt/$unzipDir /opt/ignite
+ fi
+}
-rm -Rf /opt/$TESTS_PACKAGE_UNZIP_DIR
-chown -R ignite:ignite /opt/ignite-start.sh /opt/logs-collector.sh /opt/ignite/config/ignite-cassandra-server-template.xml
+# Setups Ignite
+setupIgnite()
+{
+ echo "[INFO] Creating 'ignite' group"
+ exists=$(cat /etc/group | grep ignite)
+ if [ -z "$exists" ]; then
+ groupadd ignite
+ if [ $? -ne 0 ]; then
+ terminate "Failed to create 'ignite' group"
+ fi
+ fi
-#profile=/home/ignite/.bash_profile
-profile=/root/.bash_profile
+ echo "[INFO] Creating 'ignite' user"
+ exists=$(cat /etc/passwd | grep ignite)
+ if [ -z "$exists" ]; then
+ useradd -g ignite ignite
+ if [ $? -ne 0 ]; then
+ terminate "Failed to create 'ignite' user"
+ fi
+ fi
-echo "export JAVA_HOME=/opt/jdk1.8.0_77" >> $profile
-echo "export IGNITE_HOME=/opt/ignite" >> $profile
-echo "export USER_LIBS=\$IGNITE_HOME/libs/optional/ignite-cassandra/*:\$IGNITE_HOME/libs/optional/ignite-slf4j/*" >> $profile
-echo "export PATH=\$JAVA_HOME/bin:\IGNITE_HOME/bin:\$PATH" >> $profile
-echo "export S3_BOOTSTRAP_SUCCESS_URL=$S3_BOOTSTRAP_SUCCESS_URL" >> $profile
-echo "export S3_BOOTSTRAP_FAILURE_URL=$S3_BOOTSTRAP_FAILURE_URL" >> $profile
-echo "export S3_CASSANDRA_NODES_DISCOVERY_URL=$S3_CASSANDRA_NODES_DISCOVERY_URL" >> $profile
-echo "export S3_IGNITE_NODES_DISCOVERY_URL=$S3_IGNITE_NODES_DISCOVERY_URL" >> $profile
-echo "export S3_IGNITE_NODES_JOIN_LOCK_URL=$S3_IGNITE_NODES_JOIN_LOCK_URL" >> $profile
-echo "export S3_IGNITE_FIRST_NODE_LOCK_URL=$S3_IGNITE_FIRST_NODE_LOCK_URL" >> $profile
+ testsJar=$(find /opt/ignite-cassandra-tests -type f -name "*.jar" | grep ignite-cassandra- | grep tests.jar)
+ if [ -n "$testsJar" ]; then
+ echo "[INFO] Coping tests jar $testsJar into /opt/ignite/libs/optional/ignite-cassandra"
+ cp $testsJar /opt/ignite/libs/optional/ignite-cassandra
+ if [ $? -ne 0 ]; then
+ terminate "Failed copy $testsJar into /opt/ignite/libs/optional/ignite-cassandra"
+ fi
+ fi
+
+ rm -f /opt/ignite/config/ignite-cassandra-server-template.xml
+ mv -f /opt/ignite-cassandra-tests/bootstrap/aws/ignite/ignite-cassandra-server-template.xml /opt/ignite/config
+
+ chown -R ignite:ignite /opt/ignite /opt/ignite-cassandra-tests
+
+ echo "export JAVA_HOME=/opt/java" >> $1
+ echo "export IGNITE_HOME=/opt/ignite" >> $1
+ echo "export USER_LIBS=\$IGNITE_HOME/libs/optional/ignite-cassandra/*:\$IGNITE_HOME/libs/optional/ignite-slf4j/*" >> $1
+ echo "export PATH=\$JAVA_HOME/bin:\$IGNITE_HOME/bin:\$PATH" >> $1
+}
+
+###################################################################################################################
+
+echo "[INFO]-----------------------------------------------------------------"
+echo "[INFO] Bootstrapping Ignite node"
+echo "[INFO]-----------------------------------------------------------------"
-HOST_NAME=$(hostname -f | tr '[:upper:]' '[:lower:]')
+setupPreRequisites
+setupJava
+setupAWSCLI
+setupTestsPackage
-/opt/logs-collector.sh "/opt/ignite/work/log" "$S3_LOGS_URL/$HOST_NAME" "$S3_LOGS_TRIGGER_URL" > /opt/ignite/logs-collector.log &
+downloadIgnite
+setupIgnite "/root/.bash_profile"
-cmd="/opt/ignite-start.sh"
+cmd="/opt/ignite-cassandra-tests/bootstrap/aws/ignite/ignite-start.sh"
-#sudo -u ignite -g ignite sh -c "$cmd | tee /opt/ignite/start.log"
+#sudo -u ignite -g ignite sh -c "$cmd | tee /opt/ignite/ignite-start.log"
-$cmd | tee /opt/ignite/start.log
\ No newline at end of file
+$cmd | tee /opt/ignite/ignite-start.log
\ No newline at end of file
[4/4] ignite git commit: IGNITE-3293 AWS bootstrap scripts patch for
Ignite-Cassandra - Fixes #794.
Posted by ak...@apache.org.
IGNITE-3293 AWS bootstrap scripts patch for Ignite-Cassandra - Fixes #794.
Signed-off-by: AKuznetsov <ak...@gridgain.com>
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/ee8ac73f
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/ee8ac73f
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/ee8ac73f
Branch: refs/heads/master
Commit: ee8ac73f2e048d3bc15525378630c27738a2981a
Parents: 59fb5ef
Author: Igor <ir...@gmail.com>
Authored: Fri Aug 5 11:33:58 2016 +0700
Committer: AKuznetsov <ak...@gridgain.com>
Committed: Fri Aug 5 11:33:58 2016 +0700
----------------------------------------------------------------------
modules/cassandra/pom.xml | 24 +-
.../cassandra/src/test/bootstrap/aws/README.txt | 13 +
.../aws/cassandra/cassandra-bootstrap.sh | 449 +++---
.../bootstrap/aws/cassandra/cassandra-env.sh | 4 +
.../bootstrap/aws/cassandra/cassandra-start.sh | 483 +-----
.../aws/cassandra/cassandra-template.yaml | 9 +-
.../cassandra/src/test/bootstrap/aws/common.sh | 1481 ++++++++++++++++++
modules/cassandra/src/test/bootstrap/aws/env.sh | 113 ++
.../test/bootstrap/aws/ganglia/agent-start.sh | 75 +
.../bootstrap/aws/ganglia/ganglia-bootstrap.sh | 417 +++++
.../bootstrap/aws/ignite/ignite-bootstrap.sh | 456 +++---
.../ignite/ignite-cassandra-server-template.xml | 27 +-
.../src/test/bootstrap/aws/ignite/ignite-env.sh | 6 +-
.../test/bootstrap/aws/ignite/ignite-start.sh | 537 +------
.../src/test/bootstrap/aws/logs-collector.sh | 179 ++-
.../tests/ignite-cassandra-client-template.xml | 21 +-
.../test/bootstrap/aws/tests/tests-bootstrap.sh | 448 +++---
.../test/bootstrap/aws/tests/tests-manager.sh | 458 ++++++
.../test/bootstrap/aws/tests/tests-report.sh | 189 +--
.../src/test/bootstrap/aws/tests/tests-run.sh | 715 ---------
.../LoadTestsCassandraArtifactsCreator.java | 104 ++
.../tests/cassandra/connection-settings.xml | 6 +-
.../tests/persistence/blob/ignite-config.xml | 6 -
.../tests/persistence/pojo/ignite-config.xml | 6 -
.../persistence/primitive/ignite-config.xml | 6 -
.../primitive/ignite-remote-client-config.xml | 6 +-
.../primitive/ignite-remote-server-config.xml | 6 +-
.../scripts/recreate-cassandra-artifacts.bat | 39 +
.../scripts/recreate-cassandra-artifacts.sh | 39 +
29 files changed, 3756 insertions(+), 2566 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee8ac73f/modules/cassandra/pom.xml
----------------------------------------------------------------------
diff --git a/modules/cassandra/pom.xml b/modules/cassandra/pom.xml
index dc8b08c..9fc880b 100644
--- a/modules/cassandra/pom.xml
+++ b/modules/cassandra/pom.xml
@@ -43,11 +43,7 @@
<minlog.version>1.3.0</minlog.version>
<asm.version>5.0.3</asm.version>
<objenesis.version>2.1</objenesis.version>
- <netty-handler.version>4.0.27.Final</netty-handler.version>
- <netty-buffer.version>4.0.27.Final</netty-buffer.version>
- <netty-common.version>4.0.27.Final</netty-common.version>
- <netty-transport.version>4.0.27.Final</netty-transport.version>
- <netty-codec.version>4.0.27.Final</netty-codec.version>
+ <netty.version>4.0.33.Final</netty.version>
<guava.version>19.0</guava.version>
<metrics-core.version>3.0.2</metrics-core.version>
</properties>
@@ -121,31 +117,31 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
- <version>${netty-handler.version}</version>
+ <version>${netty.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId>
- <version>${netty-buffer.version}</version>
+ <version>${netty.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-common</artifactId>
- <version>${netty-common.version}</version>
+ <version>${netty.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport</artifactId>
- <version>${netty-transport.version}</version>
+ <version>${netty.version}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec</artifactId>
- <version>${netty-codec.version}</version>
+ <version>${netty.version}</version>
</dependency>
<dependency>
@@ -217,6 +213,14 @@
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
+ <excludeArtifactIds>
+ netty-all,cassandra-all,snappy-java,lz4,compress-lzf,commons-codec,commons-lang3,commons-math3,
+ concurrentlinkedhashmap-lru,antlr,ST4,antlr-runtime,jcl-over-slf4j,jackson-core-asl,
+ jackson-mapper-asl,json-simple,high-scale-lib,snakeyaml,jbcrypt,reporter-config3,
+ reporter-config-base,hibernate-validator,validation-api,jboss-logging,thrift-server,
+ disruptor,stream,fastutil,logback-core,logback-classic,libthrift,httpclient,httpcore,
+ cassandra-thrift,jna,jamm,joda-time,sigar,ecj,tools
+ </excludeArtifactIds>
</configuration>
</execution>
<!-- -->
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee8ac73f/modules/cassandra/src/test/bootstrap/aws/README.txt
----------------------------------------------------------------------
diff --git a/modules/cassandra/src/test/bootstrap/aws/README.txt b/modules/cassandra/src/test/bootstrap/aws/README.txt
new file mode 100644
index 0000000..4457d81
--- /dev/null
+++ b/modules/cassandra/src/test/bootstrap/aws/README.txt
@@ -0,0 +1,13 @@
+Shell scripts to spin up Ignite, Cassandra and Load tests clusters in AWS.
+
+1) cassandra - bootstrap scripts for Cassandra cluster nodes
+2) ganglia - bootstrap scripts for Ganglia master and agents
+3) ignite - bootstrap scripts for Ignite cluster nodes
+4) tests - bootstrap scripts for Load Tests cluster nodes
+5) common.sh - definitions for common functions
+6) env.sh - definitions for common variables
+7) log-collector.sh - log collector daemon script, to collect logs and upload them to S3
+
+For more details please look at the documentation:
+
+ https://apacheignite.readme.io/docs/aws-infrastructure-deployment
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee8ac73f/modules/cassandra/src/test/bootstrap/aws/cassandra/cassandra-bootstrap.sh
----------------------------------------------------------------------
diff --git a/modules/cassandra/src/test/bootstrap/aws/cassandra/cassandra-bootstrap.sh b/modules/cassandra/src/test/bootstrap/aws/cassandra/cassandra-bootstrap.sh
index 298c1b4..017b1b1 100644
--- a/modules/cassandra/src/test/bootstrap/aws/cassandra/cassandra-bootstrap.sh
+++ b/modules/cassandra/src/test/bootstrap/aws/cassandra/cassandra-bootstrap.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
#
# Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,41 +17,31 @@
# limitations under the License.
#
-AWS_CLI_DOWNLOAD_URL=https://s3.amazonaws.com/aws-cli/awscli-bundle.zip
-
-S3_ROOT=s3://bucket/folder
-S3_DOWNLOADS=$S3_ROOT/test
-S3_SYSTEM=$S3_ROOT/test1
-
-CASSANDRA_DOWNLOAD_URL=http://www-eu.apache.org/dist/cassandra/3.5/apache-cassandra-3.5-bin.tar.gz
-CASSANDRA_TARBALL=apache-cassandra-3.5-bin.tar.gz
-CASSANDRA_UNTAR_DIR=apache-cassandra-3.5
+# -----------------------------------------------------------------------------------------------
+# Bootstrap script to spin up Cassandra cluster
+# -----------------------------------------------------------------------------------------------
-TESTS_PACKAGE_DONLOAD_URL=$S3_DOWNLOADS/ignite-cassandra-tests-1.6.0-SNAPSHOT.zip
-TESTS_PACKAGE_ZIP=ignite-cassandra-tests-1.6.0-SNAPSHOT.zip
-TESTS_PACKAGE_UNZIP_DIR=ignite-cassandra-tests
+# URL to download AWS CLI tools
+AWS_CLI_DOWNLOAD_URL=https://s3.amazonaws.com/aws-cli/awscli-bundle.zip
-S3_LOGS_URL=$S3_SYSTEM/logs/c-logs
-S3_LOGS_TRIGGER_URL=$S3_SYSTEM/logs-trigger
-S3_BOOTSTRAP_SUCCESS_URL=$S3_SYSTEM/c-success
-S3_BOOTSTRAP_FAILURE_URL=$S3_SYSTEM/c-failure
-S3_CASSANDRA_NODES_DISCOVERY_URL=$S3_SYSTEM/c-discovery
-S3_CASSANDRA_FIRST_NODE_LOCK_URL=$S3_SYSTEM/c-first-node-lock
-S3_CASSANDRA_NODES_JOIN_LOCK_URL=$S3_SYSTEM/c-join-lock
+# URL to download JDK
+JDK_DOWNLOAD_URL=http://download.oracle.com/otn-pub/java/jdk/8u77-b03/jdk-8u77-linux-x64.tar.gz
-INSTANCE_REGION=us-west-2
-INSTANCE_NAME_TAG=CASSANDRA-SERVER
-INSTANCE_OWNER_TAG=ignite@apache.org
-INSTANCE_PROJECT_TAG=ignite
+# URL to download Ignite-Cassandra tests package - you should previously package and upload it to this place
+TESTS_PACKAGE_DONLOAD_URL=s3://<bucket>/<folder>/ignite-cassandra-tests-<version>.zip
+# Terminates script execution and upload logs to S3
terminate()
{
- if [[ "$S3_BOOTSTRAP_SUCCESS_URL" != */ ]]; then
- S3_BOOTSTRAP_SUCCESS_URL=${S3_BOOTSTRAP_SUCCESS_URL}/
+ SUCCESS_URL=$S3_CASSANDRA_BOOTSTRAP_SUCCESS
+ FAILURE_URL=$S3_CASSANDRA_BOOTSTRAP_FAILURE
+
+ if [ -n "$SUCCESS_URL" ] && [[ "$SUCCESS_URL" != */ ]]; then
+ SUCCESS_URL=${SUCCESS_URL}/
fi
- if [[ "$S3_BOOTSTRAP_FAILURE_URL" != */ ]]; then
- S3_BOOTSTRAP_FAILURE_URL=${S3_BOOTSTRAP_FAILURE_URL}/
+ if [ -n "$FAILURE_URL" ] && [[ "$FAILURE_URL" != */ ]]; then
+ FAILURE_URL=${FAILURE_URL}/
fi
host_name=$(hostname -f | tr '[:upper:]' '[:lower:]')
@@ -63,13 +53,23 @@ terminate()
echo "[ERROR] Cassandra node bootstrap failed"
echo "[ERROR]-----------------------------------------------------"
msg=$1
- reportFolder=${S3_BOOTSTRAP_FAILURE_URL}${host_name}
+
+ if [ -z "$FAILURE_URL" ]; then
+ exit 1
+ fi
+
+ reportFolder=${FAILURE_URL}${host_name}
reportFile=$reportFolder/__error__
else
echo "[INFO]-----------------------------------------------------"
echo "[INFO] Cassandra node bootstrap successfully completed"
echo "[INFO]-----------------------------------------------------"
- reportFolder=${S3_BOOTSTRAP_SUCCESS_URL}${host_name}
+
+ if [ -z "$SUCCESS_URL" ]; then
+ exit 0
+ fi
+
+ reportFolder=${SUCCESS_URL}${host_name}
reportFile=$reportFolder/__success__
fi
@@ -77,7 +77,7 @@ terminate()
aws s3 rm --recursive $reportFolder
if [ $? -ne 0 ]; then
- echo "[ERROR] Failed drop report folder: $reportFolder"
+ echo "[ERROR] Failed to drop report folder: $reportFolder"
fi
aws s3 cp --sse AES256 /opt/bootstrap-result $reportFile
@@ -94,165 +94,67 @@ terminate()
exit 0
}
-tagInstance()
-{
- export EC2_HOME=/opt/aws/apitools/ec2
- export JAVA_HOME=/opt/jdk1.8.0_77
- export PATH=$JAVA_HOME/bin:$EC2_HOME/bin:$PATH
-
- INSTANCE_ID=$(curl http://169.254.169.254/latest/meta-data/instance-id)
- if [ $? -ne 0 ]; then
- terminate "Failed to get instance metadata to tag it"
- fi
-
- if [ -n "$INSTANCE_NAME_TAG" ]; then
- ec2-create-tags $INSTANCE_ID --tag Name=${INSTANCE_NAME_TAG} --region $INSTANCE_REGION
- if [ $code -ne 0 ]; then
- terminate "Failed to tag EC2 instance with: Name=${INSTANCE_NAME_TAG}"
- fi
- fi
-
- if [ -n "$INSTANCE_OWNER_TAG" ]; then
- ec2-create-tags $INSTANCE_ID --tag owner=${INSTANCE_OWNER_TAG} --region $INSTANCE_REGION
- if [ $code -ne 0 ]; then
- terminate "Failed to tag EC2 instance with: owner=${INSTANCE_OWNER_TAG}"
- fi
- fi
-
- if [ -n "$INSTANCE_PROJECT_TAG" ]; then
- ec2-create-tags $INSTANCE_ID --tag project=${INSTANCE_PROJECT_TAG} --region $INSTANCE_REGION
- if [ $code -ne 0 ]; then
- terminate "Failed to tag EC2 instance with: project=${INSTANCE_PROJECT_TAG}"
- fi
- fi
-}
-
+# Downloads specified package
downloadPackage()
{
echo "[INFO] Downloading $3 package from $1 into $2"
- if [[ "$1" == s3* ]]; then
- aws s3 cp $1 $2
-
- if [ $? -ne 0 ]; then
- echo "[WARN] Failed to download $3 package from first attempt"
- rm -Rf $2
- sleep 10s
-
- echo "[INFO] Trying second attempt to download $3 package"
+ for i in 0 9;
+ do
+ if [[ "$1" == s3* ]]; then
aws s3 cp $1 $2
+ code=$?
+ else
+ curl "$1" -o "$2"
+ code=$?
+ fi
- if [ $? -ne 0 ]; then
- echo "[WARN] Failed to download $3 package from second attempt"
- rm -Rf $2
- sleep 10s
-
- echo "[INFO] Trying third attempt to download $3 package"
- aws s3 cp $1 $2
-
- if [ $? -ne 0 ]; then
- terminate "All three attempts to download $3 package from $1 are failed"
- fi
- fi
+ if [ $code -eq 0 ]; then
+ echo "[INFO] $3 package successfully downloaded from $1 into $2"
+ return 0
fi
- else
- curl "$1" -o "$2"
- if [ $? -ne 0 ] && [ $? -ne 6 ]; then
- echo "[WARN] Failed to download $3 package from first attempt"
- rm -Rf $2
- sleep 10s
+ echo "[WARN] Failed to download $3 package from $i attempt, sleeping extra 5sec"
+ sleep 5s
+ done
- echo "[INFO] Trying second attempt to download $3 package"
- curl "$1" -o "$2"
+ terminate "All 10 attempts to download $3 package from $1 are failed"
+}
- if [ $? -ne 0 ] && [ $? -ne 6 ]; then
- echo "[WARN] Failed to download $3 package from second attempt"
- rm -Rf $2
- sleep 10s
+# Downloads and setup JDK
+setupJava()
+{
+ rm -Rf /opt/java /opt/jdk.tar.gz
- echo "[INFO] Trying third attempt to download $3 package"
- curl "$1" -o "$2"
+ echo "[INFO] Downloading 'jdk'"
+ wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "$JDK_DOWNLOAD_URL" -O /opt/jdk.tar.gz
+ if [ $? -ne 0 ]; then
+ terminate "Failed to download 'jdk'"
+ fi
- if [ $? -ne 0 ] && [ $? -ne 6 ]; then
- terminate "All three attempts to download $3 package from $1 are failed"
- fi
- fi
- fi
+ echo "[INFO] Untaring 'jdk'"
+ tar -xvzf /opt/jdk.tar.gz -C /opt
+ if [ $? -ne 0 ]; then
+ terminate "Failed to untar 'jdk'"
fi
- echo "[INFO] $3 package successfully downloaded from $1 into $2"
-}
+ rm -Rf /opt/jdk.tar.gz
-if [[ "$S3_CASSANDRA_NODES_DISCOVERY_URL" != */ ]]; then
- S3_CASSANDRA_NODES_DISCOVERY_URL=${S3_CASSANDRA_NODES_DISCOVERY_URL}/
-fi
+ unzipDir=$(ls /opt | grep "jdk")
+ if [ "$unzipDir" != "java" ]; then
+ mv /opt/$unzipDir /opt/java
+ fi
+}
-echo "[INFO]-----------------------------------------------------------------"
-echo "[INFO] Bootstrapping Cassandra node"
-echo "[INFO]-----------------------------------------------------------------"
-echo "[INFO] Cassandra download URL: $CASSANDRA_DOWNLOAD_URL"
-echo "[INFO] Tests package download URL: $TESTS_PACKAGE_DONLOAD_URL"
-echo "[INFO] Logs URL: $S3_LOGS_URL"
-echo "[INFO] Logs trigger URL: $S3_LOGS_TRIGGER_URL"
-echo "[INFO] Cassandra nodes discovery URL: $S3_CASSANDRA_NODES_DISCOVERY_URL"
-echo "[INFO] Cassandra first node lock URL: $S3_CASSANDRA_FIRST_NODE_LOCK_URL"
-echo "[INFO] Cassandra nodes join lock URL: $S3_CASSANDRA_NODES_JOIN_LOCK_URL"
-echo "[INFO] Bootsrap success URL: $S3_BOOTSTRAP_SUCCESS_URL"
-echo "[INFO] Bootsrap failure URL: $S3_BOOTSTRAP_FAILURE_URL"
-echo "[INFO]-----------------------------------------------------------------"
+# Downloads and setup AWS CLI
+setupAWSCLI()
+{
+ echo "[INFO] Installing 'awscli'"
+ pip install --upgrade awscli
+ if [ $? -eq 0 ]; then
+ return 0
+ fi
-echo "[INFO] Installing 'wget' package"
-yum -y install wget
-if [ $? -ne 0 ]; then
- terminate "Failed to install 'wget' package"
-fi
-
-echo "[INFO] Installing 'net-tools' package"
-yum -y install net-tools
-if [ $? -ne 0 ]; then
- terminate "Failed to install 'net-tools' package"
-fi
-
-echo "[INFO] Installing 'python' package"
-yum -y install python
-if [ $? -ne 0 ]; then
- terminate "Failed to install 'python' package"
-fi
-
-echo "[INFO] Installing 'unzip' package"
-yum -y install unzip
-if [ $? -ne 0 ]; then
- terminate "Failed to install 'unzip' package"
-fi
-
-rm -Rf /opt/jdk1.8.0_77 /opt/jdk-8u77-linux-x64.tar.gz
-
-echo "[INFO] Downloading 'jdk-8u77'"
-wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u77-b03/jdk-8u77-linux-x64.tar.gz" -O /opt/jdk-8u77-linux-x64.tar.gz
-if [ $? -ne 0 ]; then
- terminate "Failed to download 'jdk-8u77'"
-fi
-
-echo "[INFO] Unzipping 'jdk-8u77'"
-tar -xvzf /opt/jdk-8u77-linux-x64.tar.gz -C /opt
-if [ $? -ne 0 ]; then
- terminate "Failed to untar 'jdk-8u77'"
-fi
-
-rm -Rf /opt/jdk-8u77-linux-x64.tar.gz
-
-downloadPackage "https://bootstrap.pypa.io/get-pip.py" "/opt/get-pip.py" "get-pip.py"
-
-echo "[INFO] Installing 'pip'"
-python /opt/get-pip.py
-if [ $? -ne 0 ]; then
- terminate "Failed to install 'pip'"
-fi
-
-echo "[INFO] Installing 'awscli'"
-pip install --upgrade awscli
-if [ $? -ne 0 ]; then
echo "[ERROR] Failed to install 'awscli' using pip"
echo "[INFO] Trying to install awscli using zip archive"
echo "[INFO] Downloading awscli zip"
@@ -274,100 +176,161 @@ if [ $? -ne 0 ]; then
fi
echo "[INFO] Successfully installed awscli from zip archive"
-fi
+}
+
+# Setup all the pre-requisites (packages, settings and etc.)
+setupPreRequisites()
+{
+ echo "[INFO] Installing 'wget' package"
+ yum -y install wget
+ if [ $? -ne 0 ]; then
+ terminate "Failed to install 'wget' package"
+ fi
+
+ echo "[INFO] Installing 'net-tools' package"
+ yum -y install net-tools
+ if [ $? -ne 0 ]; then
+ terminate "Failed to install 'net-tools' package"
+ fi
-tagInstance
+ echo "[INFO] Installing 'python' package"
+ yum -y install python
+ if [ $? -ne 0 ]; then
+ terminate "Failed to install 'python' package"
+ fi
-echo "[INFO] Creating 'cassandra' group"
-exists=$(cat /etc/group | grep cassandra)
-if [ -z "$exists" ]; then
- groupadd cassandra
+ echo "[INFO] Installing 'unzip' package"
+ yum -y install unzip
if [ $? -ne 0 ]; then
- terminate "Failed to create 'cassandra' group"
+ terminate "Failed to install 'unzip' package"
fi
-fi
-echo "[INFO] Creating 'cassandra' user"
-exists=$(cat /etc/passwd | grep cassandra)
-if [ -z "$exists" ]; then
- useradd -g cassandra cassandra
+ downloadPackage "https://bootstrap.pypa.io/get-pip.py" "/opt/get-pip.py" "get-pip.py"
+
+ echo "[INFO] Installing 'pip'"
+ python /opt/get-pip.py
if [ $? -ne 0 ]; then
- terminate "Failed to create 'cassandra' user"
+ terminate "Failed to install 'pip'"
fi
-fi
+}
+
+# Downloads and setup tests package
+setupTestsPackage()
+{
+ downloadPackage "$TESTS_PACKAGE_DONLOAD_URL" "/opt/ignite-cassandra-tests.zip" "Tests"
-rm -Rf /storage/cassandra /opt/cassandra /opt/$CASSANDRA_TARBALL
+ rm -Rf /opt/ignite-cassandra-tests
-echo "[INFO] Creating '/storage/cassandra' storage"
-mkdir -p /storage/cassandra
-chown -R cassandra:cassandra /storage/cassandra
-if [ $? -ne 0 ]; then
- terminate "Failed to setup Cassandra storage dir: /storage/cassandra"
-fi
+ unzip /opt/ignite-cassandra-tests.zip -d /opt
+ if [ $? -ne 0 ]; then
+ terminate "Failed to unzip tests package"
+ fi
-downloadPackage "$CASSANDRA_DOWNLOAD_URL" "/opt/$CASSANDRA_TARBALL" "Cassandra"
+ rm -f /opt/ignite-cassandra-tests.zip
-echo "[INFO] Unzipping Cassandra package"
-tar -xvzf /opt/$CASSANDRA_TARBALL -C /opt
-if [ $? -ne 0 ]; then
- terminate "Failed to untar Cassandra package"
-fi
+ unzipDir=$(ls /opt | grep "ignite-cassandra")
+ if [ "$unzipDir" != "ignite-cassandra-tests" ]; then
+ mv /opt/$unzipDir /opt/ignite-cassandra-tests
+ fi
-rm -f /opt/$CASSANDRA_TARBALL /opt/cassandra
-mv /opt/$CASSANDRA_UNTAR_DIR /opt/cassandra
-chown -R cassandra:cassandra /opt/cassandra
+ find /opt/ignite-cassandra-tests -type f -name "*.sh" -exec chmod ug+x {} \;
-downloadPackage "$TESTS_PACKAGE_DONLOAD_URL" "/opt/$TESTS_PACKAGE_ZIP" "Tests"
+ . /opt/ignite-cassandra-tests/bootstrap/aws/common.sh "cassandra"
-unzip /opt/$TESTS_PACKAGE_ZIP -d /opt
-if [ $? -ne 0 ]; then
- terminate "Failed to unzip tests package: $TESTS_PACKAGE_DONLOAD_URL"
-fi
+ setupNTP
-chown -R cassandra:cassandra /opt/$TESTS_PACKAGE_UNZIP_DIR
-find /opt/$TESTS_PACKAGE_UNZIP_DIR -type f -name "*.sh" -exec chmod ug+x {} \;
+ echo "[INFO] Starting logs collector daemon"
-if [ ! -f "/opt/$TESTS_PACKAGE_UNZIP_DIR/bootstrap/aws/cassandra/cassandra-env.sh" ]; then
- terminate "There are no cassandra-env.sh in tests package"
-fi
+ HOST_NAME=$(hostname -f | tr '[:upper:]' '[:lower:]')
+ /opt/ignite-cassandra-tests/bootstrap/aws/logs-collector.sh "$S3_LOGS_TRIGGER" "$S3_CASSANDRA_LOGS/$HOST_NAME" "/opt/cassandra/logs" "/opt/cassandra/cassandra-start.log" > /opt/logs-collector.log &
-if [ ! -f "/opt/$TESTS_PACKAGE_UNZIP_DIR/bootstrap/aws/cassandra/cassandra-start.sh" ]; then
- terminate "There are no cassandra-start.sh in tests package"
-fi
+ echo "[INFO] Logs collector daemon started: $!"
-if [ ! -f "/opt/$TESTS_PACKAGE_UNZIP_DIR/bootstrap/aws/cassandra/cassandra-template.yaml" ]; then
- terminate "There are no cassandra-start.sh in tests package"
-fi
+ echo "----------------------------------------------------------------------------------------"
+ printInstanceInfo
+ echo "----------------------------------------------------------------------------------------"
+ tagInstance
+ bootstrapGangliaAgent "cassandra" 8641
+}
-if [ ! -f "/opt/$TESTS_PACKAGE_UNZIP_DIR/bootstrap/aws/logs-collector.sh" ]; then
- terminate "There are no logs-collector.sh in tests package"
-fi
+# Downloads Cassandra package
+downloadCassandra()
+{
+ downloadPackage "$CASSANDRA_DOWNLOAD_URL" "/opt/apache-cassandra.tar.gz" "Cassandra"
-mv -f /opt/$TESTS_PACKAGE_UNZIP_DIR/bootstrap/aws/cassandra/cassandra-start.sh /opt
-mv -f /opt/$TESTS_PACKAGE_UNZIP_DIR/bootstrap/aws/cassandra/cassandra-env.sh /opt/cassandra/conf
-mv -f /opt/$TESTS_PACKAGE_UNZIP_DIR/bootstrap/aws/cassandra/cassandra-template.yaml /opt/cassandra/conf
-mv -f /opt/$TESTS_PACKAGE_UNZIP_DIR/bootstrap/aws/logs-collector.sh /opt
-rm -Rf /opt/$TESTS_PACKAGE_UNZIP_DIR
-chown -R cassandra:cassandra /opt/cassandra /opt/cassandra-start.sh /opt/logs-collector.sh
+ rm -Rf /opt/cassandra
-#profile=/home/cassandra/.bash_profile
-profile=/root/.bash_profile
+ echo "[INFO] Untaring Cassandra package"
+ tar -xvzf /opt/apache-cassandra.tar.gz -C /opt
+ if [ $? -ne 0 ]; then
+ terminate "Failed to untar Cassandra package"
+ fi
-echo "export JAVA_HOME=/opt/jdk1.8.0_77" >> $profile
-echo "export CASSANDRA_HOME=/opt/cassandra" >> $profile
-echo "export PATH=\$JAVA_HOME/bin:\$CASSANDRA_HOME/bin:\$PATH" >> $profile
-echo "export S3_BOOTSTRAP_SUCCESS_URL=$S3_BOOTSTRAP_SUCCESS_URL" >> $profile
-echo "export S3_BOOTSTRAP_FAILURE_URL=$S3_BOOTSTRAP_FAILURE_URL" >> $profile
-echo "export S3_CASSANDRA_NODES_DISCOVERY_URL=$S3_CASSANDRA_NODES_DISCOVERY_URL" >> $profile
-echo "export S3_CASSANDRA_NODES_JOIN_LOCK_URL=$S3_CASSANDRA_NODES_JOIN_LOCK_URL" >> $profile
-echo "export S3_CASSANDRA_FIRST_NODE_LOCK_URL=$S3_CASSANDRA_FIRST_NODE_LOCK_URL" >> $profile
+ rm -f /opt/apache-cassandra.tar.gz
-HOST_NAME=$(hostname -f | tr '[:upper:]' '[:lower:]')
+ unzipDir=$(ls /opt | grep "cassandra" | grep "apache")
+ if [ "$unzipDir" != "cassandra" ]; then
+ mv /opt/$unzipDir /opt/cassandra
+ fi
+}
+
+# Setups Cassandra
+setupCassandra()
+{
+ echo "[INFO] Creating 'cassandra' group"
+ exists=$(cat /etc/group | grep cassandra)
+ if [ -z "$exists" ]; then
+ groupadd cassandra
+ if [ $? -ne 0 ]; then
+ terminate "Failed to create 'cassandra' group"
+ fi
+ fi
+
+ echo "[INFO] Creating 'cassandra' user"
+ exists=$(cat /etc/passwd | grep cassandra)
+ if [ -z "$exists" ]; then
+ useradd -g cassandra cassandra
+ if [ $? -ne 0 ]; then
+ terminate "Failed to create 'cassandra' user"
+ fi
+ fi
+
+ rm -f /opt/cassandra/conf/cassandra-env.sh /opt/cassandra/conf/cassandra-template.yaml
+
+ cp /opt/ignite-cassandra-tests/bootstrap/aws/cassandra/cassandra-env.sh /opt/cassandra/conf
+ cp /opt/ignite-cassandra-tests/bootstrap/aws/cassandra/cassandra-template.yaml /opt/cassandra/conf
+
+ chown -R cassandra:cassandra /opt/cassandra /opt/ignite-cassandra-tests
+
+ createCassandraStorageLayout
+
+ cat /opt/cassandra/conf/cassandra-template.yaml | sed -r "s/\\\$\{CASSANDRA_DATA_DIR\}/$CASSANDRA_DATA_DIR/g" > /opt/cassandra/conf/cassandra-template-1.yaml
+ cat /opt/cassandra/conf/cassandra-template-1.yaml | sed -r "s/\\\$\{CASSANDRA_COMMITLOG_DIR\}/$CASSANDRA_COMMITLOG_DIR/g" > /opt/cassandra/conf/cassandra-template-2.yaml
+ cat /opt/cassandra/conf/cassandra-template-2.yaml | sed -r "s/\\\$\{CASSANDRA_CACHES_DIR\}/$CASSANDRA_CACHES_DIR/g" > /opt/cassandra/conf/cassandra-template-3.yaml
+
+ rm -f /opt/cassandra/conf/cassandra-template.yaml /opt/cassandra/conf/cassandra-template-1.yaml /opt/cassandra/conf/cassandra-template-2.yaml
+ mv /opt/cassandra/conf/cassandra-template-3.yaml /opt/cassandra/conf/cassandra-template.yaml
+
+ echo "export JAVA_HOME=/opt/java" >> $1
+ echo "export CASSANDRA_HOME=/opt/cassandra" >> $1
+ echo "export PATH=\$JAVA_HOME/bin:\$CASSANDRA_HOME/bin:\$PATH" >> $1
+}
+
+###################################################################################################################
+
+echo "[INFO]-----------------------------------------------------------------"
+echo "[INFO] Bootstrapping Cassandra node"
+echo "[INFO]-----------------------------------------------------------------"
-/opt/logs-collector.sh "/opt/cassandra/logs" "$S3_LOGS_URL/$HOST_NAME" "$S3_LOGS_TRIGGER_URL" > /opt/cassandra/logs-collector.log &
+setupPreRequisites
+setupJava
+setupAWSCLI
+setupTestsPackage
+downloadCassandra
+setupCassandra "/root/.bash_profile"
-cmd="/opt/cassandra-start.sh"
+cmd="/opt/ignite-cassandra-tests/bootstrap/aws/cassandra/cassandra-start.sh"
-#sudo -u cassandra -g cassandra sh -c "$cmd | tee /opt/cassandra/start.log"
+#sudo -u cassandra -g cassandra sh -c "$cmd | tee /opt/cassandra/cassandra-start.log"
-$cmd | tee /opt/cassandra/start.log
\ No newline at end of file
+$cmd | tee /opt/cassandra/cassandra-start.log
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee8ac73f/modules/cassandra/src/test/bootstrap/aws/cassandra/cassandra-env.sh
----------------------------------------------------------------------
diff --git a/modules/cassandra/src/test/bootstrap/aws/cassandra/cassandra-env.sh b/modules/cassandra/src/test/bootstrap/aws/cassandra/cassandra-env.sh
index 11dfc50..ba76401 100644
--- a/modules/cassandra/src/test/bootstrap/aws/cassandra/cassandra-env.sh
+++ b/modules/cassandra/src/test/bootstrap/aws/cassandra/cassandra-env.sh
@@ -15,6 +15,10 @@
# limitations under the License.
#
+# -----------------------------------------------------------------------------------------------
+# Environment setup script from Cassandra distribution
+# -----------------------------------------------------------------------------------------------
+
calculate_heap_sizes()
{
case "`uname`" in
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee8ac73f/modules/cassandra/src/test/bootstrap/aws/cassandra/cassandra-start.sh
----------------------------------------------------------------------
diff --git a/modules/cassandra/src/test/bootstrap/aws/cassandra/cassandra-start.sh b/modules/cassandra/src/test/bootstrap/aws/cassandra/cassandra-start.sh
index c73c509..4a6daef 100644
--- a/modules/cassandra/src/test/bootstrap/aws/cassandra/cassandra-start.sh
+++ b/modules/cassandra/src/test/bootstrap/aws/cassandra/cassandra-start.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
#
# Licensed to the Apache Software Foundation (ASF) under one or more
@@ -17,377 +17,40 @@
# limitations under the License.
#
+# -----------------------------------------------------------------------------------------------
+# Script to start Cassandra daemon (used by cassandra-bootstrap.sh)
+# -----------------------------------------------------------------------------------------------
+
#profile=/home/cassandra/.bash_profile
profile=/root/.bash_profile
. $profile
+. /opt/ignite-cassandra-tests/bootstrap/aws/common.sh "cassandra"
-terminate()
-{
- if [[ "$S3_BOOTSTRAP_SUCCESS_URL" != */ ]]; then
- S3_BOOTSTRAP_SUCCESS_URL=${S3_BOOTSTRAP_SUCCESS_URL}/
- fi
-
- if [[ "$S3_BOOTSTRAP_FAILURE_URL" != */ ]]; then
- S3_BOOTSTRAP_FAILURE_URL=${S3_BOOTSTRAP_FAILURE_URL}/
- fi
-
- msg=$HOST_NAME
-
- if [ -n "$1" ]; then
- echo "[ERROR] $1"
- echo "[ERROR]-----------------------------------------------------"
- echo "[ERROR] Failed to start Cassandra node"
- echo "[ERROR]-----------------------------------------------------"
- msg=$1
- reportFolder=${S3_BOOTSTRAP_FAILURE_URL}${HOST_NAME}
- reportFile=$reportFolder/__error__
- else
- echo "[INFO]-----------------------------------------------------"
- echo "[INFO] Cassandra node successfully started"
- echo "[INFO]-----------------------------------------------------"
- reportFolder=${S3_BOOTSTRAP_SUCCESS_URL}${HOST_NAME}
- reportFile=$reportFolder/__success__
- fi
-
- echo $msg > /opt/cassandra/start_result
-
- aws s3 rm --recursive $reportFolder
- if [ $? -ne 0 ]; then
- echo "[ERROR] Failed drop report folder: $reportFolder"
- fi
-
- if [ -d "/opt/cassandra/logs" ]; then
- aws s3 sync --sse AES256 /opt/cassandra/logs $reportFolder
- if [ $? -ne 0 ]; then
- echo "[ERROR] Failed to export Cassandra logs to: $reportFolder"
- fi
- fi
-
- aws s3 cp --sse AES256 /opt/cassandra/start_result $reportFile
- if [ $? -ne 0 ]; then
- echo "[ERROR] Failed to export node start result to: $reportFile"
- fi
-
- rm -f /opt/cassandra/start_result /opt/cassandra/join-lock /opt/cassandra/remote-join-lock
-
- if [ -n "$1" ]; then
- exit 1
- fi
-
- exit 0
-}
-
-registerNode()
-{
- echo "[INFO] Registering Cassandra node seed: ${S3_CASSANDRA_NODES_DISCOVERY_URL}$HOST_NAME"
-
- aws s3 cp --sse AES256 /opt/cassandra/join-lock ${S3_CASSANDRA_NODES_DISCOVERY_URL}$HOST_NAME
- if [ $? -ne 0 ]; then
- terminate "Failed to register Cassandra seed info in: ${S3_CASSANDRA_NODES_DISCOVERY_URL}$HOST_NAME"
- fi
-
- echo "[INFO] Cassandra node seed successfully registered"
-}
-
-unregisterNode()
-{
- echo "[INFO] Removing Cassandra node registration from: ${S3_CASSANDRA_NODES_DISCOVERY_URL}$HOST_NAME"
- aws s3 rm ${S3_CASSANDRA_NODES_DISCOVERY_URL}$HOST_NAME
- echo "[INFO] Cassandra node registration removed"
-}
-
-cleanupMetadata()
-{
- echo "[INFO] Running cleanup"
- aws s3 rm $S3_CASSANDRA_NODES_JOIN_LOCK_URL
- aws s3 rm --recursive $S3_CASSANDRA_NODES_DISCOVERY_URL
- aws s3 rm --recursive $S3_BOOTSTRAP_SUCCESS_URL
- aws s3 rm --recursive $S3_BOOTSTRAP_FAILURE_URL
- echo "[INFO] Cleanup completed"
-}
-
+# Setups Cassandra seeds for this EC2 node. Looks for the information in S3 about
+# already up and running Cassandra cluster nodes
setupCassandraSeeds()
{
- echo "[INFO] Setting up Cassandra seeds"
+ if [ "$FIRST_NODE_LOCK" == "true" ]; then
+ echo "[INFO] Setting up Cassandra seeds"
- if [ "$FIRST_NODE" == "true" ]; then
- CASSANDRA_SEEDS=$(hostname -f | tr '[:upper:]' '[:lower:]')
- echo "[INFO] Using host address as a seed for the first Cassandra node: $CASSANDRA_SEEDS"
- aws s3 rm --recursive ${S3_CASSANDRA_NODES_DISCOVERY_URL::-1}
- if [ $? -ne 0 ]; then
- terminate "Failed to clean Cassandra node discovery URL: $S3_CASSANDRA_NODES_DISCOVERY_URL"
- fi
+ CLUSTER_SEEDS=$(hostname -f | tr '[:upper:]' '[:lower:]')
- cat /opt/cassandra/conf/cassandra-template.yaml | sed -r "s/\\\$\{CASSANDRA_SEEDS\}/$CASSANDRA_SEEDS/g" > /opt/cassandra/conf/cassandra.yaml
-
- return 0
- fi
-
- echo "[INFO] Looking for Cassandra seeds in: $S3_CASSANDRA_NODES_DISCOVERY_URL"
-
- startTime=$(date +%s)
-
- while true; do
- seeds=$(aws s3 ls $S3_CASSANDRA_NODES_DISCOVERY_URL | grep -v PRE | sed -r "s/^.* //g")
- if [ -n "$seeds" ]; then
- seeds=($seeds)
- length=${#seeds[@]}
-
- if [ $length -lt 4 ]; then
- seed1=${seeds[0]}
- seed2=${seeds[1]}
- seed3=${seeds[2]}
- else
- pos1=$(($RANDOM%$length))
- pos2=$(($RANDOM%$length))
- pos3=$(($RANDOM%$length))
- seed1=${seeds[${pos1}]}
- seed2=${seeds[${pos2}]}
- seed3=${seeds[${pos3}]}
- fi
-
- CASSANDRA_SEEDS=$seed1
- CASSANDRA_SEED=$seed1
-
- if [ "$seed2" != "$seed1" ] && [ -n "$seed2" ]; then
- CASSANDRA_SEEDS="$CASSANDRA_SEEDS,$seed2"
- fi
-
- if [ "$seed3" != "$seed2" ] && [ "$seed3" != "$seed1" ] && [ -n "$seed3" ]; then
- CASSANDRA_SEEDS="$CASSANDRA_SEEDS,$seed3"
- fi
-
- echo "[INFO] Using Cassandra seeds: $CASSANDRA_SEEDS"
-
- cat /opt/cassandra/conf/cassandra-template.yaml | sed -r "s/\\\$\{CASSANDRA_SEEDS\}/$CASSANDRA_SEEDS/g" > /opt/cassandra/conf/cassandra.yaml
-
- return 0
- fi
-
- currentTime=$(date +%s)
- duration=$(( $currentTime-$startTime ))
- duration=$(( $duration/60 ))
-
- if [ $duration -gt $NODE_STARTUP_TIME ]; then
- terminate "${NODE_STARTUP_TIME}min timeout expired, but first Cassandra node is still not up and running"
- fi
-
- echo "[INFO] Waiting for the first Cassandra node to start and publish its seed, time passed ${duration}min"
-
- sleep 1m
- done
-}
-
-tryToGetFirstNodeLock()
-{
- echo "[INFO] Trying to get first node lock"
-
- checkFirstNodeLockExist
- if [ $? -ne 0 ]; then
- return 1
- fi
-
- createFirstNodeLock
-
- sleep 5s
-
- rm -Rf /opt/cassandra/first-node-lock
-
- aws s3 cp $S3_CASSANDRA_FIRST_NODE_LOCK_URL /opt/cassandra/first-node-lock
- if [ $? -ne 0 ]; then
- echo "[WARN] Failed to check just created first node lock"
- return 1
- fi
-
- first_host=$(cat /opt/cassandra/first-node-lock)
-
- rm -f /opt/cassandra/first-node-lock
-
- if [ "$first_host" != "$HOST_NAME" ]; then
- echo "[INFO] Node $first_host has discarded previously created first node lock"
- return 1
- fi
-
- echo "[INFO] Congratulations, got first node lock"
-
- return 0
-}
-
-checkFirstNodeLockExist()
-{
- echo "[INFO] Checking for the first node lock"
-
- lockExists=$(aws s3 ls $S3_CASSANDRA_FIRST_NODE_LOCK_URL)
- if [ -n "$lockExists" ]; then
- echo "[INFO] First node lock already exists"
- return 1
- fi
-
- echo "[INFO] First node lock doesn't exist"
-
- return 0
-}
-
-createFirstNodeLock()
-{
- aws s3 cp --sse AES256 /opt/cassandra/join-lock $S3_CASSANDRA_FIRST_NODE_LOCK_URL
- if [ $? -ne 0 ]; then
- terminate "Failed to create first node lock"
- fi
- echo "[INFO] Created first node lock"
-}
-
-removeFirstNodeLock()
-{
- aws s3 rm $S3_CASSANDRA_FIRST_NODE_LOCK_URL
- if [ $? -ne 0 ]; then
- terminate "Failed to remove first node lock"
- fi
- echo "[INFO] Removed first node lock"
-}
-
-tryToGetClusterJoinLock()
-{
- echo "[INFO] Trying to get cluster join lock"
-
- checkClusterJoinLockExist
- if [ $? -ne 0 ]; then
- return 1
- fi
-
- createClusterJoinLock
-
- sleep 5s
-
- rm -Rf /opt/cassandra/remote-join-lock
-
- aws s3 cp $S3_CASSANDRA_NODES_JOIN_LOCK_URL /opt/cassandra/remote-join-lock
- if [ $? -ne 0 ]; then
- echo "[WARN] Failed to check just created cluster join lock"
- return 1
- fi
-
- join_host=$(cat /opt/cassandra/remote-join-lock)
-
- if [ "$join_host" != "$HOST_NAME" ]; then
- echo "[INFO] Node $first_host has discarded previously created cluster join lock"
- return 1
- fi
-
- echo "[INFO] Congratulations, got cluster join lock"
-
- return 0
-}
-
-checkClusterJoinLockExist()
-{
- echo "[INFO] Checking for the cluster join lock"
-
- lockExists=$(aws s3 ls $S3_CASSANDRA_NODES_JOIN_LOCK_URL)
- if [ -n "$lockExists" ]; then
- echo "[INFO] Cluster join lock already exists"
- return 1
- fi
-
- status=$(/opt/cassandra/bin/nodetool -h $CASSANDRA_SEED status)
- leaving=$(echo $status | grep UL)
- moving=$(echo $status | grep UM)
- joining=$(echo $status | grep UJ)
-
- if [ -n "$leaving" ] || [ -n "$moving" ] || [ -n "$joining" ]; then
- echo "[INFO] Cluster join lock doesn't exist in S3, but some node still trying to join Cassandra cluster"
- return 1
- fi
-
- echo "[INFO] Cluster join lock doesn't exist"
-
- return 0
-}
-
-createClusterJoinLock()
-{
- aws s3 cp --sse AES256 /opt/cassandra/join-lock $S3_CASSANDRA_NODES_JOIN_LOCK_URL
- if [ $? -ne 0 ]; then
- terminate "Failed to create cluster join lock"
- fi
- echo "[INFO] Created cluster join lock"
-}
-
-removeClusterJoinLock()
-{
- aws s3 rm $S3_CASSANDRA_NODES_JOIN_LOCK_URL
- if [ $? -ne 0 ]; then
- terminate "Failed to remove cluster join lock"
- fi
- echo "[INFO] Removed cluster join lock"
-}
-
-waitToJoinCassandraCluster()
-{
- echo "[INFO] Waiting to join Cassandra cluster"
-
- while true; do
- tryToGetClusterJoinLock
+ echo "[INFO] Using host address as a seed for the first Cassandra node: $CLUSTER_SEEDS"
+ aws s3 rm --recursive ${S3_CASSANDRA_NODES_DISCOVERY::-1}
if [ $? -ne 0 ]; then
- echo "[INFO] Another node is trying to join cluster. Waiting for extra 1min."
- sleep 1m
- else
- echo "[INFO]-------------------------------------------------------------"
- echo "[INFO] Congratulations, got lock to join Cassandra cluster"
- echo "[INFO]-------------------------------------------------------------"
- break
+ terminate "Failed to clean Cassandra node discovery URL: $S3_CASSANDRA_NODES_DISCOVERY"
fi
- done
-}
-
-waitFirstCassandraNodeRegistered()
-{
- echo "[INFO] Waiting for the first Cassandra node to register"
-
- startTime=$(date +%s)
-
- while true; do
- first_host=
-
- exists=$(aws s3 ls $S3_CASSANDRA_FIRST_NODE_LOCK_URL)
- if [ -n "$exists" ]; then
- rm -Rf /opt/cassandra/first-node-lock
-
- aws s3 cp $S3_CASSANDRA_FIRST_NODE_LOCK_URL /opt/cassandra/first-node-lock
- if [ $? -ne 0 ]; then
- terminate "Failed to check existing first node lock"
- fi
-
- first_host=$(cat /opt/cassandra/first-node-lock)
-
- rm -Rf /opt/cassandra/first-node-lock
- fi
-
- if [ -n "$first_host" ]; then
- exists=$(aws s3 ls ${S3_CASSANDRA_NODES_DISCOVERY_URL}${first_host})
- if [ -n "$exists" ]; then
- break
- fi
- fi
-
- currentTime=$(date +%s)
- duration=$(( $currentTime-$startTime ))
- duration=$(( $duration/60 ))
-
- if [ $duration -gt $NODE_STARTUP_TIME ]; then
- terminate "${NODE_STARTUP_TIME}min timeout expired, but first Cassandra node is still not up and running"
- fi
-
- echo "[INFO] Waiting extra 1min"
-
- sleep 1m
- done
+ else
+ setupClusterSeeds "cassandra" "true"
+ CLUSTER_SEEDS=$(echo $CLUSTER_SEEDS | sed -r "s/ /,/g")
+ fi
- echo "[INFO] First Cassandra node registered"
+ cat /opt/cassandra/conf/cassandra-template.yaml | sed -r "s/\\\$\{CASSANDRA_SEEDS\}/$CLUSTER_SEEDS/g" > /opt/cassandra/conf/cassandra.yaml
}
+# Gracefully starts Cassandra daemon and waits until it joins Cassandra cluster
startCassandra()
{
echo "[INFO]-------------------------------------------------------------"
@@ -397,8 +60,13 @@ startCassandra()
setupCassandraSeeds
- if [ "$FIRST_NODE" != "true" ]; then
- waitToJoinCassandraCluster
+ waitToJoinCluster
+
+ if [ "$FIRST_NODE_LOCK" == "true" ]; then
+ aws s3 rm --recursive ${S3_CASSANDRA_NODES_DISCOVERY::-1}
+ if [ $? -ne 0 ]; then
+ terminate "Failed to clean Cassandra node discovery URL: $S3_IGNITE_NODES_DISCOVERY"
+ fi
fi
proc=$(ps -ef | grep java | grep "org.apache.cassandra.service.CassandraDaemon")
@@ -420,64 +88,40 @@ startCassandra()
START_ATTEMPT=$(( $START_ATTEMPT+1 ))
}
-# Time (in minutes) to wait for the Cassandra node up and running and register it in S3
-NODE_STARTUP_TIME=10
-
-# Number of attempts to start (not first) Cassandra daemon
-NODE_START_ATTEMPTS=3
-
-HOST_NAME=$(hostname -f | tr '[:upper:]' '[:lower:]')
-echo $HOST_NAME > /opt/cassandra/join-lock
+#######################################################################################################
START_ATTEMPT=0
-FIRST_NODE="false"
-
+# Cleans all the previous metadata about this EC2 node
unregisterNode
+# Tries to get first-node lock
tryToGetFirstNodeLock
-if [ $? -eq 0 ]; then
- FIRST_NODE="true"
-fi
-
echo "[INFO]-----------------------------------------------------------------"
-if [ "$FIRST_NODE" == "true" ]; then
+if [ "$FIRST_NODE_LOCK" == "true" ]; then
echo "[INFO] Starting first Cassandra node"
else
echo "[INFO] Starting Cassandra node"
fi
echo "[INFO]-----------------------------------------------------------------"
-echo "[INFO] Cassandra nodes discovery URL: $S3_CASSANDRA_NODES_DISCOVERY_URL"
-echo "[INFO] Cassandra first node lock URL: $S3_CASSANDRA_FIRST_NODE_LOCK_URL"
-echo "[INFO] Cassandra nodes join lock URL: $S3_CASSANDRA_NODES_JOIN_LOCK_URL"
-echo "[INFO] Start success URL: $S3_BOOTSTRAP_SUCCESS_URL"
-echo "[INFO] Start failure URL: $S3_BOOTSTRAP_FAILURE_URL"
-echo "[INFO] CASSANDRA_HOME: $CASSANDRA_HOME"
-echo "[INFO] JAVA_HOME: $JAVA_HOME"
-echo "[INFO] PATH: $PATH"
+printInstanceInfo
echo "[INFO]-----------------------------------------------------------------"
-if [ -z "$S3_CASSANDRA_NODES_DISCOVERY_URL" ]; then
- terminate "S3 discovery URL doesn't specified"
-fi
-
-if [[ "$S3_CASSANDRA_NODES_DISCOVERY_URL" != */ ]]; then
- S3_CASSANDRA_NODES_DISCOVERY_URL=${S3_CASSANDRA_NODES_DISCOVERY_URL}/
-fi
-
-if [ "$FIRST_NODE" != "true" ]; then
- waitFirstCassandraNodeRegistered
+if [ "$FIRST_NODE_LOCK" != "true" ]; then
+ waitFirstClusterNodeRegistered "true"
else
cleanupMetadata
fi
+# Start Cassandra daemon
startCassandra
startTime=$(date +%s)
+# Trying multiple attempts to start Cassandra daemon
while true; do
proc=$(ps -ef | grep java | grep "org.apache.cassandra.service.CassandraDaemon")
@@ -490,9 +134,9 @@ while true; do
echo $proc
echo "[INFO]-----------------------------------------------------"
- if [ "$FIRST_NODE" != "true" ]; then
- removeClusterJoinLock
- fi
+ # Once node joined the cluster we need to remove cluster-join lock
+ # to allow other EC2 nodes to acquire it and join cluster sequentially
+ removeClusterJoinLock
break
fi
@@ -501,43 +145,64 @@ while true; do
duration=$(( $currentTime-$startTime ))
duration=$(( $duration/60 ))
- if [ $duration -gt $NODE_STARTUP_TIME ]; then
- if [ "$FIRST_NODE" == "true" ]; then
- removeFirstNodeLock
- terminate "${NODE_STARTUP_TIME}min timeout expired, but first Cassandra daemon is still not up and running"
+ if [ $duration -gt $SERVICE_STARTUP_TIME ]; then
+ if [ "$FIRST_NODE_LOCK" == "true" ]; then
+ # If the first node of Cassandra cluster failed to start Cassandra daemon in SERVICE_STARTUP_TIME min,
+ # we will not try any other attempts and just terminate with error. Terminate function itself, will
+ # take care about removing all the locks holding by this node.
+ terminate "${SERVICE_STARTUP_TIME}min timeout expired, but first Cassandra daemon is still not up and running"
else
+ # If node isn't the first node of Cassandra cluster and it failed to start we need to
+ # remove cluster-join lock to allow other EC2 nodes to acquire it
removeClusterJoinLock
- if [ $START_ATTEMPT -gt $NODE_START_ATTEMPTS ]; then
- terminate "${NODE_START_ATTEMPTS} attempts exceed, but Cassandra daemon is still not up and running"
+ # If node failed all SERVICE_START_ATTEMPTS attempts to start Cassandra daemon we will not
+ # try anymore and terminate with error
+ if [ $START_ATTEMPT -gt $SERVICE_START_ATTEMPTS ]; then
+ terminate "${SERVICE_START_ATTEMPTS} attempts exceed, but Cassandra daemon is still not up and running"
fi
+ # New attempt to start Cassandra daemon
startCassandra
fi
continue
fi
+ # Checking for the situation when two nodes trying to simultaneously join Cassandra cluster.
+ # This actually can happen only in not standard situation, when you are trying to start
+ # Cassandra daemon on some EC2 nodes manually and not using bootstrap script.
concurrencyError=$(cat /opt/cassandra/logs/system.log | grep "java.lang.UnsupportedOperationException: Other bootstrapping/leaving/moving nodes detected, cannot bootstrap while cassandra.consistent.rangemovement is true")
- if [ -n "$concurrencyError" ] && [ "$FIRST_NODE" != "true" ]; then
+ if [ -n "$concurrencyError" ] && [ "$FIRST_NODE_LOCK" != "true" ]; then
+ # Remove cluster-join lock to allow other EC2 nodes to acquire it
removeClusterJoinLock
- echo "[WARN] Failed to concurrently start Cassandra daemon. Sleeping for extra 1min"
- sleep 1m
+
+ echo "[WARN] Failed to concurrently start Cassandra daemon. Sleeping for extra 30sec"
+ sleep 30s
+
+ # New attempt to start Cassandra daemon
startCassandra
+
continue
fi
+ # Handling situation when Cassandra daemon process abnormally terminated
if [ -z "$proc" ]; then
- if [ "$FIRST_NODE" == "true" ]; then
- removeFirstNodeLock
+ # If this is the first node of Cassandra cluster just terminating with error
+ if [ "$FIRST_NODE_LOCK" == "true" ]; then
terminate "Failed to start Cassandra daemon"
fi
+ # Remove cluster-join lock to allow other EC2 nodes to acquire it
removeClusterJoinLock
- echo "[WARN] Failed to start Cassandra daemon. Sleeping for extra 1min"
- sleep 1m
+
+ echo "[WARN] Failed to start Cassandra daemon. Sleeping for extra 30sec"
+ sleep 30s
+
+ # New attempt to start Cassandra daemon
startCassandra
+
continue
fi
@@ -545,6 +210,8 @@ while true; do
sleep 30s
done
+# Once Cassandra daemon successfully started we registering new Cassandra node in S3
registerNode
+# Terminating script with zero exit code
terminate
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/ee8ac73f/modules/cassandra/src/test/bootstrap/aws/cassandra/cassandra-template.yaml
----------------------------------------------------------------------
diff --git a/modules/cassandra/src/test/bootstrap/aws/cassandra/cassandra-template.yaml b/modules/cassandra/src/test/bootstrap/aws/cassandra/cassandra-template.yaml
index 965e34e..e621886 100644
--- a/modules/cassandra/src/test/bootstrap/aws/cassandra/cassandra-template.yaml
+++ b/modules/cassandra/src/test/bootstrap/aws/cassandra/cassandra-template.yaml
@@ -154,13 +154,12 @@ partitioner: org.apache.cassandra.dht.Murmur3Partitioner
# will spread data evenly across them, subject to the granularity of
# the configured compaction strategy.
# If not set, the default directory is $CASSANDRA_HOME/data/data.
-data_file_directories:
- - /storage/cassandra/data
+data_file_directories: ${CASSANDRA_DATA_DIR}
# commit log. when running on magnetic HDD, this should be a
# separate spindle than the data directories.
# If not set, the default directory is $CASSANDRA_HOME/data/commitlog.
-commitlog_directory: /storage/cassandra/commitlog
+commitlog_directory: ${CASSANDRA_COMMITLOG_DIR}
# policy for data disk failures:
# die: shut down gossip and client transports and kill the JVM for any fs errors or
@@ -285,7 +284,7 @@ counter_cache_save_period: 7200
# saved caches
# If not set, the default directory is $CASSANDRA_HOME/data/saved_caches.
-saved_caches_directory: /storage/cassandra/saved_caches
+saved_caches_directory: ${CASSANDRA_CACHES_DIR}
# commitlog_sync may be either "periodic" or "batch."
#
@@ -757,7 +756,7 @@ cross_node_timeout: false
#
# You can use a custom Snitch by setting this to the full class name
# of the snitch, which will be assumed to be on your classpath.
-endpoint_snitch: GossipingPropertyFileSnitch
+endpoint_snitch: Ec2Snitch
# controls how often to perform the more expensive part of host score
# calculation