Skip to content

Commit 3785deb

Browse files
committed
Fix ExtraOnSecondary test for buffered matchSecondary
matchSecondary now buffers unmatched secondaries instead of reporting immediately. Adjust the test to wait for the comparison window and call sweepExpired to trigger divergence reporting.
1 parent 1568458 commit 3785deb

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

proxy/shadow_pubsub_test.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,15 @@ func TestShadowPubSub_MissingOnSecondary(t *testing.T) {
6262
}
6363

6464
func TestShadowPubSub_ExtraOnSecondary(t *testing.T) {
65-
sp := newTestShadowPubSub(100 * time.Millisecond)
65+
sp := newTestShadowPubSub(10 * time.Millisecond)
6666

6767
sp.matchSecondary(&redis.Message{Channel: "ch1", Payload: "extra"})
6868

69+
// matchSecondary now buffers unmatched secondaries; wait for the
70+
// comparison window to expire and sweep to trigger divergence reporting.
71+
time.Sleep(20 * time.Millisecond)
72+
sp.sweepExpired()
73+
6974
val := counterValue(sp.metrics.PubSubShadowDivergences.WithLabelValues("extra_data"))
7075
assert.Equal(t, float64(1), val)
7176
}

0 commit comments

Comments
 (0)