Skip to content

Commit 72407cc

Browse files
authored
Attempting to reduce flakiness of Z*WithExpiredAndExpiringItems tests (#1492)
1 parent b4b656e commit 72407cc

1 file changed

Lines changed: 26 additions & 26 deletions

File tree

test/Garnet.test/RespSortedSetTests.cs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ public void CanGetScoresZCountWithMinHigherThanMaxScore()
543543
}
544544

545545
[Test]
546-
public async Task ZCountAndZCardWithExpiredAndExpiringItems()
546+
public void ZCountAndZCardWithExpiredAndExpiringItems()
547547
{
548548
using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig());
549549
var db = redis.GetDatabase(0);
@@ -558,7 +558,7 @@ public async Task ZCountAndZCardWithExpiredAndExpiringItems()
558558
// Set expiration for the minimum, maximum and middle items
559559
db.Execute("ZPEXPIRE", "key1", "200", "MEMBERS", "3", "a", "e", "c");
560560

561-
await Task.Delay(300);
561+
Thread.Sleep(300);
562562

563563
// ZCARD
564564
var count = db.SortedSetLength("key1");
@@ -2395,7 +2395,7 @@ public void CanDoSortedSetExpireWithAofRecovery()
23952395
}
23962396

23972397
[Test]
2398-
public async Task ZDiffWithExpiredAndExpiringItems()
2398+
public void ZDiffWithExpiredAndExpiringItems()
23992399
{
24002400
using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig());
24012401
var db = redis.GetDatabase(0);
@@ -2418,7 +2418,7 @@ public async Task ZDiffWithExpiredAndExpiringItems()
24182418
// Set expiration for matching items in key2
24192419
db.Execute("ZPEXPIRE", "key2", "200", "MEMBERS", "1", "a");
24202420

2421-
await Task.Delay(300);
2421+
Thread.Sleep(300);
24222422

24232423
// Perform ZDIFF
24242424
var diff = db.SortedSetCombine(SetOperation.Difference, ["key1", "key2"]);
@@ -2432,7 +2432,7 @@ public async Task ZDiffWithExpiredAndExpiringItems()
24322432
ClassicAssert.AreEqual("e", diffWithScores[1].Element.ToString());
24332433
ClassicAssert.AreEqual(5, diffWithScores[1].Score);
24342434

2435-
await Task.Delay(300);
2435+
Thread.Sleep(300);
24362436

24372437
// Perform ZDIFF again after more items have expired
24382438
diff = db.SortedSetCombine(SetOperation.Difference, ["key1", "key2"]);
@@ -2446,7 +2446,7 @@ public async Task ZDiffWithExpiredAndExpiringItems()
24462446
}
24472447

24482448
[Test]
2449-
public async Task ZDiffStoreWithExpiredAndExpiringItems()
2449+
public void ZDiffStoreWithExpiredAndExpiringItems()
24502450
{
24512451
using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig());
24522452
var db = redis.GetDatabase(0);
@@ -2469,7 +2469,7 @@ public async Task ZDiffStoreWithExpiredAndExpiringItems()
24692469
// Set expiration for matching items in key2
24702470
db.Execute("ZPEXPIRE", "key2", "200", "MEMBERS", "1", "a");
24712471

2472-
await Task.Delay(300);
2472+
Thread.Sleep(300);
24732473

24742474
// Perform ZDIFFSTORE
24752475
var diffStoreCount = db.SortedSetCombineAndStore(SetOperation.Difference, "key3", ["key1", "key2"]);
@@ -2483,7 +2483,7 @@ public async Task ZDiffStoreWithExpiredAndExpiringItems()
24832483
ClassicAssert.AreEqual("e", diffStoreResult[1].Element.ToString());
24842484
ClassicAssert.AreEqual(5, diffStoreResult[1].Score);
24852485

2486-
await Task.Delay(300);
2486+
Thread.Sleep(300);
24872487

24882488
// Perform ZDIFFSTORE again after more items have expired
24892489
diffStoreCount = db.SortedSetCombineAndStore(SetOperation.Difference, "key3", ["key1", "key2"]);
@@ -2497,7 +2497,7 @@ public async Task ZDiffStoreWithExpiredAndExpiringItems()
24972497
}
24982498

