diff options
author | Tor Brede Vekterli <vekterli@yahooinc.com> | 2023-06-07 12:56:32 +0000 |
---|---|---|
committer | Tor Brede Vekterli <vekterli@yahooinc.com> | 2023-06-07 12:56:32 +0000 |
commit | 86675148f8d1f915558e1958eb1e125eddfbd11d (patch) | |
tree | f61deddd121edfbea7514485fdf1b1072f6b02a7 /storage/src/tests/distributor | |
parent | 458097c79d9dec14b6359364117a2dd6cc4181ab (diff) |
Must check cluster state version in pending state, if present
Checking just the current state's version does not work as expected
if the distributor is currently _within_ a cluster state transition.
In this case, the pending state's version must be used instead.
Failure to do so will make the code erroneously believe the cluster
state has not changed since the start of the operation.
Diffstat (limited to 'storage/src/tests/distributor')
-rw-r--r-- | storage/src/tests/distributor/check_condition_test.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/storage/src/tests/distributor/check_condition_test.cpp b/storage/src/tests/distributor/check_condition_test.cpp index d355194ec0d..757a9329ea6 100644 --- a/storage/src/tests/distributor/check_condition_test.cpp +++ b/storage/src/tests/distributor/check_condition_test.cpp @@ -242,7 +242,20 @@ TEST_F(CheckConditionTest, check_fails_if_replica_set_changed_between_start_and_ }); } -TEST_F(CheckConditionTest, check_fails_if_bucket_ownership_changed_between_start_and_completion) { +TEST_F(CheckConditionTest, check_fails_if_bucket_ownership_changed_between_start_and_completion_pending_transition_case) { + test_cond_with_2_gets_sent([&](auto& cond) { + cond.handle_reply(_sender, make_matched_reply(0)); + simulate_set_pending_cluster_state("version:2 storage:1 distributor:1 .0.s:d"); // technically, no distributors own anything + cond.handle_reply(_sender, make_matched_reply(1)); + }, [&](auto& outcome) { + EXPECT_FALSE(outcome.matched_condition()); + EXPECT_FALSE(outcome.not_found()); + EXPECT_TRUE(outcome.failed()); + EXPECT_EQ(outcome.error_code().getResult(), api::ReturnCode::BUCKET_NOT_FOUND); + }); +} + +TEST_F(CheckConditionTest, check_fails_if_bucket_ownership_changed_between_start_and_completion_completed_transition_case) { test_cond_with_2_gets_sent([&](auto& cond) { cond.handle_reply(_sender, make_matched_reply(0)); enable_cluster_state("version:2 storage:1 distributor:1 .0.s:d"); // technically, no distributors own anything |