Skip to content

Commit 1e91931

Browse files
authored
Merge pull request #386 from rabbitmq/system-tests-mqtt
Remove expectation on token timeout in MQTT tests. It should reduce the flakiness of this test suite.
2 parents 4c87d13 + 48d2f01 commit 1e91931

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

system_tests/utils.go

+7-9
Original file line numberDiff line numberDiff line change
@@ -746,20 +746,18 @@ func publishAndConsumeMQTTMsg(hostname, nodePort, username, password string, ove
746746
c := mqtt.NewClient(opts)
747747

748748
var token mqtt.Token
749-
for retry := 0; retry < 5; retry++ {
750-
fmt.Printf("Attempt #%d to connect using MQTT\n", retry)
749+
Eventually(func() bool {
751750
token = c.Connect()
752751
// Waits for the network request to reach the destination and receive a response
753-
Expect(token.WaitTimeout(3 * time.Second)).To(BeTrue())
752+
if !token.WaitTimeout(3 * time.Second) {
753+
return false
754+
}
754755

755756
if err := token.Error(); err == nil {
756-
break
757+
return true
757758
}
758-
759-
time.Sleep(2 * time.Second)
760-
}
761-
762-
Expect(token.Error()).ToNot(HaveOccurred())
759+
return false
760+
}, 10, 2).Should(BeTrue(), "Expected to be able to connect to MQTT port")
763761

764762
topic := "tests/mqtt"
765763
msgReceived := false

0 commit comments

Comments
 (0)