From 10a9361dbb0101788b091f9336eac4f8ee9e32ea Mon Sep 17 00:00:00 2001 From: Philip O'Toole Date: Sat, 13 Jan 2024 13:52:42 -0500 Subject: [PATCH] Best test --- store/store_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/store/store_test.go b/store/store_test.go index e4f36099..8754db8e 100644 --- a/store/store_test.go +++ b/store/store_test.go @@ -1860,6 +1860,23 @@ func Test_MultiNodeDBAppliedIndex(t *testing.T) { if s0.DBAppliedIndex() > s2.DBAppliedIndex() { t.Fatalf("applied index on new node is not correct (%d, %d)", s0.DBAppliedIndex(), s2.DBAppliedIndex()) } + + // Write one last row, and everything should be in sync. + er = executeRequestFromStrings([]string{ + `INSERT INTO foo(id, name) VALUES(4, "fiona")`, + }, false, false) + _, err = s0.Execute(er) + if err != nil { + t.Fatalf("failed to execute on single node: %s", err.Error()) + } + + testPoll(t, func() bool { + i := s0.DBAppliedIndex() + return i == s1.DBAppliedIndex() && + i == s2.DBAppliedIndex() && + i == s3.DBAppliedIndex() + }, 100*time.Millisecond, 5*time.Second) + } func Test_MultiNodeJoinRemove(t *testing.T) { @@ -3259,6 +3276,7 @@ func asJSONAssociative(v interface{}) string { } func testPoll(t *testing.T, f func() bool, p time.Duration, d time.Duration) { + t.Helper() tck := time.NewTicker(p) defer tck.Stop() tmr := time.NewTimer(d)