diff options
Diffstat (limited to 'src/mongo/db/repl/replication_executor_test_fixture.h')
-rw-r--r-- | src/mongo/db/repl/replication_executor_test_fixture.h | 123 |
1 files changed, 63 insertions, 60 deletions
diff --git a/src/mongo/db/repl/replication_executor_test_fixture.h b/src/mongo/db/repl/replication_executor_test_fixture.h index a6fec40ebd2..e89dd99ecb6 100644 --- a/src/mongo/db/repl/replication_executor_test_fixture.h +++ b/src/mongo/db/repl/replication_executor_test_fixture.h @@ -34,73 +34,76 @@ namespace mongo { namespace executor { - class NetworkInterfaceMock; -} // namespace executor +class NetworkInterfaceMock; +} // namespace executor namespace repl { - using std::unique_ptr; +using std::unique_ptr; - class ReplicationExecutor; - class StorageInterfaceMock; +class ReplicationExecutor; +class StorageInterfaceMock; + +/** + * Test fixture for tests that require a ReplicationExecutor backed by + * a NetworkInterfaceMock. + */ +class ReplicationExecutorTest : public unittest::Test { +public: + /** + * Creates an initial error status suitable for checking if + * component has modified the 'status' field in test fixture. + */ + static Status getDetectableErrorStatus(); + +protected: + executor::NetworkInterfaceMock* getNet() { + return _net; + } + ReplicationExecutor& getExecutor() { + return *_executor; + } + /** + * Runs ReplicationExecutor in background. + */ + void launchExecutorThread(); + + /** + * Anything that needs to be done after launchExecutorThread should go in here. + */ + virtual void postExecutorThreadLaunch(); /** - * Test fixture for tests that require a ReplicationExecutor backed by - * a NetworkInterfaceMock. + * Waits for background ReplicationExecutor to stop running. + * + * The executor should be shutdown prior to calling this function + * or the test may block indefinitely. */ - class ReplicationExecutorTest : public unittest::Test { - public: - - /** - * Creates an initial error status suitable for checking if - * component has modified the 'status' field in test fixture. - */ - static Status getDetectableErrorStatus(); - - protected: - executor::NetworkInterfaceMock* getNet() { return _net; } - ReplicationExecutor& getExecutor() { return *_executor; } - /** - * Runs ReplicationExecutor in background. - */ - void launchExecutorThread(); - - /** - * Anything that needs to be done after launchExecutorThread should go in here. - */ - virtual void postExecutorThreadLaunch(); - - /** - * Waits for background ReplicationExecutor to stop running. - * - * The executor should be shutdown prior to calling this function - * or the test may block indefinitely. - */ - void joinExecutorThread(); - - /** - * Initializes both the NetworkInterfaceMock and ReplicationExecutor but - * does not run the executor in the background. - * - * To run the executor in the background, tests should invoke launchExecutorThread() or - * override this function() to achieve the same effect. - */ - void setUp() override; - - /** - * Destroys the replication executor. - * - * Shuts down running background executor. - */ - void tearDown() override; - - - private: - executor::NetworkInterfaceMock* _net; - StorageInterfaceMock* _storage; - unique_ptr<ReplicationExecutor> _executor; - unique_ptr<stdx::thread> _executorThread; - }; + void joinExecutorThread(); + + /** + * Initializes both the NetworkInterfaceMock and ReplicationExecutor but + * does not run the executor in the background. + * + * To run the executor in the background, tests should invoke launchExecutorThread() or + * override this function() to achieve the same effect. + */ + void setUp() override; + + /** + * Destroys the replication executor. + * + * Shuts down running background executor. + */ + void tearDown() override; + + +private: + executor::NetworkInterfaceMock* _net; + StorageInterfaceMock* _storage; + unique_ptr<ReplicationExecutor> _executor; + unique_ptr<stdx::thread> _executorThread; +}; } // namespace repl } // namespace mongo |