diff options
Diffstat (limited to 'src/mongo/db/s/sharding_initialization_mongod_test.cpp')
-rw-r--r-- | src/mongo/db/s/sharding_initialization_mongod_test.cpp | 84 |
1 files changed, 47 insertions, 37 deletions
diff --git a/src/mongo/db/s/sharding_initialization_mongod_test.cpp b/src/mongo/db/s/sharding_initialization_mongod_test.cpp index ab2bffb2ff7..da9d238f92a 100644 --- a/src/mongo/db/s/sharding_initialization_mongod_test.cpp +++ b/src/mongo/db/s/sharding_initialization_mongod_test.cpp @@ -94,7 +94,7 @@ protected: _dbDirectClient.reset(); // Restore the defaults before calling tearDown - storageGlobalParams.readOnly = false; + storageGlobalParams.queryableBackupMode = false; serverGlobalParams.overrideShardIdentity = BSONObj(); CatalogCacheLoader::clearForTests(getServiceContext()); @@ -271,14 +271,15 @@ TEST_F(ShardingInitializationMongoDTest, InitializeAgainWithMatchingReplSetNameS } // The tests below check for different combinations of the compatible startup parameters for -// --shardsvr, --overrideShardIdentity, and queryableBackup (readOnly) mode +// --shardsvr, --overrideShardIdentity, and queryableBackup mode /** - * readOnly and --shardsvr + * queryableBackupMode and --shardsvr */ -TEST_F(ShardingInitializationMongoDTest, - InitializeShardingAwarenessIfNeededReadOnlyAndShardServerAndNoOverrideShardIdentity) { - storageGlobalParams.readOnly = true; +TEST_F( + ShardingInitializationMongoDTest, + InitializeShardingAwarenessIfNeededQueryableBackupModeAndShardServerAndNoOverrideShardIdentity) { + storageGlobalParams.queryableBackupMode = true; ASSERT_THROWS_CODE( shardingInitialization()->initializeShardingAwarenessIfNeeded(operationContext()), @@ -286,9 +287,10 @@ TEST_F(ShardingInitializationMongoDTest, ErrorCodes::InvalidOptions); } -TEST_F(ShardingInitializationMongoDTest, - InitializeShardingAwarenessIfNeededReadOnlyAndShardServerAndInvalidOverrideShardIdentity) { - storageGlobalParams.readOnly = true; +TEST_F( + ShardingInitializationMongoDTest, + InitializeShardingAwarenessIfNeededQueryableBackupModeAndShardServerAndInvalidOverrideShardIdentity) { + storageGlobalParams.queryableBackupMode = true; serverGlobalParams.overrideShardIdentity = BSON("_id" << "shardIdentity" << ShardIdentity::kShardNameFieldName << kShardName @@ -301,9 +303,10 @@ TEST_F(ShardingInitializationMongoDTest, ErrorCodes::UnsupportedFormat); } -TEST_F(ShardingInitializationMongoDTest, - InitializeShardingAwarenessIfNeededReadOnlyAndShardServerAndValidOverrideShardIdentity) { - storageGlobalParams.readOnly = true; +TEST_F( + ShardingInitializationMongoDTest, + InitializeShardingAwarenessIfNeededQueryableBackupModeAndShardServerAndValidOverrideShardIdentity) { + storageGlobalParams.queryableBackupMode = true; serverGlobalParams.clusterRole = ClusterRole::ShardServer; serverGlobalParams.overrideShardIdentity = [] { ShardIdentityType shardIdentity; @@ -319,11 +322,12 @@ TEST_F(ShardingInitializationMongoDTest, } /** - * readOnly and not --shardsvr + * queryableBackupMode and not --shardsvr */ -TEST_F(ShardingInitializationMongoDTest, - InitializeShardingAwarenessIfNeededReadOnlyAndNotShardServerAndNoOverrideShardIdentity) { - storageGlobalParams.readOnly = true; +TEST_F( + ShardingInitializationMongoDTest, + InitializeShardingAwarenessIfNeededQueryableBackupModeAndNotShardServerAndNoOverrideShardIdentity) { + storageGlobalParams.queryableBackupMode = true; serverGlobalParams.clusterRole = ClusterRole::None; ASSERT(!shardingInitialization()->initializeShardingAwarenessIfNeeded(operationContext())); @@ -331,8 +335,8 @@ TEST_F(ShardingInitializationMongoDTest, TEST_F( ShardingInitializationMongoDTest, - InitializeShardingAwarenessIfNeededReadOnlyAndNotShardServerAndInvalidOverrideShardIdentity) { - storageGlobalParams.readOnly = true; + InitializeShardingAwarenessIfNeededQueryableBackupModeAndNotShardServerAndInvalidOverrideShardIdentity) { + storageGlobalParams.queryableBackupMode = true; serverGlobalParams.clusterRole = ClusterRole::None; serverGlobalParams.overrideShardIdentity = BSON("_id" << "shardIdentity" @@ -345,9 +349,10 @@ TEST_F( ErrorCodes::InvalidOptions); } -TEST_F(ShardingInitializationMongoDTest, - InitializeShardingAwarenessIfNeededReadOnlyAndNotShardServerAndValidOverrideShardIdentity) { - storageGlobalParams.readOnly = true; +TEST_F( + ShardingInitializationMongoDTest, + InitializeShardingAwarenessIfNeededQueryableBackupModeAndNotShardServerAndValidOverrideShardIdentity) { + storageGlobalParams.queryableBackupMode = true; serverGlobalParams.clusterRole = ClusterRole::None; serverGlobalParams.overrideShardIdentity = [] { ShardIdentityType shardIdentity; @@ -366,10 +371,10 @@ TEST_F(ShardingInitializationMongoDTest, } /** - * not readOnly and --overrideShardIdentity + * not queryableBackupMode and --overrideShardIdentity */ TEST_F(ShardingInitializationMongoDTest, - InitializeShardingAwarenessIfNeededNotReadOnlyAndInvalidOverrideShardIdentity) { + InitializeShardingAwarenessIfNeededNotQueryableBackupModeAndInvalidOverrideShardIdentity) { serverGlobalParams.clusterRole = ClusterRole::ShardServer; serverGlobalParams.overrideShardIdentity = BSON("_id" << "shardIdentity" @@ -390,7 +395,7 @@ TEST_F(ShardingInitializationMongoDTest, } TEST_F(ShardingInitializationMongoDTest, - InitializeShardingAwarenessIfNeededNotReadOnlyAndValidOverrideShardIdentity) { + InitializeShardingAwarenessIfNeededNotQueryableBackupModeAndValidOverrideShardIdentity) { serverGlobalParams.clusterRole = ClusterRole::ShardServer; serverGlobalParams.overrideShardIdentity = [] { ShardIdentityType shardIdentity; @@ -416,15 +421,16 @@ TEST_F(ShardingInitializationMongoDTest, } /** - * not readOnly and --shardsvr + * not queryableBackupMode and --shardsvr */ TEST_F(ShardingInitializationMongoDTest, - InitializeShardingAwarenessIfNeededNotReadOnlyAndShardServerAndNoShardIdentity) { + InitializeShardingAwarenessIfNeededNotQueryableBackupModeAndShardServerAndNoShardIdentity) { ASSERT(!shardingInitialization()->initializeShardingAwarenessIfNeeded(operationContext())); } -TEST_F(ShardingInitializationMongoDTest, - InitializeShardingAwarenessIfNeededNotReadOnlyAndShardServerAndInvalidShardIdentity) { +TEST_F( + ShardingInitializationMongoDTest, + InitializeShardingAwarenessIfNeededNotQueryableBackupModeAndShardServerAndInvalidShardIdentity) { // Insert the shardIdentity doc to disk while pretending that we are in "standalone" mode, // otherwise OpObserver for inserts will prevent the insert from occurring because the // shardIdentity doc is invalid @@ -448,8 +454,9 @@ TEST_F(ShardingInitializationMongoDTest, ErrorCodes::UnsupportedFormat); } -TEST_F(ShardingInitializationMongoDTest, - InitializeShardingAwarenessIfNeededNotReadOnlyAndShardServerAndValidShardIdentity) { +TEST_F( + ShardingInitializationMongoDTest, + InitializeShardingAwarenessIfNeededNotQueryableBackupModeAndShardServerAndValidShardIdentity) { // Insert the shardIdentity doc to disk while pretending that we are in "standalone" mode, // otherwise OpObserver for inserts will prevent the insert from occurring because the // shardIdentity doc is invalid @@ -474,17 +481,19 @@ TEST_F(ShardingInitializationMongoDTest, } /** - * not readOnly and not --shardsvr + * not queryableBackupMode and not --shardsvr */ -TEST_F(ShardingInitializationMongoDTest, - InitializeShardingAwarenessIfNeededNotReadOnlyAndNotShardServerAndNoShardIdentity) { +TEST_F( + ShardingInitializationMongoDTest, + InitializeShardingAwarenessIfNeededNotQueryableBackupModeAndNotShardServerAndNoShardIdentity) { ScopedSetStandaloneMode standalone(getServiceContext()); ASSERT(!shardingInitialization()->initializeShardingAwarenessIfNeeded(operationContext())); } -TEST_F(ShardingInitializationMongoDTest, - InitializeShardingAwarenessIfNeededNotReadOnlyAndNotShardServerAndInvalidShardIdentity) { +TEST_F( + ShardingInitializationMongoDTest, + InitializeShardingAwarenessIfNeededNotQueryableBackupModeAndNotShardServerAndInvalidShardIdentity) { ScopedSetStandaloneMode standalone(getServiceContext()); _dbDirectClient->insert(NamespaceString::kServerConfigurationNamespace.toString(), @@ -498,8 +507,9 @@ TEST_F(ShardingInitializationMongoDTest, ASSERT(!shardingInitialization()->initializeShardingAwarenessIfNeeded(operationContext())); } -TEST_F(ShardingInitializationMongoDTest, - InitializeShardingAwarenessIfNeededNotReadOnlyAndNotShardServerAndValidShardIdentity) { +TEST_F( + ShardingInitializationMongoDTest, + InitializeShardingAwarenessIfNeededNotQueryableBackupModeAndNotShardServerAndValidShardIdentity) { ScopedSetStandaloneMode standalone(getServiceContext()); BSONObj validShardIdentity = [&] { |