Skip to content

Commit 10371bc

Browse files
committed
[fix] Fix flakiness of TestSchema_SkipInitialScan by waiting for all docs to be indexed before querying
1 parent 3878438 commit 10371bc

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

redisearch/schema_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"github.com/stretchr/testify/assert"
66
"reflect"
77
"testing"
8+
"time"
89
)
910

1011
func TestNewSchema(t *testing.T) {
@@ -145,6 +146,15 @@ func TestSchema_SkipInitialScan(t *testing.T) {
145146
c = createClient("skip-initial-scan-test-scan")
146147
c.CreateIndexWithIndexDefinition(schema1, indexDefinition)
147148
assert.Nil(t, err)
149+
150+
// Wait for all documents to be indexed
151+
info, err := c.Info()
152+
assert.Nil(t, err)
153+
for info.IsIndexing {
154+
time.Sleep(time.Second)
155+
info, _ = c.Info()
156+
}
157+
148158
_, total, err := c.Search(q)
149159
assert.Nil(t, err)
150160
assert.Equal(t, 1, total)

0 commit comments

Comments
 (0)