Skip to content

Commit 5574531

Browse files
authored
Stabilize CI (#523)
* don't assert FT.SEARCH internals * add healthcheck to the CI servers so we don't hit incomplete clusters in race scenarios * more log only of FT.SEARCH internals * add indexing pauses in QueryEmExample
1 parent a2c9f6c commit 5574531

3 files changed

Lines changed: 112 additions & 72 deletions

File tree

‎tests/Doc/QueryEmExample.cs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,13 @@ public void Run()
210210
}
211211
// HIDE_END
212212

213+
// REMOVE_START
214+
// JSON indexing is asynchronous; wait for the background indexer to catch
215+
// up before querying, otherwise searches can intermittently return fewer
216+
// results than expected (especially under CI load). Removed from docs.
217+
Thread.Sleep(2000);
218+
// REMOVE_END
219+
213220

214221
// STEP_START em1
215222
SearchResult res1 = db.FT().Search(
@@ -260,6 +267,10 @@ public void Run()
260267

261268
db.JSON().Set("key:1", "$", "{\"email\": \"test@redis.com\"}");
262269

270+
// REMOVE_START
271+
Thread.Sleep(2000); // wait for async indexing (removed from docs)
272+
// REMOVE_END
273+
263274

264275
SearchResult res4 = db.FT().Search(
265276
"idx:email",

‎tests/NRedisStack.Tests/Search/SearchTests.cs‎

Lines changed: 84 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -894,27 +894,30 @@ public void AlterAdd(string endpointId)
894894
{
895895
Assert.Equal(100, info.NumDocs);
896896

897-
// these numbers don't make sense when considering a shard
898-
Assert.NotNull(info.MaxDocId);
899-
Assert.Equal(102, info.NumTerms);
900-
Assert.True(info.NumRecords >= 200);
901-
Assert.True(info.InvertedSzMebibytes < 1); // TODO: check this line and all the <1 lines
902-
Log($"{nameof(info.VectorIndexSzMebibytes)}: {info.VectorIndexSzMebibytes}"); // version-dependent
903-
Assert.Equal(208, info.TotalInvertedIndexBlocks);
904-
Assert.True(info.OffsetVectorsSzMebibytes < 1);
905-
Assert.True(info.DocTableSizeMebibytes < 1);
906-
Assert.Equal(0, info.SortableValueSizeMebibytes);
907-
Assert.True(info.KeyTableSizeMebibytes < 1);
908-
Assert.Equal(8, (int)info.RecordsPerDocAvg);
909-
Assert.True(info.BytesPerRecordAvg > 5);
910-
Assert.True(info.OffsetsPerTermAvg > 0.8);
911-
Assert.Equal(8, info.OffsetBitsPerRecordAvg);
897+
// These are internal index statistics whose exact values drift with the
898+
// RediSearch version and background GC timing; log them rather than assert.
899+
Log($"{nameof(info.MaxDocId)}: {info.MaxDocId}");
900+
Log($"{nameof(info.NumTerms)}: {info.NumTerms}");
901+
Log($"{nameof(info.NumRecords)}: {info.NumRecords}");
902+
Log($"{nameof(info.InvertedSzMebibytes)}: {info.InvertedSzMebibytes}");
903+
Log($"{nameof(info.VectorIndexSzMebibytes)}: {info.VectorIndexSzMebibytes}");
904+
Log($"{nameof(info.TotalInvertedIndexBlocks)}: {info.TotalInvertedIndexBlocks}");
905+
Log($"{nameof(info.OffsetVectorsSzMebibytes)}: {info.OffsetVectorsSzMebibytes}");
906+
Log($"{nameof(info.DocTableSizeMebibytes)}: {info.DocTableSizeMebibytes}");
907+
Log($"{nameof(info.SortableValueSizeMebibytes)}: {info.SortableValueSizeMebibytes}");
908+
Log($"{nameof(info.KeyTableSizeMebibytes)}: {info.KeyTableSizeMebibytes}");
909+
Log($"{nameof(info.RecordsPerDocAvg)}: {info.RecordsPerDocAvg}");
910+
Log($"{nameof(info.BytesPerRecordAvg)}: {info.BytesPerRecordAvg}");
911+
Log($"{nameof(info.OffsetsPerTermAvg)}: {info.OffsetsPerTermAvg}");
912+
Log($"{nameof(info.OffsetBitsPerRecordAvg)}: {info.OffsetBitsPerRecordAvg}");
913+
Log($"{nameof(info.NumberOfUses)}: {info.NumberOfUses}");
914+
Log($"{nameof(info.GcStats)}.Count: {info.GcStats.Count}");
915+
Log($"{nameof(info.CursorStats)}.Count: {info.CursorStats.Count}");
916+
917+
// Correctness: everything was indexed, with no failures.
912918
Assert.Equal(0, info.HashIndexingFailures);
913919
Assert.Equal(0, info.Indexing);
914920
Assert.Equal(1, info.PercentIndexed);
915-
Assert.Equal(5, info.NumberOfUses);
916-
Assert.Equal(7, info.GcStats.Count);
917-
Assert.Equal(4, info.CursorStats.Count);
918921
}
919922
}
920923

@@ -982,27 +985,30 @@ public async Task AlterAddAsync(string endpointId)
982985
{
983986
Assert.Equal(100, info.NumDocs);
984987

985-
// these numbers don't make sense when considering a shard
986-
Assert.Equal("300", info.MaxDocId);
987-
Assert.Equal(102, info.NumTerms);
988-
Assert.True(info.NumRecords >= 200);
989-
Assert.True(info.InvertedSzMebibytes < 1); // TODO: check this line and all the <1 lines
990-
Log($"{nameof(info.VectorIndexSzMebibytes)}: {info.VectorIndexSzMebibytes}"); // version-dependent
991-
Assert.Equal(208, info.TotalInvertedIndexBlocks);
992-
Assert.True(info.OffsetVectorsSzMebibytes < 1);
993-
Assert.True(info.DocTableSizeMebibytes < 1);
994-
Assert.Equal(0, info.SortableValueSizeMebibytes);
995-
Assert.True(info.KeyTableSizeMebibytes < 1);
996-
Assert.Equal(8, (int)info.RecordsPerDocAvg);
997-
Assert.True(info.BytesPerRecordAvg > 5);
998-
Assert.True(info.OffsetsPerTermAvg > 0.8);
999-
Assert.Equal(8, info.OffsetBitsPerRecordAvg);
988+
// These are internal index statistics whose exact values drift with the
989+
// RediSearch version and background GC timing; log them rather than assert.
990+
Log($"{nameof(info.MaxDocId)}: {info.MaxDocId}");
991+
Log($"{nameof(info.NumTerms)}: {info.NumTerms}");
992+
Log($"{nameof(info.NumRecords)}: {info.NumRecords}");
993+
Log($"{nameof(info.InvertedSzMebibytes)}: {info.InvertedSzMebibytes}");
994+
Log($"{nameof(info.VectorIndexSzMebibytes)}: {info.VectorIndexSzMebibytes}");
995+
Log($"{nameof(info.TotalInvertedIndexBlocks)}: {info.TotalInvertedIndexBlocks}");
996+
Log($"{nameof(info.OffsetVectorsSzMebibytes)}: {info.OffsetVectorsSzMebibytes}");
997+
Log($"{nameof(info.DocTableSizeMebibytes)}: {info.DocTableSizeMebibytes}");
998+
Log($"{nameof(info.SortableValueSizeMebibytes)}: {info.SortableValueSizeMebibytes}");
999+
Log($"{nameof(info.KeyTableSizeMebibytes)}: {info.KeyTableSizeMebibytes}");
1000+
Log($"{nameof(info.RecordsPerDocAvg)}: {info.RecordsPerDocAvg}");
1001+
Log($"{nameof(info.BytesPerRecordAvg)}: {info.BytesPerRecordAvg}");
1002+
Log($"{nameof(info.OffsetsPerTermAvg)}: {info.OffsetsPerTermAvg}");
1003+
Log($"{nameof(info.OffsetBitsPerRecordAvg)}: {info.OffsetBitsPerRecordAvg}");
1004+
Log($"{nameof(info.NumberOfUses)}: {info.NumberOfUses}");
1005+
Log($"{nameof(info.GcStats)}.Count: {info.GcStats.Count}");
1006+
Log($"{nameof(info.CursorStats)}.Count: {info.CursorStats.Count}");
1007+
1008+
// Correctness: everything was indexed, with no failures.
10001009
Assert.Equal(0, info.HashIndexingFailures);
10011010
Assert.Equal(0, info.Indexing);
10021011
Assert.Equal(1, info.PercentIndexed);
1003-
Assert.Equal(5, info.NumberOfUses);
1004-
Assert.Equal(7, info.GcStats.Count);
1005-
Assert.Equal(4, info.CursorStats.Count);
10061012
}
10071013
}
10081014

