From 56995762799374a8181afc9d6519ea5ad155bb9a Mon Sep 17 00:00:00 2001 From: lamai93 Date: Fri, 19 Oct 2018 14:47:44 +0200 Subject: [PATCH] Added test option for default arangodb docker image. --- Jenkinsfile.groovy | 4 +++- Makefile | 2 +- scripts/kube_run_tests.sh | 8 +++++--- tests/test_util.go | 16 ++++++++++++++-- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile.groovy b/Jenkinsfile.groovy index 7f5d2c227..3a91b6912 100644 --- a/Jenkinsfile.groovy +++ b/Jenkinsfile.groovy @@ -87,6 +87,7 @@ def buildTestSteps(Map myParams, String kubeConfigRoot, String kubeconfig) { "DEPLOYMENTNAMESPACE=${myParams.TESTNAMESPACE}-${env.GIT_COMMIT}", "DOCKERNAMESPACE=${myParams.DOCKERNAMESPACE}", "ENTERPRISEIMAGE=${myParams.ENTERPRISEIMAGE}", + "ARANGODIMAGE=${myParams.ARANGODIMAGE}", "IMAGETAG=jenkins-test", "KUBECONFIG=${kubeConfigRoot}/${kubeconfig}", "LONG=${myParams.LONG ? 1 : 0}", @@ -129,7 +130,8 @@ pipeline { string(name: 'DOCKERNAMESPACE', defaultValue: 'arangodb', description: 'DOCKERNAMESPACE sets the docker registry namespace in which the operator docker image will be pushed', ) string(name: 'KUBECONFIGS', defaultValue: 'kube-ams1,scw-183a3b', description: 'KUBECONFIGS is a comma separated list of Kubernetes configuration files (relative to /home/jenkins/.kube) on which the tests are run', ) string(name: 'TESTNAMESPACE', defaultValue: 'jenkins', description: 'TESTNAMESPACE sets the kubernetes namespace to ru tests in (this must be short!!)', ) - string(name: 'ENTERPRISEIMAGE', defaultValue: '', description: 'ENTERPRISEIMAGE sets the docker image used for enterprise tests)', ) + string(name: 'ENTERPRISEIMAGE', defaultValue: '', description: 'ENTERPRISEIMAGE sets the docker image used for enterprise tests', ) + string(name: 'ARANGODIMAGE', defaultValue: '', description: 'ARANGODIMAGE sets the docker image used for tests (except enterprise and update tests)', ) string(name: 'TESTOPTIONS', defaultValue: '', description: 'TESTOPTIONS is used to pass additional test options to the integration test', ) } stages { diff --git a/Makefile b/Makefile index dee2ccc3e..d327403f5 100644 --- a/Makefile +++ b/Makefile @@ -304,7 +304,7 @@ endif kubectl apply -f $(MANIFESTPATHDEPLOYMENTREPLICATION) kubectl apply -f $(MANIFESTPATHTEST) $(ROOTDIR)/scripts/kube_create_storage.sh $(DEPLOYMENTNAMESPACE) - $(ROOTDIR)/scripts/kube_run_tests.sh $(DEPLOYMENTNAMESPACE) $(TESTIMAGE) "$(ENTERPRISEIMAGE)" $(TESTTIMEOUT) $(TESTLENGTHOPTIONS) + $(ROOTDIR)/scripts/kube_run_tests.sh $(DEPLOYMENTNAMESPACE) $(TESTIMAGE) "$(ARANGODIMAGE)" "$(ENTERPRISEIMAGE)" $(TESTTIMEOUT) $(TESTLENGTHOPTIONS) $(DURATIONTESTBIN): $(GOBUILDDIR) $(SOURCES) @mkdir -p $(BINDIR) diff --git a/scripts/kube_run_tests.sh b/scripts/kube_run_tests.sh index 8e8ca4c9c..9df7dec27 100755 --- a/scripts/kube_run_tests.sh +++ b/scripts/kube_run_tests.sh @@ -4,9 +4,10 @@ DEPLOYMENTNAMESPACE=$1 TESTIMAGE=$2 -ENTERPRISEIMAGE=$3 -TESTTIMEOUT=$4 -TESTLENGTHOPTIONS=$5 +ARANGODIMAGE=$3 +ENTERPRISEIMAGE=$4 +TESTTIMEOUT=$5 +TESTLENGTHOPTIONS=$6 IMAGEID=$(docker inspect ${TESTIMAGE} '--format={{index .RepoDigests 0}}') @@ -14,6 +15,7 @@ kubectl --namespace ${DEPLOYMENTNAMESPACE} \ run arangodb-operator-test -i --rm --quiet --restart=Never \ --image=${IMAGEID} \ --env="ENTERPRISEIMAGE=${ENTERPRISEIMAGE}" \ + --env="ARANGODIMAGE=${ARANGODIMAGE}" \ --env="TEST_NAMESPACE=${DEPLOYMENTNAMESPACE}" \ --env="CLEANDEPLOYMENTS=${CLEANDEPLOYMENTS}" \ -- \ diff --git a/tests/test_util.go b/tests/test_util.go index efbb26e93..3cbe03789 100644 --- a/tests/test_util.go +++ b/tests/test_util.go @@ -52,6 +52,7 @@ import ( "github.com/arangodb/kube-arangodb/pkg/util/arangod" "github.com/arangodb/kube-arangodb/pkg/util/k8sutil" "github.com/arangodb/kube-arangodb/pkg/util/retry" + "github.com/arangodb/kube-arangodb/pkg/util" ) const ( @@ -231,9 +232,9 @@ func getNamespace(t *testing.T) string { } // newDeployment creates a basic ArangoDeployment with configured -// type & name. +// type, name and image. func newDeployment(name string) *api.ArangoDeployment { - return &api.ArangoDeployment{ + depl := &api.ArangoDeployment{ TypeMeta: metav1.TypeMeta{ APIVersion: api.SchemeGroupVersion.String(), Kind: api.ArangoDeploymentResourceKind, @@ -242,6 +243,17 @@ func newDeployment(name string) *api.ArangoDeployment { Name: strings.ToLower(name), }, } + + // set default image to the value given in env + // some tests will override this value if they need a specific version + // like update tests + // if no value is given, use the operator default, which is arangodb/arangodb:latest + image := strings.TrimSpace(os.Getenv("ARANGODIMAGE")) + if image != "" { + depl.Spec.Image = util.NewString(image) + } + + return depl } // waitUntilDeployment waits until a deployment with given name in given namespace