Skip to content

Commit 41f4211

Browse files
committed
Fix test flakiness: use consistent tick counting and ensure placement cache sync
1 parent 7d25279 commit 41f4211

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

test/Extensions/Tester.Cosmos/ReminderTests_Cosmos.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,19 +297,20 @@ public async Task Rem_Azure_GT_Basic()
297297
// Wait for at least 2 ticks for g2, and g1 should have at least 4 by now
298298
await WaitForReminderTickCountAsync(g2, DR, 2, ENDWAIT);
299299

300-
long last1 = await g1.GetCounter(DR);
300+
// Use GetReminderTickCount for consistent counting (not GetCounter which uses time-based sequence numbers)
301+
int last1 = await g1.GetReminderTickCount(DR);
301302
Assert.True(last1 >= 4, $"Expected g1 to have at least 4 ticks, got {last1}");
302-
long last2 = await g2.GetCounter(DR);
303+
int last2 = await g2.GetReminderTickCount(DR);
303304
Assert.True(last2 >= 2, $"Expected g2 to have at least 2 ticks, got {last2}");
304305

305306
await g1.StopReminder(DR);
306307
// Wait for g2 to get at least 4 ticks total (2 more periods)
307308
await WaitForReminderTickCountAsync(g2, DR, 4, ENDWAIT);
308309
await g2.StopReminder(DR);
309310

310-
long curr1 = await g1.GetCounter(DR);
311+
int curr1 = await g1.GetReminderTickCount(DR);
311312
Assert.True(curr1 >= last1 && curr1 <= last1 + 1, $"Expected g1 counter to stay near {last1} after stopping, got {curr1}");
312-
long curr2 = await g2.GetCounter(DR);
313+
int curr2 = await g2.GetReminderTickCount(DR);
313314
Assert.True(curr2 >= 4, $"Expected g2 to have at least 4 ticks, got {curr2}");
314315
}
315316

test/Extensions/TesterAzureUtils/Reminder/ReminderTests_AzureTable.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -299,21 +299,22 @@ public async Task Rem_Azure_GT_Basic()
299299
// Wait for at least 2 ticks for g2
300300
await WaitForReminderTickCountAsync(g2, DR, 2, ENDWAIT);
301301

302-
long last1 = await g1.GetCounter(DR);
302+
// Use GetReminderTickCount for consistent counting (not GetCounter which uses time-based sequence numbers)
303+
int last1 = await g1.GetReminderTickCount(DR);
303304
// g1 has been running while g2 was getting its 2 ticks, so g1 should have at least 3
304305
// (2 initial + roughly 1 more during g2's 2 ticks, given timing variance in real-time tests)
305306
Assert.True(last1 >= 3, $"Expected g1 to have at least 3 ticks, got {last1}");
306-
long last2 = await g2.GetCounter(DR);
307+
int last2 = await g2.GetReminderTickCount(DR);
307308
Assert.True(last2 >= 2, $"Expected g2 to have at least 2 ticks, got {last2}");
308309

309310
await g1.StopReminder(DR);
310311
// Wait for g2 to get at least 4 ticks total (2 more periods)
311312
await WaitForReminderTickCountAsync(g2, DR, 4, ENDWAIT);
312313
await g2.StopReminder(DR);
313314

314-
long curr1 = await g1.GetCounter(DR);
315+
int curr1 = await g1.GetReminderTickCount(DR);
315316
Assert.True(curr1 >= last1 && curr1 <= last1 + 1, $"Expected g1 counter to stay near {last1} after stopping, got {curr1}");
316-
long curr2 = await g2.GetCounter(DR);
317+
int curr2 = await g2.GetReminderTickCount(DR);
317318
Assert.True(curr2 >= 4, $"Expected g2 to have at least 4 ticks, got {curr2}");
318319
}
319320

test/TesterInternal/General/ElasticPlacementTest.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,11 @@ private async Task ElasticityGrainPlacementTest(
310310
var taintedSilo = this.HostedCluster.StartAdditionalSilo();
311311
await this.HostedCluster.WaitForLivenessToStabilizeAsync();
312312

313+
// Ensure all silos have the new silo in their placement statistics cache
314+
// before we taint it. Without this, placement directors may not know about
315+
// the new silo and fail to find candidates.
316+
await ForceStatisticsRefreshOnAllSilos();
317+
313318
const long sampleSize = 10;
314319

315320
var taintedGrain = await GetGrainAtSilo(taintedSilo.SiloAddress);

0 commit comments

Comments
 (0)