Stabilize test, wait a bit for migration

Signed-off-by: Derek Collison <derek@nats.io>
This commit is contained in:
Derek Collison
2021-03-02 05:28:55 -08:00
parent 29421bde67
commit d4a8baf030
2 changed files with 10 additions and 4 deletions

View File

@@ -515,6 +515,11 @@ func (s *Server) migrateEphemerals() {
}
}
}
// Gove time for migration information to make it out of our server.
if len(consumers) > 0 {
time.Sleep(50 * time.Millisecond)
}
}
// Shutdown jetstream for this server.

View File

@@ -2098,6 +2098,7 @@ func TestJetStreamClusterEphemeralConsumersNotReplicated(t *testing.T) {
t.Fatalf("Unexpected publish error: %v", err)
}
checkSubsPending(t, sub, 1)
sub.NextMsg(0)
if ci.Cluster == nil || len(ci.Cluster.Replicas) != 0 {
t.Fatalf("Expected ephemeral to be R=1, got %+v", ci.Cluster)
@@ -2115,13 +2116,13 @@ func TestJetStreamClusterEphemeralConsumersNotReplicated(t *testing.T) {
scl.Shutdown()
c.waitOnStreamLeader("$G", "foo")
// Let the consumer migrate and spin up.
time.Sleep(250 * time.Millisecond)
if _, err = js.Publish("foo", []byte("OK")); err != nil {
t.Fatalf("Unexpected publish error: %v", err)
}
checkSubsPending(t, sub, 2)
if _, err := sub.NextMsg(500 * time.Millisecond); err != nil {
t.Logf("Expected to see another message, but behavior is optimistic so can fail")
}
}
func TestJetStreamClusterUserSnapshotAndRestore(t *testing.T) {