diff options
Diffstat (limited to 'searchcore/src/tests')
10 files changed, 70 insertions, 38 deletions
diff --git a/searchcore/src/tests/proton/attribute/attribute_test.cpp b/searchcore/src/tests/proton/attribute/attribute_test.cpp index ce0205af29f..cb1df2df0c5 100644 --- a/searchcore/src/tests/proton/attribute/attribute_test.cpp +++ b/searchcore/src/tests/proton/attribute/attribute_test.cpp @@ -41,6 +41,7 @@ LOG_SETUP("attribute_test"); #include <vespa/vespalib/io/fileutil.h> #include <vespa/vespalib/test/insertion_operators.h> #include <vespa/vespalib/testkit/testapp.h> +#include <vespa/searchcommon/attribute/iattributevector.h> namespace vespa { namespace config { namespace search {}}} @@ -55,6 +56,7 @@ using proton::ImportedAttributesRepo; using proton::test::AttributeUtils; using search::TuneFileAttributes; using search::attribute::BitVectorSearchCache; +using search::attribute::IAttributeVector; using search::attribute::ImportedAttributeVector; using search::attribute::ReferenceAttribute; using search::index::DummyFileHeaderContext; @@ -69,10 +71,11 @@ using vespalib::tensor::Tensor; using vespalib::tensor::TensorCells; using vespalib::tensor::TensorDimensions; -typedef search::attribute::Config AVConfig; -typedef search::attribute::BasicType AVBasicType; -typedef search::attribute::CollectionType AVCollectionType; -typedef SingleValueNumericAttribute<IntegerAttributeTemplate<int32_t> > Int32AttributeVector; +using AVConfig = search::attribute::Config; +using AVBasicType = search::attribute::BasicType; +using AVCollectionType = search::attribute::CollectionType; +using Int32AttributeVector = SingleValueNumericAttribute<IntegerAttributeTemplate<int32_t> >; +using LidVector = LidVectorContext::LidVector; namespace { @@ -156,6 +159,9 @@ struct Fixture void remove(SerialNum serialNum, DocumentIdT lid, bool immediateCommit = true) { _aw->remove(serialNum, lid, immediateCommit, emptyCallback); } + void remove(const LidVector &lidVector, SerialNum serialNum, bool immediateCommit = true) { + _aw->remove(lidVector, serialNum, immediateCommit, emptyCallback); + } void commit(SerialNum serialNum) { _aw->forceCommit(serialNum, emptyCallback); } @@ -293,23 +299,23 @@ TEST_F("require that attribute writer handles predicate put", Fixture) EXPECT_TRUE(it.valid()); } +void +assertUndefined(const IAttributeVector &attr, uint32_t docId) +{ + EXPECT_TRUE(search::attribute::isUndefined<int32_t>(attr.getInt(docId))); +} + TEST_F("require that attribute writer handles remove", Fixture) { AttributeVector::SP a1 = f.addAttribute("a1"); AttributeVector::SP a2 = f.addAttribute("a2"); - Schema s; - s.addAttributeField(Schema::AttributeField("a1", schema::DataType::INT32, CollectionType::SINGLE)); - s.addAttributeField(Schema::AttributeField("a2", schema::DataType::INT32, CollectionType::SINGLE)); - - DocBuilder idb(s); - fillAttribute(a1, 1, 10, 1); fillAttribute(a2, 1, 20, 1); f.remove(2, 0); - EXPECT_TRUE(search::attribute::isUndefined<int32_t>(a1->getInt(0))); - EXPECT_TRUE(search::attribute::isUndefined<int32_t>(a2->getInt(0))); + TEST_DO(assertUndefined(*a1, 0)); + TEST_DO(assertUndefined(*a2, 0)); f.remove(2, 0); // same sync token as previous try { @@ -321,6 +327,24 @@ TEST_F("require that attribute writer handles remove", Fixture) } } +TEST_F("require that attribute writer handles batch remove", Fixture) +{ + AttributeVector::SP a1 = f.addAttribute("a1"); + AttributeVector::SP a2 = f.addAttribute("a2"); + fillAttribute(a1, 4, 22, 1); + fillAttribute(a2, 4, 33, 1); + + LidVector lidsToRemove = {1,3}; + f.remove(lidsToRemove, 2); + + TEST_DO(assertUndefined(*a1, 1)); + EXPECT_EQUAL(22, a1->getInt(2)); + TEST_DO(assertUndefined(*a1, 3)); + TEST_DO(assertUndefined(*a2, 1)); + EXPECT_EQUAL(33, a2->getInt(2)); + TEST_DO(assertUndefined(*a2, 3)); +} + void verifyAttributeContent(const AttributeVector & v, uint32_t lid, vespalib::stringref expected) { attribute::ConstCharContent sbuf; diff --git a/searchcore/src/tests/proton/docsummary/docsummary.cpp b/searchcore/src/tests/proton/docsummary/docsummary.cpp index bce3fb7267c..6705527dfa9 100644 --- a/searchcore/src/tests/proton/docsummary/docsummary.cpp +++ b/searchcore/src/tests/proton/docsummary/docsummary.cpp @@ -5,7 +5,7 @@ #include <vespa/eval/tensor/default_tensor.h> #include <vespa/eval/tensor/serialization/typed_binary_format.h> #include <vespa/eval/tensor/tensor_factory.h> -#include <vespa/persistence/spi/test.h> +#include <vespa/document/test/make_bucket_space.h> #include <vespa/searchcore/proton/attribute/attribute_writer.h> #include <vespa/searchcore/proton/test/bucketfactory.h> #include <vespa/searchcore/proton/docsummary/docsumcontext.h> @@ -43,9 +43,9 @@ using namespace search::engine; using namespace search::index; using namespace search::transactionlog; using namespace search; -using namespace storage::spi::test; using document::DocumenttypesConfig; +using document::test::makeBucketSpace; using search::TuneFileDocumentDB; using search::index::DummyFileHeaderContext; using search::index::schema::CollectionType; diff --git a/searchcore/src/tests/proton/documentdb/combiningfeedview/combiningfeedview_test.cpp b/searchcore/src/tests/proton/documentdb/combiningfeedview/combiningfeedview_test.cpp index a997b3cc3db..c7006be2804 100644 --- a/searchcore/src/tests/proton/documentdb/combiningfeedview/combiningfeedview_test.cpp +++ b/searchcore/src/tests/proton/documentdb/combiningfeedview/combiningfeedview_test.cpp @@ -2,7 +2,7 @@ #include <vespa/log/log.h> LOG_SETUP("combiningfeedview_test"); -#include <vespa/persistence/spi/test.h> +#include <vespa/document/test/make_bucket_space.h> #include <vespa/searchcore/proton/feedoperation/moveoperation.h> #include <vespa/searchcore/proton/server/combiningfeedview.h> #include <vespa/searchcore/proton/test/test.h> @@ -11,10 +11,10 @@ LOG_SETUP("combiningfeedview_test"); using document::DocumentTypeRepo; using document::DocumentUpdate; +using document::test::makeBucketSpace; using search::IDestructorCallback; using search::SerialNum; using storage::spi::Timestamp; -using storage::spi::test::makeBucketSpace; using namespace proton; typedef std::vector<IFeedView::SP> FeedViewVector; diff --git a/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp b/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp index 8369ec0630d..1b94ba36dad 100644 --- a/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp +++ b/searchcore/src/tests/proton/documentdb/document_subdbs/document_subdbs_test.cpp @@ -1,6 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/persistence/spi/test.h> +#include <vespa/document/test/make_bucket_space.h> #include <vespa/searchcore/proton/attribute/imported_attributes_repo.h> #include <vespa/searchcore/proton/bucketdb/bucketdbhandler.h> #include <vespa/searchcore/proton/common/hw_info.h> @@ -44,6 +44,7 @@ using namespace search; using namespace searchcorespi; using namespace vespalib; +using document::test::makeBucketSpace; using proton::bucketdb::BucketDBHandler; using proton::bucketdb::IBucketDBHandler; using proton::bucketdb::IBucketDBHandlerInitializer; @@ -52,7 +53,6 @@ using search::test::DirectoryHandler; using searchcorespi::IFlushTarget; using searchcorespi::index::IThreadingService; using storage::spi::Timestamp; -using storage::spi::test::makeBucketSpace; using vespa::config::search::core::ProtonConfig; using vespalib::mkdir; diff --git a/searchcore/src/tests/proton/documentdb/documentbucketmover/documentbucketmover_test.cpp b/searchcore/src/tests/proton/documentdb/documentbucketmover/documentbucketmover_test.cpp index 4419e982abf..7aa452c5aa3 100644 --- a/searchcore/src/tests/proton/documentdb/documentbucketmover/documentbucketmover_test.cpp +++ b/searchcore/src/tests/proton/documentdb/documentbucketmover/documentbucketmover_test.cpp @@ -15,7 +15,7 @@ #include <vespa/searchcore/proton/test/disk_mem_usage_notifier.h> #include <vespa/searchcore/proton/test/test.h> #include <vespa/searchlib/index/docbuilder.h> -#include <vespa/persistence/spi/test.h> +#include <vespa/document/test/make_bucket_space.h> #include <vespa/vespalib/testkit/testapp.h> using namespace proton; @@ -24,6 +24,7 @@ using document::Document; using document::DocumentId; using document::DocumentTypeRepo; using document::GlobalId; +using document::test::makeBucketSpace; using proton::bucketdb::BucketCreateNotifier; using search::DocumentIdT; using search::DocumentMetaData; @@ -32,7 +33,6 @@ using search::index::DocBuilder; using search::index::Schema; using storage::spi::BucketInfo; using storage::spi::Timestamp; -using storage::spi::test::makeBucketSpace; using vespalib::make_string; using BlockedReason = IBlockableMaintenanceJob::BlockedReason; diff --git a/searchcore/src/tests/proton/documentdb/documentdb_test.cpp b/searchcore/src/tests/proton/documentdb/documentdb_test.cpp index f7e09eeec3f..58372c59193 100644 --- a/searchcore/src/tests/proton/documentdb/documentdb_test.cpp +++ b/searchcore/src/tests/proton/documentdb/documentdb_test.cpp @@ -3,7 +3,7 @@ #include <tests/proton/common/dummydbowner.h> #include <vespa/document/datatype/documenttype.h> #include <vespa/fastos/file.h> -#include <vespa/persistence/spi/test.h> +#include <vespa/document/test/make_bucket_space.h> #include <vespa/searchcore/proton/attribute/flushableattribute.h> #include <vespa/searchcore/proton/common/feedtoken.h> #include <vespa/searchcore/proton/common/statusreport.h> @@ -27,12 +27,12 @@ using namespace cloud::config::filedistribution; using namespace proton; -using namespace storage::spi::test; using namespace vespalib::slime; using document::DocumentType; using document::DocumentTypeRepo; using document::DocumenttypesConfig; +using document::test::makeBucketSpace; using search::TuneFileDocumentDB; using search::index::DummyFileHeaderContext; using search::index::Schema; diff --git a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp index f20ad01bcf6..b84aa1c1c6c 100644 --- a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp +++ b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp @@ -1,6 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/persistence/spi/test.h> +#include <vespa/document/test/make_bucket_space.h> #include <vespa/searchcore/proton/attribute/attribute_usage_filter.h> #include <vespa/searchcore/proton/attribute/i_attribute_manager.h> #include <vespa/searchcore/proton/common/doctypename.h> @@ -43,6 +43,7 @@ using namespace vespalib::slime; using document::BucketId; using document::Document; using document::DocumentId; +using document::test::makeBucketSpace; using fastos::ClockSystem; using fastos::TimeStamp; using proton::bucketdb::BucketCreateNotifier; @@ -54,7 +55,6 @@ using search::IDestructorCallback; using search::SerialNum; using storage::spi::BucketInfo; using storage::spi::Timestamp; -using storage::spi::test::makeBucketSpace; using vespalib::Slime; using vespalib::makeClosure; using vespalib::makeTask; diff --git a/searchcore/src/tests/proton/flushengine/prepare_restart_flush_strategy/prepare_restart_flush_strategy_test.cpp b/searchcore/src/tests/proton/flushengine/prepare_restart_flush_strategy/prepare_restart_flush_strategy_test.cpp index 428cbf60996..6bc7e1b5556 100644 --- a/searchcore/src/tests/proton/flushengine/prepare_restart_flush_strategy/prepare_restart_flush_strategy_test.cpp +++ b/searchcore/src/tests/proton/flushengine/prepare_restart_flush_strategy/prepare_restart_flush_strategy_test.cpp @@ -15,7 +15,7 @@ using SimpleFlushHandler = test::DummyFlushHandler; using FlushCandidatesList = std::vector<FlushTargetCandidates>; using Config = PrepareRestartFlushStrategy::Config; -const Config DEFAULT_CFG(2.0, 4.0); +const Config DEFAULT_CFG(2.0, 0.0, 4.0); struct SimpleFlushTarget : public test::DummyFlushTarget { @@ -107,7 +107,7 @@ public: : _sortedFlushContexts(&sortedFlushContexts), _numCandidates(sortedFlushContexts.size()), _tlsStats(1000, 11, 110), - _cfg(DEFAULT_CFG) + _cfg(2.0, 3.0, 4.0) {} CandidatesBuilder &flushContexts(const FlushContext::List &sortedFlushContexts) { _sortedFlushContexts = &sortedFlushContexts; @@ -140,28 +140,35 @@ struct CandidatesFixture CandidatesFixture() : emptyContexts(), builder(emptyContexts) {} }; +void +assertCosts(double tlsReplayBytesCost, double tlsReplayOperationsCost, double flushTargetsWriteCost, const FlushTargetCandidates &candidates) +{ + EXPECT_EQUAL(tlsReplayBytesCost, candidates.getTlsReplayCost().bytesCost); + EXPECT_EQUAL(tlsReplayOperationsCost, candidates.getTlsReplayCost().operationsCost); + EXPECT_EQUAL(flushTargetsWriteCost, candidates.getFlushTargetsWriteCost()); + EXPECT_EQUAL(tlsReplayBytesCost + tlsReplayOperationsCost + flushTargetsWriteCost, candidates.getTotalCost()); +} + TEST_F("require that tls replay cost is correct for 100% replay", CandidatesFixture) { - EXPECT_EQUAL(2000, f.builder.replayEnd(110).build().getTlsReplayCost()); + TEST_DO(assertCosts(1000 * 2, 100 * 3, 0, f.builder.replayEnd(110).build())); } TEST_F("require that tls replay cost is correct for 75% replay", CandidatesFixture) { FlushContext::List contexts = ContextsBuilder().add("target1", 10, 0).add("target2", 35, 0).build(); - EXPECT_EQUAL(1500, f.builder.flushContexts(contexts).numCandidates(1).replayEnd(110). - build().getTlsReplayCost()); + TEST_DO(assertCosts(750 * 2, 75 * 3, 0, f.builder.flushContexts(contexts).numCandidates(1).replayEnd(110).build())); } TEST_F("require that tls replay cost is correct for 25% replay", CandidatesFixture) { FlushContext::List contexts = ContextsBuilder().add("target1", 10, 0).add("target2", 85, 0).build(); - EXPECT_EQUAL(500, f.builder.flushContexts(contexts).numCandidates(1).replayEnd(110). - build().getTlsReplayCost()); + TEST_DO(assertCosts(250 * 2, 25 * 3, 0, f.builder.flushContexts(contexts).numCandidates(1).replayEnd(110).build())); } TEST_F("require that tls replay cost is correct for zero operations to replay", CandidatesFixture) { - EXPECT_EQUAL(0, f.builder.replayEnd(10).build().getTlsReplayCost()); + TEST_DO(assertCosts(0, 0, 0, f.builder.replayEnd(10).build())); } TEST_F("require that flush cost is correct for zero flush targets", CandidatesFixture) @@ -172,7 +179,7 @@ TEST_F("require that flush cost is correct for zero flush targets", CandidatesFi TEST_F("require that flush cost is sum of flush targets", CandidatesFixture) { FlushContext::List contexts = ContextsBuilder().add("target1", 20, 1000).add("target2", 30, 2000).build(); - EXPECT_EQUAL(12000, f.builder.flushContexts(contexts).build().getFlushTargetsWriteCost()); + TEST_DO(assertCosts(0, 0, 1000 * 4 + 2000 * 4, f.builder.flushContexts(contexts).build())); } @@ -227,7 +234,7 @@ assertFlushContexts(const vespalib::string &expected, const FlushContext::List & * - handler1: serial numbers 10 -> 110, 1000 bytes * - handler2: serial numbers 10 -> 110, 2000 bytes * - * The cost config is: tlsReplayCost=2.0, flushTargetsWriteCost=4.0. + * The cost config is: tlsReplayByteCost=2.0, tlsReplayOperationCost=0.0, flushTargetsWriteCost=4.0. * The cost of replaying the complete TLS is then: * - handler1: 1000*2.0 = 2000 * - handler2: 2000*2.0 = 4000 diff --git a/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp b/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp index 9e13cf2ff7d..4a195514db1 100644 --- a/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp +++ b/searchcore/src/tests/proton/persistenceengine/persistenceengine_test.cpp @@ -4,6 +4,7 @@ #include <vespa/document/datatype/documenttype.h> #include <vespa/document/fieldset/fieldsets.h> #include <vespa/document/repo/documenttyperepo.h> +#include <vespa/document/test/make_bucket_space.h> #include <vespa/persistence/spi/documentselection.h> #include <vespa/persistence/spi/test.h> #include <vespa/persistence/spi/test.h> @@ -21,6 +22,7 @@ using document::BucketSpace; using document::Document; using document::DocumentId; using document::DocumentType; +using document::test::makeBucketSpace; using search::DocumentMetaData; using storage::spi::Bucket; using storage::spi::BucketChecksum; @@ -42,7 +44,6 @@ using storage::spi::Selection; using storage::spi::Timestamp; using storage::spi::UpdateResult; using storage::spi::test::makeSpiBucket; -using storage::spi::test::makeBucketSpace; using namespace proton; using namespace vespalib; @@ -610,7 +611,7 @@ TEST_F("require that setClusterState() is routed to handlers", SimpleFixture) { ClusterState state(createClusterState()); - f.engine.setClusterState(state); + f.engine.setClusterState(makeBucketSpace(), state); EXPECT_EQUAL(&state, f.hset.handler1.lastCalc); EXPECT_EQUAL(&state, f.hset.handler2.lastCalc); } diff --git a/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp b/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp index 6c682ea33e9..b9059338f27 100644 --- a/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp +++ b/searchcore/src/tests/proton/proton_config_fetcher/proton_config_fetcher_test.cpp @@ -170,12 +170,12 @@ struct ProtonConfigOwner : public proton::IProtonConfigurer return getConfigured(); } virtual void reconfigure(std::shared_ptr<ProtonConfigSnapshot> cfg) override { - std::unique_lock<std::mutex> guard(_mutex); + std::lock_guard<std::mutex> guard(_mutex); _config.set(cfg); _configured = true; } bool getConfigured() const { - std::unique_lock<std::mutex> guard(_mutex); + std::lock_guard<std::mutex> guard(_mutex); return _configured; } BootstrapConfig::SP getBootstrapConfig() { |