Skip to content

Commit

Permalink
Operator function test with alternate image tag alias
Browse files Browse the repository at this point in the history
Signed-off-by: David Vossel <[email protected]>
  • Loading branch information
davidvossel committed Mar 8, 2019
1 parent 4edb657 commit 0e53ca2
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 8 deletions.
4 changes: 4 additions & 0 deletions cluster/ephemeral-provider-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ function prepare_config() {
cat >hack/config-provider-$KUBEVIRT_PROVIDER.sh <<EOF
master_ip=$(_main_ip)
docker_tag=devel
docker_tag_alt=devel-alt
kubeconfig=${BASE_PATH}/cluster/$KUBEVIRT_PROVIDER/.kubeconfig
kubectl=${BASE_PATH}/cluster/$KUBEVIRT_PROVIDER/.kubectl
docker_prefix=localhost:$(_port registry)/kubevirt
Expand Down Expand Up @@ -50,10 +51,13 @@ function build() {
local name=$(basename $arg)
container="${container} ${manifest_docker_prefix}/${name}:${docker_tag}"
container_alias="${container_alias} ${manifest_docker_prefix}/${name}:${docker_tag} kubevirt/${name}:${docker_tag}"
# the alt tag is another image tag alias we can use while testing the virt operator
container_alt_alias="${container_alt_alias} ${manifest_docker_prefix}/${name}:${docker_tag} ${manifest_docker_prefix}/${name}:${docker_tag_alt}"
done
for i in $(seq 1 ${KUBEVIRT_NUM_NODES}); do
${_cli} ssh --prefix $provider_prefix "node$(printf "%02d" ${i})" "echo \"${container}\" | xargs \-\-max-args=1 sudo docker pull"
${_cli} ssh --prefix $provider_prefix "node$(printf "%02d" ${i})" "echo \"${container_alias}\" | xargs \-\-max-args=2 sudo docker tag"
${_cli} ssh --prefix $provider_prefix "node$(printf "%02d" ${i})" "echo \"${container_alt_alias}\" | xargs \-\-max-args=2 sudo docker tag"
done
}

Expand Down
4 changes: 2 additions & 2 deletions hack/config.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
unset binaries docker_images docker_prefix docker_tag manifest_templates \
unset binaries docker_images docker_prefix docker_tag docker_tag_alt manifest_templates \
master_ip network_provider kubeconfig manifest_docker_prefix namespace image_pull_policy verbosity

KUBEVIRT_PROVIDER=${KUBEVIRT_PROVIDER:-${PROVIDER}}
Expand All @@ -12,5 +12,5 @@ test -f "hack/config-provider-${KUBEVIRT_PROVIDER}.sh" && source hack/config-pro
# to change the version controlled config-default.sh file
test -f "hack/config-local.sh" && source hack/config-local.sh

export binaries docker_images docker_prefix docker_tag manifest_templates \
export binaries docker_images docker_prefix docker_tag docker_tag_alt manifest_templates \
master_ip network_provider kubeconfig namespace image_pull_policy verbosity
2 changes: 1 addition & 1 deletion hack/functests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ if [[ ${TARGET} == openshift* ]]; then
oc=${kubectl}
fi

${TESTS_OUT_DIR}/tests.test -kubeconfig=${kubeconfig} -container-tag=${docker_tag} -container-prefix=${functest_docker_prefix} -oc-path=${oc} -kubectl-path=${kubectl} -test.timeout 180m ${FUNC_TEST_ARGS} -installed-namespace=${namespace}
${TESTS_OUT_DIR}/tests.test -kubeconfig=${kubeconfig} -container-tag=${docker_tag} -container-tag-alt=${docker_tag_alt} -container-prefix=${functest_docker_prefix} -oc-path=${oc} -kubectl-path=${kubectl} -test.timeout 180m ${FUNC_TEST_ARGS} -installed-namespace=${namespace}
2 changes: 0 additions & 2 deletions pkg/virt-operator/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,8 @@ go_test(
"//vendor/k8s.io/api/rbac/v1:go_default_library",
"//vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1:go_default_library",
"//vendor/k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/fake:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/errors:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//vendor/k8s.io/client-go/kubernetes/fake:go_default_library",
"//vendor/k8s.io/client-go/testing:go_default_library",
"//vendor/k8s.io/client-go/tools/cache:go_default_library",
Expand Down
1 change: 1 addition & 0 deletions pkg/virt-operator/install-strategy/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ go_test(
"//vendor/k8s.io/api/core/v1:go_default_library",
"//vendor/k8s.io/api/rbac/v1:go_default_library",
"//vendor/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
],
)
6 changes: 3 additions & 3 deletions pkg/virt-operator/kubevirt.go
Original file line number Diff line number Diff line change
Expand Up @@ -735,9 +735,6 @@ func (c *KubeVirtController) syncDeployment(kv *v1.KubeVirt) error {
}
}

