diff options
author | Geir Storli <geirst@verizonmedia.com> | 2021-03-22 14:15:16 +0000 |
---|---|---|
committer | Geir Storli <geirst@verizonmedia.com> | 2021-03-22 15:05:38 +0000 |
commit | be8d412fedaa421b4433e4262bd5c6b5cf36233d (patch) | |
tree | 410983ce311a14b62080b2ef8ba140e045ce9ec0 /storage/src/tests/distributor | |
parent | ad0c199d5907794aae0e5b11068efcf338ee0c6d (diff) |
Remove functions from DistributorStripeComponent that are part of DistributorOperationContext interface.
Diffstat (limited to 'storage/src/tests/distributor')
9 files changed, 37 insertions, 30 deletions
diff --git a/storage/src/tests/distributor/distributortest.cpp b/storage/src/tests/distributor/distributortest.cpp index 61c74a263cf..6abe594388f 100644 --- a/storage/src/tests/distributor/distributortest.cpp +++ b/storage/src/tests/distributor/distributortest.cpp @@ -127,9 +127,9 @@ struct DistributorTest : Test, DistributorTestUtil { uint32_t flags(DatabaseUpdate::CREATE_IF_NONEXISTING | (resetTrusted ? DatabaseUpdate::RESET_TRUSTED : 0)); - distributor_component().updateBucketDatabase(makeDocumentBucket(document::BucketId(16, 1)), - changedNodes, - flags); + operation_context().update_bucket_database(makeDocumentBucket(document::BucketId(16, 1)), + changedNodes, + flags); } std::string retVal = dumpBucket(document::BucketId(16, 1)); @@ -572,8 +572,8 @@ TEST_F(DistributorTest, no_db_resurrection_for_bucket_not_owned_in_pending_state std::vector<BucketCopy> copies; copies.emplace_back(1234, 0, api::BucketInfo(0x567, 1, 2)); - distributor_component().updateBucketDatabase(makeDocumentBucket(nonOwnedBucket), copies, - DatabaseUpdate::CREATE_IF_NONEXISTING); + operation_context().update_bucket_database(makeDocumentBucket(nonOwnedBucket), copies, + DatabaseUpdate::CREATE_IF_NONEXISTING); EXPECT_EQ("NONEXISTING", dumpBucket(nonOwnedBucket)); } @@ -585,8 +585,8 @@ TEST_F(DistributorTest, added_db_buckets_without_gc_timestamp_implicitly_get_cur std::vector<BucketCopy> copies; copies.emplace_back(1234, 0, api::BucketInfo(0x567, 1, 2)); - distributor_component().updateBucketDatabase(makeDocumentBucket(bucket), copies, - DatabaseUpdate::CREATE_IF_NONEXISTING); + operation_context().update_bucket_database(makeDocumentBucket(bucket), copies, + DatabaseUpdate::CREATE_IF_NONEXISTING); BucketDatabase::Entry e(getBucket(bucket)); EXPECT_EQ(101234, e->getLastGarbageCollectionTime()); } diff --git a/storage/src/tests/distributor/distributortestutil.cpp b/storage/src/tests/distributor/distributortestutil.cpp index 5d7a61692f6..7929cc1c906 100644 --- a/storage/src/tests/distributor/distributortestutil.cpp +++ b/storage/src/tests/distributor/distributortestutil.cpp @@ -259,7 +259,7 @@ void DistributorTestUtil::addIdealNodes(const document::BucketId& id) { // TODO STRIPE roundabout way of getting state bundle..! - addIdealNodes(*distributor_component().getClusterStateBundle().getBaselineClusterState(), id); + addIdealNodes(*operation_context().cluster_state_bundle().getBaselineClusterState(), id); } void @@ -357,6 +357,11 @@ DistributorTestUtil::distributor_component() { return _distributor->distributor_component(); } +storage::distributor::DistributorOperationContext& +DistributorTestUtil::operation_context() { + return _distributor->distributor_component(); +} + bool DistributorTestUtil::tick() { framework::ThreadWaitInfo res( diff --git a/storage/src/tests/distributor/distributortestutil.h b/storage/src/tests/distributor/distributortestutil.h index 809a87d3bb7..d3c0445d5b5 100644 --- a/storage/src/tests/distributor/distributortestutil.h +++ b/storage/src/tests/distributor/distributortestutil.h @@ -21,10 +21,11 @@ class BucketDBUpdater; class Distributor; class DistributorBucketSpace; class DistributorBucketSpaceRepo; -class DistributorStripeComponent; +class DistributorOperationContext; class DistributorStripe; -class IdealStateManager; +class DistributorStripeComponent; class ExternalOperationHandler; +class IdealStateManager; class Operation; // TODO STRIPE rename to DistributorStripeTestUtil? @@ -115,6 +116,7 @@ public: IdealStateManager& getIdealStateManager(); ExternalOperationHandler& getExternalOperationHandler(); storage::distributor::DistributorStripeComponent& distributor_component(); + storage::distributor::DistributorOperationContext& operation_context(); Distributor& getDistributor() { return *_distributor; diff --git a/storage/src/tests/distributor/externaloperationhandlertest.cpp b/storage/src/tests/distributor/externaloperationhandlertest.cpp index 1829808990a..6d8086696b8 100644 --- a/storage/src/tests/distributor/externaloperationhandlertest.cpp +++ b/storage/src/tests/distributor/externaloperationhandlertest.cpp @@ -99,19 +99,19 @@ TEST_F(ExternalOperationHandlerTest, bucket_split_mask) { getDirConfig().getConfig("stor-distributormanager").set("minsplitcount", "16"); EXPECT_EQ(document::BucketId(16, 0xffff), - distributor_component().getBucketId(document::DocumentId( + operation_context().make_split_bit_constrained_bucket_id(document::DocumentId( vespalib::make_string("id:ns:test:n=%d::", 0xffff)) ).stripUnused()); EXPECT_EQ(document::BucketId(16, 0), - distributor_component().getBucketId(document::DocumentId( + operation_context().make_split_bit_constrained_bucket_id(document::DocumentId( vespalib::make_string("id:ns:test:n=%d::", 0x10000)) ).stripUnused()); EXPECT_EQ(document::BucketId(16, 0xffff), - distributor_component().getBucketId(document::DocumentId( + operation_context().make_split_bit_constrained_bucket_id(document::DocumentId( vespalib::make_string("id:ns:test:n=%d::", 0xffff)) ).stripUnused()); EXPECT_EQ(document::BucketId(16, 0x100), - distributor_component().getBucketId(document::DocumentId( + operation_context().make_split_bit_constrained_bucket_id(document::DocumentId( vespalib::make_string("id:ns:test:n=%d::", 0x100)) ).stripUnused()); close(); @@ -120,11 +120,11 @@ TEST_F(ExternalOperationHandlerTest, bucket_split_mask) { getDirConfig().getConfig("stor-distributormanager").set("minsplitcount", "20"); createLinks(); EXPECT_EQ(document::BucketId(20, 0x11111), - distributor_component().getBucketId(document::DocumentId( + operation_context().make_split_bit_constrained_bucket_id(document::DocumentId( vespalib::make_string("id:ns:test:n=%d::", 0x111111)) ).stripUnused()); EXPECT_EQ(document::BucketId(20, 0x22222), - distributor_component().getBucketId(document::DocumentId( + operation_context().make_split_bit_constrained_bucket_id(document::DocumentId( vespalib::make_string("id:ns:test:n=%d::", 0x222222)) ).stripUnused()); } diff --git a/storage/src/tests/distributor/getoperationtest.cpp b/storage/src/tests/distributor/getoperationtest.cpp index 1123c354ef4..cb671bb07f5 100644 --- a/storage/src/tests/distributor/getoperationtest.cpp +++ b/storage/src/tests/distributor/getoperationtest.cpp @@ -46,7 +46,7 @@ struct GetOperationTest : Test, DistributorTestUtil { createLinks(); docId = document::DocumentId("id:ns:text/html::uri"); - bucketId = distributor_component().getBucketId(docId); + bucketId = operation_context().make_split_bit_constrained_bucket_id(docId); }; void TearDown() override { diff --git a/storage/src/tests/distributor/putoperationtest.cpp b/storage/src/tests/distributor/putoperationtest.cpp index c510e08ab2a..ffd07ad9d60 100644 --- a/storage/src/tests/distributor/putoperationtest.cpp +++ b/storage/src/tests/distributor/putoperationtest.cpp @@ -104,7 +104,7 @@ document::BucketId PutOperationTest::createAndSendSampleDocument(vespalib::duration timeout) { auto doc = std::make_shared<Document>(doc_type(), DocumentId("id:test:testdoctype1::")); - document::BucketId id = distributor_component().getBucketId(doc->getId()); + document::BucketId id = operation_context().make_split_bit_constrained_bucket_id(doc->getId()); addIdealNodes(id); auto msg = std::make_shared<api::PutCommand>(makeDocumentBucket(document::BucketId(0)), doc, 0); @@ -150,7 +150,7 @@ TEST_F(PutOperationTest, bucket_database_gets_special_entry_when_CreateBucket_se // Database updated before CreateBucket is sent ASSERT_EQ("BucketId(0x4000000000008f09) : " "node(idx=0,crc=0x1,docs=0/0,bytes=0/0,trusted=true,active=true,ready=false)", - dumpBucket(distributor_component().getBucketId(doc->getId()))); + dumpBucket(operation_context().make_split_bit_constrained_bucket_id(doc->getId()))); ASSERT_EQ("Create bucket => 0,Put => 0", _sender.getCommands(true)); } @@ -197,7 +197,7 @@ TEST_F(PutOperationTest, return_success_if_op_acked_on_all_replicas_even_if_buck "id:test:testdoctype1::, timestamp 100, size 45) => 1", _sender.getCommands(true, true)); - distributor_component().removeNodeFromDB(makeDocumentBucket(document::BucketId(16, 0x1dd4)), 0); + operation_context().remove_node_from_bucket_database(makeDocumentBucket(document::BucketId(16, 0x1dd4)), 0); // If we get an ACK from the backend nodes, the operation has been persisted OK. // Even if the bucket has been removed from the DB in the meantime (usually would @@ -249,7 +249,7 @@ TEST_F(PutOperationTest, multiple_copies) { "node(idx=3,crc=0x1,docs=2/4,bytes=3/5,trusted=true,active=false,ready=false), " "node(idx=2,crc=0x1,docs=2/4,bytes=3/5,trusted=true,active=false,ready=false), " "node(idx=1,crc=0x1,docs=2/4,bytes=3/5,trusted=true,active=false,ready=false)", - dumpBucket(distributor_component().getBucketId(doc->getId()))); + dumpBucket(operation_context().make_split_bit_constrained_bucket_id(doc->getId()))); } TEST_F(PutOperationTest, multiple_copies_early_return_primary_required) { @@ -477,7 +477,7 @@ parseBucketInfoString(const std::string& nodeList) { std::string PutOperationTest::getNodes(const std::string& infoString) { Document::SP doc(createDummyDocument("test", "uri")); - document::BucketId bid(distributor_component().getBucketId(doc->getId())); + document::BucketId bid(operation_context().make_split_bit_constrained_bucket_id(doc->getId())); BucketInfo entry = parseBucketInfoString(infoString); @@ -519,7 +519,7 @@ TEST_F(PutOperationTest, replica_not_resurrected_in_db_when_node_down_in_active_ setupDistributor(Redundancy(3), NodeCount(3), "distributor:1 storage:3"); Document::SP doc(createDummyDocument("test", "uri")); - document::BucketId bId = distributor_component().getBucketId(doc->getId()); + document::BucketId bId = operation_context().make_split_bit_constrained_bucket_id(doc->getId()); addNodesToBucketDB(bId, "0=1/2/3/t,1=1/2/3/t,2=1/2/3/t"); @@ -536,14 +536,14 @@ TEST_F(PutOperationTest, replica_not_resurrected_in_db_when_node_down_in_active_ ASSERT_EQ("BucketId(0x4000000000000593) : " "node(idx=0,crc=0x7,docs=8/8,bytes=9/9,trusted=true,active=false,ready=false)", - dumpBucket(distributor_component().getBucketId(doc->getId()))); + dumpBucket(operation_context().make_split_bit_constrained_bucket_id(doc->getId()))); } TEST_F(PutOperationTest, replica_not_resurrected_in_db_when_node_down_in_pending_state) { setupDistributor(Redundancy(3), NodeCount(4), "version:1 distributor:1 storage:3"); auto doc = createDummyDocument("test", "uri"); - auto bucket = distributor_component().getBucketId(doc->getId()); + 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"); sendPut(createPut(doc)); @@ -577,7 +577,7 @@ TEST_F(PutOperationTest, replica_not_resurrected_in_db_when_node_down_in_pending TEST_F(PutOperationTest, put_is_failed_with_busy_if_target_down_in_pending_state) { setupDistributor(Redundancy(3), NodeCount(4), "version:1 distributor:1 storage:3"); auto doc = createDummyDocument("test", "test"); - auto bucket = distributor_component().getBucketId(doc->getId()); + 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"); getBucketDBUpdater().onSetSystemState( std::make_shared<api::SetSystemStateCommand>( @@ -597,7 +597,7 @@ TEST_F(PutOperationTest, send_to_retired_nodes_if_no_up_nodes_available) { "distributor:1 storage:2 .0.s:r .1.s:r"); Document::SP doc(createDummyDocument("test", "uri")); document::BucketId bucket( - distributor_component().getBucketId(doc->getId())); + operation_context().make_split_bit_constrained_bucket_id(doc->getId())); addNodesToBucketDB(bucket, "0=1/2/3/t,1=1/2/3/t"); sendPut(createPut(doc)); diff --git a/storage/src/tests/distributor/removeoperationtest.cpp b/storage/src/tests/distributor/removeoperationtest.cpp index de76379e854..c4892f342e7 100644 --- a/storage/src/tests/distributor/removeoperationtest.cpp +++ b/storage/src/tests/distributor/removeoperationtest.cpp @@ -24,7 +24,7 @@ struct RemoveOperationTest : Test, DistributorTestUtil { createLinks(); docId = document::DocumentId("id:test:test::uri"); - bucketId = distributor_component().getBucketId(docId); + bucketId = operation_context().make_split_bit_constrained_bucket_id(docId); enableDistributorClusterState("distributor:1 storage:4"); }; diff --git a/storage/src/tests/distributor/twophaseupdateoperationtest.cpp b/storage/src/tests/distributor/twophaseupdateoperationtest.cpp index 58556832f2d..dae94e41b46 100644 --- a/storage/src/tests/distributor/twophaseupdateoperationtest.cpp +++ b/storage/src/tests/distributor/twophaseupdateoperationtest.cpp @@ -309,7 +309,7 @@ TwoPhaseUpdateOperationTest::sendUpdate(const std::string& bucketState, } update->setCreateIfNonExistent(options._createIfNonExistent); - document::BucketId id = distributor_component().getBucketId(update->getId()); + document::BucketId id = operation_context().make_split_bit_constrained_bucket_id(update->getId()); document::BucketId id2 = document::BucketId(id.getUsedBits() + 1, id.getRawId()); if (bucketState.length()) { diff --git a/storage/src/tests/distributor/updateoperationtest.cpp b/storage/src/tests/distributor/updateoperationtest.cpp index ea9f0d86ac4..6620cf58571 100644 --- a/storage/src/tests/distributor/updateoperationtest.cpp +++ b/storage/src/tests/distributor/updateoperationtest.cpp @@ -60,7 +60,7 @@ UpdateOperationTest::sendUpdate(const std::string& bucketState, bool create_if_m document::DocumentId("id:ns:" + _html_type->getName() + "::1")); update->setCreateIfNonExistent(create_if_missing); - _bId = distributor_component().getBucketId(update->getId()); + _bId = operation_context().make_split_bit_constrained_bucket_id(update->getId()); addNodesToBucketDB(_bId, bucketState); |