summaryrefslogtreecommitdiffstats
path: root/storage/src/tests/distributor/distributortest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'storage/src/tests/distributor/distributortest.cpp')
-rw-r--r--storage/src/tests/distributor/distributortest.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/storage/src/tests/distributor/distributortest.cpp b/storage/src/tests/distributor/distributortest.cpp
index 2944348e639..5a5ebb8c823 100644
--- a/storage/src/tests/distributor/distributortest.cpp
+++ b/storage/src/tests/distributor/distributortest.cpp
@@ -1254,4 +1254,61 @@ TEST_F(DistributorTest, wanted_split_bit_count_is_lower_bounded) {
EXPECT_EQ(getConfig().getMinimalBucketSplit(), 8);
}
+TEST_F(DistributorTest, host_info_sent_immediately_once_all_stripes_first_reported) {
+ set_num_distributor_stripes(3);
+ createLinks();
+ getClock().setAbsoluteTimeInSeconds(1000);
+ // TODO STRIPE can't call this currently since it touches the bucket DB updater directly:
+ // setupDistributor(Redundancy(2), NodeCount(2), "version:1 distributor:1 storage:2");
+
+ tickDistributorNTimes(1);
+ EXPECT_EQ(0, explicit_node_state_reply_send_invocations()); // Nothing yet
+ getDistributor().notify_stripe_wants_to_send_host_info(1);
+ getDistributor().notify_stripe_wants_to_send_host_info(2);
+
+ tickDistributorNTimes(1);
+ // Still nothing. Missing initial report from stripe 0
+ EXPECT_EQ(0, explicit_node_state_reply_send_invocations());
+
+ getDistributor().notify_stripe_wants_to_send_host_info(0);
+ tickDistributorNTimes(1);
+ // All stripes have reported in, it's time to party!
+ EXPECT_EQ(1, explicit_node_state_reply_send_invocations());
+
+ // No further sends if stripes haven't requested it yet.
+ getClock().setAbsoluteTimeInSeconds(2000);
+ tickDistributorNTimes(10);
+ EXPECT_EQ(1, explicit_node_state_reply_send_invocations());
+}
+
+// TODO STRIPE make delay configurable instead of hardcoded
+TEST_F(DistributorTest, non_bootstrap_host_info_send_request_delays_sending) {
+ set_num_distributor_stripes(3);
+ createLinks();
+ getClock().setAbsoluteTimeInSeconds(1000);
+
+ for (uint16_t i = 0; i < 3; ++i) {
+ getDistributor().notify_stripe_wants_to_send_host_info(i);
+ }
+ tickDistributorNTimes(1);
+ // Bootstrap case
+ EXPECT_EQ(1, explicit_node_state_reply_send_invocations());
+
+ // Stripe 1 suddenly really wants to tell the cluster controller something again
+ getDistributor().notify_stripe_wants_to_send_host_info(1);
+ tickDistributorNTimes(1);
+ // But its cry for attention is not yet honored since the delay hasn't passed.
+ EXPECT_EQ(1, explicit_node_state_reply_send_invocations());
+
+ getClock().addMilliSecondsToTime(999);
+ tickDistributorNTimes(1);
+ // 1 sec delay has still not passed
+ EXPECT_EQ(1, explicit_node_state_reply_send_invocations());
+
+ getClock().addMilliSecondsToTime(1);
+ tickDistributorNTimes(1);
+ // But now it has
+ EXPECT_EQ(2, explicit_node_state_reply_send_invocations());
+}
+
}