@@ -1060,27 +1066,30 @@ public void AlterAddSortable(string endpointId)
10601066
{
10611067
Assert.Equal(100, info.NumDocs);
10621068

1063-
// these numbers don't make sense when considering a shard
1064-
Assert.NotNull(info.MaxDocId);
1065-
Assert.Equal(102, info.NumTerms);
1066-
Assert.True(info.NumRecords >= 200);
1067-
Assert.True(info.InvertedSzMebibytes < 1); // TODO: check this line and all the <1 lines
1068-
Log($"{nameof(info.VectorIndexSzMebibytes)}: {info.VectorIndexSzMebibytes}"); // version-dependent
1069-
Assert.Equal(208, info.TotalInvertedIndexBlocks);
1070-
Assert.True(info.OffsetVectorsSzMebibytes < 1);
1071-
Assert.True(info.DocTableSizeMebibytes < 1);
1072-
Assert.Equal(0, info.SortableValueSizeMebibytes);
1073-
Assert.True(info.KeyTableSizeMebibytes < 1);
1074-
Assert.Equal(8, (int)info.RecordsPerDocAvg);
1075-
Assert.True(info.BytesPerRecordAvg > 5);
1076-
Assert.True(info.OffsetsPerTermAvg > 0.8);
1077-
Assert.Equal(8, info.OffsetBitsPerRecordAvg);
1069+
// These are internal index statistics whose exact values drift with the
1070+
// RediSearch version and background GC timing; log them rather than assert.
1071+
Log($"{nameof(info.MaxDocId)}: {info.MaxDocId}");
1072+
Log($"{nameof(info.NumTerms)}: {info.NumTerms}");
1073+
Log($"{nameof(info.NumRecords)}: {info.NumRecords}");
1074+
Log($"{nameof(info.InvertedSzMebibytes)}: {info.InvertedSzMebibytes}");
1075+
Log($"{nameof(info.VectorIndexSzMebibytes)}: {info.VectorIndexSzMebibytes}");
1076+
Log($"{nameof(info.TotalInvertedIndexBlocks)}: {info.TotalInvertedIndexBlocks}");
1077+
Log($"{nameof(info.OffsetVectorsSzMebibytes)}: {info.OffsetVectorsSzMebibytes}");
1078+
Log($"{nameof(info.DocTableSizeMebibytes)}: {info.DocTableSizeMebibytes}");
1079+
Log($"{nameof(info.SortableValueSizeMebibytes)}: {info.SortableValueSizeMebibytes}");
1080+
Log($"{nameof(info.KeyTableSizeMebibytes)}: {info.KeyTableSizeMebibytes}");
1081+
Log($"{nameof(info.RecordsPerDocAvg)}: {info.RecordsPerDocAvg}");
1082+
Log($"{nameof(info.BytesPerRecordAvg)}: {info.BytesPerRecordAvg}");
1083+
Log($"{nameof(info.OffsetsPerTermAvg)}: {info.OffsetsPerTermAvg}");
1084+
Log($"{nameof(info.OffsetBitsPerRecordAvg)}: {info.OffsetBitsPerRecordAvg}");
1085+
Log($"{nameof(info.NumberOfUses)}: {info.NumberOfUses}");
1086+
Log($"{nameof(info.GcStats)}.Count: {info.GcStats.Count}");
1087+
Log($"{nameof(info.CursorStats)}.Count: {info.CursorStats.Count}");
1088+
1089+
// Correctness: everything was indexed, with no failures.
10781090
Assert.Equal(0, info.HashIndexingFailures);
10791091
Assert.Equal(0, info.Indexing);
10801092
Assert.Equal(1, info.PercentIndexed);
1081-
Assert.Equal(4, info.NumberOfUses);
1082-
Assert.Equal(7, info.GcStats.Count);
1083-
Assert.Equal(4, info.CursorStats.Count);
10841093
}
10851094
}
10861095

