Skip to content

Commit

Permalink
Use Eventually rather than for-loop
Browse files Browse the repository at this point in the history
to send a message via stream protocol
  • Loading branch information
MarcialRosales committed Oct 21, 2021
1 parent a7e0e7a commit 5de00ba
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions system_tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ func publishAndConsumeStreamMsg(host, port, username, password string) {
Expect(err).ToNot(HaveOccurred())

var env *stream.Environment
for retry := 0; retry < 5; retry++ {
Eventually(func() error{
fmt.Println("connecting to stream endpoint ...")
env, err = stream.NewEnvironment(stream.NewEnvironmentOptions().
SetHost(host).
Expand All @@ -1010,13 +1010,12 @@ func publishAndConsumeStreamMsg(host, port, username, password string) {
}))
if err == nil {
fmt.Println("connected to stream endpoint")
break
return nil
}else {
fmt.Errorf("failed to connect to stream endpoint (%s:%d) due to %g\n", host, portInt, err)
}
time.Sleep(portReadinessTimeout)
}
Expect(err).ToNot(HaveOccurred())
return err
}, portReadinessTimeout*5, portReadinessTimeout).ShouldNot(HaveOccurred())

const streamName = "system-test-stream"
Expect(env.DeclareStream(
Expand Down

0 comments on commit 5de00ba

Please sign in to comment.