diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-12-06 23:04:43 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2019-12-16 23:48:45 +0000 |
commit | a200bf7708ad94661d1fc8da8776b3884ff78ef5 (patch) | |
tree | d9af222fa3376f1e8e77ab50b0c2bd8254560b88 /searchcore/src/tests/proton/documentdb | |
parent | 2f8e6f0cb74ef77a645e7543975aca736f7649a9 (diff) |
fastos::TimeStamp -> vespalib::duration
Diffstat (limited to 'searchcore/src/tests/proton/documentdb')
7 files changed, 63 insertions, 93 deletions
diff --git a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp index 1ad6b6cdc43..7b512ad2e78 100644 --- a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp +++ b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp @@ -144,7 +144,7 @@ struct MyDocumentDBReferenceResolver : public IDocumentDBReferenceResolver { std::unique_ptr<ImportedAttributesRepo> resolve(const search::IAttributeManager &, const search::IAttributeManager &, const std::shared_ptr<search::IDocumentMetaStoreContext> &, - fastos::TimeStamp) override { + vespalib::duration) override { return std::make_unique<ImportedAttributesRepo>(); } void teardown(const search::IAttributeManager &) override { } 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 7dca5493b15..7139eb0d82d 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 @@ -115,7 +115,7 @@ struct MyDocumentDBReferenceResolver : public IDocumentDBReferenceResolver { std::unique_ptr<ImportedAttributesRepo> resolve(const search::IAttributeManager &, const search::IAttributeManager &, const std::shared_ptr<search::IDocumentMetaStoreContext> &, - fastos::TimeStamp) override { + vespalib::duration) override { return std::make_unique<ImportedAttributesRepo>(); } void teardown(const search::IAttributeManager &) override { } diff --git a/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp b/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp index d2d9f573326..2782117d8ae 100644 --- a/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp +++ b/searchcore/src/tests/proton/documentdb/fileconfigmanager/fileconfigmanager_test.cpp @@ -175,10 +175,7 @@ TEST_F("requireThatVisibilityDelayIsPropagated", cm.setProtonConfig(ProtonConfigSP(new ProtonConfig(protonConfigBuilder))); cm.loadConfig(*esnap, 70, esnap); } - EXPECT_EQUAL(61.0, esnap->getMaintenanceConfigSP()->getVisibilityDelay().sec()); + EXPECT_EQUAL(61s, esnap->getMaintenanceConfigSP()->getVisibilityDelay()); } - - TEST_MAIN() { TEST_RUN_ALL(); } - diff --git a/searchcore/src/tests/proton/documentdb/job_tracked_maintenance_job/job_tracked_maintenance_job_test.cpp b/searchcore/src/tests/proton/documentdb/job_tracked_maintenance_job/job_tracked_maintenance_job_test.cpp index 8c1ad7bf551..3f39c872ea7 100644 --- a/searchcore/src/tests/proton/documentdb/job_tracked_maintenance_job/job_tracked_maintenance_job_test.cpp +++ b/searchcore/src/tests/proton/documentdb/job_tracked_maintenance_job/job_tracked_maintenance_job_test.cpp @@ -33,17 +33,17 @@ struct MyMaintenanceJob : public IBlockableMaintenanceJob size_t _runIdx; bool _blocked; MyMaintenanceJob(size_t numRuns) - : IBlockableMaintenanceJob("myjob", 10, 20), + : IBlockableMaintenanceJob("myjob", 10s, 20s), _runGates(getGateVector(numRuns)), _runIdx(0), _blocked(false) {} void block() { setBlocked(BlockedReason::RESOURCE_LIMITS); } void unBlock() { unBlock(BlockedReason::RESOURCE_LIMITS); } - virtual void setBlocked(BlockedReason) override { _blocked = true; } - virtual void unBlock(BlockedReason) override { _blocked = false; } - virtual bool isBlocked() const override { return _blocked; } - virtual bool run() override { + void setBlocked(BlockedReason) override { _blocked = true; } + void unBlock(BlockedReason) override { _blocked = false; } + bool isBlocked() const override { return _blocked; } + bool run() override { _runGates[_runIdx++]->await(5000); return _runIdx == _runGates.size(); } @@ -90,8 +90,8 @@ struct Fixture TEST_F("require that maintenance job name, delay and interval are preserved", Fixture) { EXPECT_EQUAL("myjob", f._trackedJob->getName()); - EXPECT_EQUAL(10, f._trackedJob->getDelay()); - EXPECT_EQUAL(20, f._trackedJob->getInterval()); + EXPECT_EQUAL(10s, f._trackedJob->getDelay()); + EXPECT_EQUAL(20s, f._trackedJob->getInterval()); } TEST_F("require that maintenance job that needs 1 run is tracked", Fixture) diff --git a/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_compaction_test.cpp b/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_compaction_test.cpp index 93f3299e121..50d4106282c 100644 --- a/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_compaction_test.cpp +++ b/searchcore/src/tests/proton/documentdb/lid_space_compaction/lid_space_compaction_test.cpp @@ -26,10 +26,10 @@ using BlockedReason = IBlockableMaintenanceJob::BlockedReason; using TimePoint = LidUsageStats::TimePoint; constexpr uint32_t SUBDB_ID = 2; -constexpr double JOB_DELAY = 1.0; +constexpr vespalib::duration JOB_DELAY = 1s; constexpr uint32_t ALLOWED_LID_BLOAT = 1; constexpr double ALLOWED_LID_BLOAT_FACTOR = 0.3; -constexpr double REMOVE_BATCH_BLOCK_DELAY = 20.0; +constexpr vespalib::duration REMOVE_BATCH_BLOCK_DELAY = 20s; constexpr uint32_t MAX_DOCS_TO_SCAN = 100; constexpr double RESOURCE_LIMIT_FACTOR = 1.0; constexpr uint32_t MAX_OUTSTANDING_MOVE_OPS = 10; @@ -257,7 +257,7 @@ struct JobTestBase : public ::testing::Test { double allowedLidBloatFactor = ALLOWED_LID_BLOAT_FACTOR, uint32_t maxDocsToScan = MAX_DOCS_TO_SCAN, double resourceLimitFactor = RESOURCE_LIMIT_FACTOR, - double interval = JOB_DELAY, + vespalib::duration interval = JOB_DELAY, bool nodeRetired = false, uint32_t maxOutstandingMoveOps = MAX_OUTSTANDING_MOVE_OPS) { @@ -366,13 +366,13 @@ struct JobTest : public JobTestBase { double allowedLidBloatFactor = ALLOWED_LID_BLOAT_FACTOR, uint32_t maxDocsToScan = MAX_DOCS_TO_SCAN, double resourceLimitFactor = RESOURCE_LIMIT_FACTOR, - double interval = JOB_DELAY, + vespalib::duration interval = JOB_DELAY, bool nodeRetired = false, uint32_t maxOutstandingMoveOps = MAX_OUTSTANDING_MOVE_OPS) { JobTestBase::init(allowedLidBloat, allowedLidBloatFactor, maxDocsToScan, resourceLimitFactor, interval, nodeRetired, maxOutstandingMoveOps); _jobRunner = std::make_unique<MyDirectJobRunner>(*_job); } - void init_with_interval(double interval) { + void init_with_interval(vespalib::duration interval) { init(ALLOWED_LID_BLOAT, ALLOWED_LID_BLOAT_FACTOR, MAX_DOCS_TO_SCAN, RESOURCE_LIMIT_FACTOR, interval); } void init_with_node_retired(bool retired) { @@ -580,16 +580,16 @@ TEST_F(JobTest, resource_limit_factor_adjusts_limit) TEST_F(JobTest, delay_is_set_based_on_interval_and_is_max_300_secs) { - init_with_interval(301); - EXPECT_EQ(300, _job->getDelay()); - EXPECT_EQ(301, _job->getInterval()); + init_with_interval(301s); + EXPECT_EQ(300s, _job->getDelay()); + EXPECT_EQ(301s, _job->getInterval()); } TEST_F(JobTest, delay_is_set_based_on_interval_and_can_be_less_than_300_secs) { - init_with_interval(299); - EXPECT_EQ(299, _job->getDelay()); - EXPECT_EQ(299, _job->getInterval()); + init_with_interval(299s); + EXPECT_EQ(299s, _job->getDelay()); + EXPECT_EQ(299s, _job->getInterval()); } TEST_F(JobTest, job_is_disabled_when_node_is_retired) @@ -649,7 +649,7 @@ TEST_F(JobTest, job_is_re_enabled_when_remove_batch_is_no_longer_ongoing) EXPECT_TRUE(run()); // job is disabled assertJobContext(2, 9, 1, 0, 0); - _handler->set_last_remove_batch(last_remove_batch - std::chrono::seconds(static_cast<long>(REMOVE_BATCH_BLOCK_DELAY))); + _handler->set_last_remove_batch(last_remove_batch - REMOVE_BATCH_BLOCK_DELAY); EXPECT_FALSE(run()); // job executed as normal (with more work to do) assertJobContext(3, 8, 2, 0, 0); } diff --git a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp index 0720f59471b..ae72637ec59 100644 --- a/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp +++ b/searchcore/src/tests/proton/documentdb/maintenancecontroller/maintenancecontroller_test.cpp @@ -67,7 +67,7 @@ typedef BucketId::List BucketIdVector; typedef std::set<BucketId> BucketIdSet; constexpr int TIMEOUT_MS = 60000; -constexpr double TIMEOUT_SEC = 60.0; +constexpr vespalib::duration TIMEOUT_SEC = 60s; namespace { @@ -251,7 +251,7 @@ public: ~MyExecutor(); bool isIdle(); - bool waitIdle(double timeout); + bool waitIdle(vespalib::duration timeout); }; @@ -281,8 +281,8 @@ struct MySimpleJob : public BlockableMaintenanceJob vespalib::CountDownLatch _latch; size_t _runCnt; - MySimpleJob(double delay, - double interval, + MySimpleJob(vespalib::duration delay, + vespalib::duration interval, uint32_t finishCount) : BlockableMaintenanceJob("my_job", delay, interval), _latch(finishCount), @@ -300,8 +300,8 @@ struct MySimpleJob : public BlockableMaintenanceJob struct MySplitJob : public MySimpleJob { - MySplitJob(double delay, - double interval, + MySplitJob(vespalib::duration delay, + vespalib::duration interval, uint32_t finishCount) : MySimpleJob(delay, interval, finishCount) { @@ -318,8 +318,8 @@ struct MyLongRunningJob : public BlockableMaintenanceJob { vespalib::Gate _firstRun; - MyLongRunningJob(double delay, - double interval) + MyLongRunningJob(vespalib::duration delay, + vespalib::duration interval) : BlockableMaintenanceJob("long_running_job", delay, interval), _firstRun() { @@ -380,51 +380,24 @@ public: MaintenanceControllerFixture(); - virtual - ~MaintenanceControllerFixture(); - - void - syncSubDBs(); - - void commit() override { - } - - void commitAndWait() override { - } - - void - performSyncSubDBs(); - - void - notifyClusterStateChanged(); - - void - performNotifyClusterStateChanged(); - - void - startMaintenance(); + virtual ~MaintenanceControllerFixture(); + void syncSubDBs(); + void commit() override { } + void commitAndWait() override { } + void performSyncSubDBs(); + void notifyClusterStateChanged(); + void performNotifyClusterStateChanged(); + void startMaintenance(); void injectMaintenanceJobs(); + void performStartMaintenance(); + void stopMaintenance(); + void forwardMaintenanceConfig(); + void performForwardMaintenanceConfig(); - void - performStartMaintenance(); + void insertDocs(const test::UserDocuments &docs, MyDocumentSubDB &subDb); - void - stopMaintenance(); - - void - forwardMaintenanceConfig(); - - void - performForwardMaintenanceConfig(); - - void - insertDocs(const test::UserDocuments &docs, - MyDocumentSubDB &subDb); - - void - removeDocs(const test::UserDocuments &docs, - Timestamp timestamp); + void removeDocs(const test::UserDocuments &docs, Timestamp timestamp); void setPruneConfig(const DocumentDBPruneRemovedDocumentsConfig &pruneConfig) @@ -463,7 +436,7 @@ public: } void - setGroupingSessionPruneInterval(double groupingSessionPruneInterval) + setGroupingSessionPruneInterval(vespalib::duration groupingSessionPruneInterval) { DocumentDBMaintenanceConfig::SP newCfg(new DocumentDBMaintenanceConfig( @@ -800,11 +773,11 @@ MyExecutor::isIdle() bool -MyExecutor::waitIdle(double timeout) +MyExecutor::waitIdle(vespalib::duration timeout) { - fastos::StopWatch timer; + vespalib::Timer timer; while (!isIdle()) { - if (timer.elapsed().sec() >= timeout) + if (timer.elapsed() >= timeout) return false; } return true; @@ -1062,7 +1035,7 @@ TEST_F("require that document pruner is active", EXPECT_EQUAL(10u, f._removed.getNumUsedLids()); EXPECT_EQUAL(10u, f._removed.getDocumentCount()); MyFrozenBucket::UP frozen3(new MyFrozenBucket(f._mc, bucketId3)); - f.setPruneConfig(DocumentDBPruneRemovedDocumentsConfig(0.2, 900.0)); + f.setPruneConfig(DocumentDBPruneRemovedDocumentsConfig(200ms, 900s)); for (uint32_t i = 0; i < 6; ++i) { std::this_thread::sleep_for(100ms); ASSERT_TRUE(f._executor.waitIdle(TIMEOUT_SEC)); @@ -1087,7 +1060,7 @@ TEST_F("require that heartbeats are scheduled", { f.notifyClusterStateChanged(); f.startMaintenance(); - f.setHeartBeatConfig(DocumentDBHeartBeatConfig(0.2)); + f.setHeartBeatConfig(DocumentDBHeartBeatConfig(200ms)); for (uint32_t i = 0; i < 600; ++i) { std::this_thread::sleep_for(100ms); if (f._fh.getHeartBeats() != 0u) @@ -1102,7 +1075,7 @@ TEST_F("require that periodic session prunings are scheduled", ASSERT_FALSE(f._gsp.isInvoked); f.notifyClusterStateChanged(); f.startMaintenance(); - f.setGroupingSessionPruneInterval(0.2); + f.setGroupingSessionPruneInterval(200ms); for (uint32_t i = 0; i < 600; ++i) { std::this_thread::sleep_for(100ms); if (f._gsp.isInvoked) { @@ -1182,7 +1155,7 @@ TEST_F("require that active bucket is not moved until de-activated", Maintenance TEST_F("require that a simple maintenance job is executed", MaintenanceControllerFixture) { - IMaintenanceJob::UP job(new MySimpleJob(0.2, 0.2, 3)); + IMaintenanceJob::UP job(new MySimpleJob(200ms, 200ms, 3)); MySimpleJob &myJob = static_cast<MySimpleJob &>(*job); f._mc.registerJobInMasterThread(std::move(job)); f._injectDefaultJobs = false; @@ -1194,7 +1167,7 @@ TEST_F("require that a simple maintenance job is executed", MaintenanceControlle TEST_F("require that a split maintenance job is executed", MaintenanceControllerFixture) { - IMaintenanceJob::UP job(new MySplitJob(0.2, TIMEOUT_SEC * 2, 3)); + IMaintenanceJob::UP job(new MySplitJob(200ms, TIMEOUT_SEC * 2, 3)); MySplitJob &myJob = static_cast<MySplitJob &>(*job); f._mc.registerJobInMasterThread(std::move(job)); f._injectDefaultJobs = false; @@ -1239,7 +1212,7 @@ TEST_F("require that a blocked job is unblocked and executed after thaw bucket", TEST_F("require that blocked jobs are not executed", MaintenanceControllerFixture) { - IMaintenanceJob::UP job(new MySimpleJob(0.2, 0.2, 0)); + IMaintenanceJob::UP job(new MySimpleJob(200ms, 200ms, 0)); MySimpleJob &myJob = static_cast<MySimpleJob &>(*job); myJob.block(); f._mc.registerJobInMasterThread(std::move(job)); @@ -1253,7 +1226,7 @@ TEST_F("require that maintenance controller state list jobs", MaintenanceControl { { IMaintenanceJob::UP job1(new MySimpleJob(TIMEOUT_SEC * 2, TIMEOUT_SEC * 2, 0)); - IMaintenanceJob::UP job2(new MyLongRunningJob(0.2, 0.2)); + IMaintenanceJob::UP job2(new MyLongRunningJob(200ms, 200ms)); MyLongRunningJob &longRunningJob = static_cast<MyLongRunningJob &>(*job2); f._mc.registerJobInMasterThread(std::move(job1)); f._mc.registerJobInMasterThread(std::move(job2)); @@ -1365,9 +1338,9 @@ TEST_F("require that maintenance jobs are run by correct executor", MaintenanceC } void -assertPruneRemovedDocumentsConfig(double expDelay, double expInterval, double interval, MaintenanceControllerFixture &f) +assertPruneRemovedDocumentsConfig(vespalib::duration expDelay, vespalib::duration expInterval, vespalib::duration interval, MaintenanceControllerFixture &f) { - f.setPruneConfig(DocumentDBPruneRemovedDocumentsConfig(interval, 1000)); + f.setPruneConfig(DocumentDBPruneRemovedDocumentsConfig(interval, 1000s)); const auto *job = findJob(f._mc.getJobList(), "prune_removed_documents.searchdocument"); EXPECT_EQUAL(expDelay, job->getJob().getDelay()); EXPECT_EQUAL(expInterval, job->getJob().getInterval()); @@ -1375,8 +1348,8 @@ assertPruneRemovedDocumentsConfig(double expDelay, double expInterval, double in TEST_F("require that delay for prune removed documents is set based on interval and is max 300 secs", MaintenanceControllerFixture) { - assertPruneRemovedDocumentsConfig(300, 301, 301, f); - assertPruneRemovedDocumentsConfig(299, 299, 299, f); + assertPruneRemovedDocumentsConfig(300s, 301s, 301s, f); + assertPruneRemovedDocumentsConfig(299s, 299s, 299s, f); } TEST_MAIN() diff --git a/searchcore/src/tests/proton/documentdb/move_operation_limiter/move_operation_limiter_test.cpp b/searchcore/src/tests/proton/documentdb/move_operation_limiter/move_operation_limiter_test.cpp index df9aaab675c..77150370406 100644 --- a/searchcore/src/tests/proton/documentdb/move_operation_limiter/move_operation_limiter_test.cpp +++ b/searchcore/src/tests/proton/documentdb/move_operation_limiter/move_operation_limiter_test.cpp @@ -12,20 +12,20 @@ using namespace proton; struct MyBlockableMaintenanceJob : public IBlockableMaintenanceJob { bool blocked; MyBlockableMaintenanceJob() - : IBlockableMaintenanceJob("my_job", 1.0, 1.0), + : IBlockableMaintenanceJob("my_job", 1s, 1s), blocked(false) {} - virtual void setBlocked(BlockedReason reason) override { + void setBlocked(BlockedReason reason) override { ASSERT_TRUE(reason == BlockedReason::OUTSTANDING_OPS); EXPECT_FALSE(blocked); blocked = true; } - virtual void unBlock(BlockedReason reason) override { + void unBlock(BlockedReason reason) override { ASSERT_TRUE(reason == BlockedReason::OUTSTANDING_OPS); EXPECT_TRUE(blocked); blocked = false; } - virtual bool run() override { return true; } + bool run() override { return true; } }; struct Fixture { |