diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-02-07 04:58:29 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2023-02-08 07:23:51 +0000 |
commit | 954253af549e359d891a751ff5ccf21061056856 (patch) | |
tree | fdf7c52b57acc70fe2a35ad3a6f5cfc230f78a7d /storage/src/tests/common | |
parent | 373b320b0e418cd4ec38af2bfb9f8f0f7f856d5d (diff) |
Reduce use of getSeconds further.
Diffstat (limited to 'storage/src/tests/common')
-rw-r--r-- | storage/src/tests/common/metricstest.cpp | 20 | ||||
-rw-r--r-- | storage/src/tests/common/teststorageapp.cpp | 2 |
2 files changed, 7 insertions, 15 deletions
diff --git a/storage/src/tests/common/metricstest.cpp b/storage/src/tests/common/metricstest.cpp index 290d05e9a59..97d1c22364f 100644 --- a/storage/src/tests/common/metricstest.cpp +++ b/storage/src/tests/common/metricstest.cpp @@ -12,7 +12,6 @@ #include <tests/common/dummystoragelink.h> #include <vespa/metrics/metricmanager.h> #include <vespa/config/common/exceptions.h> -#include <vespa/vespalib/stllike/hash_map.hpp> #include <vespa/vespalib/gtest/gtest.h> #include <gmock/gmock.h> #include <filesystem> @@ -38,9 +37,7 @@ struct MetricsTest : public Test { std::shared_ptr<VisitorMetrics> _visitorMetrics; void createSnapshotForPeriod(std::chrono::seconds secs) const; - void assertMetricLastValue(const std::string& name, - int interval, - uint64_t expected) const; + void assertMetricLastValue(const std::string& name, int interval, uint64_t expected) const; MetricsTest(); ~MetricsTest() override; @@ -55,8 +52,8 @@ namespace { { framework::Clock& _clock; explicit MetricClock(framework::Clock& c) : _clock(c) {} - [[nodiscard]] time_t getTime() const override { return _clock.getTimeInSeconds().getTime(); } - time_t getTimeInMilliSecs() const override { return vespalib::count_ms(_clock.getMonotonicTime().time_since_epoch()); } + [[nodiscard]] time_t getTime() const override { return vespalib::count_s(_clock.getMonotonicTime().time_since_epoch()); } + [[nodiscard]] time_t getTimeInMilliSecs() const override { return vespalib::count_ms(_clock.getMonotonicTime().time_since_epoch()); } }; } @@ -192,7 +189,7 @@ void MetricsTest::createFakeLoad() } _clock->addSecondsToTime(60); _metricManager->timeChangedNotification(); - while (uint64_t(_metricManager->getLastProcessedTime()) < _clock->getTimeInSeconds().getTime()) { + while (int64_t(_metricManager->getLastProcessedTime()) < vespalib::count_s(_clock->getMonotonicTime().time_since_epoch())) { std::this_thread::sleep_for(5ms); _metricManager->timeChangedNotification(); } @@ -242,10 +239,7 @@ TEST_F(MetricsTest, snapshot_presenting) { for (uint32_t i=0; i<6; ++i) { _clock->addSecondsToTime(60); _metricManager->timeChangedNotification(); - while ( - uint64_t(_metricManager->getLastProcessedTime()) - < _clock->getTimeInSeconds().getTime()) - { + while (int64_t(_metricManager->getLastProcessedTime()) < vespalib::count_s(_clock->getMonotonicTime().time_since_epoch())) { std::this_thread::sleep_for(1ms); } } @@ -305,9 +299,7 @@ MetricsTest::createSnapshotForPeriod(std::chrono::seconds secs) const { _clock->addSecondsToTime(secs.count()); _metricManager->timeChangedNotification(); - while (uint64_t(_metricManager->getLastProcessedTime()) - < _clock->getTimeInSeconds().getTime()) - { + while (int64_t(_metricManager->getLastProcessedTime()) < vespalib::count_s(_clock->getMonotonicTime().time_since_epoch())) { std::this_thread::sleep_for(100ms); } } diff --git a/storage/src/tests/common/teststorageapp.cpp b/storage/src/tests/common/teststorageapp.cpp index ea35c2de36a..13861a7cdde 100644 --- a/storage/src/tests/common/teststorageapp.cpp +++ b/storage/src/tests/common/teststorageapp.cpp @@ -192,7 +192,7 @@ api::Timestamp TestDistributorApp::generate_unique_timestamp() { std::lock_guard guard(_accessLock); - uint64_t timeNow(getClock().getTimeInSeconds().getTime()); + uint64_t timeNow(vespalib::count_s(getClock().getSystemTime().time_since_epoch())); if (timeNow == _lastUniqueTimestampRequested) { ++_uniqueTimestampCounter; } else { |