summaryrefslogtreecommitdiff
path: root/src/mongo/s/cluster_identity_loader_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/s/cluster_identity_loader_test.cpp')
-rw-r--r--src/mongo/s/cluster_identity_loader_test.cpp58
1 files changed, 33 insertions, 25 deletions
diff --git a/src/mongo/s/cluster_identity_loader_test.cpp b/src/mongo/s/cluster_identity_loader_test.cpp
index 363bb33ceb3..1a06260d134 100644
--- a/src/mongo/s/cluster_identity_loader_test.cpp
+++ b/src/mongo/s/cluster_identity_loader_test.cpp
@@ -104,9 +104,10 @@ TEST_F(ClusterIdentityTest, BasicLoadSuccess) {
// The first time you ask for the cluster ID it will have to be loaded from the config servers.
auto future = launchAsync([&] {
- auto clusterIdStatus =
- ClusterIdentityLoader::get(operationContext())
- ->loadClusterId(operationContext(), repl::ReadConcernLevel::kMajorityReadConcern);
+ auto clusterIdStatus = ClusterIdentityLoader::get(operationContext())
+ ->loadClusterId(operationContext(),
+ catalogClient(),
+ repl::ReadConcernLevel::kMajorityReadConcern);
ASSERT_OK(clusterIdStatus);
ASSERT_EQUALS(clusterId, ClusterIdentityLoader::get(operationContext())->getClusterId());
});
@@ -117,18 +118,20 @@ TEST_F(ClusterIdentityTest, BasicLoadSuccess) {
// Subsequent requests for the cluster ID should not require any network traffic as we consult
// the cached version.
- ASSERT_OK(
- ClusterIdentityLoader::get(operationContext())
- ->loadClusterId(operationContext(), repl::ReadConcernLevel::kMajorityReadConcern));
+ ASSERT_OK(ClusterIdentityLoader::get(operationContext())
+ ->loadClusterId(operationContext(),
+ catalogClient(),
+ repl::ReadConcernLevel::kMajorityReadConcern));
}
TEST_F(ClusterIdentityTest, NoConfigVersionDocument) {
// If no version document is found on config server loadClusterId will return an error
auto future = launchAsync([&] {
- ASSERT_EQ(
- ClusterIdentityLoader::get(operationContext())
- ->loadClusterId(operationContext(), repl::ReadConcernLevel::kMajorityReadConcern),
- ErrorCodes::NoMatchingDocument);
+ ASSERT_EQ(ClusterIdentityLoader::get(operationContext())
+ ->loadClusterId(operationContext(),
+ catalogClient(),
+ repl::ReadConcernLevel::kMajorityReadConcern),
+ ErrorCodes::NoMatchingDocument);
});
expectConfigVersionLoad(
@@ -141,23 +144,26 @@ TEST_F(ClusterIdentityTest, MultipleThreadsLoadingSuccess) {
// Check that multiple threads calling getClusterId at once still results in only one network
// operation.
auto future1 = launchAsync([&] {
- auto clusterIdStatus =
- ClusterIdentityLoader::get(operationContext())
- ->loadClusterId(operationContext(), repl::ReadConcernLevel::kMajorityReadConcern);
+ auto clusterIdStatus = ClusterIdentityLoader::get(operationContext())
+ ->loadClusterId(operationContext(),
+ catalogClient(),
+ repl::ReadConcernLevel::kMajorityReadConcern);
ASSERT_OK(clusterIdStatus);
ASSERT_EQUALS(clusterId, ClusterIdentityLoader::get(operationContext())->getClusterId());
});
auto future2 = launchAsync([&] {
- auto clusterIdStatus =
- ClusterIdentityLoader::get(operationContext())
- ->loadClusterId(operationContext(), repl::ReadConcernLevel::kMajorityReadConcern);
+ auto clusterIdStatus = ClusterIdentityLoader::get(operationContext())
+ ->loadClusterId(operationContext(),
+ catalogClient(),
+ repl::ReadConcernLevel::kMajorityReadConcern);
ASSERT_OK(clusterIdStatus);
ASSERT_EQUALS(clusterId, ClusterIdentityLoader::get(operationContext())->getClusterId());
});
auto future3 = launchAsync([&] {
- auto clusterIdStatus =
- ClusterIdentityLoader::get(operationContext())
- ->loadClusterId(operationContext(), repl::ReadConcernLevel::kMajorityReadConcern);
+ auto clusterIdStatus = ClusterIdentityLoader::get(operationContext())
+ ->loadClusterId(operationContext(),
+ catalogClient(),
+ repl::ReadConcernLevel::kMajorityReadConcern);
ASSERT_OK(clusterIdStatus);
ASSERT_EQUALS(clusterId, ClusterIdentityLoader::get(operationContext())->getClusterId());
});
@@ -173,9 +179,10 @@ TEST_F(ClusterIdentityTest, BasicLoadFailureFollowedBySuccess) {
// The first time you ask for the cluster ID it will have to be loaded from the config servers.
auto future = launchAsync([&] {
- auto clusterIdStatus =
- ClusterIdentityLoader::get(operationContext())
- ->loadClusterId(operationContext(), repl::ReadConcernLevel::kMajorityReadConcern);
+ auto clusterIdStatus = ClusterIdentityLoader::get(operationContext())
+ ->loadClusterId(operationContext(),
+ catalogClient(),
+ repl::ReadConcernLevel::kMajorityReadConcern);
ASSERT_EQUALS(ErrorCodes::Interrupted, clusterIdStatus);
});
@@ -186,9 +193,10 @@ TEST_F(ClusterIdentityTest, BasicLoadFailureFollowedBySuccess) {
// After a failure to load the cluster ID, subsequent attempts to get the cluster ID should
// retry loading it.
future = launchAsync([&] {
- auto clusterIdStatus =
- ClusterIdentityLoader::get(operationContext())
- ->loadClusterId(operationContext(), repl::ReadConcernLevel::kMajorityReadConcern);
+ auto clusterIdStatus = ClusterIdentityLoader::get(operationContext())
+ ->loadClusterId(operationContext(),
+ catalogClient(),
+ repl::ReadConcernLevel::kMajorityReadConcern);
ASSERT_OK(clusterIdStatus);
ASSERT_EQUALS(clusterId, ClusterIdentityLoader::get(operationContext())->getClusterId());
});