summaryrefslogtreecommitdiff
path: root/src/mongo/db/repl/oplog_applier_impl_test_fixture.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/repl/oplog_applier_impl_test_fixture.cpp')
-rw-r--r--src/mongo/db/repl/oplog_applier_impl_test_fixture.cpp36
1 files changed, 32 insertions, 4 deletions
diff --git a/src/mongo/db/repl/oplog_applier_impl_test_fixture.cpp b/src/mongo/db/repl/oplog_applier_impl_test_fixture.cpp
index 35f06edd12e..4afe05e7bc5 100644
--- a/src/mongo/db/repl/oplog_applier_impl_test_fixture.cpp
+++ b/src/mongo/db/repl/oplog_applier_impl_test_fixture.cpp
@@ -32,6 +32,8 @@
#include "mongo/db/repl/oplog_applier_impl_test_fixture.h"
#include "mongo/db/catalog/document_validation.h"
+#include "mongo/db/catalog/health_log.h"
+#include "mongo/db/catalog/health_log_interface.h"
#include "mongo/db/concurrency/exception_util.h"
#include "mongo/db/curop.h"
#include "mongo/db/db_raii.h"
@@ -182,14 +184,22 @@ void OplogApplierImplTest::setUp() {
// This is necessary to generate ghost timestamps for index builds that are not 0, since 0 is an
// invalid timestamp.
VectorClockMutable::get(_opCtx.get())->tickClusterTimeTo(LogicalTime(Timestamp(1, 0)));
+
+ HealthLogInterface::set(serviceContext, std::make_unique<HealthLog>());
+ HealthLogInterface::get(serviceContext)->startup();
}
void OplogApplierImplTest::tearDown() {
+ HealthLogInterface::get(serviceContext)->shutdown();
_opCtx.reset();
_consistencyMarkers = {};
DropPendingCollectionReaper::set(serviceContext, {});
StorageInterface::set(serviceContext, {});
ServiceContextMongoDTest::tearDown();
+
+ for (auto serverParamController : _serverParamControllers) {
+ serverParamController.reset();
+ }
}
ReplicationConsistencyMarkers* OplogApplierImplTest::getConsistencyMarkers() const {
@@ -213,7 +223,10 @@ Status OplogApplierImplTest::_applyOplogEntryOrGroupedInsertsWrapper(
}
void OplogApplierImplTest::_testApplyOplogEntryOrGroupedInsertsCrudOperation(
- ErrorCodes::Error expectedError, const OplogEntry& op, bool expectedApplyOpCalled) {
+ ErrorCodes::Error expectedError,
+ const OplogEntry& op,
+ const NamespaceString& targetNss,
+ bool expectedApplyOpCalled) {
bool applyOpCalled = false;
auto checkOpCtx = [](OperationContext* opCtx) {
@@ -228,9 +241,14 @@ void OplogApplierImplTest::_testApplyOplogEntryOrGroupedInsertsCrudOperation(
_opObserver->onInsertsFn =
[&](OperationContext* opCtx, const NamespaceString& nss, const std::vector<BSONObj>& docs) {
+ // Other threads may be calling into the opObserver. Only assert if we are writing to
+ // the target ns, otherwise skip these asserts.
+ if (targetNss != nss) {
+ return Status::OK();
+ }
+
applyOpCalled = true;
checkOpCtx(opCtx);
- ASSERT_EQUALS(NamespaceString("test.t"), nss);
ASSERT_EQUALS(1U, docs.size());
// For upserts we don't know the intended value of the document.
if (op.getOpType() == repl::OpTypeEnum::kInsert) {
@@ -244,18 +262,28 @@ void OplogApplierImplTest::_testApplyOplogEntryOrGroupedInsertsCrudOperation(
const boost::optional<UUID>& uuid,
StmtId stmtId,
const OplogDeleteEntryArgs& args) {
+ // Other threads may be calling into the opObserver. Only assert if we are writing to
+ // the target ns, otherwise skip these asserts.
+ if (targetNss != nss) {
+ return Status::OK();
+ }
+
applyOpCalled = true;
checkOpCtx(opCtx);
- ASSERT_EQUALS(NamespaceString("test.t"), nss);
ASSERT(args.deletedDoc);
ASSERT_BSONOBJ_EQ(op.getObject(), *(args.deletedDoc));
return Status::OK();
};
_opObserver->onUpdateFn = [&](OperationContext* opCtx, const OplogUpdateEntryArgs& args) {
+ // Other threads may be calling into the opObserver. Only assert if we are writing to
+ // the target ns, otherwise skip these asserts.
+ if (targetNss != args.nss) {
+ return Status::OK();
+ }
+
applyOpCalled = true;
checkOpCtx(opCtx);
- ASSERT_EQUALS(NamespaceString("test.t"), args.nss);
return Status::OK();
};