1
1
package e2e
2
2
3
3
import (
4
+ "crypto/tls"
4
5
"fmt"
5
6
"io"
6
7
"os"
@@ -13,6 +14,7 @@ import (
13
14
"github.com/gruntwork-io/terratest/modules/k8s"
14
15
"github.com/gruntwork-io/terratest/modules/random"
15
16
"github.com/imroc/req/v3"
17
+ "github.com/marklogic/marklogic-kubernetes/test/testUtil"
16
18
"github.com/stretchr/testify/assert"
17
19
"github.com/tidwall/gjson"
18
20
)
@@ -44,7 +46,7 @@ func TestPathBasedRouting(t *testing.T) {
44
46
options := & helm.Options {
45
47
KubectlOptions : kubectlOptions ,
46
48
SetValues : map [string ]string {
47
- "persistence.enabled" : "false " ,
49
+ "persistence.enabled" : "true " ,
48
50
"replicaCount" : "3" ,
49
51
"image.repository" : imageRepo ,
50
52
"image.tag" : imageTag ,
@@ -68,11 +70,13 @@ func TestPathBasedRouting(t *testing.T) {
68
70
releaseName := "test-path"
69
71
helm .Install (t , options , helmChartPath , releaseName )
70
72
71
- podName := releaseName + "-2"
73
+ podZeroName := releaseName + "-0"
74
+ podOneName := releaseName + "-1"
75
+ podTwoName := releaseName + "-2"
72
76
svcName := releaseName + "-haproxy"
73
77
74
78
// wait until the pod is in Ready status
75
- k8s .WaitUntilPodAvailable (t , kubectlOptions , podName , 15 , 20 * time .Second )
79
+ k8s .WaitUntilPodAvailable (t , kubectlOptions , podTwoName , 15 , 20 * time .Second )
76
80
77
81
tunnel := k8s .NewTunnel (
78
82
kubectlOptions , k8s .ResourceTypeService , svcName , 8080 , 80 )
@@ -145,6 +149,13 @@ func TestPathBasedRouting(t *testing.T) {
145
149
t .Errorf ("basic authentication is not configured for %s AppServer" , appServers [i ])
146
150
}
147
151
}
152
+
153
+ tlsConfig := tls.Config {}
154
+ // restart 1 pod at a time in the cluster and verify its ready and MarkLogic server is healthy
155
+ testUtil .RestartPodAndVerify (t , false , []string {podZeroName , podOneName , podTwoName }, namespaceName , kubectlOptions , & tlsConfig )
156
+
157
+ // restart all pods at once in the cluster and verify its ready and MarkLogic server is healthy
158
+ testUtil .RestartPodAndVerify (t , true , []string {podZeroName , podOneName , podTwoName }, namespaceName , kubectlOptions , & tlsConfig )
148
159
}
149
160
150
161
func TestPathBasedRoutAppServers (t * testing.T ) {
@@ -159,9 +170,25 @@ func TestPathBasedRoutAppServers(t *testing.T) {
159
170
namespaceName := "ml-" + strings .ToLower (random .UniqueId ())
160
171
kubectlOptions := k8s .NewKubectlOptions ("" , "" , namespaceName )
161
172
173
+ imageRepo , repoPres := os .LookupEnv ("dockerRepository" )
174
+ imageTag , tagPres := os .LookupEnv ("dockerVersion" )
175
+ if ! repoPres {
176
+ imageRepo = "marklogicdb/marklogic-db"
177
+ t .Logf ("No imageRepo variable present, setting to default value: " + imageRepo )
178
+ }
179
+
180
+ if ! tagPres {
181
+ imageTag = "latest-11"
182
+ t .Logf ("No imageTag variable present, setting to default value: " + imageTag )
183
+ }
184
+
162
185
// Setup the args for helm install using custom values.yaml file
163
186
options := & helm.Options {
164
- ValuesFiles : []string {"../test_data/values/tls_pbr_appser_values.yaml" },
187
+ ValuesFiles : []string {"../test_data/values/tls_pbr_appser_values.yaml" },
188
+ SetValues : map [string ]string {
189
+ "image.repository" : imageRepo ,
190
+ "image.tag" : imageTag ,
191
+ },
165
192
KubectlOptions : k8s .NewKubectlOptions ("" , "" , namespaceName ),
166
193
}
167
194
@@ -175,11 +202,12 @@ func TestPathBasedRoutAppServers(t *testing.T) {
175
202
releaseName := "test-path"
176
203
helm .Install (t , options , helmChartPath , releaseName )
177
204
178
- podName := releaseName + "-1"
205
+ podZeroName := releaseName + "-0"
206
+ podOneName := releaseName + "-1"
179
207
svcName := releaseName + "-haproxy"
180
208
181
209
// wait until the pod is in Ready status
182
- k8s .WaitUntilPodAvailable (t , kubectlOptions , podName , 15 , 20 * time .Second )
210
+ k8s .WaitUntilPodAvailable (t , kubectlOptions , podOneName , 15 , 20 * time .Second )
183
211
184
212
tunnel := k8s .NewTunnel (
185
213
kubectlOptions , k8s .ResourceTypeService , svcName , 8080 , 80 )
@@ -249,6 +277,13 @@ func TestPathBasedRoutAppServers(t *testing.T) {
249
277
t .Fatalf (err .Error ())
250
278
}
251
279
assert .Contains (t , string (body ), "XDMP-MODNOTFOUND" )
280
+
281
+ tlsConfig := tls.Config {}
282
+ // restart 1 pod at a time in the cluster and verify its ready and MarkLogic server is healthy
283
+ testUtil .RestartPodAndVerify (t , false , []string {podZeroName , podOneName }, namespaceName , kubectlOptions , & tlsConfig )
284
+
285
+ // restart all pods at once in the cluster and verify its ready and MarkLogic server is healthy
286
+ testUtil .RestartPodAndVerify (t , true , []string {podZeroName , podOneName }, namespaceName , kubectlOptions , & tlsConfig )
252
287
}
253
288
254
289
func TestPathBasedRoutingWithTLS (t * testing.T ) {
@@ -278,7 +313,7 @@ func TestPathBasedRoutingWithTLS(t *testing.T) {
278
313
options := & helm.Options {
279
314
KubectlOptions : kubectlOptions ,
280
315
SetValues : map [string ]string {
281
- "persistence.enabled" : "false " ,
316
+ "persistence.enabled" : "true " ,
282
317
"replicaCount" : "3" ,
283
318
"image.repository" : imageRepo ,
284
319
"image.tag" : imageTag ,
@@ -303,11 +338,13 @@ func TestPathBasedRoutingWithTLS(t *testing.T) {
303
338
releaseName := "test-pb-tls"
304
339
helm .Install (t , options , helmChartPath , releaseName )
305
340
306
- podName := releaseName + "-2"
341
+ podZeroName := releaseName + "-0"
342
+ podOneName := releaseName + "-1"
343
+ podTwoName := releaseName + "-2"
307
344
svcName := releaseName + "-haproxy"
308
345
309
346
// wait until the pod is in Ready status
310
- k8s .WaitUntilPodAvailable (t , kubectlOptions , podName , 10 , 20 * time .Second )
347
+ k8s .WaitUntilPodAvailable (t , kubectlOptions , podTwoName , 10 , 20 * time .Second )
311
348
312
349
tunnel := k8s .NewTunnel (
313
350
kubectlOptions , k8s .ResourceTypeService , svcName , 8080 , 80 )
@@ -377,4 +414,12 @@ func TestPathBasedRoutingWithTLS(t *testing.T) {
377
414
t .Errorf ("ssl is not enabled for %s AppServer" , appServers [i ])
378
415
}
379
416
}
417
+
418
+ tlsConfig := tls.Config {}
419
+
420
+ // restart 1 pod at a time in the cluster and verify its ready and MarkLogic server is healthy
421
+ testUtil .RestartPodAndVerify (t , false , []string {podZeroName , podOneName , podTwoName }, namespaceName , kubectlOptions , & tlsConfig )
422
+
423
+ // restart all pods at once in the cluster and verify its ready and MarkLogic server is healthy
424
+ testUtil .RestartPodAndVerify (t , true , []string {podZeroName , podOneName , podTwoName }, namespaceName , kubectlOptions , & tlsConfig )
380
425
}
0 commit comments