Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(572): fix flaky test with TestSecondaryIndices_List #595

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions server/secondary_indexes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ func TestSecondaryIndices_List(t *testing.T) {
assert.Equal(t, "/b", k)
k = <-strCh
assert.Equal(t, "/c", k)
assert.Empty(t, strCh)
// NOTE: we cannot use assert.Empty to check strCh and must to validate it's closed, because when there is no more
// items to return, assert.Empty will passthrough and leave the iterator opened.
_, ok := <-strCh
assert.False(t, ok)

// Wrong index
strCh, err = lc.List(context.Background(), &proto.ListRequest{
Expand All @@ -75,7 +78,8 @@ func TestSecondaryIndices_List(t *testing.T) {
SecondaryIndexName: pb.String("wrong-idx"),
})
assert.NoError(t, err)
assert.Empty(t, strCh)
_, ok = <-strCh
assert.False(t, ok)

// Individual delete
_, err = lc.Write(context.Background(), &proto.WriteRequest{
Expand All @@ -99,8 +103,8 @@ func TestSecondaryIndices_List(t *testing.T) {
assert.Equal(t, "/d", k)
k = <-strCh
assert.Equal(t, "/e", k)

assert.Empty(t, strCh)
_, ok = <-strCh
assert.False(t, ok)

// Range delete
_, err = lc.Write(context.Background(), &proto.WriteRequest{
Expand All @@ -124,7 +128,8 @@ func TestSecondaryIndices_List(t *testing.T) {
assert.Equal(t, "/d", k)
k = <-strCh
assert.Equal(t, "/e", k)
assert.Empty(t, strCh)
_, ok = <-strCh
assert.False(t, ok)

assert.NoError(t, lc.Close())
assert.NoError(t, kvFactory.Close())
Expand Down
Loading