diff options
author | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2018-07-30 15:22:26 -0400 |
---|---|---|
committer | Kaloian Manassiev <kaloian.manassiev@mongodb.com> | 2018-08-13 17:49:02 -0400 |
commit | 200c3dc58410d8b3287a2075cc9b2ad085100e83 (patch) | |
tree | 6025b0042d610f3040b65c6c58cba45825122ca1 /src/mongo/db/s/split_chunk_test.cpp | |
parent | 55ca9666a9f40ab480f399f4ed9d915bf55925ef (diff) | |
download | mongo-200c3dc58410d8b3287a2075cc9b2ad085100e83.tar.gz |
SERVER-29908 Move all runtime logic out of ShardingState
... and move it into a ShardingInitializationMongoD class, which is
responsible for driving the sharding-awareness of the node and setting
it onto ShardingState.
Also gets rid of the 'sharding' library, so there is no more library
dependency cycle.
Diffstat (limited to 'src/mongo/db/s/split_chunk_test.cpp')
-rw-r--r-- | src/mongo/db/s/split_chunk_test.cpp | 54 |
1 files changed, 3 insertions, 51 deletions
diff --git a/src/mongo/db/s/split_chunk_test.cpp b/src/mongo/db/s/split_chunk_test.cpp index 45430b5272e..8258e3472fc 100644 --- a/src/mongo/db/s/split_chunk_test.cpp +++ b/src/mongo/db/s/split_chunk_test.cpp @@ -31,11 +31,10 @@ #include <boost/optional.hpp> -#include "mongo/db/s/split_chunk.h" - #include "mongo/client/remote_command_targeter_mock.h" #include "mongo/db/json.h" -#include "mongo/db/s/sharding_state.h" +#include "mongo/db/s/sharding_initialization_mongod.h" +#include "mongo/db/s/split_chunk.h" #include "mongo/db/server_options.h" #include "mongo/executor/network_interface_mock.h" #include "mongo/executor/remote_command_request.h" @@ -66,6 +65,7 @@ public: void setUp() override { ShardServerTestFixture::setUp(); + ShardingState::get(operationContext())->setInitialized(_shardId, OID::gen()); CatalogCacheLoader::get(getServiceContext()).initializeReplicaSetRole(true); // Instantiate names. @@ -210,7 +210,6 @@ void SplitChunkTest::emptyResponse() { } TEST_F(SplitChunkTest, HashedKeyPatternNumberLongSplitKeys) { - BSONObj keyPatternObj = BSON("foo" << "hashed"); _coll.setKeyPattern(BSON("_id" @@ -222,9 +221,6 @@ TEST_F(SplitChunkTest, HashedKeyPatternNumberLongSplitKeys) { validSplitKeys.push_back(BSON("foo" << i)); } - // Force-set the sharding state to enabled with the _shardId, for testing purposes. - ShardingState::get(operationContext())->setEnabledForTest(_shardId.toString()); - expectLock(); // Call the splitChunk function asynchronously on a different thread, so that we do not block, @@ -260,7 +256,6 @@ TEST_F(SplitChunkTest, HashedKeyPatternNumberLongSplitKeys) { } TEST_F(SplitChunkTest, HashedKeyPatternIntegerSplitKeys) { - BSONObj keyPatternObj = BSON("foo" << "hashed"); _coll.setKeyPattern(BSON("_id" @@ -271,9 +266,6 @@ TEST_F(SplitChunkTest, HashedKeyPatternIntegerSplitKeys) { std::vector<BSONObj> invalidSplitKeys{ BSON("foo" << -1), BSON("foo" << 0), BSON("foo" << 1), BSON("foo" << 42)}; - // Force-set the sharding state to enabled with the _shardId, for testing purposes. - ShardingState::get(operationContext())->setEnabledForTest(_shardId.toString()); - expectLock(); // Call the splitChunk function asynchronously on a different thread, so that we do not block, @@ -302,7 +294,6 @@ TEST_F(SplitChunkTest, HashedKeyPatternIntegerSplitKeys) { } TEST_F(SplitChunkTest, HashedKeyPatternDoubleSplitKeys) { - BSONObj keyPatternObj = BSON("foo" << "hashed"); _coll.setKeyPattern(BSON("_id" @@ -313,9 +304,6 @@ TEST_F(SplitChunkTest, HashedKeyPatternDoubleSplitKeys) { std::vector<BSONObj> invalidSplitKeys{ BSON("foo" << 47.21230129), BSON("foo" << 1.0), BSON("foo" << 0.0), BSON("foo" << -0.001)}; - // Force-set the sharding state to enabled with the _shardId, for testing purposes. - ShardingState::get(operationContext())->setEnabledForTest(_shardId.toString()); - expectLock(); // Call the splitChunk function asynchronously on a different thread, so that we do not block, @@ -344,7 +332,6 @@ TEST_F(SplitChunkTest, HashedKeyPatternDoubleSplitKeys) { } TEST_F(SplitChunkTest, HashedKeyPatternStringSplitKeys) { - BSONObj keyPatternObj = BSON("foo" << "hashed"); _coll.setKeyPattern(BSON("_id" @@ -361,9 +348,6 @@ TEST_F(SplitChunkTest, HashedKeyPatternStringSplitKeys) { BSON("foo" << "")}; - // Force-set the sharding state to enabled with the _shardId, for testing purposes. - ShardingState::get(operationContext())->setEnabledForTest(_shardId.toString()); - expectLock(); // Call the splitChunk function asynchronously on a different thread, so that we do not block, @@ -392,7 +376,6 @@ TEST_F(SplitChunkTest, HashedKeyPatternStringSplitKeys) { } TEST_F(SplitChunkTest, ValidRangeKeyPatternSplitKeys) { - BSONObj keyPatternObj = BSON("foo" << 1); // Build a vector of valid split keys, which contains values that may not necessarily be able @@ -406,9 +389,6 @@ TEST_F(SplitChunkTest, ValidRangeKeyPatternSplitKeys) { << ""), BSON("foo" << 3.1415926535)}; - // Force-set the sharding state to enabled with the _shardId, for testing purposes. - ShardingState::get(operationContext())->setEnabledForTest(_shardId.toString()); - expectLock(); // Call the splitChunk function asynchronously on a different thread, so that we do not block, @@ -444,7 +424,6 @@ TEST_F(SplitChunkTest, ValidRangeKeyPatternSplitKeys) { } TEST_F(SplitChunkTest, SplitChunkWithNoErrors) { - BSONObj keyPatternObj = BSON("foo" << 1); // Build a vector of split keys. Note that we start at {"foo" : 256} and end at {"foo" : 768}, @@ -454,9 +433,6 @@ TEST_F(SplitChunkTest, SplitChunkWithNoErrors) { splitKeys.push_back(BSON("foo" << i)); } - // Force-set the sharding state to enabled with the _shardId, for testing purposes. - ShardingState::get(operationContext())->setEnabledForTest(_shardId.toString()); - expectLock(); // Call the splitChunk function asynchronously on a different thread, so that we do not block, @@ -509,7 +485,6 @@ TEST_F(SplitChunkTest, SplitChunkWithNoErrors) { } TEST_F(SplitChunkTest, AttemptSplitWithConfigsvrError) { - BSONObj keyPatternObj = BSON("foo" << 1); // Build a vector of split keys. Note that we start at {"foo" : 0} and end at {"foo" : 1024}, @@ -519,9 +494,6 @@ TEST_F(SplitChunkTest, AttemptSplitWithConfigsvrError) { splitKeys.push_back(BSON("foo" << i)); } - // Force-set the sharding state to enabled with the _shardId, for testing purposes. - ShardingState::get(operationContext())->setEnabledForTest(_shardId.toString()); - expectLock(); // Call the splitChunk function asynchronously on a different thread, so that we do not block, @@ -557,7 +529,6 @@ TEST_F(SplitChunkTest, AttemptSplitWithConfigsvrError) { } TEST_F(SplitChunkTest, AttemptSplitOnNoDatabases) { - BSONObj keyPatternObj = BSON("foo" << 1); // Build a vector of split keys. Note that we start at {"foo" : 256} and end at {"foo" : 768}, @@ -567,9 +538,6 @@ TEST_F(SplitChunkTest, AttemptSplitOnNoDatabases) { splitKeys.push_back(BSON("foo" << i)); } - // Force-set the sharding state to enabled with the _shardId, for testing purposes. - ShardingState::get(operationContext())->setEnabledForTest(_shardId.toString()); - expectLock(); // Call the splitChunk function asynchronously on a different thread, so that we do not block, @@ -595,7 +563,6 @@ TEST_F(SplitChunkTest, AttemptSplitOnNoDatabases) { } TEST_F(SplitChunkTest, AttemptSplitOnNoCollections) { - BSONObj keyPatternObj = BSON("foo" << 1); // Build a vector of split keys. Note that we start at {"foo" : 256} and end at {"foo" : 768}, @@ -605,9 +572,6 @@ TEST_F(SplitChunkTest, AttemptSplitOnNoCollections) { splitKeys.push_back(BSON("foo" << i)); } - // Force-set the sharding state to enabled with the _shardId, for testing purposes. - ShardingState::get(operationContext())->setEnabledForTest(_shardId.toString()); - expectLock(); // Call the splitChunk function asynchronously on a different thread, so that we do not block, @@ -636,7 +600,6 @@ TEST_F(SplitChunkTest, AttemptSplitOnNoCollections) { } TEST_F(SplitChunkTest, AttemptSplitOnNoChunks) { - BSONObj keyPatternObj = BSON("foo" << 1); // Build a vector of split keys. Note that we start at {"foo" : 256} and end at {"foo" : 768}, @@ -646,9 +609,6 @@ TEST_F(SplitChunkTest, AttemptSplitOnNoChunks) { splitKeys.push_back(BSON("foo" << i)); } - // Force-set the sharding state to enabled with the _shardId, for testing purposes. - ShardingState::get(operationContext())->setEnabledForTest(_shardId.toString()); - expectLock(); // Call the splitChunk function asynchronously on a different thread, so that we do not block, @@ -683,7 +643,6 @@ TEST_F(SplitChunkTest, AttemptSplitOnNoChunks) { } TEST_F(SplitChunkTest, NoCollectionAfterSplit) { - BSONObj keyPatternObj = BSON("foo" << 1); // Build a vector of split keys. Note that we start at {"foo" : 256} and end at {"foo" : 768}, @@ -693,9 +652,6 @@ TEST_F(SplitChunkTest, NoCollectionAfterSplit) { splitKeys.push_back(BSON("foo" << i)); } - // Force-set the sharding state to enabled with the _shardId, for testing purposes. - ShardingState::get(operationContext())->setEnabledForTest(_shardId.toString()); - expectLock(); // Call the splitChunk function asynchronously on a different thread, so that we do not block, @@ -731,7 +687,6 @@ TEST_F(SplitChunkTest, NoCollectionAfterSplit) { } TEST_F(SplitChunkTest, NoChunksAfterSplit) { - BSONObj keyPatternObj = BSON("foo" << 1); // Build a vector of split keys. Note that we start at {"foo" : 256} and end at {"foo" : 768}, @@ -741,9 +696,6 @@ TEST_F(SplitChunkTest, NoChunksAfterSplit) { splitKeys.push_back(BSON("foo" << i)); } - // Force-set the sharding state to enabled with the _shardId, for testing purposes. - ShardingState::get(operationContext())->setEnabledForTest(_shardId.toString()); - expectLock(); // Call the splitChunk function asynchronously on a different thread, so that we do not block, |