Skip to content

Commit

Permalink
Add etcd sonobuoy tests
Browse files Browse the repository at this point in the history
Closes a gap in test coverage. Also fixes an issue where args and hooks
from previous test runs were not being reset for subsequent runs.

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
(cherry picked from commit 52e450f)
  • Loading branch information
brandond committed Dec 22, 2021
1 parent 24b0000 commit c4d5800
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 9 deletions.
1 change: 1 addition & 0 deletions scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ echo "Did test-run-sonobuoy $?"

# ---

test-run-sonobuoy etcd
test-run-sonobuoy mysql
test-run-sonobuoy postgres

Expand Down
21 changes: 16 additions & 5 deletions scripts/test-helpers
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,6 @@ test-setup() {
exit 0
fi

local setupFile=./scripts/test-setup-${TEST_TYPE}
[ -f $setupFile ] && source $setupFile

echo ${RANDOM}${RANDOM}${RANDOM} >$TEST_DIR/metadata/secret
}
export -f test-setup
Expand Down Expand Up @@ -422,7 +419,6 @@ provision-server() {
local count=$(inc-count servers)
local testID=$(basename $TEST_DIR)
local name=$(echo "k3s-server-$count-$testID" | tee $TEST_DIR/servers/$count/metadata/name)
#local args=$(cat $TEST_DIR/args $TEST_DIR/servers/args $TEST_DIR/servers/$count/args 2>/dev/null)
local port=$(timeout --foreground 5s bash -c get-port | tee $TEST_DIR/servers/$count/metadata/port)
local SERVER_INSTANCE_ARGS="SERVER_${count}_ARGS"

Expand Down Expand Up @@ -454,7 +450,6 @@ provision-agent() {
local count=$(inc-count agents)
local testID=$(basename $TEST_DIR)
local name=$(echo "k3s-agent-$count-$testID" | tee $TEST_DIR/agents/$count/metadata/name)
#local args=$(cat $TEST_DIR/args $TEST_DIR/agents/args $TEST_DIR/agents/$count/args 2>/dev/null)
local AGENT_INSTANCE_ARGS="AGENT_${count}_ARGS"

run-function agent-pre-hook $count
Expand Down Expand Up @@ -581,6 +576,21 @@ export -f run-test

# ---

cleanup-test-env(){
export NUM_SERVERS=1
export NUM_AGENTS=1
export AGENT_ARGS=''
export SERVER_ARGS=''
export WAIT_SERVICES="${all_services[@]}"

unset AGENT_1_ARGS AGENT_2_ARGS AGENT_3_ARGS
unset SERVER_1_ARGS SERVER_2_ARGS SERVER_3_ARGS

unset -f server-pre-hook server-post-hook agent-pre-hook agent-post-hook cluster-pre-hook cluster-post-hook test-post-hook
}

# ---

count-running-tests(){
local count=0
for pid in ${pids[@]}; do
Expand Down Expand Up @@ -631,6 +641,7 @@ test-run-sonobuoy() {
export LABEL_SUFFIX=$1
fi

cleanup-test-env
. ./scripts/test-setup-sonobuoy$suffix
run-e2e-tests
}
Expand Down
2 changes: 2 additions & 0 deletions scripts/test-run-basics
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@ export -f use-local-storage-volume

# --- create a basic cluster and check for valid versions
LABEL=BASICS run-test

cleanup-test-env
2 changes: 2 additions & 0 deletions scripts/test-run-compat
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ K3S_IMAGE_AGENT=${REPO}/${IMAGE_NAME}:${STABLE_VERSION} LABEL=STABLE-AGENT run-t
# --- create a basic cluster to test for compat with the latest version of the server and agent
K3S_IMAGE_SERVER=${REPO}/${IMAGE_NAME}:${LATEST_VERSION} LABEL=LATEST-SERVER run-test
K3S_IMAGE_AGENT=${REPO}/${IMAGE_NAME}:${LATEST_VERSION} LABEL=LATEST-AGENT run-test

cleanup-test-env
2 changes: 2 additions & 0 deletions scripts/test-run-lazypull
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,5 @@ export -f get-topmost-layer

# --- create a basic cluster and check for lazy pulling
LABEL=LAZYPULL run-test

cleanup-test-env
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@

export NUM_SERVERS=2
export NUM_AGENTS=0

export SERVER_1_ARGS=--cluster-init

# ---
export SERVER_1_ARGS="--cluster-init"

server-post-hook() {
if [ $1 -eq 1 ]; then
Expand Down

0 comments on commit c4d5800

Please sign in to comment.