Skip to content

Commit 38c1486

Browse files
MLE-99999: Changes in upgrade tests to use default image from initial chart while deploying cluster (#271)
* added logger for error * updated tests to use image from helm repo for upgrades * updates for tls tests to use image from initial chart when running upgrade tests
1 parent b6997ae commit 38c1486

10 files changed

+211
-153
lines changed

test/e2e/admin_secrets_test.go

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,19 @@ func TestMlAdminSecrets(t *testing.T) {
3939

4040
namespaceName := "ml-" + strings.ToLower(random.UniqueId())
4141
kubectlOptions := k8s.NewKubectlOptions("", "", namespaceName)
42+
valuesMap := map[string]string{"persistence.enabled": "true",
43+
"replicaCount": "1",
44+
"image.repository": imageRepo,
45+
"image.tag": imageTag,
46+
"auth.adminUsername": "admin",
47+
"auth.adminPassword": "admin",
48+
"auth.walletPassword": "admin",
49+
}
50+
4251
options := &helm.Options{
4352
KubectlOptions: kubectlOptions,
44-
SetValues: map[string]string{
45-
"persistence.enabled": "true",
46-
"replicaCount": "1",
47-
"image.repository": imageRepo,
48-
"image.tag": imageTag,
49-
"auth.adminUsername": "admin",
50-
"auth.adminPassword": "admin",
51-
"auth.walletPassword": "admin",
52-
},
53-
Version: initialChartVersion,
53+
SetValues: valuesMap,
54+
Version: initialChartVersion,
5455
}
5556

5657
t.Logf("====Creating namespace: " + namespaceName)
@@ -68,6 +69,8 @@ func TestMlAdminSecrets(t *testing.T) {
6869
//add the helm chart repo and install the last helm chart release from repository
6970
//to test and upgrade this chart to the latest one to be released
7071
if runUpgradeTest {
72+
delete(valuesMap, "image.repository")
73+
delete(valuesMap, "image.tag")
7174
helm.AddRepo(t, options, "marklogic", "https://marklogic.github.io/marklogic-kubernetes/")
7275
defer helm.RemoveRepo(t, options, "marklogic")
7376
helmChartPath = "marklogic/marklogic"

test/e2e/backup_restore_test.go

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func DeleteDocs(client *req.Client, deleteEndpoint string) (string, error) {
8787
return result, err
8888
}
8989

90-
func RunRequests(client *req.Client, dbReq string, hostsEndpoint string) (string, error) {
90+
func RunRequests(t *testing.T, client *req.Client, dbReq string, hostsEndpoint string) (string, error) {
9191
var err error
9292
var body []byte
9393
headerMap := map[string]string{
@@ -99,11 +99,11 @@ func RunRequests(client *req.Client, dbReq string, hostsEndpoint string) (string
9999
operation := (gjson.Get(dbReq, `operation`)).Str
100100
var retryFn = (func(resp *req.Response, err error) bool {
101101
if err != nil {
102-
fmt.Println(err.Error())
102+
t.Fatalf(err.Error())
103103
}
104104
body, err = io.ReadAll(resp.Body)
105105
if err != nil {
106-
fmt.Println(err.Error())
106+
t.Fatalf(err.Error())
107107
}
108108
result = (string(body))
109109
return true
@@ -112,7 +112,7 @@ func RunRequests(client *req.Client, dbReq string, hostsEndpoint string) (string
112112
if operation == "backup-status" {
113113
retryFn = (func(resp *req.Response, err error) bool {
114114
if err != nil {
115-
fmt.Printf("error: %s", err.Error())
115+
t.Fatalf(err.Error())
116116
}
117117
body, _ := io.ReadAll(resp.Body)
118118
status = (gjson.Get(string(body), `status`)).Str
@@ -130,7 +130,7 @@ func RunRequests(client *req.Client, dbReq string, hostsEndpoint string) (string
130130
SetBodyString(dbReq).
131131
Post(hostsEndpoint)
132132
if err != nil {
133-
return "", err
133+
t.Fatalf(err.Error())
134134
}
135135
defer resp.Body.Close()
136136

@@ -158,7 +158,7 @@ func TestMlDbBackupRestore(t *testing.T) {
158158
}
159159

160160
if !tagPres {
161-
imageTag = "11.1.0-centos-1.1.2"
161+
imageTag = "11.3.0-ubi-rootless"
162162
t.Logf("No imageTag variable present, setting to default value: " + imageTag)
163163
}
164164

@@ -167,18 +167,20 @@ func TestMlDbBackupRestore(t *testing.T) {
167167

168168
namespaceName := "ml-" + strings.ToLower(random.UniqueId())
169169
kubectlOptions := k8s.NewKubectlOptions("", "", namespaceName)
170+
valuesMap := map[string]string{
171+
"persistence.enabled": "true",
172+
"replicaCount": "1",
173+
"image.repository": imageRepo,
174+
"image.tag": imageTag,
175+
"auth.adminUsername": username,
176+
"auth.adminPassword": password,
177+
"logCollection.enabled": "false",
178+
}
179+
170180
options := &helm.Options{
171181
KubectlOptions: kubectlOptions,
172-
SetValues: map[string]string{
173-
"persistence.enabled": "true",
174-
"replicaCount": "1",
175-
"image.repository": imageRepo,
176-
"image.tag": imageTag,
177-
"auth.adminUsername": username,
178-
"auth.adminPassword": password,
179-
"logCollection.enabled": "false",
180-
},
181-
Version: initialChartVersion,
182+
SetValues: valuesMap,
183+
Version: initialChartVersion,
182184
}
183185

184186
t.Logf("====Installing Helm Chart")
@@ -198,6 +200,8 @@ func TestMlDbBackupRestore(t *testing.T) {
198200
//add the helm chart repo and install the last helm chart release from repository
199201
//to test and upgrade this chart to the latest one to be released
200202
if runUpgradeTest {
203+
delete(valuesMap, "image.repository")
204+
delete(valuesMap, "image.tag")
201205
helm.AddRepo(t, options, "marklogic", "https://marklogic.github.io/marklogic-kubernetes/")
202206
defer helm.RemoveRepo(t, options, "marklogic")
203207
helmChartPath = "marklogic/marklogic"
@@ -236,6 +240,15 @@ func TestMlDbBackupRestore(t *testing.T) {
236240
testUtil.HelmUpgrade(t, helmUpgradeOptions, releaseName, kubectlOptions, []string{podName}, initialChartVersion)
237241
}
238242

243+
// wait until the pod is in Running status
244+
output, err := testUtil.WaitUntilPodRunning(t, kubectlOptions, podName, 10, 15*time.Second)
245+
if err != nil {
246+
t.Error(err.Error())
247+
}
248+
if output != "Running" {
249+
t.Error(output)
250+
}
251+
239252
//create backup directories and setup permissions
240253
k8s.RunKubectl(t, kubectlOptions, "exec", podName, "--", "/bin/bash", "-c", "cd /tmp && mkdir backup && chmod 777 backup && mkdir backup/incrBackup && chmod 777 backup/incrBackup")
241254

@@ -287,8 +300,9 @@ func TestMlDbBackupRestore(t *testing.T) {
287300
IncludeReplicas: "true"}
288301
bkupReqRes, _ := json.Marshal(bkupReq)
289302

303+
t.Log("====Full backup for Documents DB")
290304
//full backup for Documents DB
291-
result, err = RunRequests(client, string(bkupReqRes), manageEndpoint)
305+
result, err = RunRequests(t, client, string(bkupReqRes), manageEndpoint)
292306
if err != nil {
293307
t.Fatalf(err.Error())
294308
}
@@ -302,7 +316,7 @@ func TestMlDbBackupRestore(t *testing.T) {
302316
bkupStatusReqRes, _ := json.Marshal(bkupStatusReq)
303317

304318
//get status of full backup job
305-
result, err = RunRequests(client, string(bkupStatusReqRes), manageEndpoint)
319+
result, err = RunRequests(t, client, string(bkupStatusReqRes), manageEndpoint)
306320
if err != nil {
307321
t.Fatalf(err.Error())
308322
}
@@ -311,10 +325,12 @@ func TestMlDbBackupRestore(t *testing.T) {
311325
//verify full backup is completed
312326
assert.Equal(t, "completed", bkupStatus)
313327

328+
t.Log("====Delete a document from Documents DB")
314329
deleteEndpoint := fmt.Sprintf("http://%s/v1/documents?database=Documents&uri=%s", tunnel8000.Endpoint(), docs[1])
315330
fmt.Println(deleteEndpoint)
316331

317332
//incremental backup
333+
t.Log("====Incremental backup for Documents DB")
318334
incrBkupReq := &BackupRestoreReq{
319335
Operation: "backup-database",
320336
BackupDir: "/tmp/backup",
@@ -324,7 +340,7 @@ func TestMlDbBackupRestore(t *testing.T) {
324340
incrBkupReqRes, _ := json.Marshal(incrBkupReq)
325341

326342
//incremnetal backup for Documents DB
327-
result, err = RunRequests(client, string(incrBkupReqRes), manageEndpoint)
343+
result, err = RunRequests(t, client, string(incrBkupReqRes), manageEndpoint)
328344
if err != nil {
329345
t.Fatalf(err.Error())
330346
}
@@ -338,7 +354,7 @@ func TestMlDbBackupRestore(t *testing.T) {
338354
incrBkupStatusReqRes, _ := json.Marshal(incrBkupStatusReq)
339355

340356
//get status of backup job
341-
result, err = RunRequests(client, string(incrBkupStatusReqRes), manageEndpoint)
357+
result, err = RunRequests(t, client, string(incrBkupStatusReqRes), manageEndpoint)
342358
if err != nil {
343359
t.Fatalf(err.Error())
344360
}
@@ -361,7 +377,7 @@ func TestMlDbBackupRestore(t *testing.T) {
361377
brstrReqRes, _ := json.Marshal(rstrReq)
362378

363379
//restore Documents DB from incremental backup
364-
result, err = RunRequests(client, string(brstrReqRes), manageEndpoint)
380+
result, err = RunRequests(t, client, string(brstrReqRes), manageEndpoint)
365381
if err != nil {
366382
t.Fatalf(err.Error())
367383
}

test/e2e/clustering_test.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,18 @@ func TestClusterJoin(t *testing.T) {
4848

4949
namespaceName := "ml-" + strings.ToLower(random.UniqueId())
5050
kubectlOptions := k8s.NewKubectlOptions("", "", namespaceName)
51+
valuesMap := map[string]string{"persistence.enabled": "true",
52+
"replicaCount": "2",
53+
"image.repository": imageRepo,
54+
"image.tag": imageTag,
55+
"auth.adminUsername": username,
56+
"auth.adminPassword": password,
57+
"logCollection.enabled": "false",
58+
}
5159
options := &helm.Options{
5260
KubectlOptions: kubectlOptions,
53-
SetValues: map[string]string{
54-
"persistence.enabled": "true",
55-
"replicaCount": "2",
56-
"image.repository": imageRepo,
57-
"image.tag": imageTag,
58-
"auth.adminUsername": username,
59-
"auth.adminPassword": password,
60-
"logCollection.enabled": "false",
61-
},
62-
Version: initialChartVersion,
61+
SetValues: valuesMap,
62+
Version: initialChartVersion,
6363
}
6464

6565
t.Logf("====Creating namespace: " + namespaceName)
@@ -72,6 +72,8 @@ func TestClusterJoin(t *testing.T) {
7272
//add the helm chart repo and install the last helm chart release from repository
7373
//to test and upgrade this chart to the latest one to be released
7474
if runUpgradeTest {
75+
delete(valuesMap, "image.repository")
76+
delete(valuesMap, "image.tag")
7577
helm.AddRepo(t, options, "marklogic", "https://marklogic.github.io/marklogic-kubernetes/")
7678
defer helm.RemoveRepo(t, options, "marklogic")
7779
helmChartPath = "marklogic/marklogic"

test/e2e/env_param_test.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,19 @@ func TestEnableConvertersAndLicense(t *testing.T) {
5151

5252
namespaceName := "ml-" + strings.ToLower(random.UniqueId())
5353
kubectlOptions := k8s.NewKubectlOptions("", "", namespaceName)
54+
valuesMap := map[string]string{"persistence.enabled": "true",
55+
"replicaCount": "1",
56+
"image.repository": imageRepo,
57+
"image.tag": imageTag,
58+
"auth.adminUsername": username,
59+
"auth.adminPassword": password,
60+
"logCollection.enabled": "false",
61+
"enableConverters": "true",
62+
}
5463
options := &helm.Options{
5564
KubectlOptions: kubectlOptions,
56-
SetValues: map[string]string{
57-
"persistence.enabled": "true",
58-
"replicaCount": "1",
59-
"image.repository": imageRepo,
60-
"image.tag": imageTag,
61-
"auth.adminUsername": username,
62-
"auth.adminPassword": password,
63-
"logCollection.enabled": "false",
64-
"enableConverters": "true",
65-
},
66-
Version: initialChartVersion,
65+
SetValues: valuesMap,
66+
Version: initialChartVersion,
6767
}
6868

6969
t.Logf("====Creating namespace: " + namespaceName)
@@ -77,6 +77,8 @@ func TestEnableConvertersAndLicense(t *testing.T) {
7777
//add the helm chart repo and install the last helm chart release from repository
7878
//to test and upgrade this chart to the latest one to be released
7979
if runUpgradeTest {
80+
delete(valuesMap, "image.repository")
81+
delete(valuesMap, "image.tag")
8082
helm.AddRepo(t, options, "marklogic", "https://marklogic.github.io/marklogic-kubernetes/")
8183
defer helm.RemoveRepo(t, options, "marklogic")
8284
helmChartPath = "marklogic/marklogic"

test/e2e/install_test.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,16 @@ func TestHelmInstall(t *testing.T) {
4949

5050
namespaceName := "ml-" + strings.ToLower(random.UniqueId())
5151
kubectlOptions := k8s.NewKubectlOptions("", "", namespaceName)
52+
valuesMap := map[string]string{"persistence.enabled": "true",
53+
"replicaCount": "2",
54+
"image.repository": imageRepo,
55+
"image.tag": imageTag,
56+
"logCollection.enabled": "false",
57+
}
5258
options := &helm.Options{
5359
KubectlOptions: kubectlOptions,
54-
SetValues: map[string]string{
55-
"persistence.enabled": "true",
56-
"replicaCount": "2",
57-
"image.repository": imageRepo,
58-
"image.tag": imageTag,
59-
"logCollection.enabled": "false",
60-
},
61-
Version: initialChartVersion,
60+
SetValues: valuesMap,
61+
Version: initialChartVersion,
6262
}
6363

6464
t.Logf("====Creating namespace: " + namespaceName)
@@ -74,6 +74,8 @@ func TestHelmInstall(t *testing.T) {
7474
//add the helm chart repo and install the last helm chart release from repository
7575
//to test and upgrade this chart to the latest one to be released
7676
if runUpgradeTest {
77+
delete(valuesMap, "image.repository")
78+
delete(valuesMap, "image.tag")
7779
helm.AddRepo(t, options, "marklogic", "https://marklogic.github.io/marklogic-kubernetes/")
7880
defer helm.RemoveRepo(t, options, "marklogic")
7981
helmChartPath = "marklogic/marklogic"

test/e2e/ready_test.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,18 @@ func TestMarklogicReady(t *testing.T) {
5050

5151
namespaceName := "ml-" + strings.ToLower(random.UniqueId())
5252
kubectlOptions := k8s.NewKubectlOptions("", "", namespaceName)
53+
valuesMap := map[string]string{"persistence.enabled": "true",
54+
"replicaCount": "2",
55+
"image.repository": imageRepo,
56+
"image.tag": imageTag,
57+
"auth.adminUsername": username,
58+
"auth.adminPassword": password,
59+
"logCollection.enabled": "false",
60+
}
5361
options := &helm.Options{
5462
KubectlOptions: kubectlOptions,
55-
SetValues: map[string]string{
56-
"persistence.enabled": "true",
57-
"replicaCount": "2",
58-
"image.repository": imageRepo,
59-
"image.tag": imageTag,
60-
"auth.adminUsername": username,
61-
"auth.adminPassword": password,
62-
"logCollection.enabled": "false",
63-
},
64-
Version: initialChartVersion,
63+
SetValues: valuesMap,
64+
Version: initialChartVersion,
6565
}
6666

6767
t.Logf("====Creating namespace: " + namespaceName)
@@ -75,6 +75,8 @@ func TestMarklogicReady(t *testing.T) {
7575
//add the helm chart repo and install the last helm chart release from repository
7676
//to test and upgrade this chart to the latest one to be released
7777
if runUpgradeTest {
78+
delete(valuesMap, "image.repository")
79+
delete(valuesMap, "image.tag")
7880
helm.AddRepo(t, options, "marklogic", "https://marklogic.github.io/marklogic-kubernetes/")
7981
defer helm.RemoveRepo(t, options, "marklogic")
8082
helmChartPath = "marklogic/marklogic"

0 commit comments

Comments
 (0)