diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2024-06-27 00:36:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-27 00:36:33 +0200 |
commit | 79843a4d03303404ea976cc8e83b969c7f22ad5b (patch) | |
tree | 86e060f534213500560f1fe90cf77c5c02229ee1 | |
parent | fbc6c50b8f1e722955d36327f2ecb9f4e549aaee (diff) | |
parent | 9e933c3eb0496235c3eddd5b9de5d2c3846c381b (diff) |
Merge pull request #31735 from vespa-engine/balder/more-tests-in-same-binary
Balder/more tests in same binary
25 files changed, 230 insertions, 359 deletions
diff --git a/searchcore/CMakeLists.txt b/searchcore/CMakeLists.txt index 6a5d3915d6a..71958c62ffa 100644 --- a/searchcore/CMakeLists.txt +++ b/searchcore/CMakeLists.txt @@ -74,10 +74,7 @@ vespa_define_module( src/tests/proton/docsummary src/tests/proton/document_iterator src/tests/proton/documentdb - src/tests/proton/documentdb/buckethandler src/tests/proton/documentdb/clusterstatehandler - src/tests/proton/documentdb/combiningfeedview - src/tests/proton/documentdb/configurer src/tests/proton/documentdb/document_scan_iterator src/tests/proton/documentdb/document_subdbs src/tests/proton/documentdb/documentbucketmover @@ -85,14 +82,9 @@ vespa_define_module( src/tests/proton/documentdb/documentdbconfigscout src/tests/proton/documentdb/executor_threading_service src/tests/proton/documentdb/feedhandler - src/tests/proton/documentdb/feedview src/tests/proton/documentdb/fileconfigmanager src/tests/proton/documentdb/job_tracked_maintenance_job src/tests/proton/documentdb/lid_space_compaction - src/tests/proton/documentdb/maintenancecontroller - src/tests/proton/documentdb/move_operation_limiter - src/tests/proton/documentdb/storeonlyfeedview - src/tests/proton/documentdb/threading_service_config src/tests/proton/documentmetastore src/tests/proton/documentmetastore/lidreusedelayer src/tests/proton/documentmetastore/lid_allocator diff --git a/searchcore/src/tests/proton/documentdb/CMakeLists.txt b/searchcore/src/tests/proton/documentdb/CMakeLists.txt index 485c583990c..374cdb6ab52 100644 --- a/searchcore/src/tests/proton/documentdb/CMakeLists.txt +++ b/searchcore/src/tests/proton/documentdb/CMakeLists.txt @@ -21,3 +21,19 @@ vespa_add_executable(searchcore_documentdb_test_app TEST searchcore_proton_metrics ) vespa_add_test(NAME searchcore_documentdb_test_app COMMAND searchcore_documentdb_test_app) + +vespa_add_executable(searchcore_proton_documentdb_vespa_test_app TEST + SOURCES + vespa_testrunner.cpp + buckethandler_test.cpp + combiningfeedview_test.cpp + configurer_test.cpp + feedview_test.cpp + maintenancecontroller_test.cpp + storeonlyfeedview_test.cpp + DEPENDS + searchcore_server + searchcore_feedoperation + searchcore_test +) +vespa_add_test(NAME searchcore_proton_documentdb_vespa_test_app COMMAND searchcore_proton_documentdb_vespa_test_app) diff --git a/searchcore/src/tests/proton/documentdb/buckethandler/.gitignore b/searchcore/src/tests/proton/documentdb/buckethandler/.gitignore deleted file mode 100644 index c159971ebc7..00000000000 --- a/searchcore/src/tests/proton/documentdb/buckethandler/.gitignore +++ /dev/null @@ -1 +0,0 @@ -searchcore_buckethandler_test_app diff --git a/searchcore/src/tests/proton/documentdb/buckethandler/CMakeLists.txt b/searchcore/src/tests/proton/documentdb/buckethandler/CMakeLists.txt deleted file mode 100644 index e67143c1b5d..00000000000 --- a/searchcore/src/tests/proton/documentdb/buckethandler/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(searchcore_buckethandler_test_app TEST - SOURCES - buckethandler_test.cpp - DEPENDS - searchcore_test - searchcore_server - searchcore_feedoperation - searchcore_matching - searchcore_attribute - searchcore_documentmetastore - searchcore_bucketdb - searchcore_pcommon - searchcore_grouping -) -vespa_add_test(NAME searchcore_buckethandler_test_app COMMAND searchcore_buckethandler_test_app) diff --git a/searchcore/src/tests/proton/documentdb/buckethandler/buckethandler_test.cpp b/searchcore/src/tests/proton/documentdb/buckethandler_test.cpp index e09a0d2ea2b..4cf6b49d090 100644 --- a/searchcore/src/tests/proton/documentdb/buckethandler/buckethandler_test.cpp +++ b/searchcore/src/tests/proton/documentdb/buckethandler_test.cpp @@ -9,9 +9,6 @@ #include <vespa/vespalib/util/threadstackexecutor.h> #include <vespa/vespalib/testkit/test_kit.h> -#include <vespa/log/log.h> -LOG_SETUP("buckethandler_test"); - using namespace proton; using document::BucketId; using document::GlobalId; @@ -22,6 +19,7 @@ using storage::spi::test::makeSpiBucket; using vespalib::ThreadStackExecutor; using proton::test::BucketStateCalculator; +namespace { const GlobalId GID_1("111111111111"); const BucketId BUCKET_1(8, GID_1.convertToBucketId().getRawId()); const Timestamp TIME_1(1u); @@ -95,41 +93,8 @@ struct Fixture test::BucketIdListResultHandler _bucketList; test::BucketInfoResultHandler _bucketInfo; std::shared_ptr<test::GenericResultHandler> _genResult; - Fixture() - : _builder(), - _bucketDB(std::make_shared<bucketdb::BucketDBOwner>()), - _ready(_bucketDB, SubDbType::READY), - _removed(_bucketDB, SubDbType::REMOVED), - _notReady(_bucketDB, SubDbType::NOTREADY), - _exec(1), - _handler(_exec), - _changedHandler(), - _calc(new BucketStateCalculator()), - _bucketList(), _bucketInfo(), - _genResult(std::make_shared<test::GenericResultHandler>()) - { - // bucket 2 & 3 & 4 & 7 in ready - _ready.insertDocs(_builder.createDocs(2, 1, 3). // 2 docs - createDocs(3, 3, 6). // 3 docs - createDocs(4, 6, 10). // 4 docs - createDocs(7, 10, 11). // 1 doc - getDocs()); - // bucket 2 in removed - _removed.insertDocs(_builder.clearDocs(). - createDocs(2, 16, 20). // 4 docs - getDocs()); - // bucket 4 in not ready - _notReady.insertDocs(_builder.clearDocs(). - createDocs(4, 22, 24). // 2 docs - getDocs()); - _handler.setReadyBucketHandler(_ready._metaStore); - _handler.addBucketStateChangedHandler(&_changedHandler); - _handler.notifyClusterStateChanged(_calc); - } - ~Fixture() - { - _handler.removeBucketStateChangedHandler(&_changedHandler); - } + Fixture() __attribute__((noinline)); + ~Fixture() __attribute__((noinline)); void sync() { _exec.sync(); } void handleGetBucketInfo(const BucketId &bucket) { _handler.handleGetBucketInfo(makeSpiBucket(bucket), _bucketInfo); @@ -147,6 +112,44 @@ struct Fixture } }; +Fixture::Fixture() + : _builder(), + _bucketDB(std::make_shared<bucketdb::BucketDBOwner>()), + _ready(_bucketDB, SubDbType::READY), + _removed(_bucketDB, SubDbType::REMOVED), + _notReady(_bucketDB, SubDbType::NOTREADY), + _exec(1), + _handler(_exec), + _changedHandler(), + _calc(std::make_shared<BucketStateCalculator>()), + _bucketList(), _bucketInfo(), + _genResult(std::make_shared<test::GenericResultHandler>()) +{ + // bucket 2 & 3 & 4 & 7 in ready + _ready.insertDocs(_builder.createDocs(2, 1, 3). // 2 docs + createDocs(3, 3, 6). // 3 docs + createDocs(4, 6, 10). // 4 docs + createDocs(7, 10, 11). // 1 doc + getDocs()); + // bucket 2 in removed + _removed.insertDocs(_builder.clearDocs(). + createDocs(2, 16, 20). // 4 docs + getDocs()); + // bucket 4 in not ready + _notReady.insertDocs(_builder.clearDocs(). + createDocs(4, 22, 24). // 2 docs + getDocs()); + _handler.setReadyBucketHandler(_ready._metaStore); + _handler.addBucketStateChangedHandler(&_changedHandler); + _handler.notifyClusterStateChanged(_calc); +} +Fixture::~Fixture() +{ + _handler.removeBucketStateChangedHandler(&_changedHandler); +} + +} + TEST_F("require that handleListBuckets() returns buckets from all sub dbs", Fixture) { @@ -291,9 +294,3 @@ TEST_F("node going from maintenance to down state deactivates all buckets", Fixt f.handleGetBucketInfo(f._ready.bucket(2)); EXPECT_FALSE(f._bucketInfo.getInfo().isActive()); } - -TEST_MAIN() -{ - TEST_RUN_ALL(); -} - diff --git a/searchcore/src/tests/proton/documentdb/combiningfeedview/.gitignore b/searchcore/src/tests/proton/documentdb/combiningfeedview/.gitignore deleted file mode 100644 index 3302e827c3e..00000000000 --- a/searchcore/src/tests/proton/documentdb/combiningfeedview/.gitignore +++ /dev/null @@ -1 +0,0 @@ -searchcore_combiningfeedview_test_app diff --git a/searchcore/src/tests/proton/documentdb/combiningfeedview/CMakeLists.txt b/searchcore/src/tests/proton/documentdb/combiningfeedview/CMakeLists.txt deleted file mode 100644 index 223befab60d..00000000000 --- a/searchcore/src/tests/proton/documentdb/combiningfeedview/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(searchcore_combiningfeedview_test_app TEST - SOURCES - combiningfeedview_test.cpp - DEPENDS - searchcore_test - searchcore_server - searchcore_feedoperation - searchcore_matching - searchcore_attribute - searchcore_documentmetastore - searchcore_bucketdb - searchcore_pcommon - searchcore_grouping - searchcore_proton_metrics -) -vespa_add_test(NAME searchcore_combiningfeedview_test_app COMMAND searchcore_combiningfeedview_test_app) diff --git a/searchcore/src/tests/proton/documentdb/combiningfeedview/combiningfeedview_test.cpp b/searchcore/src/tests/proton/documentdb/combiningfeedview_test.cpp index c713108dcc0..4ad0f993d1b 100644 --- a/searchcore/src/tests/proton/documentdb/combiningfeedview/combiningfeedview_test.cpp +++ b/searchcore/src/tests/proton/documentdb/combiningfeedview_test.cpp @@ -10,9 +10,6 @@ #include <vespa/document/update/documentupdate.h> #include <vespa/vespalib/testkit/test_kit.h> -#include <vespa/log/log.h> -LOG_SETUP("combiningfeedview_test"); - using document::DocumentTypeRepo; using document::DocumentUpdate; using document::test::makeBucketSpace; @@ -23,6 +20,7 @@ using namespace proton; using FeedViewVector = std::vector<IFeedView::SP>; +namespace { struct MyFeedView : public test::DummyFeedView { using SP = std::shared_ptr<MyFeedView>; @@ -128,18 +126,8 @@ struct Fixture MySubDb _notReady; test::BucketStateCalculator::SP _calc; CombiningFeedView _view; - Fixture() : - _builder(), - _bucketDB(std::make_shared<bucketdb::BucketDBOwner>()), - _ready(_builder.getRepo(), _bucketDB, SubDbType::READY), - _removed(_builder.getRepo(), _bucketDB, SubDbType::REMOVED), - _notReady(_builder.getRepo(), _bucketDB, SubDbType::NOTREADY), - _calc(new test::BucketStateCalculator()), - _view(getVector(_ready, _removed, _notReady), makeBucketSpace(), _calc) - { - _builder.createDoc(1, 1); - _builder.createDoc(2, 2); - } + Fixture() __attribute__((noinline)); + ~Fixture() __attribute__((noinline)); const test::UserDocuments &userDocs() const { return _builder.getDocs(); } const test::BucketDocuments &userDocs(uint32_t userId) const { return userDocs().getUserDocs(userId); } PutOperation put(uint32_t userId) { @@ -163,6 +151,22 @@ struct Fixture } }; +Fixture::Fixture() + : _builder(), + _bucketDB(std::make_shared<bucketdb::BucketDBOwner>()), + _ready(_builder.getRepo(), _bucketDB, SubDbType::READY), + _removed(_builder.getRepo(), _bucketDB, SubDbType::REMOVED), + _notReady(_builder.getRepo(), _bucketDB, SubDbType::NOTREADY), + _calc(new test::BucketStateCalculator()), + _view(getVector(_ready, _removed, _notReady), makeBucketSpace(), _calc) +{ + _builder.createDoc(1, 1); + _builder.createDoc(2, 2); +} +Fixture::~Fixture() = default; + +} + TEST_F("require that preparePut() sends to ready view", Fixture) { @@ -425,9 +429,3 @@ TEST_F("require that compactLidSpace() is sent to correct feed view", Fixture) EXPECT_EQUAL(99u, f._removed._view->_wantedLidLimit); EXPECT_EQUAL(0u, f._notReady._view->_wantedLidLimit); } - -TEST_MAIN() -{ - TEST_RUN_ALL(); -} - diff --git a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp b/searchcore/src/tests/proton/documentdb/configurer_test.cpp index 2eeae63dc5f..9362d26a3b9 100644 --- a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp +++ b/searchcore/src/tests/proton/documentdb/configurer_test.cpp @@ -69,6 +69,7 @@ using Configurer = SearchableDocSubDBConfigurer; using ConfigurerUP = std::unique_ptr<SearchableDocSubDBConfigurer>; using DocumenttypesConfigSP = proton::DocumentDBConfig::DocumenttypesConfigSP; +namespace { const vespalib::string BASE_DIR("baseDir"); const vespalib::string DOC_TYPE("invalid"); @@ -204,7 +205,9 @@ Fixture::Fixture() _configurer = std::make_unique<Configurer>(_views._summaryMgr, _views.searchView, _views.feedView, _queryLimiter, _constantValueFactory, _clock.nowRef(), "test", 0); } -Fixture::~Fixture() = default; +Fixture::~Fixture() { + std::filesystem::remove_all(std::filesystem::path(BASE_DIR)); +} void Fixture::initViewSet(ViewSet &views) @@ -293,56 +296,51 @@ struct MyFastAccessFeedView std::shared_ptr<PendingLidTrackerBase> _pendingLidsForCommit; VarHolder<FastAccessFeedView::SP> _feedView; - explicit MyFastAccessFeedView(IThreadingService &writeService) - : _fileHeaderContext(), - _docIdLimit(0), - _writeService(writeService), - _hwInfo(), - _dmsc(), - _gidToLidChangeHandler(make_shared<DummyGidToLidChangeHandler>()), - _pendingLidsForCommit(std::make_shared<PendingLidTracker>()), - _feedView() - { - init(); - } - + explicit MyFastAccessFeedView(IThreadingService &writeService) __attribute__((noinline)); ~MyFastAccessFeedView(); - void init() { - MySummaryAdapter::SP summaryAdapter = std::make_shared<MySummaryAdapter>(); - Schema::SP schema = std::make_shared<Schema>(); - _dmsc = make_shared<DocumentMetaStoreContext>(std::make_shared<bucketdb::BucketDBOwner>()); - std::shared_ptr<const DocumentTypeRepo> repo = createRepo(); - StoreOnlyFeedView::Context storeOnlyCtx(summaryAdapter, schema, _dmsc, repo, - _pendingLidsForCommit, *_gidToLidChangeHandler, _writeService); - StoreOnlyFeedView::PersistentParams params(1, 1, DocTypeName(DOC_TYPE), 0, SubDbType::NOTREADY); - auto mgr = make_shared<AttributeManager>(BASE_DIR, "test.subdb", TuneFileAttributes(), - _fileHeaderContext, std::make_shared<search::attribute::Interlock>(), - _writeService.field_writer(), _writeService.shared(), _hwInfo); - auto writer = std::make_shared<AttributeWriter>(mgr); - FastAccessFeedView::Context fastUpdateCtx(writer, _docIdLimit); - _feedView.set(std::make_shared<FastAccessFeedView>(std::move(storeOnlyCtx), params, fastUpdateCtx)); - } + void init() __attribute__((noinline)); }; +MyFastAccessFeedView::MyFastAccessFeedView(IThreadingService &writeService) + : _fileHeaderContext(), + _docIdLimit(0), + _writeService(writeService), + _hwInfo(), + _dmsc(), + _gidToLidChangeHandler(make_shared<DummyGidToLidChangeHandler>()), + _pendingLidsForCommit(std::make_shared<PendingLidTracker>()), + _feedView() +{ + init(); +} + MyFastAccessFeedView::~MyFastAccessFeedView() = default; +void +MyFastAccessFeedView::init() { + MySummaryAdapter::SP summaryAdapter = std::make_shared<MySummaryAdapter>(); + Schema::SP schema = std::make_shared<Schema>(); + _dmsc = make_shared<DocumentMetaStoreContext>(std::make_shared<bucketdb::BucketDBOwner>()); + std::shared_ptr<const DocumentTypeRepo> repo = createRepo(); + StoreOnlyFeedView::Context storeOnlyCtx(summaryAdapter, schema, _dmsc, repo, + _pendingLidsForCommit, *_gidToLidChangeHandler, _writeService); + StoreOnlyFeedView::PersistentParams params(1, 1, DocTypeName(DOC_TYPE), 0, SubDbType::NOTREADY); + auto mgr = make_shared<AttributeManager>(BASE_DIR, "test.subdb", TuneFileAttributes(), + _fileHeaderContext, std::make_shared<search::attribute::Interlock>(), + _writeService.field_writer(), _writeService.shared(), _hwInfo); + auto writer = std::make_shared<AttributeWriter>(mgr); + FastAccessFeedView::Context fastUpdateCtx(writer, _docIdLimit); + _feedView.set(std::make_shared<FastAccessFeedView>(std::move(storeOnlyCtx), params, fastUpdateCtx)); +} + struct FastAccessFixture { TransportAndExecutorService _service; MyFastAccessFeedView _view; FastAccessDocSubDBConfigurer _configurer; - FastAccessFixture() - : _service(1), - _view(_service.write()), - _configurer(_view._feedView, "test") - { - std::filesystem::remove_all(std::filesystem::path(BASE_DIR)); - std::filesystem::create_directory(std::filesystem::path(BASE_DIR)); - } - ~FastAccessFixture() { - _service.shutdown(); - } + FastAccessFixture() __attribute__((noinline)); + ~FastAccessFixture() __attribute__((noinline)); IReprocessingInitializer::UP reconfigure(const DocumentDBConfig& new_config_snapshot, @@ -351,6 +349,19 @@ struct FastAccessFixture SerialNum serial_num); }; +FastAccessFixture::FastAccessFixture() + : _service(1), + _view(_service.write()), + _configurer(_view._feedView, "test") +{ + std::filesystem::remove_all(std::filesystem::path(BASE_DIR)); + std::filesystem::create_directory(std::filesystem::path(BASE_DIR)); +} +FastAccessFixture::~FastAccessFixture() { + _service.shutdown(); +} + + IReprocessingInitializer::UP FastAccessFixture::reconfigure(const DocumentDBConfig& new_config_snapshot, const DocumentDBConfig& old_config_snapshot, @@ -491,6 +502,8 @@ FastAccessFeedViewComparer::FastAccessFeedViewComparer(FastAccessFeedView::SP ol {} FastAccessFeedViewComparer::~FastAccessFeedViewComparer() = default; +} + TEST_F("require that we can reconfigure index searchable", Fixture) { ViewPtrs o = f._views.getViewPtrs(); @@ -782,9 +795,3 @@ TEST("require that summary manager should change if relevant config changed") TEST_DO(assertSummaryManagerShouldChange(CCR().setStoreChanged(true))); TEST_DO(assertSummaryManagerShouldChange(CCR().setSchemaChanged(true))); } - -TEST_MAIN() -{ - TEST_RUN_ALL(); - std::filesystem::remove_all(std::filesystem::path(BASE_DIR)); -} diff --git a/searchcore/src/tests/proton/documentdb/feedview/.gitignore b/searchcore/src/tests/proton/documentdb/feedview/.gitignore deleted file mode 100644 index 596e11ac15a..00000000000 --- a/searchcore/src/tests/proton/documentdb/feedview/.gitignore +++ /dev/null @@ -1 +0,0 @@ -searchcore_feedview_test_app diff --git a/searchcore/src/tests/proton/documentdb/feedview/CMakeLists.txt b/searchcore/src/tests/proton/documentdb/feedview/CMakeLists.txt deleted file mode 100644 index cbb1612b3f0..00000000000 --- a/searchcore/src/tests/proton/documentdb/feedview/CMakeLists.txt +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(searchcore_feedview_test_app TEST - SOURCES - feedview_test.cpp - DEPENDS - searchcore_test - searchcore_server - searchcore_index - searchcore_feedoperation - searchcore_matching - searchcore_attribute - searchcore_documentmetastore - searchcore_bucketdb - searchcore_pcommon - searchcore_grouping - searchcore_proton_metrics -) -vespa_add_test(NAME searchcore_feedview_test_app COMMAND searchcore_feedview_test_app) diff --git a/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp b/searchcore/src/tests/proton/documentdb/feedview_test.cpp index 77ae6be3d65..e2a8b227f57 100644 --- a/searchcore/src/tests/proton/documentdb/feedview/feedview_test.cpp +++ b/searchcore/src/tests/proton/documentdb/feedview_test.cpp @@ -33,7 +33,7 @@ #include <vespa/vespalib/stllike/asciistream.h> #include <vespa/log/log.h> -LOG_SETUP("feedview_test"); +LOG_SETUP(".feedview_test"); using document::BucketId; using document::DataType; @@ -65,6 +65,7 @@ using namespace search::index; using SerialNum = SearchableFeedView::SerialNum; using DocumentIdT = search::DocumentIdT; +namespace { struct MyLidVector : public std::vector<DocumentIdT> { MyLidVector &add(DocumentIdT lid) { push_back(lid); return *this; } @@ -518,9 +519,9 @@ struct FixtureBase test::ThreadingServiceObserver _writeService; SerialNum serial; std::shared_ptr<MyGidToLidChangeHandler> _gidToLidChangeHandler; - FixtureBase(); + FixtureBase() __attribute__((noinline)); - virtual ~FixtureBase(); + virtual ~FixtureBase() __attribute__((noinline)); const test::DocumentMetaStoreObserver &metaStoreObserver() { return _dmsc->getObserver(); @@ -650,18 +651,7 @@ struct FixtureBase return EXPECT_EQUAL(exp, _tracer._os.str()); } - DocumentContext::List - makeDummyDocs(uint32_t first, uint32_t count, uint64_t tsfirst) { - DocumentContext::List docs; - for (uint32_t i = 0; i < count; ++i) { - uint32_t id = first + i; - uint64_t ts = tsfirst + i; - vespalib::asciistream os; - os << "id:ns:searchdocument::" << id; - docs.push_back(doc(os.str(), ts)); - } - return docs; - } + DocumentContext::List makeDummyDocs(uint32_t first, uint32_t count, uint64_t tsfirst) __attribute__((noinline)); void performCompactLidSpace(uint32_t wantedLidLimit, IDestructorCallback::SP onDone) { auto &fv = getFeedView(); @@ -718,6 +708,19 @@ FixtureBase::~FixtureBase() { _service.shutdown(); } +DocumentContext::List +FixtureBase::makeDummyDocs(uint32_t first, uint32_t count, uint64_t tsfirst) { + DocumentContext::List docs; + for (uint32_t i = 0; i < count; ++i) { + uint32_t id = first + i; + uint64_t ts = tsfirst + i; + vespalib::asciistream os; + os << "id:ns:searchdocument::" << id; + docs.push_back(doc(os.str(), ts)); + } + return docs; +} + void FixtureBase::populateBeforeCompactLidSpace() { @@ -729,44 +732,46 @@ FixtureBase::populateBeforeCompactLidSpace() struct SearchableFeedViewFixture : public FixtureBase { SearchableFeedView fv; - SearchableFeedViewFixture() : - FixtureBase(), - fv(StoreOnlyFeedView::Context(sa, sc._schema, _dmsc, - sc.getRepo(), _pendingLidsForCommit, - *_gidToLidChangeHandler, _writeService), - pc.getParams(), - FastAccessFeedView::Context(aw, _docIdLimit), - SearchableFeedView::Context(iw)) - { - } - ~SearchableFeedViewFixture() override { - forceCommitAndWait(); - } + SearchableFeedViewFixture() __attribute__((noinline)); + ~SearchableFeedViewFixture() override __attribute__((noinline)); IFeedView &getFeedView() override { return fv; } }; +SearchableFeedViewFixture::SearchableFeedViewFixture() + : FixtureBase(), + fv(StoreOnlyFeedView::Context(sa, sc._schema, _dmsc, + sc.getRepo(), _pendingLidsForCommit, + *_gidToLidChangeHandler, _writeService), + pc.getParams(), + FastAccessFeedView::Context(aw, _docIdLimit), + SearchableFeedView::Context(iw)) +{ } +SearchableFeedViewFixture::~SearchableFeedViewFixture() { + forceCommitAndWait(); +} + struct FastAccessFeedViewFixture : public FixtureBase { FastAccessFeedView fv; - FastAccessFeedViewFixture() : - FixtureBase(), - fv(StoreOnlyFeedView::Context(sa, sc._schema, _dmsc, sc.getRepo(), _pendingLidsForCommit, - *_gidToLidChangeHandler, _writeService), - pc.getParams(), - FastAccessFeedView::Context(aw, _docIdLimit)) - { - } - ~FastAccessFeedViewFixture() override { - forceCommitAndWait(); - } + FastAccessFeedViewFixture() __attribute__((noinline)); + ~FastAccessFeedViewFixture() override __attribute__((noinline)); IFeedView &getFeedView() override { return fv; } }; -void -assertBucketInfo(const BucketId &ebid, - const Timestamp &ets, - uint32_t lid, - const IDocumentMetaStore &metaStore) +FastAccessFeedViewFixture::FastAccessFeedViewFixture() + : FixtureBase(), + fv(StoreOnlyFeedView::Context(sa, sc._schema, _dmsc, sc.getRepo(), _pendingLidsForCommit, + *_gidToLidChangeHandler, _writeService), + pc.getParams(), + FastAccessFeedView::Context(aw, _docIdLimit)) +{ } + +FastAccessFeedViewFixture::~FastAccessFeedViewFixture() { + forceCommitAndWait(); +} + +void assertBucketInfo(const BucketId &ebid, const Timestamp &ets, uint32_t lid, const IDocumentMetaStore &metaStore) __attribute__((noinline)); +void assertBucketInfo(const BucketId &ebid, const Timestamp &ets, uint32_t lid, const IDocumentMetaStore &metaStore) { document::GlobalId gid; EXPECT_TRUE(metaStore.getGid(lid, gid)); @@ -777,8 +782,8 @@ assertBucketInfo(const BucketId &ebid, EXPECT_EQUAL(ets, meta.timestamp); } -void -assertLidVector(const MyLidVector &exp, const MyLidVector &act) +void assertLidVector(const MyLidVector &exp, const MyLidVector &act) __attribute__((noinline)); +void assertLidVector(const MyLidVector &exp, const MyLidVector &act) { EXPECT_EQUAL(exp.size(), act.size()); for (size_t i = 0; i < exp.size(); ++i) { @@ -795,6 +800,8 @@ assertAttributeUpdate(SerialNum serialNum, const document::DocumentId &docId, EXPECT_EQUAL(lid, adapter._updateLid); } +} + TEST_F("require that put() updates document meta store with bucket info", SearchableFeedViewFixture) @@ -1287,9 +1294,3 @@ TEST_F("require that move() notifies gid to lid change handler", SearchableFeedV f.forceCommitAndWait(); TEST_DO(f.assertChangeHandler(dc2.gid(), 1u, 4u)); } - -TEST_MAIN() -{ - TEST_RUN_ALL(); -} - diff --git a/searchcore/src/tests/proton/documentdb/maintenancecontroller/.gitignore b/searchcore/src/tests/proton/documentdb/maintenancecontroller/.gitignore deleted file mode 100644 index 7ce70f9cbcd..00000000000 --- a/searchcore/src/tests/proton/documentdb/maintenancecontroller/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -searchcore_frozenbucketsmap_test_app -searchcore_maintenancecontroller_test_app diff --git a/searchcore/src/tests/proton/documentdb/maintenancecontroller/CMakeLists.txt b/searchcore/src/tests/proton/documentdb/maintenancecontroller/CMakeLists.txt deleted file mode 100644 index 0b4220902dc..00000000000 --- a/searchcore/src/tests/proton/documentdb/maintenancecontroller/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(searchcore_maintenancecontroller_test_app TEST - SOURCES - maintenancecontroller_test.cpp - DEPENDS - searchcore_test - searchcore_server - searchcore_feedoperation - searchcore_matching - searchcore_attribute - searchcore_documentmetastore - searchcore_bucketdb - searchcore_pcommon - searchcore_persistenceengine - searchcore_grouping - searchcore_proton_metrics - searchlib_test -) -vespa_add_test(NAME searchcore_maintenancecontroller_test_app COMMAND searchcore_maintenancecontroller_test_app) diff --git a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp b/searchcore/src/tests/proton/documentdb/maintenancecontroller_test.cpp index 6c67848ae51..891af3eda39 100644 --- a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp +++ b/searchcore/src/tests/proton/documentdb/maintenancecontroller_test.cpp @@ -41,12 +41,8 @@ #include <vespa/vespalib/util/lambdatask.h> #include <vespa/vespalib/util/monitored_refcount.h> #include <vespa/vespalib/util/threadstackexecutor.h> -#include <unistd.h> #include <thread> -#include <vespa/log/log.h> -LOG_SETUP("maintenancecontroller_test"); - using namespace proton; using namespace vespalib::slime; using document::BucketId; @@ -74,6 +70,7 @@ using BlockedReason = IBlockableMaintenanceJob::BlockedReason; using BucketIdVector = BucketId::List; constexpr vespalib::duration TIMEOUT = 60s; +constexpr vespalib::duration DELAY = 10ms; namespace { @@ -151,40 +148,13 @@ struct MyDocumentRetriever : public DocumentRetrieverBaseForTest { MyDocumentSubDB &_subDB; - explicit MyDocumentRetriever(MyDocumentSubDB &subDB) noexcept - : _subDB(subDB) - { - } - - const document::DocumentTypeRepo & - getDocumentTypeRepo() const override - { - LOG_ABORT("should not be reached"); - } - - void - getBucketMetaData(const storage::spi::Bucket &, - DocumentMetaData::Vector &) const override - { - LOG_ABORT("should not be reached"); - } - DocumentMetaData - getDocumentMetaData(const DocumentId &) const override - { - return DocumentMetaData(); - } - - Document::UP - getFullDocument(DocumentIdT lid) const override - { - return _subDB.getDocument(lid); - } + explicit MyDocumentRetriever(MyDocumentSubDB &subDB) noexcept : _subDB(subDB) { } - CachedSelect::SP - parseSelect(const vespalib::string &) const override - { - return CachedSelect::SP(); - } + const document::DocumentTypeRepo & getDocumentTypeRepo() const override { abort(); } + void getBucketMetaData(const storage::spi::Bucket &, DocumentMetaData::Vector &) const override { abort(); } + DocumentMetaData getDocumentMetaData(const DocumentId &) const override { return {}; } + Document::UP getFullDocument(DocumentIdT lid) const override { return _subDB.getDocument(lid); } + CachedSelect::SP parseSelect(const vespalib::string &) const override { return {}; } }; @@ -268,7 +238,6 @@ struct MySimpleJob : public BlockableMaintenanceJob { } void block() { setBlocked(BlockedReason::FROZEN_BUCKET); } bool run() override { - LOG(info, "MySimpleJob::run()"); _latch.countDown(); ++_runCnt; return true; @@ -284,7 +253,6 @@ struct MySplitJob : public MySimpleJob { } bool run() override { - LOG(info, "MySplitJob::run()"); _latch.countDown(); ++_runCnt; return _latch.getCount() == 0; @@ -304,7 +272,7 @@ struct MyLongRunningJob : public BlockableMaintenanceJob void block() { setBlocked(BlockedReason::FROZEN_BUCKET); } bool run() override { _firstRun.countDown(); - usleep(10000); + std::this_thread::sleep_for(1ms); return false; } }; @@ -885,9 +853,9 @@ TEST_F("require that document pruner is active", MaintenanceControllerFixture) ASSERT_TRUE(f._executor.waitIdle(TIMEOUT)); EXPECT_EQUAL(10u, f._removed.getNumUsedLids()); EXPECT_EQUAL(10u, f._removed.getDocumentCount()); - f.setPruneConfig(DocumentDBPruneConfig(200ms, 900s)); - for (uint32_t i = 0; i < 600; ++i) { - std::this_thread::sleep_for(100ms); + f.setPruneConfig(DocumentDBPruneConfig(DELAY, 900s)); + for (uint32_t i = 0; i < 60000; ++i) { + std::this_thread::sleep_for(1ms); ASSERT_TRUE(f._executor.waitIdle(TIMEOUT)); if (f._removed.getNumUsedLids() != 10u) break; @@ -902,9 +870,9 @@ TEST_F("require that heartbeats are scheduled", MaintenanceControllerFixture) { f.notifyClusterStateChanged(); f.startMaintenance(); - f.setHeartBeatConfig(DocumentDBHeartBeatConfig(200ms)); - for (uint32_t i = 0; i < 600; ++i) { - std::this_thread::sleep_for(100ms); + f.setHeartBeatConfig(DocumentDBHeartBeatConfig(DELAY)); + for (uint32_t i = 0; i < 60000; ++i) { + std::this_thread::sleep_for(1ms); if (f._fh.getHeartBeats() != 0u) break; } @@ -913,7 +881,7 @@ TEST_F("require that heartbeats are scheduled", MaintenanceControllerFixture) TEST_F("require that a simple maintenance job is executed", MaintenanceControllerFixture) { - auto job = std::make_unique<MySimpleJob>(200ms, 200ms, 3); + auto job = std::make_unique<MySimpleJob>(DELAY, DELAY, 3); MySimpleJob &myJob = *job; f._mc.registerJob(std::move(job)); f._injectDefaultJobs = false; @@ -925,7 +893,7 @@ TEST_F("require that a simple maintenance job is executed", MaintenanceControlle TEST_F("require that a split maintenance job is executed", MaintenanceControllerFixture) { - auto job = std::make_unique<MySplitJob>(200ms, TIMEOUT * 2, 3); + auto job = std::make_unique<MySplitJob>(DELAY, TIMEOUT * 2, 3); MySplitJob &myJob = *job; f._mc.registerJob(std::move(job)); f._injectDefaultJobs = false; @@ -937,13 +905,15 @@ TEST_F("require that a split maintenance job is executed", MaintenanceController TEST_F("require that blocked jobs are not executed", MaintenanceControllerFixture) { - auto job = std::make_unique<MySimpleJob>(200ms, 200ms, 0); + auto job = std::make_unique<MySimpleJob>(DELAY, DELAY, 0); MySimpleJob &myJob = *job; myJob.block(); f._mc.registerJob(std::move(job)); f._injectDefaultJobs = false; f.startMaintenance(); - std::this_thread::sleep_for(2s); + for (uint32_t napCount = 0; (myJob._runCnt != 0) && (napCount < 200); napCount++) { + std::this_thread::sleep_for(10ms); + } EXPECT_EQUAL(0u, myJob._runCnt); } @@ -951,7 +921,7 @@ TEST_F("require that maintenance controller state list jobs", MaintenanceControl { { auto job1 = std::make_unique<MySimpleJob>(TIMEOUT * 2, TIMEOUT * 2, 0); - auto job2 = std::make_unique<MyLongRunningJob>(200ms, 200ms); + auto job2 = std::make_unique<MyLongRunningJob>(DELAY, DELAY); auto &longRunningJob = dynamic_cast<MyLongRunningJob &>(*job2); f._mc.registerJob(std::move(job1)); f._mc.registerJob(std::move(job2)); @@ -1022,8 +992,3 @@ TEST_F("require that delay for prune removed documents is set based on interval assertPruneRemovedDocumentsConfig(300s, 301s, 301s, f); assertPruneRemovedDocumentsConfig(299s, 299s, 299s, f); } - -TEST_MAIN() -{ - TEST_RUN_ALL(); -} diff --git a/searchcore/src/tests/proton/documentdb/move_operation_limiter/CMakeLists.txt b/searchcore/src/tests/proton/documentdb/move_operation_limiter/CMakeLists.txt deleted file mode 100644 index 2f10bd9f025..00000000000 --- a/searchcore/src/tests/proton/documentdb/move_operation_limiter/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(searchcore_move_operation_limiter_test_app TEST - SOURCES - move_operation_limiter_test.cpp - DEPENDS - searchcore_server -) -vespa_add_test(NAME searchcore_move_operation_limiter_test_app COMMAND searchcore_move_operation_limiter_test_app) diff --git a/searchcore/src/tests/proton/documentdb/storeonlyfeedview/.gitignore b/searchcore/src/tests/proton/documentdb/storeonlyfeedview/.gitignore deleted file mode 100644 index eaabc7b9279..00000000000 --- a/searchcore/src/tests/proton/documentdb/storeonlyfeedview/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -Makefile -.depend -*_test -searchcore_storeonlyfeedview_test_app diff --git a/searchcore/src/tests/proton/documentdb/storeonlyfeedview/CMakeLists.txt b/searchcore/src/tests/proton/documentdb/storeonlyfeedview/CMakeLists.txt deleted file mode 100644 index 58a4afc4a72..00000000000 --- a/searchcore/src/tests/proton/documentdb/storeonlyfeedview/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(searchcore_storeonlyfeedview_test_app TEST - SOURCES - storeonlyfeedview_test.cpp - DEPENDS - searchcore_test - searchcore_server - searchcore_feedoperation - searchcore_documentmetastore - searchcore_bucketdb - searchcore_proton_metrics - searchcore_pcommon -) -vespa_add_test(NAME searchcore_storeonlyfeedview_test_app COMMAND searchcore_storeonlyfeedview_test_app) diff --git a/searchcore/src/tests/proton/documentdb/storeonlyfeedview/storeonlyfeedview_test.cpp b/searchcore/src/tests/proton/documentdb/storeonlyfeedview_test.cpp index db30c8e03fb..8938f1a0745 100644 --- a/searchcore/src/tests/proton/documentdb/storeonlyfeedview/storeonlyfeedview_test.cpp +++ b/searchcore/src/tests/proton/documentdb/storeonlyfeedview_test.cpp @@ -19,9 +19,6 @@ #include <vespa/vespalib/util/size_literals.h> #include <vespa/vespalib/testkit/test_kit.h> -#include <vespa/log/log.h> -LOG_SETUP("storeonlyfeedview_test"); - using document::BucketId; using document::DataType; using document::Document; @@ -314,8 +311,7 @@ struct MoveFixture : public FixtureBase<MoveOperationFeedView> { }); // First we wait for everything propagated to MinimalFeedView while (ctx.use_count() > (expected + 1)) { - LOG(info, "use_count = %ld", ctx.use_count()); - std::this_thread::sleep_for(1s); + std::this_thread::sleep_for(10ms); } // And then we must wait for everyone else to finish up too. feedview->waitFor(expected*2); @@ -447,5 +443,3 @@ TEST_F("require that heartbeat propagates and commits meta store", Fixture) } } // namespace - -TEST_MAIN() { TEST_RUN_ALL(); } diff --git a/searchcore/src/tests/proton/documentdb/threading_service_config/CMakeLists.txt b/searchcore/src/tests/proton/documentdb/threading_service_config/CMakeLists.txt deleted file mode 100644 index f03d0597367..00000000000 --- a/searchcore/src/tests/proton/documentdb/threading_service_config/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -vespa_add_executable(searchcore_threading_service_config_test_app TEST - SOURCES - threading_service_config_test.cpp - DEPENDS - searchcore_server -) -vespa_add_test(NAME searchcore_threading_service_config_test_app COMMAND searchcore_threading_service_config_test_app) diff --git a/searchcore/src/tests/proton/documentdb/vespa_testrunner.cpp b/searchcore/src/tests/proton/documentdb/vespa_testrunner.cpp new file mode 100644 index 00000000000..1e4e79047c3 --- /dev/null +++ b/searchcore/src/tests/proton/documentdb/vespa_testrunner.cpp @@ -0,0 +1,8 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Unit tests for predicate_index. +#include <vespa/vespalib/testkit/test_kit.h> + +#include <vespa/log/log.h> +LOG_SETUP("proton_common_test"); + +TEST_MAIN() { TEST_RUN_ALL(); } diff --git a/searchcore/src/tests/proton/server/CMakeLists.txt b/searchcore/src/tests/proton/server/CMakeLists.txt index c522f4ede9c..abad9718818 100644 --- a/searchcore/src/tests/proton/server/CMakeLists.txt +++ b/searchcore/src/tests/proton/server/CMakeLists.txt @@ -42,3 +42,13 @@ vespa_add_executable(searchcore_memoryconfigstore_test_app TEST searchcore_pcommon ) vespa_add_test(NAME searchcore_memoryconfigstore_test_app COMMAND searchcore_memoryconfigstore_test_app) + +vespa_add_executable(searchcore_proton_server_vespa_test_app TEST + SOURCES + vespa_testrunner.cpp + move_operation_limiter_test.cpp + threading_service_config_test.cpp + DEPENDS + searchcore_server +) +vespa_add_test(NAME searchcore_proton_server_vespa_test_app COMMAND searchcore_proton_server_vespa_test_app) diff --git a/searchcore/src/tests/proton/documentdb/move_operation_limiter/move_operation_limiter_test.cpp b/searchcore/src/tests/proton/server/move_operation_limiter_test.cpp index 766158bd178..dee5fd2fd2c 100644 --- a/searchcore/src/tests/proton/documentdb/move_operation_limiter/move_operation_limiter_test.cpp +++ b/searchcore/src/tests/proton/server/move_operation_limiter_test.cpp @@ -5,9 +5,6 @@ #include <vespa/vespalib/testkit/test_kit.h> #include <queue> -#include <vespa/log/log.h> -LOG_SETUP("move_operation_limiter_test"); - using namespace proton; struct MyBlockableMaintenanceJob : public IBlockableMaintenanceJob { @@ -110,8 +107,3 @@ TEST_F("require that destructor callback has reference to limiter via shared ptr f.endOp(); EXPECT_FALSE(f.job.blocked); } - -TEST_MAIN() -{ - TEST_RUN_ALL(); -} diff --git a/searchcore/src/tests/proton/documentdb/threading_service_config/threading_service_config_test.cpp b/searchcore/src/tests/proton/server/threading_service_config_test.cpp index 7a16e6b17cb..567a723de39 100644 --- a/searchcore/src/tests/proton/documentdb/threading_service_config/threading_service_config_test.cpp +++ b/searchcore/src/tests/proton/server/threading_service_config_test.cpp @@ -5,9 +5,6 @@ #include <vespa/vespalib/testkit/test_kit.h> #include <vespa/vespalib/util/hw_info.h> -#include <vespa/log/log.h> -LOG_SETUP("threading_service_config_test"); - using namespace proton; using ProtonConfig = vespa::config::search::core::ProtonConfig; using ProtonConfigBuilder = vespa::config::search::core::ProtonConfigBuilder; @@ -63,8 +60,3 @@ TEST_FF("require that config can be somewhat updated", Fixture(), Fixture(3000, cfg1.update(cfg2); assertConfig(3000u, 1000u, cfg1); } - -TEST_MAIN() -{ - TEST_RUN_ALL(); -} diff --git a/searchcore/src/tests/proton/server/vespa_testrunner.cpp b/searchcore/src/tests/proton/server/vespa_testrunner.cpp new file mode 100644 index 00000000000..1e4e79047c3 --- /dev/null +++ b/searchcore/src/tests/proton/server/vespa_testrunner.cpp @@ -0,0 +1,8 @@ +// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +// Unit tests for predicate_index. +#include <vespa/vespalib/testkit/test_kit.h> + +#include <vespa/log/log.h> +LOG_SETUP("proton_common_test"); + +TEST_MAIN() { TEST_RUN_ALL(); } |