24992499
[Test]
2500-
public async Task ZIncrByWithExpiringAndExpiredItems()
2500+
public void ZIncrByWithExpiredAndExpiringItems()
25012501
{
25022502
using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig());
25032503
var db = redis.GetDatabase(0);
@@ -2510,7 +2510,7 @@ public async Task ZIncrByWithExpiringAndExpiredItems()
25102510
// Set expiration for some items in key1
25112511
db.Execute("ZPEXPIRE", "key1", "200", "MEMBERS", "1", "a");
25122512

2513-
await Task.Delay(10);
2513+
Thread.Sleep(10);
25142514

25152515
// Try to increment the score of an expiring item
25162516
var newScore = db.SortedSetIncrement("key1", "a", 5);
@@ -2521,7 +2521,7 @@ public async Task ZIncrByWithExpiringAndExpiredItems()
25212521
ClassicAssert.LessOrEqual((long)ttl, 200);
25222522
ClassicAssert.Greater((long)ttl, 0);
25232523

2524-
await Task.Delay(200);
2524+
Thread.Sleep(200);
25252525

25262526
// Check the item has expired
25272527
ttl = db.Execute("ZPTTL", "key1", "MEMBERS", "1", "a");
@@ -2537,7 +2537,7 @@ public async Task ZIncrByWithExpiringAndExpiredItems()
25372537
}
25382538

25392539
[Test]
2540-
public async Task ZInterWithExpiredAndExpiringItems()
2540+
public void ZInterWithExpiredAndExpiringItems()
25412541
{
25422542
using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig());
25432543
var db = redis.GetDatabase(0);
@@ -2560,21 +2560,21 @@ public async Task ZInterWithExpiredAndExpiringItems()
25602560
var inter = db.SortedSetCombine(SetOperation.Intersect, ["key1", "key2"]);
25612561
ClassicAssert.AreEqual(3, inter.Length);
25622562

2563-
await Task.Delay(300);
2563+
Thread.Sleep(300);
25642564

25652565
var interWithScores = db.SortedSetCombineWithScores(SetOperation.Intersect, ["key1", "key2"]);
25662566
ClassicAssert.AreEqual(1, interWithScores.Length); // Only "b" should remain
25672567
ClassicAssert.AreEqual("b", interWithScores[0].Element.ToString());
25682568
ClassicAssert.AreEqual(4, interWithScores[0].Score); // Sum of scores
25692569

2570-
await Task.Delay(300);
2570+
Thread.Sleep(300);
25712571

25722572
inter = db.SortedSetCombine(SetOperation.Intersect, ["key1", "key2"]);
25732573
ClassicAssert.AreEqual(0, inter.Length);
25742574
}
25752575

25762576
[Test]
2577-
public async Task ZInterCardWithExpiredAndExpiringItems()
2577+
public void ZInterCardWithExpiredAndExpiringItems()
25782578
{
25792579
using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig());
25802580
var db = redis.GetDatabase(0);
@@ -2593,19 +2593,19 @@ public async Task ZInterCardWithExpiredAndExpiringItems()
25932593
db.Execute("ZPEXPIRE", "key1", "500", "MEMBERS", "1", "b");
25942594
db.Execute("ZPEXPIRE", "key2", "200", "MEMBERS", "1", "a");
25952595

2596-
await Task.Delay(300);
2596+
Thread.Sleep(300);
25972597

25982598
var interCardCount = (long)db.Execute("ZINTERCARD", "2", "key1", "key2");
25992599
ClassicAssert.AreEqual(1, interCardCount); // Only "b" should remain
26002600

2601-
await Task.Delay(300);
2601+
Thread.Sleep(300);
26022602

26032603
interCardCount = (long)db.Execute("ZINTERCARD", "2", "key1", "key2");
26042604
ClassicAssert.AreEqual(0, interCardCount); // No items should remain
26052605
}
26062606

26072607
[Test]
2608-
public async Task ZInterStoreWithExpiredAndExpiringItems()
2608+
public void ZInterStoreWithExpiredAndExpiringItems()
26092609
{
26102610
using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig());
26112611
var db = redis.GetDatabase(0);
@@ -2624,7 +2624,7 @@ public async Task ZInterStoreWithExpiredAndExpiringItems()
26242624
db.Execute("ZPEXPIRE", "key1", "500", "MEMBERS", "1", "b");
26252625
db.Execute("ZPEXPIRE", "key2", "200", "MEMBERS", "1", "a");
26262626