@@ -1172,27 +1181,30 @@ public async Task AlterAddSortableAsync(string endpointId)
11721181
{
11731182
Assert.Equal(100, info.NumDocs);
11741183

1175-
// these numbers don't make sense when considering a shard
1176-
Assert.Equal("300", info.MaxDocId);
1177-
Assert.Equal(102, info.NumTerms);
1178-
Assert.True(info.NumRecords >= 200);
1179-
Assert.True(info.InvertedSzMebibytes < 1); // TODO: check this line and all the <1 lines
1180-
Log($"{nameof(info.VectorIndexSzMebibytes)}: {info.VectorIndexSzMebibytes}"); // version-dependent
1181-
Assert.Equal(208, info.TotalInvertedIndexBlocks);
1182-
Assert.True(info.OffsetVectorsSzMebibytes < 1);
1183-
Assert.True(info.DocTableSizeMebibytes < 1);
1184-
Assert.Equal(0, info.SortableValueSizeMebibytes);
1185-
Assert.True(info.KeyTableSizeMebibytes < 1);
1186-
Assert.Equal(8, (int)info.RecordsPerDocAvg);
1187-
Assert.True(info.BytesPerRecordAvg > 5);
1188-
Assert.True(info.OffsetsPerTermAvg > 0.8);
1189-
Assert.Equal(8, info.OffsetBitsPerRecordAvg);
1184+
// These are internal index statistics whose exact values drift with the
1185+
// RediSearch version and background GC timing; log them rather than assert.
1186+
Log($"{nameof(info.MaxDocId)}: {info.MaxDocId}");
1187+
Log($"{nameof(info.NumTerms)}: {info.NumTerms}");
1188+
Log($"{nameof(info.NumRecords)}: {info.NumRecords}");
1189+
Log($"{nameof(info.InvertedSzMebibytes)}: {info.InvertedSzMebibytes}");
1190+
Log($"{nameof(info.VectorIndexSzMebibytes)}: {info.VectorIndexSzMebibytes}");
1191+
Log($"{nameof(info.TotalInvertedIndexBlocks)}: {info.TotalInvertedIndexBlocks}");
1192+
Log($"{nameof(info.OffsetVectorsSzMebibytes)}: {info.OffsetVectorsSzMebibytes}");
1193+
Log($"{nameof(info.DocTableSizeMebibytes)}: {info.DocTableSizeMebibytes}");
1194+
Log($"{nameof(info.SortableValueSizeMebibytes)}: {info.SortableValueSizeMebibytes}");
1195+
Log($"{nameof(info.KeyTableSizeMebibytes)}: {info.KeyTableSizeMebibytes}");
1196+
Log($"{nameof(info.RecordsPerDocAvg)}: {info.RecordsPerDocAvg}");
1197+
Log($"{nameof(info.BytesPerRecordAvg)}: {info.BytesPerRecordAvg}");
1198+
Log($"{nameof(info.OffsetsPerTermAvg)}: {info.OffsetsPerTermAvg}");
1199+
Log($"{nameof(info.OffsetBitsPerRecordAvg)}: {info.OffsetBitsPerRecordAvg}");
1200+
Log($"{nameof(info.NumberOfUses)}: {info.NumberOfUses}");
1201+
Log($"{nameof(info.GcStats)}.Count: {info.GcStats.Count}");
1202+
Log($"{nameof(info.CursorStats)}.Count: {info.CursorStats.Count}");
1203+
1204+
// Correctness: everything was indexed, with no failures.
11901205
Assert.Equal(0, info.HashIndexingFailures);
11911206
Assert.Equal(0, info.Indexing);
11921207
Assert.Equal(1, info.PercentIndexed);
1193-
Assert.Equal(4, info.NumberOfUses);
1194-
Assert.Equal(7, info.GcStats.Count);
1195-
Assert.Equal(4, info.CursorStats.Count);
11961208
}
11971209
}
11981210

