Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
Add e2e test for seeds=2
Browse files Browse the repository at this point in the history
  • Loading branch information
kragniz committed Feb 28, 2018
1 parent f42ebf3 commit 179ba9c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
42 changes: 24 additions & 18 deletions hack/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -187,13 +187,23 @@ if [[ "test_elasticsearchcluster" = "${TEST_PREFIX}"* ]]; then
kube_delete_namespace_and_wait "${ES_TEST_NS}"
fi

function apply_cassandracluster() {
kubectl apply \
--namespace "${namespace}" \
--filename \
<(envsubst \
'$NAVIGATOR_IMAGE_REPOSITORY:$NAVIGATOR_IMAGE_TAG:$NAVIGATOR_IMAGE_PULLPOLICY:$CASS_NAME:$CASS_REPLICAS:$CASS_CQL_PORT:$CASS_SEEDS' \
< "${SCRIPT_DIR}/testdata/cass-cluster-test.template.yaml")
}

function test_cassandracluster() {
echo "Testing CassandraCluster"
local namespace="${1}"

export CASS_NAME="test"
export CASS_REPLICAS=1
export CASS_CQL_PORT=9042
export CASS_SEEDS=1

kubectl create namespace "${namespace}"

Expand All @@ -203,12 +213,7 @@ function test_cassandracluster() {
fail_test "Failed to get cassandraclusters"
fi

if ! kubectl apply \
--namespace "${namespace}" \
--filename \
<(envsubst \
'$NAVIGATOR_IMAGE_REPOSITORY:$NAVIGATOR_IMAGE_TAG:$NAVIGATOR_IMAGE_PULLPOLICY:$CASS_NAME:$CASS_REPLICAS:$CASS_CQL_PORT' \
< "${SCRIPT_DIR}/testdata/cass-cluster-test.template.yaml")
if ! apply_cassandracluster
then
fail_test "Failed to create cassandracluster"
fi
Expand Down Expand Up @@ -292,12 +297,7 @@ function test_cassandracluster() {

# Change the CQL port
export CASS_CQL_PORT=9043
kubectl apply \
--namespace "${namespace}" \
--filename \
<(envsubst \
'$NAVIGATOR_IMAGE_REPOSITORY:$NAVIGATOR_IMAGE_TAG:$NAVIGATOR_IMAGE_PULLPOLICY:$CASS_NAME:$CASS_REPLICAS:$CASS_CQL_PORT' \
< "${SCRIPT_DIR}/testdata/cass-cluster-test.template.yaml")
apply_cassandracluster

# Wait 60s for cassandra CQL port to change
if ! retry TIMEOUT=60 cql_connect \
Expand All @@ -309,12 +309,7 @@ function test_cassandracluster() {

# Increment the replica count
export CASS_REPLICAS=2
kubectl apply \
--namespace "${namespace}" \
--filename \
<(envsubst \
'$NAVIGATOR_IMAGE_REPOSITORY:$NAVIGATOR_IMAGE_TAG:$NAVIGATOR_IMAGE_PULLPOLICY:$CASS_NAME:$CASS_REPLICAS:$CASS_CQL_PORT' \
< "${SCRIPT_DIR}/testdata/cass-cluster-test.template.yaml")
apply_cassandracluster

if ! retry TIMEOUT=300 stdout_equals 2 kubectl \
--namespace "${namespace}" \
Expand Down Expand Up @@ -343,6 +338,17 @@ function test_cassandracluster() {
9043; then
fail_test "Cassandra readiness probe failed to bypass dead node"
fi

export CASS_REPLICAS=2
export CASS_SEEDS=2
apply_cassandracluster

seed_label=$(kubectl get pods --namespace "${namespace}" \
cass-${CASS_NAME}-ringnodes-1 \
-o jsonpath='{.metadata.labels.seed}')
if [ "$seed_label" != "true" ]; then
fail_test "Second cassandra node not marked as seed"
fi
}

if [[ "test_cassandracluster" = "${TEST_PREFIX}"* ]]; then
Expand Down
1 change: 1 addition & 0 deletions hack/testdata/cass-cluster-test.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ spec:
replicas: ${CASS_REPLICAS}
datacenter: "${CASS_NAME}-datacenter"
rack: "{CASS_NAME}-rack"
seeds: ${CASS_SEEDS}
persistence:
enabled: true
size: "5Gi"
Expand Down

0 comments on commit 179ba9c

Please sign in to comment.