Skip to content

Commit c00392b

Browse files
author
lamai93
committed
Added more test environment for license stuff.
1 parent 82ad6b3 commit c00392b

7 files changed

+38
-5
lines changed

Jenkinsfile.groovy

+6-1
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,16 @@ def buildTestSteps(Map myParams, String kubeConfigRoot, String kubeconfig) {
8181
return {
8282
timestamps {
8383
timeout(time: myParams.LONG ? 180 : 30) {
84-
withCredentials([string(credentialsId: 'ENTERPRISEIMAGE', variable: 'DEFAULTENTERPRISEIMAGE')]) {
84+
withCredentials([
85+
string(credentialsId: 'ENTERPRISEIMAGE', variable: 'DEFAULTENTERPRISEIMAGE'),
86+
string(credentialsId: 'ENTERPRISELICENSE', variable: 'DEFAULTENTERPRISELICENSE'),
87+
]) {
8588
withEnv([
8689
"CLEANDEPLOYMENTS=1",
8790
"DEPLOYMENTNAMESPACE=${myParams.TESTNAMESPACE}-${env.GIT_COMMIT}",
8891
"DOCKERNAMESPACE=${myParams.DOCKERNAMESPACE}",
8992
"ENTERPRISEIMAGE=${myParams.ENTERPRISEIMAGE}",
93+
"ENTERPRISELICENSE=${myParams.ENTERPRISELICENSE}",
9094
"ARANGODIMAGE=${myParams.ARANGODIMAGE}",
9195
"IMAGETAG=jenkins-test",
9296
"KUBECONFIG=${kubeConfigRoot}/${kubeconfig}",
@@ -132,6 +136,7 @@ pipeline {
132136
string(name: 'TESTNAMESPACE', defaultValue: 'jenkins', description: 'TESTNAMESPACE sets the kubernetes namespace to ru tests in (this must be short!!)', )
133137
string(name: 'ENTERPRISEIMAGE', defaultValue: '', description: 'ENTERPRISEIMAGE sets the docker image used for enterprise tests', )
134138
string(name: 'ARANGODIMAGE', defaultValue: '', description: 'ARANGODIMAGE sets the docker image used for tests (except enterprise and update tests)', )
139+
string(name: 'ENTERPRISELICENSE', defaultValue: '', description: 'ENTERPRISELICENSE sets the enterprise license key for enterprise tests', )
135140
string(name: 'TESTOPTIONS', defaultValue: '', description: 'TESTOPTIONS is used to pass additional test options to the integration test', )
136141
}
137142
stages {

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ endif
7373
ifndef ENTERPRISEIMAGE
7474
ENTERPRISEIMAGE := $(DEFAULTENTERPRISEIMAGE)
7575
endif
76+
ifndef ENTERPRISELICENSE
77+
ENTERPRISELICENSE := $(DEFAULTENTERPRISELICENSE)
78+
endif
7679
DASHBOARDBUILDIMAGE := kube-arangodb-dashboard-builder
7780

7881
ifndef ALLOWCHAOS
@@ -307,6 +310,7 @@ endif
307310
kubectl apply -f $(MANIFESTPATHDEPLOYMENTREPLICATION)
308311
kubectl apply -f $(MANIFESTPATHTEST)
309312
$(ROOTDIR)/scripts/kube_create_storage.sh $(DEPLOYMENTNAMESPACE)
313+
$(ROOTDIR)/scripts/kube_create_license_key_secret.sh
310314
$(ROOTDIR)/scripts/kube_run_tests.sh $(DEPLOYMENTNAMESPACE) $(TESTIMAGE) "$(ARANGODIMAGE)" "$(ENTERPRISEIMAGE)" $(TESTTIMEOUT) $(TESTLENGTHOPTIONS)
311315

312316
$(DURATIONTESTBIN): $(GOBUILDDIR) $(SOURCES)
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
3+
if [ -z $ENTERPRISELICENSE ]; then
4+
echo "Please specify ENTERPRISELICENSE"
5+
exit 1
6+
fi
7+
8+
LICENSE=$(echo "${ENTERPRISELICENSE}" | base64 )
9+
10+
kubectl apply -f - <<EOF
11+
apiVersion: v1
12+
data:
13+
token: ${LICENSE}
14+
kind: Secret
15+
metadata:
16+
name: arangodb-jenkins-license-key
17+
namespace: default
18+
type: Opaque
19+
EOF

tests/auth_test.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ func TestAuthenticationSingleCustomSecret(t *testing.T) {
104104
if err := k8sutil.CreateTokenSecret(secrets, depl.Spec.Authentication.GetJWTSecretName(), "foo", nil); err != nil {
105105
t.Fatalf("Create JWT secret failed: %v", err)
106106
}
107+
defer removeSecret(kubecli, depl.Spec.Authentication.GetJWTSecretName(), ns)
107108

108109
// Create deployment
109110
apiObject, err := c.DatabaseV1alpha().ArangoDeployments(ns).Create(depl)
@@ -133,9 +134,6 @@ func TestAuthenticationSingleCustomSecret(t *testing.T) {
133134
if _, err := waitUntilSecret(kubecli, depl.Spec.Authentication.GetJWTSecretName(), ns, nil, time.Second); err != nil {
134135
t.Fatalf("JWT secret '%s' not found: %v", depl.Spec.Authentication.GetJWTSecretName(), err)
135136
}
136-
137-
// Cleanup secret
138-
removeSecret(kubecli, depl.Spec.Authentication.GetJWTSecretName(), ns)
139137
}
140138

141139
// TestAuthenticationNoneSingle creating a single server

tests/environments_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ func TestEnvironmentProduction(t *testing.T) {
6060
depl.Spec.StorageEngine = api.NewStorageEngine(engine)
6161
depl.Spec.TLS = api.TLSSpec{}
6262
depl.Spec.Environment = api.NewEnvironment(api.EnvironmentProduction)
63-
depl.Spec.Image = util.NewString("arangodb/arangodb:3.3.4")
6463
depl.Spec.DBServers.Count = util.NewInt(numNodes + 1)
6564
depl.Spec.SetDefaults(depl.GetName()) // this must be last
6665
assert.NoError(t, depl.Spec.Validate())

tests/license_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package tests

tests/test_util.go

+7
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,12 @@ func getEnterpriseImageOrSkip(t *testing.T) string {
155155
return image
156156
}
157157

158+
const TestEnterpriseLicenseKeySecretName = "arangodb-jenkins-license-key"
159+
160+
func getEnterpriseLicenseKey() string {
161+
return strings.TrimSpace(os.Getenv("ENTERPRISELICENSE"))
162+
}
163+
158164
// shouldCleanDeployments returns true when deployments created
159165
// by tests should be removed, even when the test fails.
160166
func shouldCleanDeployments() bool {
@@ -244,6 +250,7 @@ func newDeployment(name string) *api.ArangoDeployment {
244250
},
245251
Spec: api.DeploymentSpec{
246252
ImagePullPolicy: util.NewPullPolicy(v1.PullAlways),
253+
LicenseKey: util.NewString(TestEnterpriseLicenseKeySecretName),
247254
},
248255
}
249256

0 commit comments

Comments
 (0)