summaryrefslogtreecommitdiffstats
path: root/storage/src/tests/distributor
diff options
context:
space:
mode:
Diffstat (limited to 'storage/src/tests/distributor')
-rw-r--r--storage/src/tests/distributor/distributortestutil.cpp12
-rw-r--r--storage/src/tests/distributor/distributortestutil.h5
-rw-r--r--storage/src/tests/distributor/getoperationtest.cpp2
-rw-r--r--storage/src/tests/distributor/putoperationtest.cpp6
-rw-r--r--storage/src/tests/distributor/read_for_write_visitor_operation_test.cpp2
-rw-r--r--storage/src/tests/distributor/removelocationtest.cpp6
-rw-r--r--storage/src/tests/distributor/removeoperationtest.cpp4
-rw-r--r--storage/src/tests/distributor/statecheckerstest.cpp36
-rw-r--r--storage/src/tests/distributor/statoperationtest.cpp2
-rw-r--r--storage/src/tests/distributor/twophaseupdateoperationtest.cpp4
-rw-r--r--storage/src/tests/distributor/updateoperationtest.cpp3
-rw-r--r--storage/src/tests/distributor/visitoroperationtest.cpp4
12 files changed, 52 insertions, 34 deletions
diff --git a/storage/src/tests/distributor/distributortestutil.cpp b/storage/src/tests/distributor/distributortestutil.cpp
index e92ba0374bc..a2f32d8faa2 100644
--- a/storage/src/tests/distributor/distributortestutil.cpp
+++ b/storage/src/tests/distributor/distributortestutil.cpp
@@ -295,7 +295,7 @@ DistributorTestUtil::insertBucketInfo(document::BucketId id,
if (active) {
info2.setActive();
}
- BucketCopy copy(distributor_component().getUniqueTimestamp(), node, info2);
+ BucketCopy copy(operation_context().generate_unique_timestamp(), node, info2);
entry->addNode(copy.setTrusted(trusted), toVector<uint16_t>(0));
@@ -355,9 +355,8 @@ DistributorTestUtil::getExternalOperationHandler() {
return _distributor->external_operation_handler();
}
-storage::distributor::DistributorStripeComponent&
-DistributorTestUtil::distributor_component() {
- // TODO STRIPE tests use this to indirectly access bucket space repos/DBs!
+const storage::distributor::DistributorNodeContext&
+DistributorTestUtil::node_context() const {
return _distributor->distributor_component();
}
@@ -366,6 +365,11 @@ DistributorTestUtil::operation_context() {
return _distributor->distributor_component();
}
+const DocumentSelectionParser&
+DistributorTestUtil::doc_selection_parser() const {
+ 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 63ca47755e6..6664b8d823d 100644
--- a/storage/src/tests/distributor/distributortestutil.h
+++ b/storage/src/tests/distributor/distributortestutil.h
@@ -20,10 +20,12 @@ namespace distributor {
class Distributor;
class DistributorBucketSpace;
class DistributorBucketSpaceRepo;
+class DistributorNodeContext;
class DistributorStripe;
class DistributorStripeComponent;
class DistributorStripeOperationContext;
class DistributorStripePool;
+class DocumentSelectionParser;
class ExternalOperationHandler;
class IdealStateManager;
class Operation;
@@ -116,8 +118,9 @@ public:
StripeBucketDBUpdater& getBucketDBUpdater();
IdealStateManager& getIdealStateManager();
ExternalOperationHandler& getExternalOperationHandler();
- storage::distributor::DistributorStripeComponent& distributor_component();
+ const storage::distributor::DistributorNodeContext& node_context() const;
storage::distributor::DistributorStripeOperationContext& operation_context();
+ const DocumentSelectionParser& doc_selection_parser() const;
Distributor& getDistributor() noexcept { return *_distributor; }
const Distributor& getDistributor() const noexcept { return *_distributor; }
diff --git a/storage/src/tests/distributor/getoperationtest.cpp b/storage/src/tests/distributor/getoperationtest.cpp
index cb671bb07f5..c853dd692a0 100644
--- a/storage/src/tests/distributor/getoperationtest.cpp
+++ b/storage/src/tests/distributor/getoperationtest.cpp
@@ -57,7 +57,7 @@ struct GetOperationTest : Test, DistributorTestUtil {
void sendGet(api::InternalReadConsistency consistency = api::InternalReadConsistency::Strong) {
auto msg = std::make_shared<api::GetCommand>(makeDocumentBucket(BucketId(0)), docId, document::AllFields::NAME);
op = std::make_unique<GetOperation>(
- distributor_component(), getDistributorBucketSpace(),
+ node_context(), getDistributorBucketSpace(),
getDistributorBucketSpace().getBucketDatabase().acquire_read_guard(),
msg, getDistributor().getMetrics().gets,
consistency);
diff --git a/storage/src/tests/distributor/putoperationtest.cpp b/storage/src/tests/distributor/putoperationtest.cpp
index ffd07ad9d60..b75751c1270 100644
--- a/storage/src/tests/distributor/putoperationtest.cpp
+++ b/storage/src/tests/distributor/putoperationtest.cpp
@@ -74,8 +74,8 @@ public:
}
void sendPut(std::shared_ptr<api::PutCommand> msg) {
- op = std::make_unique<PutOperation>(distributor_component(),
- distributor_component(),
+ op = std::make_unique<PutOperation>(node_context(),
+ operation_context(),
getDistributorBucketSpace(),
msg,
getDistributor().getMetrics().
@@ -402,7 +402,7 @@ TEST_F(PutOperationTest, do_not_send_CreateBucket_if_already_pending) {
// Manually shove sent messages into pending message tracker, since
// this isn't done automatically.
for (size_t i = 0; i < _sender.commands().size(); ++i) {
- distributor_component().getDistributor().getPendingMessageTracker()
+ operation_context().pending_message_tracker()
.insert(_sender.command(i));
}
diff --git a/storage/src/tests/distributor/read_for_write_visitor_operation_test.cpp b/storage/src/tests/distributor/read_for_write_visitor_operation_test.cpp
index 478f20796d0..e6f86f56d47 100644
--- a/storage/src/tests/distributor/read_for_write_visitor_operation_test.cpp
+++ b/storage/src/tests/distributor/read_for_write_visitor_operation_test.cpp
@@ -84,7 +84,7 @@ struct ReadForWriteVisitorOperationStarterTest : Test, DistributorTestUtil {
cmd->addBucketToBeVisited(BucketId()); // Will be inferred to first sub-bucket in DB
}
return std::make_shared<VisitorOperation>(
- distributor_component(), distributor_component(),
+ node_context(), operation_context(),
getDistributorBucketSpace(), cmd, _default_config,
getDistributor().getMetrics().visits);
}
diff --git a/storage/src/tests/distributor/removelocationtest.cpp b/storage/src/tests/distributor/removelocationtest.cpp
index 7ba2995d8e3..02164d67a46 100644
--- a/storage/src/tests/distributor/removelocationtest.cpp
+++ b/storage/src/tests/distributor/removelocationtest.cpp
@@ -28,9 +28,9 @@ struct RemoveLocationOperationTest : Test, DistributorTestUtil {
auto msg = std::make_shared<api::RemoveLocationCommand>(selection, makeDocumentBucket(document::BucketId(0)));
op = std::make_unique<RemoveLocationOperation>(
- distributor_component(),
- distributor_component(),
- distributor_component(),
+ node_context(),
+ operation_context(),
+ doc_selection_parser(),
getDistributorBucketSpace(),
msg,
getDistributor().getMetrics().
diff --git a/storage/src/tests/distributor/removeoperationtest.cpp b/storage/src/tests/distributor/removeoperationtest.cpp
index c4892f342e7..77ecb5d7aeb 100644
--- a/storage/src/tests/distributor/removeoperationtest.cpp
+++ b/storage/src/tests/distributor/removeoperationtest.cpp
@@ -36,8 +36,8 @@ struct RemoveOperationTest : Test, DistributorTestUtil {
auto msg = std::make_shared<api::RemoveCommand>(makeDocumentBucket(document::BucketId(0)), dId, 100);
op = std::make_unique<RemoveOperation>(
- distributor_component(),
- distributor_component(),
+ node_context(),
+ operation_context(),
getDistributorBucketSpace(),
msg,
getDistributor().getMetrics().
diff --git a/storage/src/tests/distributor/statecheckerstest.cpp b/storage/src/tests/distributor/statecheckerstest.cpp
index 8310e4e38e0..e4ecb672171 100644
--- a/storage/src/tests/distributor/statecheckerstest.cpp
+++ b/storage/src/tests/distributor/statecheckerstest.cpp
@@ -240,7 +240,8 @@ struct StateCheckersTest : Test, DistributorTestUtil {
tick(); // Trigger command processing and pending state setup.
}
NodeMaintenanceStatsTracker statsTracker;
- StateChecker::Context c(distributor_component(),
+ StateChecker::Context c(node_context(),
+ operation_context(),
getBucketSpaceRepo().get(params._bucket_space),
statsTracker,
bucket);
@@ -292,7 +293,8 @@ std::string StateCheckersTest::testSplit(uint32_t splitCount,
SplitBucketStateChecker checker;
NodeMaintenanceStatsTracker statsTracker;
- StateChecker::Context c(distributor_component(), getDistributorBucketSpace(), statsTracker, makeDocumentBucket(bid));
+ StateChecker::Context c(node_context(), operation_context(),
+ getDistributorBucketSpace(), statsTracker, makeDocumentBucket(bid));
getConfig().setSplitSize(splitSize);
getConfig().setSplitCount(splitCount);
getConfig().setMinimalBucketSplit(minSplitBits);
@@ -377,7 +379,8 @@ StateCheckersTest::testInconsistentSplit(const document::BucketId& bid,
{
SplitInconsistentStateChecker checker;
NodeMaintenanceStatsTracker statsTracker;
- StateChecker::Context c(distributor_component(), getDistributorBucketSpace(), statsTracker, makeDocumentBucket(bid));
+ StateChecker::Context c(node_context(), operation_context(),
+ getDistributorBucketSpace(), statsTracker, makeDocumentBucket(bid));
return testStateChecker(checker, c, true,
PendingMessage(), includePriority);
}
@@ -435,7 +438,8 @@ StateCheckersTest::testJoin(uint32_t joinCount,
getConfig().setMinimalBucketSplit(minSplitBits);
NodeMaintenanceStatsTracker statsTracker;
- StateChecker::Context c(distributor_component(), getDistributorBucketSpace(), statsTracker, makeDocumentBucket(bid));
+ StateChecker::Context c(node_context(), operation_context(),
+ getDistributorBucketSpace(), statsTracker, makeDocumentBucket(bid));
return testStateChecker(checker, c, true, blocker, includePriority);
}
@@ -588,7 +592,8 @@ StateCheckersTest::testSynchronizeAndMove(const std::string& bucketInfo,
enableDistributorClusterState(clusterState);
NodeMaintenanceStatsTracker statsTracker;
- StateChecker::Context c(distributor_component(), getDistributorBucketSpace(), statsTracker, makeDocumentBucket(bid));
+ StateChecker::Context c(node_context(), operation_context(),
+ getDistributorBucketSpace(), statsTracker, makeDocumentBucket(bid));
return testStateChecker(checker, c, false, blocker, includePriority);
}
@@ -822,7 +827,8 @@ StateCheckersTest::testDeleteExtraCopies(
}
DeleteExtraCopiesStateChecker checker;
NodeMaintenanceStatsTracker statsTracker;
- StateChecker::Context c(distributor_component(), getDistributorBucketSpace(), statsTracker, makeDocumentBucket(bid));
+ StateChecker::Context c(node_context(), operation_context(),
+ getDistributorBucketSpace(), statsTracker, makeDocumentBucket(bid));
return testStateChecker(checker, c, false, blocker, includePriority);
}
@@ -939,7 +945,8 @@ std::string StateCheckersTest::testBucketState(
BucketStateStateChecker checker;
NodeMaintenanceStatsTracker statsTracker;
- StateChecker::Context c(distributor_component(), getDistributorBucketSpace(), statsTracker, makeDocumentBucket(bid));
+ StateChecker::Context c(node_context(), operation_context(),
+ getDistributorBucketSpace(), statsTracker, makeDocumentBucket(bid));
return testStateChecker(checker, c, false, PendingMessage(),
includePriority);
}
@@ -1099,7 +1106,8 @@ std::string StateCheckersTest::testBucketStatePerGroup(
BucketStateStateChecker checker;
NodeMaintenanceStatsTracker statsTracker;
- StateChecker::Context c(distributor_component(), getDistributorBucketSpace(), statsTracker, makeDocumentBucket(bid));
+ StateChecker::Context c(node_context(), operation_context(),
+ getDistributorBucketSpace(), statsTracker, makeDocumentBucket(bid));
return testStateChecker(checker, c, false, PendingMessage(),
includePriority);
}
@@ -1286,7 +1294,8 @@ std::string StateCheckersTest::testGarbageCollection(
getConfig().setGarbageCollection("music", std::chrono::seconds(checkInterval));
getConfig().setLastGarbageCollectionChangeTime(vespalib::steady_time(std::chrono::seconds(lastChangeTime)));
NodeMaintenanceStatsTracker statsTracker;
- StateChecker::Context c(distributor_component(), getDistributorBucketSpace(), statsTracker,
+ StateChecker::Context c(node_context(), operation_context(),
+ getDistributorBucketSpace(), statsTracker,
makeDocumentBucket(e.getBucketId()));
getClock().setAbsoluteTimeInSeconds(nowTimestamp);
return testStateChecker(checker, c, false, PendingMessage(),
@@ -1359,7 +1368,8 @@ TEST_F(StateCheckersTest, gc_inhibited_when_ideal_node_in_maintenance) {
getConfig().setGarbageCollection("music", 3600s);
getConfig().setLastGarbageCollectionChangeTime(vespalib::steady_time(vespalib::duration::zero()));
NodeMaintenanceStatsTracker statsTracker;
- StateChecker::Context c(distributor_component(), getDistributorBucketSpace(), statsTracker,
+ StateChecker::Context c(node_context(), operation_context(),
+ getDistributorBucketSpace(), statsTracker,
makeDocumentBucket(bucket));
getClock().setAbsoluteTimeInSeconds(4000);
// Would normally (in a non-maintenance case) trigger GC due to having
@@ -1503,7 +1513,8 @@ TEST_F(StateCheckersTest, context_populates_ideal_state_containers) {
setupDistributor(2, 100, "distributor:1 storage:4");
NodeMaintenanceStatsTracker statsTracker;
- StateChecker::Context c(distributor_component(), getDistributorBucketSpace(), statsTracker, makeDocumentBucket({17, 0}));
+ StateChecker::Context c(node_context(), operation_context(),
+ getDistributorBucketSpace(), statsTracker, makeDocumentBucket({17, 0}));
ASSERT_THAT(c.idealState, ElementsAre(1, 3));
// TODO replace with UnorderedElementsAre once we can build gmock without issues
@@ -1546,7 +1557,8 @@ public:
// NOTE: resets the bucket database!
void runFor(const document::BucketId& bid) {
Checker checker;
- StateChecker::Context c(_fixture.distributor_component(), _fixture.getDistributorBucketSpace(), _statsTracker, makeDocumentBucket(bid));
+ StateChecker::Context c(_fixture.node_context(), _fixture.operation_context(),
+ _fixture.getDistributorBucketSpace(), _statsTracker, makeDocumentBucket(bid));
_result = _fixture.testStateChecker(
checker, c, false, StateCheckersTest::PendingMessage(), false);
}
diff --git a/storage/src/tests/distributor/statoperationtest.cpp b/storage/src/tests/distributor/statoperationtest.cpp
index a80eb9533bb..be4fe414b8b 100644
--- a/storage/src/tests/distributor/statoperationtest.cpp
+++ b/storage/src/tests/distributor/statoperationtest.cpp
@@ -73,7 +73,7 @@ TEST_F(StatOperationTest, bucket_list) {
StatBucketListOperation op(
getDistributorBucketSpace().getBucketDatabase(),
getIdealStateManager(),
- distributor_component().getIndex(),
+ node_context().node_index(),
msg);
op.start(_sender, framework::MilliSecTime(0));
diff --git a/storage/src/tests/distributor/twophaseupdateoperationtest.cpp b/storage/src/tests/distributor/twophaseupdateoperationtest.cpp
index dae94e41b46..ea170441a13 100644
--- a/storage/src/tests/distributor/twophaseupdateoperationtest.cpp
+++ b/storage/src/tests/distributor/twophaseupdateoperationtest.cpp
@@ -332,9 +332,9 @@ TwoPhaseUpdateOperationTest::sendUpdate(const std::string& bucketState,
msg->setCondition(options._condition);
msg->setTransportContext(std::make_unique<DummyTransportContext>());
- auto& comp = distributor_component();
return std::make_shared<TwoPhaseUpdateOperation>(
- comp, comp, comp, getDistributorBucketSpace(), msg, getDistributor().getMetrics());
+ node_context(), operation_context(), doc_selection_parser(),
+ getDistributorBucketSpace(), msg, getDistributor().getMetrics());
}
TEST_F(TwoPhaseUpdateOperationTest, simple) {
diff --git a/storage/src/tests/distributor/updateoperationtest.cpp b/storage/src/tests/distributor/updateoperationtest.cpp
index 6620cf58571..e31a5f0a768 100644
--- a/storage/src/tests/distributor/updateoperationtest.cpp
+++ b/storage/src/tests/distributor/updateoperationtest.cpp
@@ -66,9 +66,8 @@ UpdateOperationTest::sendUpdate(const std::string& bucketState, bool create_if_m
auto msg = std::make_shared<api::UpdateCommand>(makeDocumentBucket(document::BucketId(0)), update, 100);
- auto& comp = distributor_component();
return std::make_shared<UpdateOperation>(
- comp, comp, getDistributorBucketSpace(), msg, std::vector<BucketDatabase::Entry>(),
+ node_context(), operation_context(), getDistributorBucketSpace(), msg, std::vector<BucketDatabase::Entry>(),
getDistributor().getMetrics().updates);
}
diff --git a/storage/src/tests/distributor/visitoroperationtest.cpp b/storage/src/tests/distributor/visitoroperationtest.cpp
index f9a4e6dbe0f..011bf0e81fd 100644
--- a/storage/src/tests/distributor/visitoroperationtest.cpp
+++ b/storage/src/tests/distributor/visitoroperationtest.cpp
@@ -104,8 +104,8 @@ struct VisitorOperationTest : Test, DistributorTestUtil {
const VisitorOperation::Config& config)
{
return std::make_unique<VisitorOperation>(
- distributor_component(),
- distributor_component(),
+ node_context(),
+ operation_context(),
getDistributorBucketSpace(),
msg,
config,