2627-
await Task.Delay(300);
2627+
Thread.Sleep(300);
26282628

26292629
var interStoreCount = db.SortedSetCombineAndStore(SetOperation.Intersect, "key3", ["key1", "key2"]);
26302630
ClassicAssert.AreEqual(1, interStoreCount); // Only "b" should remain
@@ -2634,7 +2634,7 @@ public async Task ZInterStoreWithExpiredAndExpiringItems()
26342634
ClassicAssert.AreEqual("b", interStoreResult[0].Element.ToString());
26352635
ClassicAssert.AreEqual(4, interStoreResult[0].Score); // Sum of scores
26362636

2637-
await Task.Delay(300);
2637+
Thread.Sleep(300);
26382638

26392639
interStoreCount = db.SortedSetCombineAndStore(SetOperation.Intersect, "key3", ["key1", "key2"]);
26402640
ClassicAssert.AreEqual(0, interStoreCount); // No items should remain
@@ -2644,7 +2644,7 @@ public async Task ZInterStoreWithExpiredAndExpiringItems()
26442644
}
26452645

26462646
[Test]
2647-
public async Task ZLexCountWithExpiredAndExpiringItems()
2647+
public void ZLexCountWithExpiredAndExpiringItems()
26482648
{
26492649
using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig());
26502650
var db = redis.GetDatabase(0);
@@ -2658,15 +2658,15 @@ public async Task ZLexCountWithExpiredAndExpiringItems()
26582658
db.Execute("ZPEXPIRE", "key1", "200", "MEMBERS", "3", "a", "e", "c");
26592659
db.Execute("ZPEXPIRE", "key1", "500", "MEMBERS", "1", "b");
26602660

2661-
await Task.Delay(300);
2661+
Thread.Sleep(300);
26622662

26632663
var lexCount = (int)db.Execute("ZLEXCOUNT", "key1", "-", "+"); // SortedSetLengthByValue will check - and + to [- and [+
26642664
ClassicAssert.AreEqual(2, lexCount); // Only "b" and "d" should remain
26652665

26662666
var lexCountRange = db.SortedSetLengthByValue("key1", "b", "d", Exclude.Stop);
26672667
ClassicAssert.AreEqual(1, lexCountRange); // Only "b" should remain within the range
26682668

2669-
await Task.Delay(300);
2669+
Thread.Sleep(300);
26702670

26712671
lexCount = (int)db.Execute("ZLEXCOUNT", "key1", "-", "+");
26722672
ClassicAssert.AreEqual(1, lexCount); // Only "d" should remain
@@ -3293,7 +3293,7 @@ public async Task ZScanWithExpiredItems()
32933293
}
32943294

32953295
[Test]
3296-
public async Task ZScoreWithExpiringAndExpiredItems()
3296+
public void ZScoreWithExpiredAndExpiringItems()
32973297
{
32983298
using var redis = ConnectionMultiplexer.Connect(TestUtils.GetConfig());
32993299
var db = redis.GetDatabase(0);
@@ -3306,7 +3306,7 @@ public async Task ZScoreWithExpiringAndExpiredItems()
33063306
// Set expiration for some items in key1
33073307
db.Execute("ZPEXPIRE", "key1", "200", "MEMBERS", "1", "a");
33083308

3309-
await Task.Delay(10);
3309+
Thread.Sleep(10);
33103310

33113311
// Check the score of an expiring item
33123312
var score = db.SortedSetScore("key1", "a");
@@ -3317,7 +3317,7 @@ public async Task ZScoreWithExpiringAndExpiredItems()
33173317
ClassicAssert.LessOrEqual((long)ttl, 200);
33183318
ClassicAssert.Greater((long)ttl, 0);
33193319

3320-
await Task.Delay(200);
3320+
Thread.Sleep(200);
33213321

33223322
// Check the item has expired
33233323
ttl = db.Execute("ZPTTL", "key1", "MEMBERS", "1", "a");

0 commit comments

Comments
 (0)