Skip to content

Commit 5de00ba

Browse files
Use Eventually rather than for-loop
to send a message via stream protocol
1 parent a7e0e7a commit 5de00ba

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

system_tests/utils.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ func publishAndConsumeStreamMsg(host, port, username, password string) {
997997
Expect(err).ToNot(HaveOccurred())
998998

999999
var env *stream.Environment
1000-
for retry := 0; retry < 5; retry++ {
1000+
Eventually(func() error{
10011001
fmt.Println("connecting to stream endpoint ...")
10021002
env, err = stream.NewEnvironment(stream.NewEnvironmentOptions().
10031003
SetHost(host).
@@ -1010,13 +1010,12 @@ func publishAndConsumeStreamMsg(host, port, username, password string) {
10101010
}))
10111011
if err == nil {
10121012
fmt.Println("connected to stream endpoint")
1013-
break
1013+
return nil
10141014
}else {
10151015
fmt.Errorf("failed to connect to stream endpoint (%s:%d) due to %g\n", host, portInt, err)
10161016
}
1017-
time.Sleep(portReadinessTimeout)
1018-
}
1019-
Expect(err).ToNot(HaveOccurred())
1017+
return err
1018+
}, portReadinessTimeout*5, portReadinessTimeout).ShouldNot(HaveOccurred())
10201019

10211020
const streamName = "system-test-stream"
10221021
Expect(env.DeclareStream(

0 commit comments

Comments
 (0)