summaryrefslogtreecommitdiff
path: root/src/mongo/db/s/resharding/resharding_metrics_test.cpp
diff options
context:
space:
mode:
authorMatt Boros <matt.boros@mongodb.com>2021-12-16 21:14:31 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-12-16 21:56:38 +0000
commitaf124a52fdc593418c4146b76c0c55f732739d16 (patch)
treeea0f241b7e200a65595372889a7173273a175ed8 /src/mongo/db/s/resharding/resharding_metrics_test.cpp
parent298f70be324278def91cd5350a358cf3405146bc (diff)
downloadmongo-af124a52fdc593418c4146b76c0c55f732739d16.tar.gz
SERVER-57766 Omit shardingStatistics.resharding section when resharding hasn't been run
Diffstat (limited to 'src/mongo/db/s/resharding/resharding_metrics_test.cpp')
-rw-r--r--src/mongo/db/s/resharding/resharding_metrics_test.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/mongo/db/s/resharding/resharding_metrics_test.cpp b/src/mongo/db/s/resharding/resharding_metrics_test.cpp
index 3f8d5545c29..fdaf9d36739 100644
--- a/src/mongo/db/s/resharding/resharding_metrics_test.cpp
+++ b/src/mongo/db/s/resharding/resharding_metrics_test.cpp
@@ -96,6 +96,10 @@ public:
_clockSource->advance(step);
}
+ auto getWasReshardingEverAttempted() {
+ return getMetrics()->wasReshardingEverAttempted();
+ }
+
auto getReport(OpReportType reportType) {
BSONObjBuilder bob;
if (reportType == OpReportType::CumulativeReport) {
@@ -834,5 +838,56 @@ TEST_F(ReshardingMetricsTest, CumulativeOpMetricsAccumulate) {
OpReportType::CumulativeReport);
}
+TEST_F(ReshardingMetricsTest, TestWasReshardingEverAttemptedStartComplete) {
+ ASSERT_FALSE(getWasReshardingEverAttempted());
+
+ startOperation(ReshardingMetrics::Role::kRecipient);
+ ASSERT_TRUE(getWasReshardingEverAttempted());
+
+ completeOperation(ReshardingMetrics::Role::kRecipient, ReshardingOperationStatusEnum::kSuccess);
+ ASSERT_TRUE(getWasReshardingEverAttempted());
+}
+
+TEST_F(ReshardingMetricsTest, TestWasReshardingEverAttemptedStartStepDownStepUp) {
+ ASSERT_FALSE(getWasReshardingEverAttempted());
+
+ startOperation(ReshardingMetrics::Role::kRecipient);
+ ASSERT_TRUE(getWasReshardingEverAttempted());
+
+ stepDownOperation(ReshardingMetrics::Role::kRecipient);
+ ASSERT_TRUE(getWasReshardingEverAttempted());
+
+ stepUpOperation(ReshardingMetrics::Role::kRecipient);
+ ASSERT_TRUE(getWasReshardingEverAttempted());
+}
+
+TEST_F(ReshardingMetricsTest, TestWasReshardingEverAttemptedStepUpStepDown) {
+ ASSERT_FALSE(getWasReshardingEverAttempted());
+
+ stepUpOperation(ReshardingMetrics::Role::kRecipient);
+ ASSERT_TRUE(getWasReshardingEverAttempted());
+
+ stepDownOperation(ReshardingMetrics::Role::kRecipient);
+ ASSERT_TRUE(getWasReshardingEverAttempted());
+}
+
+TEST_F(ReshardingMetricsTest, TestWasReshardingEverAttemptedStepUpComplete) {
+ ASSERT_FALSE(getWasReshardingEverAttempted());
+
+ stepUpOperation(ReshardingMetrics::Role::kRecipient);
+ ASSERT_TRUE(getWasReshardingEverAttempted());
+
+ completeOperation(ReshardingMetrics::Role::kRecipient, ReshardingOperationStatusEnum::kSuccess);
+ ASSERT_TRUE(getWasReshardingEverAttempted());
+}
+
+TEST_F(ReshardingMetricsTest, TestOnStepUpWithDonorMetrics) {
+ ASSERT_FALSE(getWasReshardingEverAttempted());
+
+ getMetrics()->onStepUp(DonorStateEnum::kUnused, ReshardingDonorMetrics());
+
+ ASSERT_TRUE(getWasReshardingEverAttempted());
+}
+
} // namespace
} // namespace mongo