Skip to content

Commit 81a25db

Browse files
Jimmy Lufacebook-github-bot
Jimmy Lu
authored andcommitted
Make test InsertRetryRemoveOther less flaky
Summary: The SingleMockThreadScheduler has a background thread that runs jobs. So it's possible for our assertion on number of jobs done to be racy and fail the test. The changes now will explicitly wait until all jobs have completed in the scheduler before checking, which eliminates the race. Reviewed By: haowu14 Differential Revision: D47580097 fbshipit-source-id: adc3474d384e9fc3755371c584d3f665305a279e
1 parent 86ae8aa commit 81a25db

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

cachelib/navy/driver/tests/DriverTest.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,12 +466,18 @@ TEST(Driver, InsertRetryRemoveOther) {
466466
auto driver = std::make_unique<Driver>(std::move(config));
467467

468468
EXPECT_EQ(Status::Ok, driver->insert(makeHK("key"), largeValue.view()));
469+
470+
// Flush the scheduler first
471+
exPtr->finish();
469472
EXPECT_EQ(exPtr->getRescheduleCount(), 0);
470473
EXPECT_EQ(exPtr->getDoneCount(), 1);
471474

472475
// The returned status code is Ok because it's not rejected by admission test.
473476
// Under the hood, the schedule went through one reschedule and one succeed.
474477
EXPECT_EQ(Status::Ok, driver->insert(makeHK("key"), smallValue.view()));
478+
479+
// Flush the scheduler first
480+
exPtr->finish();
475481
EXPECT_EQ(exPtr->getRescheduleCount(), 1);
476482
EXPECT_EQ(exPtr->getDoneCount(), 2);
477483

0 commit comments

Comments
 (0)