From 4309333343f825c02cadb4a82fec61357e7c776c Mon Sep 17 00:00:00 2001 From: bzsuni Date: Tue, 6 Aug 2024 20:09:11 +0800 Subject: [PATCH] Add nodeconformance test Signed-off-by: bzsuni --- .github/workflows/main.yaml | 10 +++++++- Makefile | 2 +- build/conformance/node-e2e-runner/run.go | 5 ++++ tests/scripts/conformance_e2e.sh | 31 ++++++++++++++++++------ 4 files changed, 39 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index a28e4a8585b..29cc49a98bf 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -400,6 +400,13 @@ jobs: needs: image-prepare env: GO111MODULE: on + strategy: + matrix: + cases: + - conformance-type: "conformance" + result-name: "conformance-test-results" + - conformance-type: "nodeconformance" + result-name: "nodeconformance-test-results" steps: - name: Install Go uses: actions/setup-go@v4 @@ -442,11 +449,12 @@ jobs: - name: Run conformance e2e run: | export KIND_IMAGE=kindest/node:v1.29.2 + export CONFORMANCE_TYPE=${{ matrix.cases.conformance-type }} make conformance_e2e - name: Upload conformance e2e test results uses: actions/upload-artifact@v4 if: always() with: - name: kube-conformance-e2e-results + name: ${{ matrix.cases.result-name }} path: /tmp/results/ \ No newline at end of file diff --git a/Makefile b/Makefile index f53f7c7cd2e..f3fe71ecc65 100644 --- a/Makefile +++ b/Makefile @@ -481,5 +481,5 @@ conformance_e2e: @echo "$$CONFORMANCE_E2E_HELP_INFO" else conformance_e2e: - tests/scripts/conformance_e2e.sh ${KIND_IMAGE} + tests/scripts/conformance_e2e.sh ${KIND_IMAGE} ${CONFORMANCE_TYPE} endif \ No newline at end of file diff --git a/build/conformance/node-e2e-runner/run.go b/build/conformance/node-e2e-runner/run.go index 13347ff6f6b..1491e66fa9a 100644 --- a/build/conformance/node-e2e-runner/run.go +++ b/build/conformance/node-e2e-runner/run.go @@ -33,6 +33,7 @@ import ( ) const ( + parallelEnvKey = "E2E_PARALLEL" dryRunEnvKey = "E2E_DRYRUN" skipEnvKey = "E2E_SKIP" focusEnvKey = "E2E_FOCUS" @@ -139,6 +140,10 @@ func makeCmd(w io.Writer) (*exec.Cmd, error) { ginkgoArgs = append(ginkgoArgs, "--dryRun=true") } + if parallelEnvValue := util.GetEnvWithDefault(parallelEnvKey, ""); len(parallelEnvValue) > 0 { + ginkgoArgs = append(ginkgoArgs, parallelEnvValue) + } + extraArgs := []string{ "--report-dir=" + util.GetEnvWithDefault(resultsDirEnvKey, defaultResultsDir), "--report-prefix=" + util.GetEnvWithDefault(reportPrefixEnvKey, defaultReportPrefix), diff --git a/tests/scripts/conformance_e2e.sh b/tests/scripts/conformance_e2e.sh index 68296382da2..41cef0c0ccc 100755 --- a/tests/scripts/conformance_e2e.sh +++ b/tests/scripts/conformance_e2e.sh @@ -21,7 +21,8 @@ KUBEEDGE_ROOT=$PWD TEST_DIR=$(realpath $(dirname $0)/..) GOPATH=${GOPATH:-$(go env GOPATH)} -KIND_IMAGE=${1:-"kindest/node:v1.28.0"} +KIND_IMAGE=${1:-"kindest/node:v1.29.2"} +CONFORMANCE_TYPE=${2:-"nodeconformance"} VERSION=$(git rev-parse --short=12 HEAD) function cleanup() { @@ -68,10 +69,7 @@ fi rm -rf /tmp/results/* function run_conformance_test() { - local image_name=$1 - local tag_name=$2 - - docker build -t "$image_name:$tag_name" -f ${KUBEEDGE_ROOT}/build/conformance/Dockerfile . + local image=$1 docker run --rm \ --env E2E_SKIP="\[Serial\]" \ @@ -83,7 +81,26 @@ function run_conformance_test() { --env E2E_EXTRA_ARGS="--kube-master=https://${MASTER_IP}:6443" \ -v ${KUBECONFIG}:/root/.kube/config \ -v /tmp/results:/tmp/results \ - --network host "$image_name:$tag_name" + --network host $image } -run_conformance_test "kubeedge/conformance-test" ${VERSION} || { echo "Conformance test failed with exit code $?"; exit 1; } \ No newline at end of file +case $CONFORMANCE_TYPE in + "nodeconformance") + echo "Running nodeconformance test" + image="kubeedge/nodeconformance-test:${VERSION}" + docker build -t "$image" -f ${KUBEEDGE_ROOT}/build/conformance/nodeconformance.Dockerfile . + + run_conformance_test "$image" || { echo "Node conformance test failed with exit code $?"; exit 1; } + ;; + "conformance") + echo "Running conformance test" + image="kubeedge/conformance-test:${VERSION}" + docker build -t "$image" -f ${KUBEEDGE_ROOT}/build/conformance/Dockerfile . + + run_conformance_test "$image" || { echo "Conformance test failed with exit code $?"; exit 1; } + ;; + *) + echo "Invalid conformance type: $CONFORMANCE_TYPE" + exit 1 + ;; +esac \ No newline at end of file