diff options
author | ali-mir <ali.mir@mongodb.com> | 2021-10-06 23:36:31 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-10-07 00:03:01 +0000 |
commit | 2c98afa8b441f2917b9b019458805d5b7bd3f174 (patch) | |
tree | ee1736543f96b48e67b19ae3f8eb17a71e182039 | |
parent | 9b77b2447deea6ffbeba320b89969ece04efe20d (diff) | |
download | mongo-2c98afa8b441f2917b9b019458805d5b7bd3f174.tar.gz |
SERVER-57827 Allow putSingleton override in storage_interface_mock.h and maintain initial sync id in replication_consistency_markers_mock.h
-rw-r--r-- | src/mongo/db/repl/replication_consistency_markers_mock.cpp | 12 | ||||
-rw-r--r-- | src/mongo/db/repl/replication_consistency_markers_mock.h | 1 | ||||
-rw-r--r-- | src/mongo/db/repl/storage_interface_mock.h | 8 |
3 files changed, 17 insertions, 4 deletions
diff --git a/src/mongo/db/repl/replication_consistency_markers_mock.cpp b/src/mongo/db/repl/replication_consistency_markers_mock.cpp index 875c47f9e3d..b2b843e8c74 100644 --- a/src/mongo/db/repl/replication_consistency_markers_mock.cpp +++ b/src/mongo/db/repl/replication_consistency_markers_mock.cpp @@ -135,12 +135,18 @@ Status ReplicationConsistencyMarkersMock::createInternalCollections(OperationCon return Status::OK(); } -void ReplicationConsistencyMarkersMock::setInitialSyncIdIfNotSet(OperationContext* opCtx) {} +void ReplicationConsistencyMarkersMock::setInitialSyncIdIfNotSet(OperationContext* opCtx) { + if (_initialSyncId.isEmpty()) { + _initialSyncId = UUID::gen().toBSON(); + } +} -void ReplicationConsistencyMarkersMock::clearInitialSyncId(OperationContext* opCtx) {} +void ReplicationConsistencyMarkersMock::clearInitialSyncId(OperationContext* opCtx) { + _initialSyncId = BSONObj(); +} BSONObj ReplicationConsistencyMarkersMock::getInitialSyncId(OperationContext* opCtx) { - return BSONObj(); + return _initialSyncId; } } // namespace repl diff --git a/src/mongo/db/repl/replication_consistency_markers_mock.h b/src/mongo/db/repl/replication_consistency_markers_mock.h index a925e014d93..7330fecbea6 100644 --- a/src/mongo/db/repl/replication_consistency_markers_mock.h +++ b/src/mongo/db/repl/replication_consistency_markers_mock.h @@ -97,6 +97,7 @@ private: OpTime _appliedThrough; OpTime _minValid; Timestamp _oplogTruncateAfterPoint; + BSONObj _initialSyncId; }; } // namespace repl diff --git a/src/mongo/db/repl/storage_interface_mock.h b/src/mongo/db/repl/storage_interface_mock.h index 03416512bb9..97b0a312584 100644 --- a/src/mongo/db/repl/storage_interface_mock.h +++ b/src/mongo/db/repl/storage_interface_mock.h @@ -125,6 +125,8 @@ public: const BSONObj&, BoundInclusion, std::size_t)>; + using PutSingletonFn = + std::function<Status(OperationContext*, const NamespaceString&, const TimestampedBSONObj&)>; using IsAdminDbValidFn = std::function<Status(OperationContext*)>; using GetCollectionUUIDFn = std::function<StatusWith<UUID>(OperationContext*, const NamespaceString&)>; @@ -240,7 +242,7 @@ public: Status putSingleton(OperationContext* opCtx, const NamespaceString& nss, const TimestampedBSONObj& update) override { - return Status{ErrorCodes::IllegalOperation, "putSingleton not implemented."}; + return putSingletonFn(opCtx, nss, update); } Status updateSingleton(OperationContext* opCtx, @@ -427,6 +429,10 @@ public: std::size_t limit) { return Status{ErrorCodes::IllegalOperation, "DeleteOneFn not implemented."}; }; + PutSingletonFn putSingletonFn = + [](OperationContext* opCtx, const NamespaceString& nss, const TimestampedBSONObj& update) { + return Status{ErrorCodes::IllegalOperation, "PutSingletonFn not implemented."}; + }; IsAdminDbValidFn isAdminDbValidFn = [](OperationContext*) { return Status{ErrorCodes::IllegalOperation, "IsAdminDbValidFn not implemented."}; }; |