aboutsummaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
authorGeir Storli <geirst@verizonmedia.com>2021-08-27 08:51:41 +0000
committerGeir Storli <geirst@verizonmedia.com>2021-08-27 14:32:03 +0000
commit6efa6dde912fba2118e86ed9afc30c453396294e (patch)
treebd5aa5e0ddf5cbc28ec8af2c913ce9deb9dacb84 /storage
parenta3aefda8646615e3a0fc7055875849dd602545ed (diff)
Rewrite ideal state manager tests to not use legacy test util.
Diffstat (limited to 'storage')
-rw-r--r--storage/src/tests/distributor/distributor_stripe_test_util.cpp10
-rw-r--r--storage/src/tests/distributor/distributor_stripe_test_util.h3
-rw-r--r--storage/src/tests/distributor/externaloperationhandlertest.cpp4
-rw-r--r--storage/src/tests/distributor/idealstatemanagertest.cpp48
-rw-r--r--storage/src/tests/distributor/putoperationtest.cpp6
-rw-r--r--storage/src/tests/distributor/visitoroperationtest.cpp3
6 files changed, 38 insertions, 36 deletions
diff --git a/storage/src/tests/distributor/distributor_stripe_test_util.cpp b/storage/src/tests/distributor/distributor_stripe_test_util.cpp
index abc28d54919..0605099e09b 100644
--- a/storage/src/tests/distributor/distributor_stripe_test_util.cpp
+++ b/storage/src/tests/distributor/distributor_stripe_test_util.cpp
@@ -136,8 +136,10 @@ DistributorStripeTestUtil::handle_top_level_message(const std::shared_ptr<api::S
}
void
-DistributorStripeTestUtil::simulate_set_pending_cluster_state(const lib::ClusterStateBundle& pending_state)
+DistributorStripeTestUtil::simulate_set_pending_cluster_state(const vespalib::string& state_str)
{
+ lib::ClusterState state(state_str);
+ lib::ClusterStateBundle pending_state(state);
for (auto& space : _stripe->getBucketSpaceRepo()) {
const auto& new_cluster_state = pending_state.getDerivedClusterState(space.first);
_stripe->update_read_snapshot_before_db_pruning();
@@ -148,6 +150,12 @@ DistributorStripeTestUtil::simulate_set_pending_cluster_state(const lib::Cluster
}
void
+DistributorStripeTestUtil::clear_pending_cluster_state_bundle()
+{
+ _stripe->clear_pending_cluster_state_bundle();
+}
+
+void
DistributorStripeTestUtil::setTypeRepo(const std::shared_ptr<const document::DocumentTypeRepo>& repo)
{
_node->getComponentRegister().setDocumentTypeRepo(repo);
diff --git a/storage/src/tests/distributor/distributor_stripe_test_util.h b/storage/src/tests/distributor/distributor_stripe_test_util.h
index 20af2b8c939..e7b14cc7cd6 100644
--- a/storage/src/tests/distributor/distributor_stripe_test_util.h
+++ b/storage/src/tests/distributor/distributor_stripe_test_util.h
@@ -204,7 +204,8 @@ public:
void handle_top_level_message(const std::shared_ptr<api::StorageMessage>& msg);
- void simulate_set_pending_cluster_state(const lib::ClusterStateBundle& pending_state);
+ void simulate_set_pending_cluster_state(const vespalib::string& state_str);
+ void clear_pending_cluster_state_bundle();
protected:
vdstestlib::DirConfig _config;
diff --git a/storage/src/tests/distributor/externaloperationhandlertest.cpp b/storage/src/tests/distributor/externaloperationhandlertest.cpp
index 73a048d2994..769029524e5 100644
--- a/storage/src/tests/distributor/externaloperationhandlertest.cpp
+++ b/storage/src/tests/distributor/externaloperationhandlertest.cpp
@@ -249,7 +249,7 @@ TEST_F(ExternalOperationHandlerTest, mutating_operation_busy_bounced_on_wrong_pe
document::BucketId b(findOwned1stNotOwned2ndInStates(current, pending));
// Trigger pending cluster state
- simulate_set_pending_cluster_state(lib::ClusterStateBundle(lib::ClusterState(pending)));
+ simulate_set_pending_cluster_state(pending);
auto cmd = makeUpdateCommandForUser(b.withoutCountBits());
@@ -529,7 +529,7 @@ document::BucketId ExternalOperationHandlerTest::set_up_pending_cluster_state_tr
configure_stripe(cfg);
// Trigger pending cluster state
- simulate_set_pending_cluster_state(lib::ClusterStateBundle(lib::ClusterState(pending)));
+ simulate_set_pending_cluster_state(pending);
return findOwned1stNotOwned2ndInStates(current, pending);
}
diff --git a/storage/src/tests/distributor/idealstatemanagertest.cpp b/storage/src/tests/distributor/idealstatemanagertest.cpp
index e38e4b5b668..248b2b7064b 100644
--- a/storage/src/tests/distributor/idealstatemanagertest.cpp
+++ b/storage/src/tests/distributor/idealstatemanagertest.cpp
@@ -1,20 +1,19 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <tests/common/dummystoragelink.h>
-#include <vespa/storageapi/message/persistence.h>
+#include "dummy_cluster_context.h"
+#include <tests/distributor/distributor_stripe_test_util.h>
+#include <vespa/document/bucket/fixed_bucket_spaces.h>
+#include <vespa/document/test/make_bucket_space.h>
+#include <vespa/document/test/make_document_bucket.h>
#include <vespa/storage/distributor/bucketdbupdater.h>
#include <vespa/storage/distributor/distributor.h>
#include <vespa/storage/distributor/distributor_stripe.h>
-#include <vespa/storage/distributor/operations/idealstate/mergeoperation.h>
#include <vespa/storage/distributor/operation_sequencer.h>
+#include <vespa/storage/distributor/operations/idealstate/mergeoperation.h>
+#include <vespa/storageapi/message/bucketsplitting.h>
+#include <vespa/storageapi/message/persistence.h>
#include <vespa/storageapi/message/stat.h>
#include <vespa/storageapi/message/visitor.h>
-#include <vespa/storageapi/message/bucketsplitting.h>
-#include <tests/distributor/distributortestutil.h>
-#include <vespa/document/bucket/fixed_bucket_spaces.h>
-#include <vespa/document/test/make_document_bucket.h>
-#include <vespa/document/test/make_bucket_space.h>
#include <vespa/vespalib/gtest/gtest.h>
-#include "dummy_cluster_context.h"
using document::test::makeDocumentBucket;
using document::test::makeBucketSpace;
@@ -23,10 +22,10 @@ using namespace ::testing;
namespace storage::distributor {
-struct IdealStateManagerTest : Test, DistributorTestUtil {
+struct IdealStateManagerTest : Test, DistributorStripeTestUtil {
IdealStateManagerTest()
: Test(),
- DistributorTestUtil(),
+ DistributorStripeTestUtil(),
_bucketSpaces()
{}
void SetUp() override {
@@ -80,7 +79,7 @@ TEST_F(IdealStateManagerTest, status_page) {
getDirConfig().getConfig("stor-distributormanager").set("joinsize", "0");
getDirConfig().getConfig("stor-distributormanager").set("joincount", "0");
createLinks();
- setupDistributor(1, 1, "distributor:1 storage:1");
+ setup_stripe(1, 1, "distributor:1 storage:1");
insertBucketInfo(document::BucketId(16, 5), 0, 0xff, 100, 200, true, true);
insertBucketInfo(document::BucketId(16, 2), 0, 0xff, 10, 10, true, true);
@@ -96,11 +95,13 @@ TEST_F(IdealStateManagerTest, status_page) {
}
TEST_F(IdealStateManagerTest, disabled_state_checker) {
- setupDistributor(1, 1, "distributor:1 storage:1");
+ setup_stripe(1, 1, "distributor:1 storage:1");
- getConfig().setSplitSize(100);
- getConfig().setSplitCount(1000000);
- getConfig().disableStateChecker("SplitBucket");
+ auto cfg = make_config();
+ cfg->setSplitSize(100);
+ cfg->setSplitCount(1000000);
+ cfg->disableStateChecker("SplitBucket");
+ configure_stripe(cfg);
insertBucketInfo(document::BucketId(16, 5), 0, 0xff, 100, 200, true, true);
insertBucketInfo(document::BucketId(16, 2), 0, 0xff, 10, 10, true, true);
@@ -184,10 +185,10 @@ TEST_F(IdealStateManagerTest, recheck_when_active) {
*/
TEST_F(IdealStateManagerTest, block_ideal_state_ops_when_pending_cluster_state_is_present) {
- setupDistributor(2, 10, "version:1 distributor:1 storage:1 .0.s:d");
+ setup_stripe(2, 10, "version:1 distributor:1 storage:1 .0.s:d");
// Trigger a pending cluster state with bucket info requests towards 1 node
- receive_set_system_state_command("version:2 distributor:1 storage:1");
+ simulate_set_pending_cluster_state("version:2 distributor:1 storage:1");
OperationSequencer op_seq;
document::BucketId bid(16, 1234);
@@ -198,12 +199,7 @@ TEST_F(IdealStateManagerTest, block_ideal_state_ops_when_pending_cluster_state_i
EXPECT_TRUE(op.isBlocked(operation_context(), op_seq));
}
- // Clear pending by replying with zero buckets for all bucket spaces
- ASSERT_EQ(_bucketSpaces.size(), _sender.commands().size());
- for (uint32_t i = 0; i < _sender.commands().size(); ++i) {
- auto& bucket_req = dynamic_cast<api::RequestBucketInfoCommand&>(*_sender.command(i));
- handle_top_level_message(bucket_req.makeReply());
- }
+ clear_pending_cluster_state_bundle();
{
RemoveBucketOperation op(dummy_cluster_context,
@@ -213,7 +209,7 @@ TEST_F(IdealStateManagerTest, block_ideal_state_ops_when_pending_cluster_state_i
}
TEST_F(IdealStateManagerTest, block_check_for_all_operations_to_specific_bucket) {
- setupDistributor(2, 10, "distributor:1 storage:2");
+ setup_stripe(2, 10, "distributor:1 storage:2");
framework::defaultimplementation::FakeClock clock;
OperationSequencer op_seq;
document::BucketId bid(16, 1234);
@@ -234,7 +230,7 @@ TEST_F(IdealStateManagerTest, block_check_for_all_operations_to_specific_bucket)
}
TEST_F(IdealStateManagerTest, block_operations_with_locked_buckets) {
- setupDistributor(2, 10, "distributor:1 storage:2");
+ setup_stripe(2, 10, "distributor:1 storage:2");
framework::defaultimplementation::FakeClock clock;
OperationSequencer op_seq;
const auto bucket = makeDocumentBucket(document::BucketId(16, 1234));
diff --git a/storage/src/tests/distributor/putoperationtest.cpp b/storage/src/tests/distributor/putoperationtest.cpp
index 3433b2f3ce0..b6f12a87e9a 100644
--- a/storage/src/tests/distributor/putoperationtest.cpp
+++ b/storage/src/tests/distributor/putoperationtest.cpp
@@ -561,8 +561,7 @@ TEST_F(PutOperationTest, replica_not_resurrected_in_db_when_node_down_in_pending
// fetch here; if we just set a node down the cluster state would be immediately applied
// and the distributor's "clear pending messages for downed nodes" logic would kick in
// and hide the problem.
- simulate_set_pending_cluster_state(lib::ClusterStateBundle(
- lib::ClusterState("version:2 distributor:1 storage:4 .0.s:d .2.s:m")));
+ simulate_set_pending_cluster_state("version:2 distributor:1 storage:4 .0.s:d .2.s:m");
sendReply(0, api::ReturnCode::OK, api::BucketInfo(5, 6, 7));
sendReply(1, api::ReturnCode::OK, api::BucketInfo(6, 7, 8));
@@ -580,8 +579,7 @@ TEST_F(PutOperationTest, put_is_failed_with_busy_if_target_down_in_pending_state
auto doc = createDummyDocument("test", "test");
auto bucket = operation_context().make_split_bit_constrained_bucket_id(doc->getId());
addNodesToBucketDB(bucket, "0=1/2/3/t,1=1/2/3/t,2=1/2/3/t");
- simulate_set_pending_cluster_state(lib::ClusterStateBundle(
- lib::ClusterState("version:2 distributor:1 storage:4 .0.s:d .2.s:m")));
+ simulate_set_pending_cluster_state("version:2 distributor:1 storage:4 .0.s:d .2.s:m");
_sender.clear();
sendPut(createPut(doc));
diff --git a/storage/src/tests/distributor/visitoroperationtest.cpp b/storage/src/tests/distributor/visitoroperationtest.cpp
index 57ee965f0b0..a1342086c29 100644
--- a/storage/src/tests/distributor/visitoroperationtest.cpp
+++ b/storage/src/tests/distributor/visitoroperationtest.cpp
@@ -557,8 +557,7 @@ TEST_F(VisitorOperationTest, wrong_distribution_in_pending_state) {
setup_stripe(1, 100, "distributor:1 storage:2");
// Trigger pending cluster state. Note: increase in storage node count
// to force resending of bucket info requests.
- simulate_set_pending_cluster_state(lib::ClusterStateBundle(
- lib::ClusterState("distributor:100 storage:3")));
+ simulate_set_pending_cluster_state("distributor:100 storage:3");
document::BucketId id(uint64_t(0x400000000000127b));
ASSERT_EQ("CreateVisitorReply(last=BucketId(0x0000000000000000)) "