summaryrefslogtreecommitdiff
path: root/src/mongo/executor
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2017-03-09 14:50:59 -0500
committerBenety Goh <benety@mongodb.com>2017-03-23 16:00:31 -0400
commitc1964e817459a575a64609229a473d57d08aa4d0 (patch)
tree83d079215cfc9010f99ef381e7a3c7d8b9b11db3 /src/mongo/executor
parent41d56f108e341c88fe26632084d6140ea75813c0 (diff)
downloadmongo-c1964e817459a575a64609229a473d57d08aa4d0.tar.gz
SERVER-28204 added RollbackTest fixture
Diffstat (limited to 'src/mongo/executor')
-rw-r--r--src/mongo/executor/task_executor_test_fixture.cpp5
-rw-r--r--src/mongo/executor/task_executor_test_fixture.h11
-rw-r--r--src/mongo/executor/thread_pool_task_executor_test_fixture.cpp7
-rw-r--r--src/mongo/executor/thread_pool_task_executor_test_fixture.h16
4 files changed, 37 insertions, 2 deletions
diff --git a/src/mongo/executor/task_executor_test_fixture.cpp b/src/mongo/executor/task_executor_test_fixture.cpp
index bc99e1538fa..a97c3559e7e 100644
--- a/src/mongo/executor/task_executor_test_fixture.cpp
+++ b/src/mongo/executor/task_executor_test_fixture.cpp
@@ -34,6 +34,7 @@
#include "mongo/executor/network_interface_mock.h"
#include "mongo/executor/remote_command_request.h"
#include "mongo/stdx/memory.h"
+#include "mongo/util/assert_util.h"
#include "mongo/util/mongoutils/str.h"
namespace mongo {
@@ -100,6 +101,10 @@ void TaskExecutorTest::joinExecutorThread() {
_executorState = LifecycleState::kShutdownComplete;
}
+void TaskExecutorTest::_doTest() {
+ MONGO_UNREACHABLE;
+}
+
void TaskExecutorTest::postExecutorThreadLaunch() {}
} // namespace executor
diff --git a/src/mongo/executor/task_executor_test_fixture.h b/src/mongo/executor/task_executor_test_fixture.h
index d89b6e0062d..e90cbaec413 100644
--- a/src/mongo/executor/task_executor_test_fixture.h
+++ b/src/mongo/executor/task_executor_test_fixture.h
@@ -59,7 +59,6 @@ public:
static RemoteCommandRequest assertRemoteCommandNameEquals(StringData cmdName,
const RemoteCommandRequest& request);
-protected:
virtual ~TaskExecutorTest();
executor::NetworkInterfaceMock* getNet() {
@@ -86,6 +85,16 @@ protected:
void joinExecutorThread();
private:
+ /**
+ * Unused implementation of test function. This allows us to instantiate
+ * TaskExecutorTest on its own without the need to inherit from it in a test.
+ * This supports using TaskExecutorTest inside another test fixture and works around the
+ * limitation that tests cannot inherit from multiple test fixtures.
+ *
+ * It is an error to call this implementation of _doTest() directly.
+ */
+ void _doTest() override;
+
virtual std::unique_ptr<TaskExecutor> makeTaskExecutor(
std::unique_ptr<NetworkInterfaceMock> net) = 0;
diff --git a/src/mongo/executor/thread_pool_task_executor_test_fixture.cpp b/src/mongo/executor/thread_pool_task_executor_test_fixture.cpp
index 4973363707d..ebd0ea6dbbe 100644
--- a/src/mongo/executor/thread_pool_task_executor_test_fixture.cpp
+++ b/src/mongo/executor/thread_pool_task_executor_test_fixture.cpp
@@ -43,8 +43,13 @@ std::unique_ptr<ThreadPoolTaskExecutor> makeThreadPoolTestExecutor(
stdx::make_unique<ThreadPoolMock>(netPtr, 1, std::move(options)), std::move(net));
}
+ThreadPoolExecutorTest::ThreadPoolExecutorTest() {}
+
+ThreadPoolExecutorTest::ThreadPoolExecutorTest(ThreadPoolMock::Options options)
+ : _options(std::move(options)) {}
+
ThreadPoolMock::Options ThreadPoolExecutorTest::makeThreadPoolMockOptions() const {
- return ThreadPoolMock::Options();
+ return _options;
}
std::unique_ptr<TaskExecutor> ThreadPoolExecutorTest::makeTaskExecutor(
diff --git a/src/mongo/executor/thread_pool_task_executor_test_fixture.h b/src/mongo/executor/thread_pool_task_executor_test_fixture.h
index 31444809758..ebe2d77d23f 100644
--- a/src/mongo/executor/thread_pool_task_executor_test_fixture.h
+++ b/src/mongo/executor/thread_pool_task_executor_test_fixture.h
@@ -49,10 +49,26 @@ std::unique_ptr<ThreadPoolTaskExecutor> makeThreadPoolTestExecutor(
* Useful fixture class for tests that use a ThreadPoolTaskExecutor.
*/
class ThreadPoolExecutorTest : public TaskExecutorTest {
+public:
+ /**
+ * This default constructor supports the use of this class as a base class for a test fixture.
+ */
+ ThreadPoolExecutorTest();
+
+ /**
+ * This constructor supports the use of this class as a member variable to be used alongside
+ * another test fixture. Accepts a ThreadPoolMock::Options that will be used to override the
+ * result of makeThreadPoolMockOptions().
+ */
+ explicit ThreadPoolExecutorTest(ThreadPoolMock::Options options);
+
private:
virtual ThreadPoolMock::Options makeThreadPoolMockOptions() const;
std::unique_ptr<TaskExecutor> makeTaskExecutor(
std::unique_ptr<NetworkInterfaceMock> net) override;
+
+ // Returned by makeThreadPoolMockOptions().
+ const ThreadPoolMock::Options _options = {};
};
} // namespace executor