diff options
author | Tor Brede Vekterli <vekterli@oath.com> | 2018-02-14 15:29:29 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-14 15:29:29 +0100 |
commit | eadf1968da3755ae6318c5624b454d329ccf745b (patch) | |
tree | e253f16322af024d94a1995b3e8f9b931b2504e0 /storage/src/tests/distributor/distributortest.cpp | |
parent | 22963ff602da9338422feb2f783ebd9abc0b30d1 (diff) | |
parent | 9c5bb6a1a6920ef62a2e26a80b7848c9c9bae8d5 (diff) |
Merge pull request #5035 from vespa-engine/toregge/adjust-distributor-unit-tests-for-multiple-bucket-spaces
Adjust distributor unit tests to handle global distributor bucket space.
Diffstat (limited to 'storage/src/tests/distributor/distributortest.cpp')
-rw-r--r-- | storage/src/tests/distributor/distributortest.cpp | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/storage/src/tests/distributor/distributortest.cpp b/storage/src/tests/distributor/distributortest.cpp index 1640af0f871..d585c4d0d32 100644 --- a/storage/src/tests/distributor/distributortest.cpp +++ b/storage/src/tests/distributor/distributortest.cpp @@ -9,6 +9,7 @@ #include <vespa/storageapi/message/removelocation.h> #include <vespa/storageframework/defaultimplementation/thread/threadpoolimpl.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/storage/config/config-stor-distributormanager.h> @@ -18,6 +19,7 @@ using document::test::makeDocumentBucket; using document::test::makeBucketSpace; +using document::FixedBucketSpaces; namespace storage { @@ -58,6 +60,9 @@ class Distributor_Test : public CppUnit::TestFixture, CPPUNIT_TEST(closing_aborts_priority_queued_client_requests); CPPUNIT_TEST_SUITE_END(); +public: + Distributor_Test(); + protected: void testOperationGeneration(); void testOperationsGeneratedAndStartedWithoutDuplicates(); @@ -89,9 +94,12 @@ protected: void internal_messages_are_started_in_fifo_order_batch(); void closing_aborts_priority_queued_client_requests(); + std::vector<document::BucketSpace> _bucketSpaces; + public: void setUp() override { createLinks(); + _bucketSpaces = getBucketSpaces(); }; void tearDown() override { @@ -197,6 +205,13 @@ private: CPPUNIT_TEST_SUITE_REGISTRATION(Distributor_Test); +Distributor_Test::Distributor_Test() + : CppUnit::TestFixture(), + DistributorTestUtil(), + _bucketSpaces() +{ +} + void Distributor_Test::testOperationGeneration() { @@ -752,19 +767,23 @@ void Distributor_Test::sendDownClusterStateCommand() { } void Distributor_Test::replyToSingleRequestBucketInfoCommandWith1Bucket() { - CPPUNIT_ASSERT_EQUAL(size_t(1), _sender.commands.size()); - CPPUNIT_ASSERT_EQUAL(api::MessageType::REQUESTBUCKETINFO, - _sender.commands[0]->getType()); - auto& bucketReq(static_cast<api::RequestBucketInfoCommand&>( - *_sender.commands[0])); - auto bucketReply = bucketReq.makeReply(); - // Make sure we have a bucket to route our remove op to, or we'd get - // an immediate reply anyway. - dynamic_cast<api::RequestBucketInfoReply&>(*bucketReply) - .getBucketInfo().push_back( - api::RequestBucketInfoReply::Entry(document::BucketId(1, 1), - api::BucketInfo(20, 10, 12, 50, 60, true, true))); - _distributor->handleMessage(std::move(bucketReply)); + CPPUNIT_ASSERT_EQUAL(_bucketSpaces.size(), _sender.commands.size()); + for (uint32_t i = 0; i < _sender.commands.size(); ++i) { + CPPUNIT_ASSERT_EQUAL(api::MessageType::REQUESTBUCKETINFO, + _sender.commands[i]->getType()); + auto& bucketReq(static_cast<api::RequestBucketInfoCommand&> + (*_sender.commands[i])); + auto bucketReply = bucketReq.makeReply(); + if (bucketReq.getBucketSpace() == FixedBucketSpaces::default_space()) { + // Make sure we have a bucket to route our remove op to, or we'd get + // an immediate reply anyway. + dynamic_cast<api::RequestBucketInfoReply&>(*bucketReply) + .getBucketInfo().push_back( + api::RequestBucketInfoReply::Entry(document::BucketId(1, 1), + api::BucketInfo(20, 10, 12, 50, 60, true, true))); + } + _distributor->handleMessage(std::move(bucketReply)); + } _sender.commands.clear(); } |