Skip to content

Commit f1aa4a4

Browse files
committed
Parameterize docker image used by tests
1 parent fda5e5f commit f1aa4a4

File tree

3 files changed

+52
-8
lines changed

3 files changed

+52
-8
lines changed

test/e2e/clustering_test.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ package e2e
22

33
import (
44
"fmt"
5+
"go/printer"
56
"io/ioutil"
67
"net/http"
8+
"os"
79
"path/filepath"
810
"strings"
911
"testing"
@@ -23,6 +25,20 @@ func TestClusterJoin(t *testing.T) {
2325
}
2426
username := "admin"
2527
password := "admin"
28+
29+
imageRepo, repoPres := os.LookupEnv("dockerRepository")
30+
imageTag, tagPres := os.LookupEnv("dockerVersion")
31+
32+
if !repoPres {
33+
imageRepo = "marklogic-centos/marklogic-server-centos"
34+
t.Logf("No imageRepo variable present, setting to default value: " + imageRepo)
35+
}
36+
37+
if !tagPres {
38+
imageTag = "10-internal"
39+
t.Logf("No imageTag variable present, setting to default value: " + imageTag)
40+
}
41+
2642
var resp *http.Response
2743
var body []byte
2844
var err error
@@ -33,8 +49,8 @@ func TestClusterJoin(t *testing.T) {
3349
SetValues: map[string]string{
3450
"persistence.enabled": "false",
3551
"replicaCount": "2",
36-
"image.repository": "marklogic-centos/marklogic-server-centos",
37-
"image.tag": "10-internal",
52+
"image.repository": imageRepo,
53+
"image.tag": imageTag,
3854
"auth.adminUsername": username,
3955
"auth.adminPassword": password,
4056
"logCollection.enabled": "false",

test/e2e/install_test.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"strings"
88
"testing"
99
"time"
10+
"os"
1011

1112
"github.com/gruntwork-io/terratest/modules/helm"
1213
http_helper "github.com/gruntwork-io/terratest/modules/http-helper"
@@ -20,15 +21,28 @@ func TestHelmInstall(t *testing.T) {
2021
if e != nil {
2122
t.Fatalf(e.Error())
2223
}
24+
imageRepo, repoPres := os.LookupEnv("dockerRepository")
25+
imageTag, tagPres := os.LookupEnv("dockerVersion")
26+
27+
if !repoPres {
28+
imageRepo = "marklogic-centos/marklogic-server-centos"
29+
t.Logf("No imageRepo variable present, setting to default value: " + imageRepo)
30+
}
31+
32+
if !tagPres {
33+
imageTag = "10-internal"
34+
t.Logf("No imageTag variable present, setting to default value: " + imageTag)
35+
}
36+
2337
namespaceName := "marklogic-" + strings.ToLower(random.UniqueId())
2438
kubectlOptions := k8s.NewKubectlOptions("", "", namespaceName)
2539
options := &helm.Options{
2640
KubectlOptions: kubectlOptions,
2741
SetValues: map[string]string{
2842
"persistence.enabled": "false",
2943
"replicaCount": "1",
30-
"image.repository": "marklogic-centos/marklogic-server-centos",
31-
"image.tag": "10-internal",
44+
"image.repository": imageRepo,
45+
"image.tag": imageTag,
3246
"logCollection.enabled": "false",
3347
},
3448
}

test/e2e/upgrade_test.go

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"strings"
88
"testing"
99
"time"
10+
"os"
1011

1112
"github.com/gruntwork-io/terratest/modules/helm"
1213
http_helper "github.com/gruntwork-io/terratest/modules/http-helper"
@@ -20,15 +21,28 @@ func TestHelmUpgrade(t *testing.T) {
2021
if e != nil {
2122
t.Fatalf(e.Error())
2223
}
24+
imageRepo, repoPres := os.LookupEnv("dockerRepository")
25+
imageTag, tagPres := os.LookupEnv("dockerVersion")
26+
27+
if !repoPres {
28+
imageRepo = "marklogic-centos/marklogic-server-centos"
29+
t.Logf("No imageRepo variable present, setting to default value: " + imageRepo)
30+
}
31+
32+
if !tagPres {
33+
imageTag = "10-internal"
34+
t.Logf("No imageTag variable present, setting to default value: " + imageTag)
35+
}
36+
2337
namespaceName := "marklogic-" + strings.ToLower(random.UniqueId())
2438
kubectlOptions := k8s.NewKubectlOptions("", "", namespaceName)
2539
options := &helm.Options{
2640
KubectlOptions: kubectlOptions,
2741
SetValues: map[string]string{
2842
"persistence.enabled": "false",
2943
"replicaCount": "1",
30-
"image.repository": "marklogic-centos/marklogic-server-centos",
31-
"image.tag": "10-internal",
44+
"image.repository": imageRepo,
45+
"image.tag": imageTag,
3246
"logCollection.enabled": "false",
3347
},
3448
}
@@ -47,8 +61,8 @@ func TestHelmUpgrade(t *testing.T) {
4761
SetValues: map[string]string{
4862
"persistence.enabled": "false",
4963
"replicaCount": "2",
50-
"image.repository": "marklogic-centos/marklogic-server-centos",
51-
"image.tag": "10-internal",
64+
"image.repository": imageRepo,
65+
"image.tag": imageTag,
5266
"logCollection.enabled": "false",
5367
},
5468
}

0 commit comments

Comments
 (0)