diff --git a/scripts/test b/scripts/test index 57b9c88af3..956ad02e90 100755 --- a/scripts/test +++ b/scripts/test @@ -35,6 +35,7 @@ echo "Did test-run-sonobuoy $?" # --- +test-run-sonobuoy etcd test-run-sonobuoy mysql test-run-sonobuoy postgres diff --git a/scripts/test-helpers b/scripts/test-helpers index e99e6a0f95..ea7de05c51 100755 --- a/scripts/test-helpers +++ b/scripts/test-helpers @@ -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 @@ -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" @@ -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 @@ -571,6 +566,35 @@ 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 + if [ $(pgrep -c -P $pid) -gt 0 ]; then + ((count++)) + fi + done + echo "Currently running ${count} tests" 1>&2 + echo ${count} +} +export -f count-running-tests + +# --- + e2e-test() { local label=$label if [ -n "$LABEL_SUFFIX" ]; then @@ -607,6 +631,7 @@ test-run-sonobuoy() { export LABEL_SUFFIX=$1 fi + cleanup-test-env . ./scripts/test-setup-sonobuoy$suffix run-e2e-tests } diff --git a/scripts/test-run-basics b/scripts/test-run-basics index dc3b41fb92..a221b5b7c3 100755 --- a/scripts/test-run-basics +++ b/scripts/test-run-basics @@ -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 diff --git a/scripts/test-run-compat b/scripts/test-run-compat index 1a26375411..9fd5809878 100755 --- a/scripts/test-run-compat +++ b/scripts/test-run-compat @@ -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 diff --git a/scripts/test-setup-sonobuoy-dqlite b/scripts/test-setup-sonobuoy-etcd similarity index 85% rename from scripts/test-setup-sonobuoy-dqlite rename to scripts/test-setup-sonobuoy-etcd index 9b98b6e6c2..a6adebfcb1 100644 --- a/scripts/test-setup-sonobuoy-dqlite +++ b/scripts/test-setup-sonobuoy-etcd @@ -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