Fix flaky CommitOnRestart test
@@ -406,9 +406,19 @@ func TestCommitOnRestart(t *testing.T) {
// Publish some more messages.
for i := 0; i < num; i++ {
+ // Wrap in a retry since we might have been connected to the server
+ // that was killed.
+ for j := 0; j < 5; j++ {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
_, err = client.Publish(ctx, name, []byte("hello"))
+ if err != nil {
+ time.Sleep(100 * time.Millisecond)
+ continue
+ } else {
+ break
+ }
+ }
require.NoError(t, err)
}
