diff --git a/test/js_test.go b/test/js_test.go index 849de3cbb..a8c7eac12 100644 --- a/test/js_test.go +++ b/test/js_test.go @@ -4155,12 +4155,11 @@ func TestJetStreamSubscribe_AckPolicy(t *testing.T) { } <-ctx.Done() - sub.Drain() - if got != totalMsgs { t.Fatalf("Expected %d, got %d", totalMsgs, got) } + // check if consumer is configured properly ci, err := js.ConsumerInfo("TEST", test.name) if err != nil { t.Fatalf("Unexpected error: %v", err) @@ -4168,6 +4167,9 @@ func TestJetStreamSubscribe_AckPolicy(t *testing.T) { if ci.Config.AckPolicy != test.expected { t.Fatalf("Expected %v, got %v", test.expected, ci.Config.AckPolicy) } + + // drain the subscription. This will remove the consumer + sub.Drain() }) } diff --git a/test/kv_test.go b/test/kv_test.go index c668e6f12..78f741ee0 100644 --- a/test/kv_test.go +++ b/test/kv_test.go @@ -952,6 +952,8 @@ func TestKeyValueMirrorCrossDomains(t *testing.T) { _, err = mkv.PutString("v", "vv") expectOk(t, err) + // wait for the key to be propagated to the mirror + time.Sleep(10 * time.Millisecond) e, err := mkv.Get("v") expectOk(t, err) if e.Operation() != nats.KeyValuePut { @@ -959,6 +961,7 @@ func TestKeyValueMirrorCrossDomains(t *testing.T) { } err = mkv.Delete("v") expectOk(t, err) + time.Sleep(10 * time.Millisecond) _, err = mkv.Get("v") expectErr(t, err, nats.ErrKeyNotFound) @@ -983,6 +986,7 @@ func TestKeyValueMirrorCrossDomains(t *testing.T) { _, err = rkv.PutString("name", "ivan") expectOk(t, err) + time.Sleep(10 * time.Millisecond) e, err = rkv.Get("name") expectOk(t, err) if string(e.Value()) != "ivan" { @@ -990,6 +994,7 @@ func TestKeyValueMirrorCrossDomains(t *testing.T) { } _, err = rkv.PutString("v", "vv") expectOk(t, err) + time.Sleep(10 * time.Millisecond) e, err = mkv.Get("v") expectOk(t, err) if e.Operation() != nats.KeyValuePut { @@ -997,6 +1002,7 @@ func TestKeyValueMirrorCrossDomains(t *testing.T) { } err = rkv.Delete("v") expectOk(t, err) + time.Sleep(10 * time.Millisecond) _, err = rkv.Get("v") expectErr(t, err, nats.ErrKeyNotFound)