Skip to content

Commit be61f15

Browse files
RamSubbaraoGitHub Enterprise
authored andcommitted
Use golang cleanup and fix TestVolumeUnmount (#1025)
1 parent 2d3d88a commit be61f15

File tree

7 files changed

+185
-151
lines changed

7 files changed

+185
-151
lines changed

test/container/devconfig_test.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func TestDevGoldenPath(t *testing.T) {
4646
},
4747
}
4848
id := runContainerWithPorts(t, cli, &containerConfig, []int{9443, 1414})
49-
defer cleanContainer(t, cli, id, false)
49+
cleanupAfterTest(t, cli, id, false)
5050
waitForReady(t, cli, id)
5151
waitForWebReady(t, cli, id, insecureTLSConfig)
5252
t.Run("JMS", func(t *testing.T) {
@@ -111,7 +111,7 @@ func TestDevSecure(t *testing.T) {
111111
if err != nil {
112112
t.Fatal(err)
113113
}
114-
defer cleanContainer(t, cli, ID, false)
114+
cleanupAfterTest(t, cli, ID, false)
115115
startContainer(t, cli, ID)
116116
waitForReady(t, cli, ID)
117117
cert := filepath.Join(tlsDir(t, true), "server.crt")
@@ -146,7 +146,7 @@ func TestDevWebDisabled(t *testing.T) {
146146
},
147147
}
148148
id := runContainerWithPorts(t, cli, &containerConfig, []int{1414})
149-
defer cleanContainer(t, cli, id, false)
149+
cleanupAfterTest(t, cli, id, false)
150150
waitForReady(t, cli, id)
151151
t.Run("Web", func(t *testing.T) {
152152
_, dspmqweb := cli.ExecContainer(id, "", []string{"dspmqweb"})
@@ -176,7 +176,7 @@ func TestDevConfigDisabled(t *testing.T) {
176176
},
177177
}
178178
id := runContainerWithPorts(t, cli, &containerConfig, []int{9443})
179-
defer cleanContainer(t, cli, id, false)
179+
cleanupAfterTest(t, cli, id, false)
180180
waitForReady(t, cli, id)
181181
rc, _ := execContainer(t, cli, id, "", []string{"bash", "-c", "echo 'display qlocal(DEV*)' | runmqsc"})
182182
if rc == 0 {
@@ -200,7 +200,7 @@ func TestSSLKEYRBlank(t *testing.T) {
200200
},
201201
}
202202
id := runContainerWithPorts(t, cli, &containerConfig, []int{9443})
203-
defer cleanContainer(t, cli, id, false)
203+
cleanupAfterTest(t, cli, id, false)
204204
waitForReady(t, cli, id)
205205

206206
// execute runmqsc to display qmgr SSLKEYR and CERTLABL attibutes.
@@ -256,7 +256,7 @@ func TestSSLKEYRWithSuppliedKeyAndCert(t *testing.T) {
256256
if err != nil {
257257
t.Fatal(err)
258258
}
259-
defer cleanContainer(t, cli, ID, false)
259+
cleanupAfterTest(t, cli, ID, false)
260260
startContainer(t, cli, ID)
261261
waitForReady(t, cli, ID)
262262

@@ -323,7 +323,7 @@ func TestSSLKEYRWithCACert(t *testing.T) {
323323
if err != nil {
324324
t.Fatal(err)
325325
}
326-
defer cleanContainer(t, cli, ID, false)
326+
cleanupAfterTest(t, cli, ID, false)
327327
startContainer(t, cli, ID)
328328
waitForReady(t, cli, ID)
329329

@@ -386,7 +386,7 @@ func TestSSLFIPSNO(t *testing.T) {
386386
if err != nil {
387387
t.Fatal(err)
388388
}
389-
defer cleanContainer(t, cli, ID, false)
389+
cleanupAfterTest(t, cli, ID, false)
390390
startContainer(t, cli, ID)
391391
waitForReady(t, cli, ID)
392392

@@ -447,7 +447,7 @@ func TestSSLFIPSYES(t *testing.T) {
447447
if err != nil {
448448
t.Fatal(err)
449449
}
450-
defer cleanContainer(t, cli, ID, false)
450+
cleanupAfterTest(t, cli, ID, false)
451451
startContainer(t, cli, ID)
452452
waitForReady(t, cli, ID)
453453

@@ -527,7 +527,7 @@ func TestDevSecureFIPSTrueWeb(t *testing.T) {
527527
if err != nil {
528528
t.Fatal(err)
529529
}
530-
defer cleanContainer(t, cli, ID, false)
530+
cleanupAfterTest(t, cli, ID, false)
531531

532532
startContainer(t, cli, ID)
533533
waitForReady(t, cli, ID)
@@ -598,7 +598,7 @@ func TestDevSecureFalseFIPSWeb(t *testing.T) {
598598
if err != nil {
599599
t.Fatal(err)
600600
}
601-
defer cleanContainer(t, cli, ID, false)
601+
cleanupAfterTest(t, cli, ID, false)
602602
startContainer(t, cli, ID)
603603
waitForReady(t, cli, ID)
604604

@@ -649,7 +649,7 @@ func TestSSLFIPSTrueNoCerts(t *testing.T) {
649649
if err != nil {
650650
t.Fatal(err)
651651
}
652-
defer cleanContainer(t, cli, ID, false)
652+
cleanupAfterTest(t, cli, ID, false)
653653
startContainer(t, cli, ID)
654654
waitForReady(t, cli, ID)
655655

@@ -697,7 +697,7 @@ func TestSSLFIPSInvalidValue(t *testing.T) {
697697
if err != nil {
698698
t.Fatal(err)
699699
}
700-
defer cleanContainer(t, cli, ID, false)
700+
cleanupAfterTest(t, cli, ID, false)
701701
startContainer(t, cli, ID)
702702
waitForReady(t, cli, ID)
703703

@@ -746,7 +746,7 @@ func TestSSLFIPSBadCerts(t *testing.T) {
746746
if err != nil {
747747
t.Fatal(err)
748748
}
749-
defer cleanContainer(t, cli, ID, false)
749+
cleanupAfterTest(t, cli, ID, false)
750750
startContainer(t, cli, ID)
751751

752752
rc := waitForContainer(t, cli, ID, 20*time.Second)
@@ -784,7 +784,7 @@ func TestDevNoDefCreds(t *testing.T) {
784784
},
785785
}
786786
id := runContainerWithPorts(t, cli, &containerConfig, []int{9443, 1414})
787-
defer cleanContainer(t, cli, id, false)
787+
cleanupAfterTest(t, cli, id, false)
788788
waitForReady(t, cli, id)
789789
waitForWebReady(t, cli, id, insecureTLSConfig)
790790
// Expect a 401 Unauthorized HTTP Response
@@ -829,7 +829,7 @@ func testDevNoDefaultCredsUtil(t *testing.T, mqsimpleauthEnvs []string, htpwdInL
829829
containerConfig.Env = append(containerConfig.Env, mqsimpleauthEnvs...)
830830

831831
id := runContainerWithPorts(t, cli, &containerConfig, []int{1414})
832-
defer cleanContainer(t, cli, id, false)
832+
cleanupAfterTest(t, cli, id, false)
833833
waitForReady(t, cli, id)
834834
defer stopContainer(t, cli, id)
835835

@@ -868,11 +868,11 @@ func TestRORFSDevNoAppPassword(t *testing.T) {
868868

869869
// Create volumes for mounting into container
870870
ephData := createVolume(t, cli, "ephData"+t.Name())
871-
defer removeVolume(t, cli, ephData)
871+
cleanupVolume(t, cli, ephData)
872872
ephRun := createVolume(t, cli, "ephRun"+t.Name())
873-
defer removeVolume(t, cli, ephRun)
873+
cleanupVolume(t, cli, ephRun)
874874
ephTmp := createVolume(t, cli, "ephTmp"+t.Name())
875-
defer removeVolume(t, cli, ephTmp)
875+
cleanupVolume(t, cli, ephTmp)
876876

877877
hostConfig := ce.ContainerHostConfig{
878878
Binds: []string{
@@ -899,7 +899,7 @@ func TestRORFSDevNoAppPassword(t *testing.T) {
899899
if err != nil {
900900
t.Fatal(err)
901901
}
902-
defer cleanContainer(t, cli, id, false)
902+
cleanupAfterTest(t, cli, id, false)
903903
startContainer(t, cli, id)
904904

905905
waitForReady(t, cli, id)

test/container/devconfig_test_util.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func waitForWebReady(t *testing.T, cli ce.ContainerInterface, ID string, tlsConf
6262
t.Fatal(err)
6363
}
6464
url := fmt.Sprintf("https://localhost:%s/ibmmq/rest/v1/admin/installation", port)
65-
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
65+
ctx, cancel := context.WithTimeout(context.Background(), 4*time.Minute)
6666
defer cancel()
6767

6868
for {
@@ -152,7 +152,7 @@ func runJMSTests(t *testing.T, cli ce.ContainerInterface, ID string, tls bool, u
152152
}
153153
}
154154

155-
defer cleanContainer(t, cli, jmsID, false)
155+
cleanupAfterTest(t, cli, jmsID, false)
156156
}
157157

158158
// Parse JUnit log line and return true if line contains failed or aborted tests

0 commit comments

Comments
 (0)