mirror of https://github.com/k3s-io/k3s
Add etcd sonobuoy tests
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 52e450f033
)
pull/4825/head
parent
c130c11064
commit
c938d93216
|
@ -11,7 +11,7 @@ ENV no_proxy=$no_proxy
|
||||||
RUN apk -U --no-cache add bash git gcc musl-dev docker vim less file curl wget ca-certificates jq linux-headers \
|
RUN apk -U --no-cache add bash git gcc musl-dev docker vim less file curl wget ca-certificates jq linux-headers \
|
||||||
zlib-dev tar zip squashfs-tools npm coreutils python3 openssl-dev libffi-dev libseccomp libseccomp-dev \
|
zlib-dev tar zip squashfs-tools npm coreutils python3 openssl-dev libffi-dev libseccomp libseccomp-dev \
|
||||||
libseccomp-static make libuv-static sqlite-dev sqlite-static libselinux libselinux-dev zlib-dev zlib-static \
|
libseccomp-static make libuv-static sqlite-dev sqlite-static libselinux libselinux-dev zlib-dev zlib-static \
|
||||||
zstd gzip alpine-sdk binutils-gold
|
zstd gzip alpine-sdk binutils-gold gawk
|
||||||
RUN if [ "$(go env GOARCH)" = "arm64" ]; then \
|
RUN if [ "$(go env GOARCH)" = "arm64" ]; then \
|
||||||
wget https://github.com/aquasecurity/trivy/releases/download/v0.16.0/trivy_0.16.0_Linux-ARM64.tar.gz && \
|
wget https://github.com/aquasecurity/trivy/releases/download/v0.16.0/trivy_0.16.0_Linux-ARM64.tar.gz && \
|
||||||
tar -zxvf trivy_0.16.0_Linux-ARM64.tar.gz && \
|
tar -zxvf trivy_0.16.0_Linux-ARM64.tar.gz && \
|
||||||
|
|
|
@ -4,11 +4,7 @@ cd $(dirname $0)/..
|
||||||
|
|
||||||
. ./scripts/version.sh
|
. ./scripts/version.sh
|
||||||
|
|
||||||
TRAEFIK_CHART_VERSION=$(yq e '.spec.chart' manifests/traefik.yaml | awk 'match($0, /([0-9.]+)([0-9]{2})/, m) { print m[1]; exit; }')
|
TRAEFIK_VERSION=$(yq e '.spec.chart' manifests/traefik.yaml | awk 'match($0, /([0-9.]+[0-9])/, m) { print m[1]; exit; }')
|
||||||
TRAEFIK_PACKAGE_VERSION=$(yq e '.spec.chart' manifests/traefik.yaml | awk 'match($0, /([0-9.]+)([0-9]{2})/, m) { print m[2]; exit; }')
|
|
||||||
TRAEFIK_FILE=traefik-${TRAEFIK_CHART_VERSION}${TRAEFIK_PACKAGE_VERSION}.tgz
|
|
||||||
TRAEFIK_CRD_FILE=traefik-crd-${TRAEFIK_CHART_VERSION}${TRAEFIK_PACKAGE_VERSION}.tgz
|
|
||||||
TRAEFIK_URL=https://helm.traefik.io/traefik/traefik-${TRAEFIK_CHART_VERSION}.tgz
|
|
||||||
CHARTS_DIR=build/static/charts
|
CHARTS_DIR=build/static/charts
|
||||||
RUNC_DIR=build/src/github.com/opencontainers/runc
|
RUNC_DIR=build/src/github.com/opencontainers/runc
|
||||||
DATA_DIR=build/data
|
DATA_DIR=build/data
|
||||||
|
|
|
@ -36,6 +36,7 @@ echo "Did test-run-sonobuoy $?"
|
||||||
|
|
||||||
# ---
|
# ---
|
||||||
|
|
||||||
|
test-run-sonobuoy etcd
|
||||||
test-run-sonobuoy mysql
|
test-run-sonobuoy mysql
|
||||||
test-run-sonobuoy postgres
|
test-run-sonobuoy postgres
|
||||||
|
|
||||||
|
|
|
@ -321,9 +321,6 @@ test-setup() {
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local setupFile=./scripts/test-setup-${TEST_TYPE}
|
|
||||||
[ -f $setupFile ] && source $setupFile
|
|
||||||
|
|
||||||
echo ${RANDOM}${RANDOM}${RANDOM} >$TEST_DIR/metadata/secret
|
echo ${RANDOM}${RANDOM}${RANDOM} >$TEST_DIR/metadata/secret
|
||||||
}
|
}
|
||||||
export -f test-setup
|
export -f test-setup
|
||||||
|
@ -422,7 +419,6 @@ provision-server() {
|
||||||
local count=$(inc-count servers)
|
local count=$(inc-count servers)
|
||||||
local testID=$(basename $TEST_DIR)
|
local testID=$(basename $TEST_DIR)
|
||||||
local name=$(echo "k3s-server-$count-$testID" | tee $TEST_DIR/servers/$count/metadata/name)
|
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 port=$(timeout --foreground 5s bash -c get-port | tee $TEST_DIR/servers/$count/metadata/port)
|
||||||
local SERVER_INSTANCE_ARGS="SERVER_${count}_ARGS"
|
local SERVER_INSTANCE_ARGS="SERVER_${count}_ARGS"
|
||||||
|
|
||||||
|
@ -454,7 +450,6 @@ provision-agent() {
|
||||||
local count=$(inc-count agents)
|
local count=$(inc-count agents)
|
||||||
local testID=$(basename $TEST_DIR)
|
local testID=$(basename $TEST_DIR)
|
||||||
local name=$(echo "k3s-agent-$count-$testID" | tee $TEST_DIR/agents/$count/metadata/name)
|
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"
|
local AGENT_INSTANCE_ARGS="AGENT_${count}_ARGS"
|
||||||
|
|
||||||
run-function agent-pre-hook $count
|
run-function agent-pre-hook $count
|
||||||
|
@ -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(){
|
count-running-tests(){
|
||||||
local count=0
|
local count=0
|
||||||
for pid in ${pids[@]}; do
|
for pid in ${pids[@]}; do
|
||||||
|
@ -631,6 +641,7 @@ test-run-sonobuoy() {
|
||||||
export LABEL_SUFFIX=$1
|
export LABEL_SUFFIX=$1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
cleanup-test-env
|
||||||
. ./scripts/test-setup-sonobuoy$suffix
|
. ./scripts/test-setup-sonobuoy$suffix
|
||||||
run-e2e-tests
|
run-e2e-tests
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,3 +46,5 @@ export -f use-local-storage-volume
|
||||||
|
|
||||||
# --- create a basic cluster and check for valid versions
|
# --- create a basic cluster and check for valid versions
|
||||||
LABEL=BASICS run-test
|
LABEL=BASICS run-test
|
||||||
|
|
||||||
|
cleanup-test-env
|
||||||
|
|
|
@ -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
|
# --- 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_SERVER=${REPO}/${IMAGE_NAME}:${LATEST_VERSION} LABEL=LATEST-SERVER run-test
|
||||||
K3S_IMAGE_AGENT=${REPO}/${IMAGE_NAME}:${LATEST_VERSION} LABEL=LATEST-AGENT run-test
|
K3S_IMAGE_AGENT=${REPO}/${IMAGE_NAME}:${LATEST_VERSION} LABEL=LATEST-AGENT run-test
|
||||||
|
|
||||||
|
cleanup-test-env
|
||||||
|
|
|
@ -4,10 +4,7 @@
|
||||||
|
|
||||||
export NUM_SERVERS=2
|
export NUM_SERVERS=2
|
||||||
export NUM_AGENTS=0
|
export NUM_AGENTS=0
|
||||||
|
export SERVER_1_ARGS="--cluster-init"
|
||||||
export SERVER_1_ARGS=--cluster-init
|
|
||||||
|
|
||||||
# ---
|
|
||||||
|
|
||||||
server-post-hook() {
|
server-post-hook() {
|
||||||
if [ $1 -eq 1 ]; then
|
if [ $1 -eq 1 ]; then
|
Loading…
Reference in New Issue