From 30f8a38fff6df3f5585ca906c96010863b8d97a3 Mon Sep 17 00:00:00 2001 From: Ilya Zuyev Date: Wed, 5 May 2021 13:28:39 -0700 Subject: [PATCH] add functional_podman_ubuntu test Fix test error messages Fix test comment and docs --- .github/workflows/master.yml | 105 +++++++++++++++++ .github/workflows/pr.yml | 106 +++++++++++++++++- site/content/en/docs/contrib/tests.en.md | 7 +- test/integration/functional_test.go | 61 +++++++++- .../integration/functional_test_mount_test.go | 4 + 5 files changed, 277 insertions(+), 6 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index aa9c5f1a632d..849f31988d8a 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -282,6 +282,109 @@ jobs: if [ "$numPass" -eq 0 ];then echo "*** 0 Passed! ***";exit 2;fi if [ "$numPass" -lt 36 ];then echo "*** Failed to pass at least 36 ! ***";exit 2;fi if [ "$numPass" -eq 0 ];then echo "*** Passed! ***";exit 0;fi + + functional_podman_ubuntu: + needs: [ build_minikube ] + env: + TIME_ELAPSED: time + JOB_NAME: functional_podman_ubuntu + GOPOGH_RESULT: "" + SHELL: "/bin/bash" # To prevent https://github.com/kubernetes/minikube/issues/6643 + runs-on: ubuntu-20.04 + steps: + - name: Install kubectl + shell: bash + run: | + curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.18.0/bin/linux/amd64/kubectl + sudo install kubectl /usr/local/bin/kubectl + kubectl version --client=true + + - name: Install Podman + shell: bash + run: | + sudo apt update + sudo apt install -y podman + echo "--------------------------" + podman version || true + echo "--------------------------" + podman info || true + echo "--------------------------" + podman system df || true + echo "--------------------------" + podman system info --format='{{json .}}'|| true + echo "--------------------------" + podman ps || true + echo "--------------------------" + # go 1.14.6+ is needed because of this bug https://github.com/golang/go/issues/39308 + - uses: actions/setup-go@v2 + with: + go-version: ${{env.GO_VERSION}} + stable: true + - name: Install gopogh + shell: bash + run: | + curl -LO https://github.com/medyagh/gopogh/releases/download/v0.6.0/gopogh-linux-amd64 + sudo install gopogh-linux-amd64 /usr/local/bin/gopogh + - name: Download Binaries + uses: actions/download-artifact@v1 + with: + name: minikube_binaries + - name: Run Integration Test + continue-on-error: false + # bash {0} to allow test to continue to next step. in case of + shell: bash {0} + run: | + cd minikube_binaries + mkdir -p report + mkdir -p testhome + chmod a+x e2e-* + chmod a+x minikube-* + sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/ + sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld + START_TIME=$(date -u +%s) + KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome ./e2e-linux-amd64 -minikube-start-args=--vm-driver=podman -v=6 --alsologtostderr -test.run TestFunctional -test.timeout=10m -test.v -timeout-multiplier=1.5 -binary=./minikube-linux-amd64 2>&1 | tee ./report/testout.txt + END_TIME=$(date -u +%s) + TIME_ELAPSED=$(($END_TIME-$START_TIME)) + min=$((${TIME_ELAPSED}/60)) + sec=$((${TIME_ELAPSED}%60)) + TIME_ELAPSED="${min} min $sec seconds " + echo "TIME_ELAPSED=${TIME_ELAPSED}" >> $GITHUB_ENV + - name: Generate HTML Report + shell: bash + run: | + cd minikube_binaries + export PATH=${PATH}:`go env GOPATH`/bin + go tool test2json -t < ./report/testout.txt > ./report/testout.json || true + STAT=$(gopogh -in ./report/testout.json -out_html ./report/testout.html -out_summary ./report/testout_summary.json -name "${JOB_NAME} ${GITHUB_REF}" -repo "${GITHUB_REPOSITORY}" -details "${GITHUB_SHA}") || true + echo status: ${STAT} + FailNum=$(echo $STAT | jq '.NumberOfFail') + TestsNum=$(echo $STAT | jq '.NumberOfTests') + GOPOGH_RESULT="${JOB_NAME} : completed with ${FailNum} / ${TestsNum} failures in ${TIME_ELAPSED}" + echo "GOPOGH_RESULT=${GOPOGH_RESULT}" >> $GITHUB_ENV + echo 'STAT<> $GITHUB_ENV + echo "${STAT}" >> $GITHUB_ENV + echo 'EOF' >> $GITHUB_ENV + - uses: actions/upload-artifact@v1 + with: + name: functional_podman_ubuntu + path: minikube_binaries/report + - name: The End Result functional_podman_ubuntu + shell: bash + run: | + echo ${GOPOGH_RESULT} + numFail=$(echo $STAT | jq '.NumberOfFail') + numPass=$(echo $STAT | jq '.NumberOfPass') + echo "*******************${numPass} Passes :) *******************" + echo $STAT | jq '.PassedTests' || true + echo "*******************************************************" + echo "---------------- ${numFail} Failures :( ----------------------------" + echo $STAT | jq '.FailedTests' || true + echo "-------------------------------------------------------" + if [ "$numFail" -gt 0 ];then echo "*** $numFail Failed ***";exit 2;fi + if [ "$numPass" -eq 0 ];then echo "*** 0 Passed! ***";exit 2;fi + if [ "$numPass" -lt 36 ];then echo "*** Failed to pass at least 36 ! ***";exit 2;fi + if [ "$numPass" -eq 0 ];then echo "*** Passed! ***";exit 0;fi + functional_virtualbox_macos: needs: [build_minikube] env: @@ -882,6 +985,7 @@ jobs: functional_docker_ubuntu, functional_docker_containerd_ubuntu, functional_docker_ubuntu_arm64, + functional_podman_ubuntu, functional_virtualbox_macos, functional_docker_windows, functional_hyperv_windows, @@ -900,6 +1004,7 @@ jobs: cp -r ./functional_docker_ubuntu ./all_reports/ cp -r ./functional_docker_containerd_ubuntu ./all_reports/ cp -r ./functional_docker_ubuntu_arm64 ./all_reports/ + cp -r ./functional_podman_ubuntu ./all_reports/ cp -r ./functional_virtualbox_macos ./all_reports/ cp -r ./functional_docker_windows ./all_reports/ cp -r ./functional_hyperv_windows ./all_reports/ diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 6b19aa4ac520..23e898472d62 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -117,7 +117,6 @@ jobs: go-version: ${{env.GO_VERSION}} stable: true - name: Install gopogh - shell: bash run: | curl -LO https://github.com/medyagh/gopogh/releases/download/v0.6.0/gopogh-linux-amd64 @@ -280,6 +279,109 @@ jobs: if [ "$numPass" -eq 0 ];then echo "*** 0 Passed! ***";exit 2;fi if [ "$numPass" -lt 36 ];then echo "*** Failed to pass at least 36 ! ***";exit 2;fi if [ "$numPass" -eq 0 ];then echo "*** Passed! ***";exit 0;fi + + functional_podman_ubuntu: + needs: [ build_minikube ] + env: + TIME_ELAPSED: time + JOB_NAME: functional_podman_ubuntu + GOPOGH_RESULT: "" + SHELL: "/bin/bash" # To prevent https://github.com/kubernetes/minikube/issues/6643 + runs-on: ubuntu-20.04 + steps: + - name: Install kubectl + shell: bash + run: | + curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.18.0/bin/linux/amd64/kubectl + sudo install kubectl /usr/local/bin/kubectl + kubectl version --client=true + + - name: Install Podman + shell: bash + run: | + sudo apt update + sudo apt install -y podman + echo "--------------------------" + podman version || true + echo "--------------------------" + podman info || true + echo "--------------------------" + podman system df || true + echo "--------------------------" + podman system info --format='{{json .}}'|| true + echo "--------------------------" + podman ps || true + echo "--------------------------" + # go 1.14.6+ is needed because of this bug https://github.com/golang/go/issues/39308 + - uses: actions/setup-go@v2 + with: + go-version: ${{env.GO_VERSION}} + stable: true + - name: Install gopogh + shell: bash + run: | + curl -LO https://github.com/medyagh/gopogh/releases/download/v0.6.0/gopogh-linux-amd64 + sudo install gopogh-linux-amd64 /usr/local/bin/gopogh + - name: Download Binaries + uses: actions/download-artifact@v1 + with: + name: minikube_binaries + - name: Run Integration Test + continue-on-error: false + # bash {0} to allow test to continue to next step. in case of + shell: bash {0} + run: | + cd minikube_binaries + mkdir -p report + mkdir -p testhome + chmod a+x e2e-* + chmod a+x minikube-* + sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/ + sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld + START_TIME=$(date -u +%s) + KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome ./e2e-linux-amd64 -minikube-start-args=--vm-driver=podman -v=6 --alsologtostderr -test.run TestFunctional -test.timeout=10m -test.v -timeout-multiplier=1.5 -binary=./minikube-linux-amd64 2>&1 | tee ./report/testout.txt + END_TIME=$(date -u +%s) + TIME_ELAPSED=$(($END_TIME-$START_TIME)) + min=$((${TIME_ELAPSED}/60)) + sec=$((${TIME_ELAPSED}%60)) + TIME_ELAPSED="${min} min $sec seconds " + echo "TIME_ELAPSED=${TIME_ELAPSED}" >> $GITHUB_ENV + - name: Generate HTML Report + shell: bash + run: | + cd minikube_binaries + export PATH=${PATH}:`go env GOPATH`/bin + go tool test2json -t < ./report/testout.txt > ./report/testout.json || true + STAT=$(gopogh -in ./report/testout.json -out_html ./report/testout.html -out_summary ./report/testout_summary.json -name "${JOB_NAME} ${GITHUB_REF}" -repo "${GITHUB_REPOSITORY}" -details "${GITHUB_SHA}") || true + echo status: ${STAT} + FailNum=$(echo $STAT | jq '.NumberOfFail') + TestsNum=$(echo $STAT | jq '.NumberOfTests') + GOPOGH_RESULT="${JOB_NAME} : completed with ${FailNum} / ${TestsNum} failures in ${TIME_ELAPSED}" + echo "GOPOGH_RESULT=${GOPOGH_RESULT}" >> $GITHUB_ENV + echo 'STAT<> $GITHUB_ENV + echo "${STAT}" >> $GITHUB_ENV + echo 'EOF' >> $GITHUB_ENV + - uses: actions/upload-artifact@v1 + with: + name: functional_podman_ubuntu + path: minikube_binaries/report + - name: The End Result functional_podman_ubuntu + shell: bash + run: | + echo ${GOPOGH_RESULT} + numFail=$(echo $STAT | jq '.NumberOfFail') + numPass=$(echo $STAT | jq '.NumberOfPass') + echo "*******************${numPass} Passes :) *******************" + echo $STAT | jq '.PassedTests' || true + echo "*******************************************************" + echo "---------------- ${numFail} Failures :( ----------------------------" + echo $STAT | jq '.FailedTests' || true + echo "-------------------------------------------------------" + if [ "$numFail" -gt 0 ];then echo "*** $numFail Failed ***";exit 2;fi + if [ "$numPass" -eq 0 ];then echo "*** 0 Passed! ***";exit 2;fi + if [ "$numPass" -lt 36 ];then echo "*** Failed to pass at least 36 ! ***";exit 2;fi + if [ "$numPass" -eq 0 ];then echo "*** Passed! ***";exit 0;fi + functional_virtualbox_macos: needs: [build_minikube] env: @@ -879,6 +981,7 @@ jobs: [ functional_docker_ubuntu, functional_docker_containerd_ubuntu, + functional_podman_ubuntu, functional_docker_ubuntu_arm64, functional_virtualbox_macos, functional_docker_windows, @@ -897,6 +1000,7 @@ jobs: ls -lah cp -r ./functional_docker_ubuntu ./all_reports/ cp -r ./functional_docker_containerd_ubuntu ./all_reports/ + cp -r ./functional_podman_ubuntu ./all_reports/ cp -r ./functional_docker_ubuntu_arm64 ./all_reports/ cp -r ./functional_virtualbox_macos ./all_reports/ cp -r ./functional_docker_windows ./all_reports/ diff --git a/site/content/en/docs/contrib/tests.en.md b/site/content/en/docs/contrib/tests.en.md index 9272890b391b..e9ffa2a65df5 100644 --- a/site/content/en/docs/contrib/tests.en.md +++ b/site/content/en/docs/contrib/tests.en.md @@ -88,7 +88,10 @@ validateBuildImage makes sures that `minikube image build` works as expected validateListImages makes sures that `minikube image ls` works as expected #### validateDockerEnv -check functionality of minikube after evaling docker-env +check functionality of minikube after evaluating docker-env + +#### validatePodmanEnv +check functionality of minikube after evaluating podman-env #### validateStartWithProxy validateStartWithProxy makes sure minikube start respects the HTTP_PROXY environment variable @@ -351,4 +354,4 @@ TestKubernetesUpgrade upgrades Kubernetes from oldest to newest ## TestMissingContainerUpgrade TestMissingContainerUpgrade tests a Docker upgrade where the underlying container is missing -TEST COUNT: 112 +TEST COUNT: 113 diff --git a/test/integration/functional_test.go b/test/integration/functional_test.go index 021481cfd5ea..ab3a7088f0cb 100644 --- a/test/integration/functional_test.go +++ b/test/integration/functional_test.go @@ -46,7 +46,7 @@ import ( "k8s.io/minikube/pkg/util/retry" "github.com/elazarl/goproxy" - retryablehttp "github.com/hashicorp/go-retryablehttp" + "github.com/hashicorp/go-retryablehttp" "github.com/otiai10/copy" "github.com/phayes/freeport" "github.com/pkg/errors" @@ -131,6 +131,7 @@ func TestFunctional(t *testing.T) { {"CertSync", validateCertSync}, {"UpdateContextCmd", validateUpdateContextCmd}, {"DockerEnv", validateDockerEnv}, + {"PodmanEnv", validatePodmanEnv}, {"NodeLabels", validateNodeLabels}, {"LoadImage", validateLoadImage}, {"RemoveImage", validateRemoveImage}, @@ -399,8 +400,7 @@ func validateListImages(ctx context.Context, t *testing.T, profile string) { } } -// check functionality of minikube after evaling docker-env -// TODO: Add validatePodmanEnv for crio runtime: #10231 +// check functionality of minikube after evaluating docker-env func validateDockerEnv(ctx context.Context, t *testing.T, profile string) { if NoneDriver() { t.Skipf("none driver does not support docker-env") @@ -460,6 +460,61 @@ func validateDockerEnv(ctx context.Context, t *testing.T, profile string) { } } +// check functionality of minikube after evaluating podman-env +func validatePodmanEnv(ctx context.Context, t *testing.T, profile string) { + if NoneDriver() { + t.Skipf("none driver does not support podman-env") + } + + if cr := ContainerRuntime(); cr != "podman" { + t.Skipf("only validate podman env with docker container runtime, currently testing %s", cr) + } + + if runtime.GOOS != "linux" { + t.Skipf("only validate podman env on linux, currently testing %s", runtime.GOOS) + } + + defer PostMortemLogs(t, profile) + + mctx, cancel := context.WithTimeout(ctx, Seconds(120)) + defer cancel() + + c := exec.CommandContext(mctx, "/bin/bash", "-c", "eval $("+Target()+" -p "+profile+" podman-env) && "+Target()+" status -p "+profile) + // we should be able to get minikube status with a bash which evaluated podman-env + rr, err := Run(t, c) + + if mctx.Err() == context.DeadlineExceeded { + t.Errorf("failed to run the command by deadline. exceeded timeout. %s", rr.Command()) + } + if err != nil { + t.Fatalf("failed to do status after eval-ing podman-env. error: %v", err) + } + if !strings.Contains(rr.Output(), "Running") { + t.Fatalf("expected status output to include 'Running' after eval podman-env but got: *%s*", rr.Output()) + } + if !strings.Contains(rr.Output(), "in-use") { + t.Fatalf("expected status output to include `in-use` after eval podman-env but got *%s*", rr.Output()) + } + + mctx, cancel = context.WithTimeout(ctx, Seconds(60)) + defer cancel() + // do a eval $(minikube -p profile podman-env) and check if we are point to docker inside minikube + c = exec.CommandContext(mctx, "/bin/bash", "-c", "eval $("+Target()+" -p "+profile+" podman-env) && docker images") + rr, err = Run(t, c) + + if mctx.Err() == context.DeadlineExceeded { + t.Errorf("failed to run the command in 30 seconds. exceeded 30s timeout. %s", rr.Command()) + } + if err != nil { + t.Fatalf("failed to run minikube podman-env. args %q : %v ", rr.Command(), err) + } + + expectedImgInside := "gcr.io/k8s-minikube/storage-provisioner" + if !strings.Contains(rr.Output(), expectedImgInside) { + t.Fatalf("expected 'docker images' to have %q inside minikube. but the output is: *%s*", expectedImgInside, rr.Output()) + } +} + // validateStartWithProxy makes sure minikube start respects the HTTP_PROXY environment variable func validateStartWithProxy(ctx context.Context, t *testing.T, profile string) { defer PostMortemLogs(t, profile) diff --git a/test/integration/functional_test_mount_test.go b/test/integration/functional_test_mount_test.go index a320841f423c..ff5893692d4b 100644 --- a/test/integration/functional_test_mount_test.go +++ b/test/integration/functional_test_mount_test.go @@ -56,6 +56,10 @@ func validateMountCmd(ctx context.Context, t *testing.T, profile string) { // no t.Skip("skipping: mount broken on windows: https://github.com/kubernetes/minikube/issues/8303") } + if GithubActionRunner() && PodmanDriver() { + t.Skip("skipping: https://github.com/kubernetes/minikube/issues/11293") + } + tempDir, err := ioutil.TempDir("", "mounttest") defer func() { // clean up tempdir err := os.RemoveAll(tempDir)