summaryrefslogtreecommitdiff
path: root/src/mongo/db/curop_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/curop_test.cpp')
-rw-r--r--src/mongo/db/curop_test.cpp100
1 files changed, 50 insertions, 50 deletions
diff --git a/src/mongo/db/curop_test.cpp b/src/mongo/db/curop_test.cpp
index 0edbde43d31..098ead0674f 100644
--- a/src/mongo/db/curop_test.cpp
+++ b/src/mongo/db/curop_test.cpp
@@ -40,63 +40,63 @@
namespace mongo {
- namespace {
+namespace {
- const long long intervalLong = 2000 * 1000; // 2s in micros
- const long long intervalShort = 10 * 1000; // 10ms in micros
+const long long intervalLong = 2000 * 1000; // 2s in micros
+const long long intervalShort = 10 * 1000; // 10ms in micros
- //
- // Before executing the TimeHasExpired suite, spawn a dummy listener thread to be the
- // process time tracker (the tests rely on Listener::_timeTracker being available).
- //
+//
+// Before executing the TimeHasExpired suite, spawn a dummy listener thread to be the
+// process time tracker (the tests rely on Listener::_timeTracker being available).
+//
- class TestListener : public Listener {
- public:
- TestListener() : Listener("test", "", 0) {} // port 0 => any available high port
- virtual void acceptedMP(MessagingPort *mp) {}
- };
+class TestListener : public Listener {
+public:
+ TestListener() : Listener("test", "", 0) {} // port 0 => any available high port
+ virtual void acceptedMP(MessagingPort* mp) {}
+};
- void timeTrackerSetup() {
- TestListener listener;
- listener.setAsTimeTracker();
- listener.setupSockets();
- listener.initAndListen();
- }
+void timeTrackerSetup() {
+ TestListener listener;
+ listener.setAsTimeTracker();
+ listener.setupSockets();
+ listener.initAndListen();
+}
- MONGO_INITIALIZER(CurOpTest)(InitializerContext* context) {
- stdx::thread t(timeTrackerSetup);
+MONGO_INITIALIZER(CurOpTest)(InitializerContext* context) {
+ stdx::thread t(timeTrackerSetup);
- // Wait for listener thread to start tracking time.
- while (Listener::getElapsedTimeMillis() == 0) {
- sleepmillis(10);
- }
- return Status::OK();
- }
+ // Wait for listener thread to start tracking time.
+ while (Listener::getElapsedTimeMillis() == 0) {
+ sleepmillis(10);
+ }
+ return Status::OK();
+}
- // Long operation + short timeout => time should expire.
- TEST(TimeHasExpired, PosSimple) {
- auto service = stdx::make_unique<ServiceContextNoop>();
- auto client = service->makeClient("CurOpTest");
- OperationContextNoop txn(client.get(), 100);
- CurOp curOp(&txn);
- curOp.setMaxTimeMicros(intervalShort);
- curOp.ensureStarted();
- sleepmicros(intervalLong);
- ASSERT_TRUE(curOp.maxTimeHasExpired());
- }
+// Long operation + short timeout => time should expire.
+TEST(TimeHasExpired, PosSimple) {
+ auto service = stdx::make_unique<ServiceContextNoop>();
+ auto client = service->makeClient("CurOpTest");
+ OperationContextNoop txn(client.get(), 100);
+ CurOp curOp(&txn);
+ curOp.setMaxTimeMicros(intervalShort);
+ curOp.ensureStarted();
+ sleepmicros(intervalLong);
+ ASSERT_TRUE(curOp.maxTimeHasExpired());
+}
- // Short operation + long timeout => time should not expire.
- TEST(TimeHasExpired, NegSimple) {
- auto service = stdx::make_unique<ServiceContextNoop>();
- auto client = service->makeClient("CurOpTest");
- OperationContextNoop txn(client.get(), 100);
- CurOp curOp(&txn);
- curOp.setMaxTimeMicros(intervalLong);
- curOp.ensureStarted();
- sleepmicros(intervalShort);
- ASSERT_FALSE(curOp.maxTimeHasExpired());
- }
+// Short operation + long timeout => time should not expire.
+TEST(TimeHasExpired, NegSimple) {
+ auto service = stdx::make_unique<ServiceContextNoop>();
+ auto client = service->makeClient("CurOpTest");
+ OperationContextNoop txn(client.get(), 100);
+ CurOp curOp(&txn);
+ curOp.setMaxTimeMicros(intervalLong);
+ curOp.ensureStarted();
+ sleepmicros(intervalShort);
+ ASSERT_FALSE(curOp.maxTimeHasExpired());
+}
- } // namespace
+} // namespace
-} // namespace mongo
+} // namespace mongo