‎tests/dockers/docker-compose.yml‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ services:
1616
- 6666:6666 # TLS port
1717
volumes:
1818
- "./standalone:/redis/work"
19+
healthcheck:
20+
# gate `up --wait` on the server actually accepting commands
21+
test: ["CMD-SHELL", "redis-cli -p 6379 PING | grep -q PONG"]
22+
interval: 1s
23+
timeout: 5s
24+
retries: 30
25+
start_period: 1s
1926
profiles:
2027
- standalone
2128
- all
@@ -36,6 +43,16 @@ services:
3643
- "27379-27384:27379-27384"
3744
volumes:
3845
- "./cluster:/redis/work"
46+
healthcheck:
47+
# gate `up --wait` on the cluster being fully formed (all 16384 slots
48+
# assigned). Without this the container reports "running" while
49+
# redis-cli --cluster create is still assigning slots, so tests connect
50+
# to a half-formed cluster and cache a stale slot map -> spurious -MOVED.
51+
test: ["CMD-SHELL", "redis-cli -p 16379 CLUSTER INFO | grep -q cluster_state:ok"]
52+
interval: 1s
53+
timeout: 5s
54+
retries: 60
55+
start_period: 2s
3956
profiles:
4057
- cluster
4158
- all

0 commit comments

Comments
 (0)