diff options
Diffstat (limited to 'storage/src/tests')
-rw-r--r-- | storage/src/tests/distributor/bucketdbupdatertest.cpp | 37 | ||||
-rw-r--r-- | storage/src/tests/distributor/distributortestutil.cpp | 10 | ||||
-rw-r--r-- | storage/src/tests/distributor/distributortestutil.h | 3 |
3 files changed, 34 insertions, 16 deletions
diff --git a/storage/src/tests/distributor/bucketdbupdatertest.cpp b/storage/src/tests/distributor/bucketdbupdatertest.cpp index d1a54c04359..03a51cf6180 100644 --- a/storage/src/tests/distributor/bucketdbupdatertest.cpp +++ b/storage/src/tests/distributor/bucketdbupdatertest.cpp @@ -4,11 +4,14 @@ #include <iomanip> #include <vespa/storageapi/message/persistence.h> #include <vespa/storage/distributor/bucketdbupdater.h> +#include <vespa/storage/distributor/pending_bucket_space_db_transition.h> +#include <vespa/storage/distributor/outdated_nodes_map.h> #include <vespa/vespalib/io/fileutil.h> #include <vespa/storageframework/defaultimplementation/clock/realclock.h> #include <vespa/storage/storageutil/distributorstatecache.h> #include <tests/distributor/distributortestutil.h> #include <vespa/document/test/make_document_bucket.h> +#include <vespa/document/test/make_bucket_space.h> #include <vespa/storage/distributor/simpleclusterinformation.h> #include <vespa/storage/distributor/distributor.h> #include <vespa/vespalib/text/stringtokenizer.h> @@ -16,6 +19,7 @@ using namespace storage::api; using namespace storage::lib; using document::test::makeDocumentBucket; +using document::test::makeBucketSpace; namespace storage { namespace distributor { @@ -154,6 +158,7 @@ protected: } public: + using OutdatedNodesMap = dbtransition::OutdatedNodesMap; void setUp() override { createLinks(); }; @@ -536,9 +541,9 @@ public: ClusterInformation::CSP clusterInfo( owner.createClusterInfo(oldClusterState)); - std::unordered_set<uint16_t> outdatedNodes; + OutdatedNodesMap outdatedNodesMap; state = PendingClusterState::createForClusterStateChange( - clock, clusterInfo, sender, cmd, outdatedNodes, + clock, clusterInfo, sender, owner.getBucketSpaceRepo(), cmd, outdatedNodesMap, api::Timestamp(1)); } @@ -549,9 +554,8 @@ public: ClusterInformation::CSP clusterInfo( owner.createClusterInfo(oldClusterState)); - std::unordered_set<uint16_t> outdatedNodes; state = PendingClusterState::createForDistributionChange( - clock, clusterInfo, sender, api::Timestamp(1)); + clock, clusterInfo, sender, owner.getBucketSpaceRepo(), api::Timestamp(1)); } }; @@ -1475,7 +1479,7 @@ BucketDBUpdaterTest::getSentNodesDistributionChanged( ClusterInformation::CSP clusterInfo(createClusterInfo(oldClusterState)); std::unique_ptr<PendingClusterState> state( PendingClusterState::createForDistributionChange( - clock, clusterInfo, sender, api::Timestamp(1))); + clock, clusterInfo, sender, getBucketSpaceRepo(), api::Timestamp(1))); sortSentMessagesByIndex(sender); @@ -1637,10 +1641,10 @@ BucketDBUpdaterTest::testPendingClusterStateReceive() framework::defaultimplementation::FakeClock clock; ClusterInformation::CSP clusterInfo(createClusterInfo("cluster:d")); - std::unordered_set<uint16_t> outdatedNodes; + OutdatedNodesMap outdatedNodesMap; std::unique_ptr<PendingClusterState> state( PendingClusterState::createForClusterStateChange( - clock, clusterInfo, sender, cmd, outdatedNodes, + clock, clusterInfo, sender, getBucketSpaceRepo(), cmd, outdatedNodesMap, api::Timestamp(1))); CPPUNIT_ASSERT_EQUAL(3, (int)sender.commands.size()); @@ -1668,7 +1672,8 @@ BucketDBUpdaterTest::testPendingClusterStateReceive() state->done()); } - CPPUNIT_ASSERT_EQUAL(3, (int)state->results().size()); + auto &pendingTransition = state->getPendingBucketSpaceDbTransition(makeBucketSpace()); + CPPUNIT_ASSERT_EQUAL(3, (int)pendingTransition.results().size()); } void @@ -1721,13 +1726,14 @@ parseInputData(const std::string& data, uint16_t node = atoi(tok2[0].c_str()); state.setNodeReplied(node); + auto &pendingTransition = state.getPendingBucketSpaceDbTransition(makeBucketSpace()); vespalib::StringTokenizer tok3(tok2[1], ","); for (uint32_t j = 0; j < tok3.size(); j++) { if (includeBucketInfo) { vespalib::StringTokenizer tok4(tok3[j], "/"); - state.addNodeInfo( + pendingTransition.addNodeInfo( document::BucketId(16, atoi(tok4[0].c_str())), BucketCopy( timestamp, @@ -1739,7 +1745,7 @@ parseInputData(const std::string& data, atoi(tok4[2].c_str()), atoi(tok4[3].c_str())))); } else { - state.addNodeInfo( + pendingTransition.addNodeInfo( document::BucketId(16, atoi(tok3[j].c_str())), BucketCopy(timestamp, node, @@ -1793,7 +1799,7 @@ BucketDBUpdaterTest::mergeBucketLists( framework::MilliSecTimer timer(clock); MessageSenderStub sender; - std::unordered_set<uint16_t> outdatedNodes; + OutdatedNodesMap outdatedNodesMap; { auto cmd(std::make_shared<api::SetSystemStateCommand>(oldState)); @@ -1803,11 +1809,11 @@ BucketDBUpdaterTest::mergeBucketLists( ClusterInformation::CSP clusterInfo(createClusterInfo("cluster:d")); std::unique_ptr<PendingClusterState> state( PendingClusterState::createForClusterStateChange( - clock, clusterInfo, sender, cmd, outdatedNodes, + clock, clusterInfo, sender, getBucketSpaceRepo(), cmd, outdatedNodesMap, beforeTime)); parseInputData(existingData, beforeTime, *state, includeBucketInfo); - state->mergeInto(getBucketDBUpdater().getDistributorComponent().getBucketDatabase()); + state->mergeIntoBucketDatabases(); } BucketDumper dumper_tmp(true); @@ -1822,12 +1828,11 @@ BucketDBUpdaterTest::mergeBucketLists( ClusterInformation::CSP clusterInfo(createClusterInfo(oldState.toString())); std::unique_ptr<PendingClusterState> state( PendingClusterState::createForClusterStateChange( - clock, clusterInfo, sender, cmd, outdatedNodes, + clock, clusterInfo, sender, getBucketSpaceRepo(), cmd, outdatedNodesMap, afterTime)); parseInputData(newData, afterTime, *state, includeBucketInfo); - state->mergeInto(getBucketDBUpdater().getDistributorComponent() - .getBucketDatabase()); + state->mergeIntoBucketDatabases(); } BucketDumper dumper(includeBucketInfo); diff --git a/storage/src/tests/distributor/distributortestutil.cpp b/storage/src/tests/distributor/distributortestutil.cpp index 5deb31f8579..a0aa8e00070 100644 --- a/storage/src/tests/distributor/distributortestutil.cpp +++ b/storage/src/tests/distributor/distributortestutil.cpp @@ -358,6 +358,16 @@ DistributorTestUtil::getBucketDatabase() const { return _distributor->getDefaultBucketSpace().getBucketDatabase(); } +DistributorBucketSpaceRepo & +DistributorTestUtil::getBucketSpaceRepo() { + return _distributor->getBucketSpaceRepo(); +} + +const DistributorBucketSpaceRepo & +DistributorTestUtil::getBucketSpaceRepo() const { + return _distributor->getBucketSpaceRepo(); +} + const lib::Distribution& DistributorTestUtil::getDistribution() const { return _distributor->getDefaultBucketSpace().getDistribution(); diff --git a/storage/src/tests/distributor/distributortestutil.h b/storage/src/tests/distributor/distributortestutil.h index 4f09c11ac03..19da0483165 100644 --- a/storage/src/tests/distributor/distributortestutil.h +++ b/storage/src/tests/distributor/distributortestutil.h @@ -20,6 +20,7 @@ namespace distributor { class BucketDBUpdater; class Distributor; class DistributorBucketSpace; +class DistributorBucketSpaceRepo; class IdealStateManager; class ExternalOperationHandler; class Operation; @@ -125,6 +126,8 @@ public: DistributorBucketSpace &getDistributorBucketSpace(); BucketDatabase& getBucketDatabase(); const BucketDatabase& getBucketDatabase() const; + DistributorBucketSpaceRepo &getBucketSpaceRepo(); + const DistributorBucketSpaceRepo &getBucketSpaceRepo() const; const lib::Distribution& getDistribution() const; // "End to end" distribution change trigger, which will invoke the bucket |