diff options
author | Dianna Hohensee <dianna.hohensee@10gen.com> | 2016-10-12 17:41:07 -0400 |
---|---|---|
committer | Dianna Hohensee <dianna.hohensee@10gen.com> | 2016-10-17 13:33:40 -0400 |
commit | 9447aa349ef2f3ef140e61b6cfb53d032c1c021f (patch) | |
tree | fd9c953f98348c33cfadf91d96e630028d2d243f /src | |
parent | 26cb6b14f4a2ab445293e3503f53e32c19e0dd53 (diff) | |
download | mongo-9447aa349ef2f3ef140e61b6cfb53d032c1c021f.tar.gz |
SERVER-25758 unit test DistLockCatalogImpl::unlock by name
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/s/catalog/dist_lock_catalog_impl_test.cpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/mongo/s/catalog/dist_lock_catalog_impl_test.cpp b/src/mongo/s/catalog/dist_lock_catalog_impl_test.cpp index ff9430efb96..8130c7d168e 100644 --- a/src/mongo/s/catalog/dist_lock_catalog_impl_test.cpp +++ b/src/mongo/s/catalog/dist_lock_catalog_impl_test.cpp @@ -898,6 +898,40 @@ TEST_F(DistLockCatalogFixture, BasicUnlock) { future.timed_get(kFutureTimeout); } +TEST_F(DistLockCatalogFixture, BasicUnlockWithName) { + auto future = launchAsync([this] { + auto status = distLockCatalog()->unlock( + operationContext(), OID("555f99712c99a78c5b083358"), "TestDB.TestColl"); + ASSERT_OK(status); + }); + + onCommand([](const RemoteCommandRequest& request) -> StatusWith<BSONObj> { + ASSERT_EQUALS(dummyHost, request.target); + ASSERT_EQUALS("config", request.dbname); + + BSONObj expectedCmd(fromjson(R"({ + findAndModify: "locks", + query: { ts: ObjectId("555f99712c99a78c5b083358"), _id: "TestDB.TestColl" }, + update: { $set: { state: 0 }}, + writeConcern: { w: "majority", wtimeout: 15000 }, + maxTimeMS: 30000 + })")); + + ASSERT_BSONOBJ_EQ(expectedCmd, request.cmdObj); + + return fromjson(R"({ + ok: 1, + value: { + _id: "TestDB.TestColl", + ts: ObjectId("555f99712c99a78c5b083358"), + state: 0 + } + })"); + }); + + future.timed_get(kFutureTimeout); +} + TEST_F(DistLockCatalogFixture, UnlockWithNoNewDoc) { auto future = launchAsync([this] { auto status = @@ -928,6 +962,36 @@ TEST_F(DistLockCatalogFixture, UnlockWithNoNewDoc) { future.timed_get(kFutureTimeout); } +TEST_F(DistLockCatalogFixture, UnlockWithNameWithNoNewDoc) { + auto future = launchAsync([this] { + auto status = distLockCatalog()->unlock( + operationContext(), OID("555f99712c99a78c5b083358"), "TestDB.TestColl"); + ASSERT_OK(status); + }); + + onCommand([](const RemoteCommandRequest& request) -> StatusWith<BSONObj> { + ASSERT_EQUALS(dummyHost, request.target); + ASSERT_EQUALS("config", request.dbname); + + BSONObj expectedCmd(fromjson(R"({ + findAndModify: "locks", + query: { ts: ObjectId("555f99712c99a78c5b083358"), _id: "TestDB.TestColl" }, + update: { $set: { state: 0 }}, + writeConcern: { w: "majority", wtimeout: 15000 }, + maxTimeMS: 30000 + })")); + + ASSERT_BSONOBJ_EQ(expectedCmd, request.cmdObj); + + return fromjson(R"({ + ok: 1, + value: null + })"); + }); + + future.timed_get(kFutureTimeout); +} + TEST_F(DistLockCatalogFixture, UnlockTargetError) { configTargeter()->setFindHostReturnValue({ErrorCodes::InternalError, "can't target"}); auto status = distLockCatalog()->unlock(operationContext(), OID()); |