Skip to content

Commit b04ef21

Browse files
committed
Allow for slow standby take-over in MIQM test
In TestMultiInstanceContainerStop, if the standby hasn't taken over by the time the active has stopped, the test fails. This causes problems on slow machines for the CI/CD pipeline. This commit adds a 30 second timeout on the take-over.
1 parent 6acc281 commit b04ef21

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

test/docker/mq_multi_instance_test.go

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
© Copyright IBM Corporation 2019, 2020
2+
© Copyright IBM Corporation 2019, 2022
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -16,6 +16,7 @@ limitations under the License.
1616
package main
1717

1818
import (
19+
"context"
1920
"strings"
2021
"testing"
2122
"time"
@@ -92,15 +93,28 @@ func TestMultiInstanceContainerStop(t *testing.T) {
9293
waitForReady(t, cli, qm1aId)
9394
waitForReady(t, cli, qm1bId)
9495

95-
err, active, standby := getActiveStandbyQueueManager(t, cli, qm1aId, qm1bId)
96+
err, originalActive, originalStandby := getActiveStandbyQueueManager(t, cli, qm1aId, qm1bId)
9697
if err != nil {
9798
t.Fatal(err)
9899
}
99100

100-
stopContainer(t, cli, active)
101+
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
102+
defer cancel()
103+
stopContainer(t, cli, originalActive)
101104

102-
if status := getQueueManagerStatus(t, cli, standby, "QM1"); strings.Compare(status, "Running") != 0 {
103-
t.Fatalf("Expected QM1 to be running as active queue manager, dspmq returned status of %v", status)
105+
for {
106+
status := getQueueManagerStatus(t, cli, originalStandby, "QM1")
107+
select {
108+
case <-time.After(1 * time.Second):
109+
if status == "Running" {
110+
t.Logf("Original standby is now the active")
111+
return
112+
} else if status == "Starting" {
113+
t.Logf("Original standby is starting")
114+
}
115+
case <-ctx.Done():
116+
t.Fatalf("%s Timed out waiting for standby to become the active. Status=%v", time.Now().Format(time.RFC3339), status)
117+
}
104118
}
105119
}
106120

test/docker/mq_multi_instance_test_util.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
© Copyright IBM Corporation 2019
2+
© Copyright IBM Corporation 2019, 2022
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -77,6 +77,7 @@ func getActiveStandbyQueueManager(t *testing.T, cli *client.Client, qm1aId strin
7777

7878
func getQueueManagerStatus(t *testing.T, cli *client.Client, containerID string, queueManagerName string) string {
7979
_, dspmqOut := execContainer(t, cli, containerID, "", []string{"bash", "-c", "dspmq", "-m", queueManagerName})
80+
t.Logf("dspmq for %v (%v) returned: %v", containerID, queueManagerName, dspmqOut)
8081
regex := regexp.MustCompile(`STATUS\(.*\)`)
8182
status := regex.FindString(dspmqOut)
8283
status = strings.TrimSuffix(strings.TrimPrefix(status, "STATUS("), ")")

0 commit comments

Comments
 (0)