summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Carey <jcarey@argv.me>2018-08-17 11:52:40 -0400
committerJason Carey <jcarey@argv.me>2018-08-28 15:52:47 -0400
commit5321f4b168cb70fc03711f42b9f58c34935ff101 (patch)
tree62cfc887502d597b3a5b602df39d838b158565e4
parent529b7e260862c8748212f1158764b4a93f967eda (diff)
downloadmongo-5321f4b168cb70fc03711f42b9f58c34935ff101.tar.gz
SERVER-36725 force periodic_runner_impl_test to call tearDown
The periodic_runner_impl_test holds references to stack allocated condvars in every one of its tests. All of them have a chance to data race (destruction and job invocation, or the end of job invocation). Manually calling tearDown in all cases fixes those races
-rw-r--r--src/mongo/util/periodic_runner_impl_test.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/mongo/util/periodic_runner_impl_test.cpp b/src/mongo/util/periodic_runner_impl_test.cpp
index 583825d21e4..8e341f8e5b6 100644
--- a/src/mongo/util/periodic_runner_impl_test.cpp
+++ b/src/mongo/util/periodic_runner_impl_test.cpp
@@ -103,6 +103,8 @@ TEST_F(PeriodicRunnerImplTest, OneJobTest) {
cv.wait(lk, [&count, &i] { return count > i; });
}
}
+
+ tearDown();
}
TEST_F(PeriodicRunnerImplTest, OnePausableJobDoesNotRunWithoutStart) {
@@ -126,6 +128,8 @@ TEST_F(PeriodicRunnerImplTest, OnePausableJobDoesNotRunWithoutStart) {
auto handle = runner().makeJob(std::move(job));
clockSource().advance(interval);
ASSERT_EQ(count, 0);
+
+ tearDown();
}
TEST_F(PeriodicRunnerImplTest, OnePausableJobRunsCorrectlyWithStart) {
@@ -156,6 +160,8 @@ TEST_F(PeriodicRunnerImplTest, OnePausableJobRunsCorrectlyWithStart) {
cv.wait(lk, [&count, &i] { return count > i; });
}
}
+
+ tearDown();
}
TEST_F(PeriodicRunnerImplTest, OnePausableJobPausesCorrectly) {
@@ -193,6 +199,8 @@ TEST_F(PeriodicRunnerImplTest, OnePausableJobPausesCorrectly) {
clockSource().advance(interval);
}
ASSERT_TRUE(count == numExecutionsBeforePause || count == numExecutionsBeforePause + 1);
+
+ tearDown();
}
TEST_F(PeriodicRunnerImplTest, OnePausableJobResumesCorrectly) {
@@ -245,6 +253,8 @@ TEST_F(PeriodicRunnerImplTest, OnePausableJobResumesCorrectly) {
// This is slightly racy so once in a while count will be one extra
ASSERT_TRUE(count == numFastForwardsForIterationWhileActive * 2 ||
count == numFastForwardsForIterationWhileActive * 2 + 1);
+
+ tearDown();
}
TEST_F(PeriodicRunnerImplTestNoSetup, ScheduleBeforeStartupTest) {
@@ -274,6 +284,8 @@ TEST_F(PeriodicRunnerImplTestNoSetup, ScheduleBeforeStartupTest) {
stdx::unique_lock<stdx::mutex> lk(mutex);
cv.wait(lk, [&count] { return count > 0; });
+
+ tearDown();
}
TEST_F(PeriodicRunnerImplTest, TwoJobsTest) {
@@ -317,6 +329,7 @@ TEST_F(PeriodicRunnerImplTest, TwoJobsTest) {
cv.wait(lk, [&countA, &countB, &i] { return (countA > i && countB >= i / 2); });
}
}
+
tearDown();
}