From 0949f4fe68fe4d00e784fb443acd5a1160a9c4bd Mon Sep 17 00:00:00 2001 From: Petr Horacek Date: Fri, 8 Nov 2019 19:34:44 +0100 Subject: [PATCH] simplify e2e automation Get rid of smart PROVIDER parsing and simply keep single shell script per target. Since we switched to kubevirtci's cluster-up, switch from OpenShift 3 to OKD 4 as part of this patch. Signed-off-by: Petr Horacek --- .../check-patch.e2e-lifecycle-k8s.mounts | 1 + .../check-patch.e2e-lifecycle-k8s.packages | 1 + automation/check-patch.e2e-lifecycle-k8s.sh | 27 ++++++++++++ .../check-patch.e2e-lifecycle-okd.mounts | 1 + .../check-patch.e2e-lifecycle-okd.packages | 1 + automation/check-patch.e2e-lifecycle-okd.sh | 27 ++++++++++++ .../check-patch.e2e-workflow-k8s.mounts | 1 + .../check-patch.e2e-workflow-k8s.packages | 1 + automation/check-patch.e2e-workflow-k8s.sh | 28 +++++++++++++ .../check-patch.e2e-workflow-okd.mounts | 1 + .../check-patch.e2e-workflow-okd.packages | 1 + automation/check-patch.e2e-workflow-okd.sh | 28 +++++++++++++ ...ck-patch.mounts => check-patch.e2e.mounts} | 0 ...atch.packages => check-patch.e2e.packages} | 0 automation/check-patch.e2e.setup.sh | 27 ++++++++++++ .../check-patch.lifecycle.k8s-1.13.3.mounts | 1 - .../check-patch.lifecycle.k8s-1.13.3.packages | 1 - .../check-patch.lifecycle.k8s-1.13.3.sh | 1 - .../check-patch.lifecycle.os-3.11.0.mounts | 1 - .../check-patch.lifecycle.os-3.11.0.packages | 1 - automation/check-patch.lifecycle.os-3.11.0.sh | 1 - automation/check-patch.sh | 41 ------------------- .../check-patch.workflow.k8s-1.13.3.mounts | 1 - .../check-patch.workflow.k8s-1.13.3.packages | 1 - automation/check-patch.workflow.k8s-1.13.3.sh | 1 - .../check-patch.workflow.os-3.11.0.mounts | 1 - .../check-patch.workflow.os-3.11.0.packages | 1 - automation/check-patch.workflow.os-3.11.0.sh | 1 - automation/test.sh | 21 ---------- cluster/operator-push.sh | 13 +++--- stdci.yaml | 8 ++-- test/check/check.go | 12 ++++++ test/check/components.go | 1 - test/e2e/workflow/deployment_test.go | 16 +++++--- test/okd/okd.go | 10 +++++ test/releases/releases.go | 16 ++++++++ 36 files changed, 203 insertions(+), 92 deletions(-) create mode 120000 automation/check-patch.e2e-lifecycle-k8s.mounts create mode 120000 automation/check-patch.e2e-lifecycle-k8s.packages create mode 100755 automation/check-patch.e2e-lifecycle-k8s.sh create mode 120000 automation/check-patch.e2e-lifecycle-okd.mounts create mode 120000 automation/check-patch.e2e-lifecycle-okd.packages create mode 100755 automation/check-patch.e2e-lifecycle-okd.sh create mode 120000 automation/check-patch.e2e-workflow-k8s.mounts create mode 120000 automation/check-patch.e2e-workflow-k8s.packages create mode 100755 automation/check-patch.e2e-workflow-k8s.sh create mode 120000 automation/check-patch.e2e-workflow-okd.mounts create mode 120000 automation/check-patch.e2e-workflow-okd.packages create mode 100755 automation/check-patch.e2e-workflow-okd.sh rename automation/{check-patch.mounts => check-patch.e2e.mounts} (100%) rename automation/{check-patch.packages => check-patch.e2e.packages} (100%) create mode 100644 automation/check-patch.e2e.setup.sh delete mode 120000 automation/check-patch.lifecycle.k8s-1.13.3.mounts delete mode 120000 automation/check-patch.lifecycle.k8s-1.13.3.packages delete mode 120000 automation/check-patch.lifecycle.k8s-1.13.3.sh delete mode 120000 automation/check-patch.lifecycle.os-3.11.0.mounts delete mode 120000 automation/check-patch.lifecycle.os-3.11.0.packages delete mode 120000 automation/check-patch.lifecycle.os-3.11.0.sh delete mode 100755 automation/check-patch.sh delete mode 120000 automation/check-patch.workflow.k8s-1.13.3.mounts delete mode 120000 automation/check-patch.workflow.k8s-1.13.3.packages delete mode 120000 automation/check-patch.workflow.k8s-1.13.3.sh delete mode 120000 automation/check-patch.workflow.os-3.11.0.mounts delete mode 120000 automation/check-patch.workflow.os-3.11.0.packages delete mode 120000 automation/check-patch.workflow.os-3.11.0.sh delete mode 100755 automation/test.sh create mode 100644 test/okd/okd.go diff --git a/automation/check-patch.e2e-lifecycle-k8s.mounts b/automation/check-patch.e2e-lifecycle-k8s.mounts new file mode 120000 index 000000000..9f37834f1 --- /dev/null +++ b/automation/check-patch.e2e-lifecycle-k8s.mounts @@ -0,0 +1 @@ +check-patch.e2e.mounts \ No newline at end of file diff --git a/automation/check-patch.e2e-lifecycle-k8s.packages b/automation/check-patch.e2e-lifecycle-k8s.packages new file mode 120000 index 000000000..1111d9fd9 --- /dev/null +++ b/automation/check-patch.e2e-lifecycle-k8s.packages @@ -0,0 +1 @@ +check-patch.e2e.packages \ No newline at end of file diff --git a/automation/check-patch.e2e-lifecycle-k8s.sh b/automation/check-patch.e2e-lifecycle-k8s.sh new file mode 100755 index 000000000..33b84ae42 --- /dev/null +++ b/automation/check-patch.e2e-lifecycle-k8s.sh @@ -0,0 +1,27 @@ +#!/bin/bash -xe + +# This script should be able to execute lifecycle functional tests against +# Kubernetes cluster on any environment with basic dependencies listed in +# check-patch.packages installed and docker running. +# +# yum -y install automation/check-patch.packages +# automation/check-patch.e2e-lifecycle-k8s.sh + +teardown() { + make cluster-down +} + +main() { + export KUBEVIRT_PROVIDER='k8s-1.14.6' + + source automation/check-patch.e2e.setup.sh + cd ${TMP_PROJECT_PATH} + + make cluster-down + make cluster-up + trap teardown EXIT SIGINT SIGTERM SIGSTOP + make cluster-operator-push + make test/e2e/lifecycle +} + +[[ "${BASH_SOURCE[0]}" == "$0" ]] && main "$@" diff --git a/automation/check-patch.e2e-lifecycle-okd.mounts b/automation/check-patch.e2e-lifecycle-okd.mounts new file mode 120000 index 000000000..9f37834f1 --- /dev/null +++ b/automation/check-patch.e2e-lifecycle-okd.mounts @@ -0,0 +1 @@ +check-patch.e2e.mounts \ No newline at end of file diff --git a/automation/check-patch.e2e-lifecycle-okd.packages b/automation/check-patch.e2e-lifecycle-okd.packages new file mode 120000 index 000000000..1111d9fd9 --- /dev/null +++ b/automation/check-patch.e2e-lifecycle-okd.packages @@ -0,0 +1 @@ +check-patch.e2e.packages \ No newline at end of file diff --git a/automation/check-patch.e2e-lifecycle-okd.sh b/automation/check-patch.e2e-lifecycle-okd.sh new file mode 100755 index 000000000..7b87d2188 --- /dev/null +++ b/automation/check-patch.e2e-lifecycle-okd.sh @@ -0,0 +1,27 @@ +#!/bin/bash -xe + +# This script should be able to execute functional tests against OKD cluster on +# any environment with basic dependencies listed in check-patch.packages +# installed and docker running. +# +# yum -y install automation/check-patch.packages +# automation/check-patch.e2e-lifecycle-okd.sh + +teardown() { + make cluster-down +} + +main() { + export KUBEVIRT_PROVIDER='okd-4.1' + + source automation/check-patch.e2e.setup.sh + cd ${TMP_PROJECT_PATH} + + make cluster-down + make cluster-up + trap teardown EXIT SIGINT SIGTERM SIGSTOP + make cluster-operator-push + make test/e2e/lifecycle +} + +[[ "${BASH_SOURCE[0]}" == "$0" ]] && main "$@" diff --git a/automation/check-patch.e2e-workflow-k8s.mounts b/automation/check-patch.e2e-workflow-k8s.mounts new file mode 120000 index 000000000..9f37834f1 --- /dev/null +++ b/automation/check-patch.e2e-workflow-k8s.mounts @@ -0,0 +1 @@ +check-patch.e2e.mounts \ No newline at end of file diff --git a/automation/check-patch.e2e-workflow-k8s.packages b/automation/check-patch.e2e-workflow-k8s.packages new file mode 120000 index 000000000..1111d9fd9 --- /dev/null +++ b/automation/check-patch.e2e-workflow-k8s.packages @@ -0,0 +1 @@ +check-patch.e2e.packages \ No newline at end of file diff --git a/automation/check-patch.e2e-workflow-k8s.sh b/automation/check-patch.e2e-workflow-k8s.sh new file mode 100755 index 000000000..78d8862a7 --- /dev/null +++ b/automation/check-patch.e2e-workflow-k8s.sh @@ -0,0 +1,28 @@ +#!/bin/bash -xe + +# This script should be able to execute workflow functional tests against +# Kubernetes cluster on any environment with basic dependencies listed in +# check-patch.packages installed and docker running. +# +# yum -y install automation/check-patch.packages +# automation/check-patch.e2e-workflow-k8s.sh + +teardown() { + make cluster-down +} + +main() { + export KUBEVIRT_PROVIDER='k8s-1.14.6' + + source automation/check-patch.e2e.setup.sh + cd ${TMP_PROJECT_PATH} + + make cluster-down + make cluster-up + trap teardown EXIT SIGINT SIGTERM SIGSTOP + make cluster-operator-push + make cluster-operator-install + make test/e2e/workflow +} + +[[ "${BASH_SOURCE[0]}" == "$0" ]] && main "$@" diff --git a/automation/check-patch.e2e-workflow-okd.mounts b/automation/check-patch.e2e-workflow-okd.mounts new file mode 120000 index 000000000..9f37834f1 --- /dev/null +++ b/automation/check-patch.e2e-workflow-okd.mounts @@ -0,0 +1 @@ +check-patch.e2e.mounts \ No newline at end of file diff --git a/automation/check-patch.e2e-workflow-okd.packages b/automation/check-patch.e2e-workflow-okd.packages new file mode 120000 index 000000000..1111d9fd9 --- /dev/null +++ b/automation/check-patch.e2e-workflow-okd.packages @@ -0,0 +1 @@ +check-patch.e2e.packages \ No newline at end of file diff --git a/automation/check-patch.e2e-workflow-okd.sh b/automation/check-patch.e2e-workflow-okd.sh new file mode 100755 index 000000000..5d951c530 --- /dev/null +++ b/automation/check-patch.e2e-workflow-okd.sh @@ -0,0 +1,28 @@ +#!/bin/bash -xe + +# This script should be able to execute workflow functional tests against OKD +# cluster on any environment with basic dependencies listed in +# check-patch.packages installed and docker running. +# +# yum -y install automation/check-patch.packages +# automation/check-patch.e2e-workflow-okd.sh + +teardown() { + make cluster-down +} + +main() { + export KUBEVIRT_PROVIDER='okd-4.1' + + source automation/check-patch.e2e.setup.sh + cd ${TMP_PROJECT_PATH} + + make cluster-down + make cluster-up + trap teardown EXIT SIGINT SIGTERM SIGSTOP + make cluster-operator-push + make cluster-operator-install + make test/e2e/workflow +} + +[[ "${BASH_SOURCE[0]}" == "$0" ]] && main "$@" diff --git a/automation/check-patch.mounts b/automation/check-patch.e2e.mounts similarity index 100% rename from automation/check-patch.mounts rename to automation/check-patch.e2e.mounts diff --git a/automation/check-patch.packages b/automation/check-patch.e2e.packages similarity index 100% rename from automation/check-patch.packages rename to automation/check-patch.e2e.packages diff --git a/automation/check-patch.e2e.setup.sh b/automation/check-patch.e2e.setup.sh new file mode 100644 index 000000000..3fabe6a9d --- /dev/null +++ b/automation/check-patch.e2e.setup.sh @@ -0,0 +1,27 @@ +# Prepare environment for CNAO end to end testing. This includes temporary Go paths and binaries. +# +# source automation/check-patch.e2e.setup.sh +# cd ${TMP_PROJECT_PATH} + +echo 'Setup Go paths' +export GOROOT=/tmp/cluster-network-addons-operator/go/root +mkdir -p $GOROOT +export GOPATH=/tmp/cluster-network-addons-operator/go/path +mkdir -p $GOPATH +export PATH=${GOPATH}/bin:${GOROOT}/bin:${PATH} + +echo 'Install Go 1.12' +export GIMME_GO_VERSION=1.12 +GIMME=/tmp/cluster-network-addons-operator/go/gimme +mkdir -p $GIMME +curl -sL https://raw.githubusercontent.com/travis-ci/gimme/master/gimme | HOME=${GIMME} bash >> ${GIMME}/gimme.sh +source ${GIMME}/gimme.sh + +echo 'Install operator repository under the temporary Go path' +TMP_PROJECT_PATH=${GOPATH}/src/github.com/kubevirt/cluster-network-addons-operator +rm -rf ${TMP_PROJECT_PATH} +mkdir -p ${TMP_PROJECT_PATH} +cp -rf $(pwd)/* ${TMP_PROJECT_PATH} + +echo 'Exporting temporary project path' +export TMP_PROJECT_PATH diff --git a/automation/check-patch.lifecycle.k8s-1.13.3.mounts b/automation/check-patch.lifecycle.k8s-1.13.3.mounts deleted file mode 120000 index c459a2524..000000000 --- a/automation/check-patch.lifecycle.k8s-1.13.3.mounts +++ /dev/null @@ -1 +0,0 @@ -check-patch.mounts \ No newline at end of file diff --git a/automation/check-patch.lifecycle.k8s-1.13.3.packages b/automation/check-patch.lifecycle.k8s-1.13.3.packages deleted file mode 120000 index 3858aae7d..000000000 --- a/automation/check-patch.lifecycle.k8s-1.13.3.packages +++ /dev/null @@ -1 +0,0 @@ -check-patch.packages \ No newline at end of file diff --git a/automation/check-patch.lifecycle.k8s-1.13.3.sh b/automation/check-patch.lifecycle.k8s-1.13.3.sh deleted file mode 120000 index a61652ade..000000000 --- a/automation/check-patch.lifecycle.k8s-1.13.3.sh +++ /dev/null @@ -1 +0,0 @@ -check-patch.sh \ No newline at end of file diff --git a/automation/check-patch.lifecycle.os-3.11.0.mounts b/automation/check-patch.lifecycle.os-3.11.0.mounts deleted file mode 120000 index c459a2524..000000000 --- a/automation/check-patch.lifecycle.os-3.11.0.mounts +++ /dev/null @@ -1 +0,0 @@ -check-patch.mounts \ No newline at end of file diff --git a/automation/check-patch.lifecycle.os-3.11.0.packages b/automation/check-patch.lifecycle.os-3.11.0.packages deleted file mode 120000 index 3858aae7d..000000000 --- a/automation/check-patch.lifecycle.os-3.11.0.packages +++ /dev/null @@ -1 +0,0 @@ -check-patch.packages \ No newline at end of file diff --git a/automation/check-patch.lifecycle.os-3.11.0.sh b/automation/check-patch.lifecycle.os-3.11.0.sh deleted file mode 120000 index a61652ade..000000000 --- a/automation/check-patch.lifecycle.os-3.11.0.sh +++ /dev/null @@ -1 +0,0 @@ -check-patch.sh \ No newline at end of file diff --git a/automation/check-patch.sh b/automation/check-patch.sh deleted file mode 100755 index 2319518ce..000000000 --- a/automation/check-patch.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -xe - -main() { - CLUSTER_PROVIDER="$0" - CLUSTER_PROVIDER="${CLUSTER_PROVIDER#./}" - CLUSTER_PROVIDER="${CLUSTER_PROVIDER#*.*.}" - CLUSTER_PROVIDER="${CLUSTER_PROVIDER%.*}" - echo "CLUSTER_PROVIDER=$CLUSTER_PROVIDER" - export CLUSTER_PROVIDER - - TEST_SUITE="$0" - TEST_SUITE="${TEST_SUITE#./}" - TEST_SUITE="${TEST_SUITE#*.}" - TEST_SUITE="${TEST_SUITE%%.*}" - echo "TEST_SUITE=$TEST_SUITE" - export TEST_SUITE - - echo "Setup Go paths" - cd .. - export GOROOT=/usr/local/go - export GOPATH=$(pwd)/go - export PATH=$GOPATH/bin:$GOROOT/bin:$PATH - mkdir -p $GOPATH - - echo "Install Go 1.11" - export GIMME_GO_VERSION=1.11 - mkdir -p /gimme - curl -sL https://raw.githubusercontent.com/travis-ci/gimme/master/gimme | HOME=/gimme bash >> /etc/profile.d/gimme.sh - source /etc/profile.d/gimme.sh - - echo "Install operator repository to the right place" - mkdir -p $GOPATH/src/github.com/kubevirt - mkdir -p $GOPATH/pkg - ln -s $(pwd)/cluster-network-addons-operator $GOPATH/src/github.com/kubevirt/ - cd $GOPATH/src/github.com/kubevirt/cluster-network-addons-operator - - echo "Run functional tests" - exec automation/test.sh -} - -[[ "${BASH_SOURCE[0]}" == "$0" ]] && main "$@" diff --git a/automation/check-patch.workflow.k8s-1.13.3.mounts b/automation/check-patch.workflow.k8s-1.13.3.mounts deleted file mode 120000 index c459a2524..000000000 --- a/automation/check-patch.workflow.k8s-1.13.3.mounts +++ /dev/null @@ -1 +0,0 @@ -check-patch.mounts \ No newline at end of file diff --git a/automation/check-patch.workflow.k8s-1.13.3.packages b/automation/check-patch.workflow.k8s-1.13.3.packages deleted file mode 120000 index 3858aae7d..000000000 --- a/automation/check-patch.workflow.k8s-1.13.3.packages +++ /dev/null @@ -1 +0,0 @@ -check-patch.packages \ No newline at end of file diff --git a/automation/check-patch.workflow.k8s-1.13.3.sh b/automation/check-patch.workflow.k8s-1.13.3.sh deleted file mode 120000 index a61652ade..000000000 --- a/automation/check-patch.workflow.k8s-1.13.3.sh +++ /dev/null @@ -1 +0,0 @@ -check-patch.sh \ No newline at end of file diff --git a/automation/check-patch.workflow.os-3.11.0.mounts b/automation/check-patch.workflow.os-3.11.0.mounts deleted file mode 120000 index c459a2524..000000000 --- a/automation/check-patch.workflow.os-3.11.0.mounts +++ /dev/null @@ -1 +0,0 @@ -check-patch.mounts \ No newline at end of file diff --git a/automation/check-patch.workflow.os-3.11.0.packages b/automation/check-patch.workflow.os-3.11.0.packages deleted file mode 120000 index 3858aae7d..000000000 --- a/automation/check-patch.workflow.os-3.11.0.packages +++ /dev/null @@ -1 +0,0 @@ -check-patch.packages \ No newline at end of file diff --git a/automation/check-patch.workflow.os-3.11.0.sh b/automation/check-patch.workflow.os-3.11.0.sh deleted file mode 120000 index a61652ade..000000000 --- a/automation/check-patch.workflow.os-3.11.0.sh +++ /dev/null @@ -1 +0,0 @@ -check-patch.sh \ No newline at end of file diff --git a/automation/test.sh b/automation/test.sh deleted file mode 100755 index 677fb38fe..000000000 --- a/automation/test.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -ex - -kubectl() { cluster/kubectl.sh "$@"; } - -# Make sure that the VM is properly shut down on exit -trap '{ make cluster-down; }' EXIT SIGINT SIGTERM SIGSTOP - -export E2E_TEST_EXTRA_ARGS="-ginkgo.noColor" - -make cluster-down -make cluster-up -if [ "${TEST_SUITE}" == "workflow" ]; then - make cluster-operator-push - make cluster-operator-install - make test/e2e/workflow -elif [ "${TEST_SUITE}" == "lifecycle" ]; then - make cluster-operator-push - make test/e2e/lifecycle -else - echo "Unknown test suite ${TEST_SUITE}" -fi diff --git a/cluster/operator-push.sh b/cluster/operator-push.sh index c6478caa9..e32f0b652 100755 --- a/cluster/operator-push.sh +++ b/cluster/operator-push.sh @@ -17,7 +17,11 @@ set -ex registry_port=$(./cluster/cli.sh ports registry | tr -d '\r') -registry=localhost:$registry_port +if [[ "${KUBEVIRT_PROVIDER}" =~ ^okd-.*$ ]]; then \ + registry=localhost:$(./cluster/cli.sh ports --container-name=cluster registry | tr -d '\r') +else + registry=localhost:$(./cluster/cli.sh ports registry | tr -d '\r') +fi # Cleanup previously generated manifests rm -rf _out/ @@ -29,12 +33,5 @@ make cluster-clean IMAGE_REGISTRY=$registry make docker-build-operator docker-push-operator -for i in $(seq 1 ${CLUSTER_NUM_NODES}); do - ./cluster/cli.sh ssh "node$(printf "%02d" ${i})" 'sudo docker pull registry:5000/cluster-network-addons-operator' - # Temporary until image is updated with provisioner that sets this field - # This field is required by buildah tool - ./cluster/cli.sh ssh "node$(printf "%02d" ${i})" 'sudo sysctl -w user.max_user_namespaces=1024' -done - ./cluster/kubectl.sh create -f _out/cluster-network-addons/${VERSION}/namespace.yaml ./cluster/kubectl.sh create -f _out/cluster-network-addons/${VERSION}/network-addons-config.crd.yaml diff --git a/stdci.yaml b/stdci.yaml index 8e2f839f8..4e0570345 100644 --- a/stdci.yaml +++ b/stdci.yaml @@ -1,8 +1,8 @@ sub-stages: - - lifecycle.k8s-1.13.3 - - lifecycle.os-3.11.0 - - workflow.k8s-1.13.3 - - workflow.os-3.11.0 + - e2e-lifecycle-k8s + - e2e-lifecycle-okd + - e2e-workflow-k8s + - e2e-workflow-okd runtime_requirements: support_nesting_level: 2 diff --git a/test/check/check.go b/test/check/check.go index f0230d3a0..724cf8ac2 100644 --- a/test/check/check.go +++ b/test/check/check.go @@ -25,6 +25,8 @@ import ( opv1alpha1 "github.com/kubevirt/cluster-network-addons-operator/pkg/apis/networkaddonsoperator/v1alpha1" "github.com/kubevirt/cluster-network-addons-operator/pkg/components" "github.com/kubevirt/cluster-network-addons-operator/pkg/names" + + . "github.com/kubevirt/cluster-network-addons-operator/test/okd" ) const ( @@ -35,6 +37,11 @@ const ( func CheckComponentsDeployment(components []Component) { for _, component := range components { + if component.ComponentName == MultusComponent.ComponentName && IsOnOKDCluster() { + // On OpenShift 4, Multus is not owned by us + continue + } + By(fmt.Sprintf("Checking that component %s is deployed", component.ComponentName)) err := checkForComponent(&component) Expect(err).NotTo(HaveOccurred(), "Component has not been fully deployed") @@ -43,6 +50,11 @@ func CheckComponentsDeployment(components []Component) { func CheckComponentsRemoval(components []Component) { for _, component := range components { + if component.ComponentName == MultusComponent.ComponentName && IsOnOKDCluster() { + // On OpenShift 4, Multus is not owned by us + continue + } + // TODO: Once finalizers are implemented, we should switch to using // once-time checks, since after NodeNetworkState removal, no components // should be left over. diff --git a/test/check/components.go b/test/check/components.go index 30b8eb561..8f637ac20 100644 --- a/test/check/components.go +++ b/test/check/components.go @@ -40,7 +40,6 @@ var ( SecurityContextConstraints: "nmstate", DaemonSets: []string{"nmstate-handler"}, } - OvsComponent = Component{ ComponentName: "Ovs", ClusterRole: "ovs-cni-marker-cr", diff --git a/test/e2e/workflow/deployment_test.go b/test/e2e/workflow/deployment_test.go index 675589d43..ffca3465e 100644 --- a/test/e2e/workflow/deployment_test.go +++ b/test/e2e/workflow/deployment_test.go @@ -9,6 +9,7 @@ import ( opv1alpha1 "github.com/kubevirt/cluster-network-addons-operator/pkg/apis/networkaddonsoperator/v1alpha1" . "github.com/kubevirt/cluster-network-addons-operator/test/check" + . "github.com/kubevirt/cluster-network-addons-operator/test/okd" . "github.com/kubevirt/cluster-network-addons-operator/test/operations" ) @@ -190,7 +191,16 @@ func testConfigUpdate(configSpec opv1alpha1.NetworkAddonsConfigSpec, components } func checkConfigChange(components []Component) { - if len(components) > 0 { + // On OpenShift 4, Multus is already deployed by default + onlyMultusOnOKDCluster := (len(components) == 1 && + IsOnOKDCluster() && + components[0].ComponentName == MultusComponent.ComponentName) + noComponentToDeploy := len(components) == 0 || onlyMultusOnOKDCluster + if noComponentToDeploy { + // Wait until Available condition is reported. Should be fast when no components are + // being deployed + CheckConfigCondition(ConditionAvailable, ConditionTrue, 5*time.Minute, CheckDoNotRepeat) + } else { // If there are any components to deploy wait until Progressing condition is reported CheckConfigCondition(ConditionProgressing, ConditionTrue, time.Minute, CheckDoNotRepeat) @@ -201,9 +211,5 @@ func checkConfigChange(components []Component) { // Check that all requested components have been deployed CheckComponentsDeployment(components) - } else { - // Wait until Available condition is reported. Should be fast when no components are - // being deployed - CheckConfigCondition(ConditionAvailable, ConditionTrue, 5*time.Minute, CheckDoNotRepeat) } } diff --git a/test/okd/okd.go b/test/okd/okd.go new file mode 100644 index 000000000..3b58536a5 --- /dev/null +++ b/test/okd/okd.go @@ -0,0 +1,10 @@ +package okd + +import ( + "os" + "strings" +) + +func IsOnOKDCluster() bool { + return strings.HasPrefix(os.Getenv("KUBEVIRT_PROVIDER"), "okd-") +} diff --git a/test/releases/releases.go b/test/releases/releases.go index f8620ab75..c65db395c 100644 --- a/test/releases/releases.go +++ b/test/releases/releases.go @@ -3,6 +3,7 @@ package releases import ( "fmt" "sort" + "strings" "github.com/blang/semver" . "github.com/onsi/ginkgo" @@ -10,6 +11,7 @@ import ( opv1alpha1 "github.com/kubevirt/cluster-network-addons-operator/pkg/apis/networkaddonsoperator/v1alpha1" . "github.com/kubevirt/cluster-network-addons-operator/test/kubectl" + . "github.com/kubevirt/cluster-network-addons-operator/test/okd" . "github.com/kubevirt/cluster-network-addons-operator/test/operations" ) @@ -80,6 +82,10 @@ func CheckReleaseUsesExpectedContainerImages(release Release) { By(fmt.Sprintf("Checking that all deployed images match release %s", release.Version)) expectedContainers := sortContainers(release.Containers) + if IsOnOKDCluster() { + // On OpenShift 4, Multus is not owned by us and will not be reported in Status + expectedContainers = dropMultusContainers(expectedContainers) + } config := GetConfig() deployedContainers := sortContainers(config.Status.Containers) @@ -95,3 +101,13 @@ func sortContainers(containers []opv1alpha1.Container) []opv1alpha1.Container { }) return containers } + +func dropMultusContainers(containers []opv1alpha1.Container) []opv1alpha1.Container { + filteredContainers := []opv1alpha1.Container{} + for _, container := range containers { + if !strings.Contains(container.Name, "multus") { + filteredContainers = append(filteredContainers, container) + } + } + return filteredContainers +}