// add finalizer to prevent deletion of CR before KubeVirt was undeployed
util.AddFinalizer(kv)

strategy, pending, err := c.loadInstallStrategy(kv, c.getImageTag(kv), c.getImageRegistry(kv))
if err != nil {
return err
Expand All @@ -748,6 +745,9 @@ func (c *KubeVirtController) syncDeployment(kv *v1.KubeVirt) error {
return nil
}

// add finalizer to prevent deletion of CR before KubeVirt was undeployed
util.AddFinalizer(kv)

// once all the install strategies are loaded, garbage collect any
// install strategy jobs that were created.
c.garbageCollectInstallStrategyJobs()
Expand Down
38 changes: 38 additions & 0 deletions tests/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,44 @@ var _ = Describe("Operator", func() {
sanityCheckDeploymentsExist()
})

It("should be able to create kubevirt install with custom image tag", func() {

if tests.KubeVirtVersionTagAlt == "" {
Skip("Skip operator custom image tag test because alt tag is not present")
}

allPodsAreReady()
sanityCheckDeploymentsExist()

By("Deleting KubeVirt object")
deleteAllKvAndWait(false)

// this is just verifying some common known components do in fact get deleted.
By("Sanity Checking Deployments infrastructure is deleted")
sanityCheckDeploymentsDeleted()

By("Creating KubeVirt Object")
kv := copyOriginalKv()
kv.Name = "kubevirt-alt-install"
kv.Spec = v1.KubeVirtSpec{
ImageTag: tests.KubeVirtVersionTagAlt,
ImageRegistry: tests.KubeVirtRepoPrefix,
}
createKv(kv)

By("Creating KubeVirt Object Created and Ready Condition")
waitForKv(kv)

By("Verifying infrastructure is Ready")
allPodsAreReady()
// We're just verifying that a few common components that
// should always exist get re-deployed.
sanityCheckDeploymentsExist()

By("Deleting KubeVirt object")
deleteAllKvAndWait(false)
})

It("should fail if KV object already exists", func() {

newKv := copyOriginalKv()
Expand Down
2 changes: 2 additions & 0 deletions tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ import (
)

var KubeVirtVersionTag = "latest"
var KubeVirtVersionTagAlt = ""
var KubeVirtRepoPrefix = "kubevirt"
var ContainerizedDataImporterNamespace = "cdi"
var KubeVirtKubectlPath = ""
Expand All @@ -87,6 +88,7 @@ var PathToTestingInfrastrucureManifests = ""

func init() {
flag.StringVar(&KubeVirtVersionTag, "container-tag", "latest", "Set the image tag or digest to use")
flag.StringVar(&KubeVirtVersionTagAlt, "container-tag-alt", "", "An alternate tag that can be used to test operator deployments")
flag.StringVar(&KubeVirtRepoPrefix, "container-prefix", "kubevirt", "Set the repository prefix for all images")
flag.StringVar(&ContainerizedDataImporterNamespace, "cdi-namespace", "cdi", "Set the repository prefix for CDI components")
flag.StringVar(&KubeVirtKubectlPath, "kubectl-path", "", "Set path to kubectl binary")
Expand Down

0 comments on commit 0e53ca2

Please sign in to comment.