diff options
author | Kevin Pulo <kevin.pulo@mongodb.com> | 2020-05-19 14:29:26 +1000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-06-05 12:48:36 +0000 |
commit | 7074dee1fbf6763c0d463c377c2e47d8ef2c4f6f (patch) | |
tree | 80d364f790c795d16b77fb1efa1cc5e3788e1d9c /src/mongo/db/key_generator_update_test.cpp | |
parent | 5072922b32f94857098546366f17c93673154e72 (diff) | |
download | mongo-7074dee1fbf6763c0d463c377c2e47d8ef2c4f6f.tar.gz |
SERVER-47914 Move clusterTime from LogicalClock to VectorClock
Diffstat (limited to 'src/mongo/db/key_generator_update_test.cpp')
-rw-r--r-- | src/mongo/db/key_generator_update_test.cpp | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/src/mongo/db/key_generator_update_test.cpp b/src/mongo/db/key_generator_update_test.cpp index 885d7dfe25b..511c9e493fc 100644 --- a/src/mongo/db/key_generator_update_test.cpp +++ b/src/mongo/db/key_generator_update_test.cpp @@ -37,7 +37,7 @@ #include "mongo/db/key_generator.h" #include "mongo/db/keys_collection_client_sharded.h" #include "mongo/db/keys_collection_document.h" -#include "mongo/db/logical_clock.h" +#include "mongo/db/vector_clock_mutable.h" #include "mongo/s/catalog/dist_lock_manager_mock.h" #include "mongo/s/config_server_test_fixture.h" #include "mongo/unittest/unittest.h" @@ -79,7 +79,8 @@ TEST_F(KeyGeneratorUpdateTest, ShouldCreate2KeysFromEmpty) { KeyGenerator generator("dummy", catalogClient(), Seconds(5)); const LogicalTime currentTime(LogicalTime(Timestamp(100, 2))); - LogicalClock::get(operationContext())->setClusterTimeFromTrustedSource(currentTime); + VectorClockMutable::get(operationContext()) + ->tickTo(VectorClock::Component::ClusterTime, currentTime); auto generateStatus = generator.generateNewKeysIfNeeded(operationContext()); ASSERT_OK(generateStatus); @@ -105,7 +106,8 @@ TEST_F(KeyGeneratorUpdateTest, ShouldPropagateWriteError) { KeyGenerator generator("dummy", catalogClient(), Seconds(5)); const LogicalTime currentTime(LogicalTime(Timestamp(100, 2))); - LogicalClock::get(operationContext())->setClusterTimeFromTrustedSource(currentTime); + VectorClockMutable::get(operationContext()) + ->tickTo(VectorClock::Component::ClusterTime, currentTime); FailPointEnableBlock failWriteBlock("failCollectionInserts"); @@ -116,8 +118,8 @@ TEST_F(KeyGeneratorUpdateTest, ShouldPropagateWriteError) { TEST_F(KeyGeneratorUpdateTest, ShouldCreateAnotherKeyIfOnlyOneKeyExists) { KeyGenerator generator("dummy", catalogClient(), Seconds(5)); - LogicalClock::get(operationContext()) - ->setClusterTimeFromTrustedSource(LogicalTime(Timestamp(100, 2))); + VectorClockMutable::get(operationContext()) + ->tickTo(VectorClock::Component::ClusterTime, LogicalTime(Timestamp(100, 2))); KeysCollectionDocument origKey1( 1, "dummy", TimeProofService::generateRandomKey(), LogicalTime(Timestamp(105, 0))); @@ -135,7 +137,8 @@ TEST_F(KeyGeneratorUpdateTest, ShouldCreateAnotherKeyIfOnlyOneKeyExists) { ASSERT_EQ(Timestamp(105, 0), key1.getExpiresAt().asTimestamp()); } - auto currentTime = LogicalClock::get(operationContext())->getClusterTime(); + auto currentTime = + VectorClock::get(operationContext())->getTime()[VectorClock::Component::ClusterTime]; auto generateStatus = generator.generateNewKeysIfNeeded(operationContext()); ASSERT_OK(generateStatus); @@ -163,8 +166,8 @@ TEST_F(KeyGeneratorUpdateTest, ShouldCreateAnotherKeyIfOnlyOneKeyExists) { TEST_F(KeyGeneratorUpdateTest, ShouldCreateAnotherKeyIfNoValidKeyAfterCurrent) { KeyGenerator generator("dummy", catalogClient(), Seconds(5)); - LogicalClock::get(operationContext()) - ->setClusterTimeFromTrustedSource(LogicalTime(Timestamp(108, 2))); + VectorClockMutable::get(operationContext()) + ->tickTo(VectorClock::Component::ClusterTime, LogicalTime(Timestamp(108, 2))); KeysCollectionDocument origKey1( 1, "dummy", TimeProofService::generateRandomKey(), LogicalTime(Timestamp(105, 0))); @@ -192,7 +195,8 @@ TEST_F(KeyGeneratorUpdateTest, ShouldCreateAnotherKeyIfNoValidKeyAfterCurrent) { ASSERT_EQ(Timestamp(110, 0), key2.getExpiresAt().asTimestamp()); } - auto currentTime = LogicalClock::get(operationContext())->getClusterTime(); + auto currentTime = + VectorClock::get(operationContext())->getTime()[VectorClock::Component::ClusterTime]; auto generateStatus = generator.generateNewKeysIfNeeded(operationContext()); ASSERT_OK(generateStatus); @@ -246,8 +250,8 @@ TEST_F(KeyGeneratorUpdateTest, ShouldCreateAnotherKeyIfNoValidKeyAfterCurrent) { TEST_F(KeyGeneratorUpdateTest, ShouldCreate2KeysIfAllKeysAreExpired) { KeyGenerator generator("dummy", catalogClient(), Seconds(5)); - LogicalClock::get(operationContext()) - ->setClusterTimeFromTrustedSource(LogicalTime(Timestamp(120, 2))); + VectorClockMutable::get(operationContext()) + ->tickTo(VectorClock::Component::ClusterTime, LogicalTime(Timestamp(120, 2))); KeysCollectionDocument origKey1( 1, "dummy", TimeProofService::generateRandomKey(), LogicalTime(Timestamp(105, 0))); @@ -275,7 +279,8 @@ TEST_F(KeyGeneratorUpdateTest, ShouldCreate2KeysIfAllKeysAreExpired) { ASSERT_EQ(Timestamp(110, 0), key2.getExpiresAt().asTimestamp()); } - auto currentTime = LogicalClock::get(operationContext())->getClusterTime(); + auto currentTime = + VectorClock::get(operationContext())->getTime()[VectorClock::Component::ClusterTime]; auto generateStatus = generator.generateNewKeysIfNeeded(operationContext()); ASSERT_OK(generateStatus); @@ -344,7 +349,8 @@ TEST_F(KeyGeneratorUpdateTest, ShouldNotCreateNewKeyIfThereAre2UnexpiredKeys) { KeyGenerator generator("dummy", catalogClient(), Seconds(5)); const LogicalTime currentTime(LogicalTime(Timestamp(100, 2))); - LogicalClock::get(operationContext())->setClusterTimeFromTrustedSource(currentTime); + VectorClockMutable::get(operationContext()) + ->tickTo(VectorClock::Component::ClusterTime, currentTime); KeysCollectionDocument origKey1( 1, "dummy", TimeProofService::generateRandomKey(), LogicalTime(Timestamp(105, 0))); @@ -403,7 +409,8 @@ TEST_F(KeyGeneratorUpdateTest, ShouldNotCreateKeysWithDisableKeyGenerationFailPo KeyGenerator generator("dummy", catalogClient(), Seconds(5)); const LogicalTime currentTime(LogicalTime(Timestamp(100, 0))); - LogicalClock::get(operationContext())->setClusterTimeFromTrustedSource(currentTime); + VectorClockMutable::get(operationContext()) + ->tickTo(VectorClock::Component::ClusterTime, currentTime); { FailPointEnableBlock failKeyGenerationBlock("disableKeyGeneration"); |