Skip to content

Commit

Permalink
Merge pull request kubevirt#258 from kubevirt/simple_automation
Browse files Browse the repository at this point in the history
run tests against OKD and simplify e2e automation scripts
  • Loading branch information
phoracek authored Nov 11, 2019
2 parents 187c8bb + 0949f4f commit e9145a0
Show file tree
Hide file tree
Showing 36 changed files with 203 additions and 92 deletions.
1 change: 1 addition & 0 deletions automation/check-patch.e2e-lifecycle-k8s.mounts
1 change: 1 addition & 0 deletions automation/check-patch.e2e-lifecycle-k8s.packages
27 changes: 27 additions & 0 deletions automation/check-patch.e2e-lifecycle-k8s.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"
1 change: 1 addition & 0 deletions automation/check-patch.e2e-lifecycle-okd.mounts
1 change: 1 addition & 0 deletions automation/check-patch.e2e-lifecycle-okd.packages
27 changes: 27 additions & 0 deletions automation/check-patch.e2e-lifecycle-okd.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"
1 change: 1 addition & 0 deletions automation/check-patch.e2e-workflow-k8s.mounts
1 change: 1 addition & 0 deletions automation/check-patch.e2e-workflow-k8s.packages
28 changes: 28 additions & 0 deletions automation/check-patch.e2e-workflow-k8s.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"
1 change: 1 addition & 0 deletions automation/check-patch.e2e-workflow-okd.mounts
1 change: 1 addition & 0 deletions automation/check-patch.e2e-workflow-okd.packages
28 changes: 28 additions & 0 deletions automation/check-patch.e2e-workflow-okd.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"
File renamed without changes.
File renamed without changes.
27 changes: 27 additions & 0 deletions automation/check-patch.e2e.setup.sh
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion automation/check-patch.lifecycle.k8s-1.13.3.mounts

This file was deleted.

1 change: 0 additions & 1 deletion automation/check-patch.lifecycle.k8s-1.13.3.packages

This file was deleted.

1 change: 0 additions & 1 deletion automation/check-patch.lifecycle.k8s-1.13.3.sh

This file was deleted.

1 change: 0 additions & 1 deletion automation/check-patch.lifecycle.os-3.11.0.mounts

This file was deleted.

1 change: 0 additions & 1 deletion automation/check-patch.lifecycle.os-3.11.0.packages

This file was deleted.

1 change: 0 additions & 1 deletion automation/check-patch.lifecycle.os-3.11.0.sh

This file was deleted.

41 changes: 0 additions & 41 deletions automation/check-patch.sh

This file was deleted.

1 change: 0 additions & 1 deletion automation/check-patch.workflow.k8s-1.13.3.mounts

This file was deleted.

1 change: 0 additions & 1 deletion automation/check-patch.workflow.k8s-1.13.3.packages

This file was deleted.

1 change: 0 additions & 1 deletion automation/check-patch.workflow.k8s-1.13.3.sh

This file was deleted.

1 change: 0 additions & 1 deletion automation/check-patch.workflow.os-3.11.0.mounts

This file was deleted.

1 change: 0 additions & 1 deletion automation/check-patch.workflow.os-3.11.0.packages

This file was deleted.

1 change: 0 additions & 1 deletion automation/check-patch.workflow.os-3.11.0.sh

This file was deleted.

21 changes: 0 additions & 21 deletions automation/test.sh

This file was deleted.

13 changes: 5 additions & 8 deletions cluster/operator-push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand All @@ -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
8 changes: 4 additions & 4 deletions stdci.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
12 changes: 12 additions & 0 deletions test/check/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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")
Expand All @@ -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.
Expand Down
1 change: 0 additions & 1 deletion test/check/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ var (
SecurityContextConstraints: "nmstate",
DaemonSets: []string{"nmstate-handler"},
}

OvsComponent = Component{
ComponentName: "Ovs",
ClusterRole: "ovs-cni-marker-cr",
Expand Down
16 changes: 11 additions & 5 deletions test/e2e/workflow/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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)

Expand All @@ -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)
}
}
10 changes: 10 additions & 0 deletions test/okd/okd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package okd

import (
"os"
"strings"
)

func IsOnOKDCluster() bool {
return strings.HasPrefix(os.Getenv("KUBEVIRT_PROVIDER"), "okd-")
}
Loading

0 comments on commit e9145a0

Please sign in to comment.