diff options
| author | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-11 15:07:35 -0300 |
|---|---|---|
| committer | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-11 15:07:35 -0300 |
| commit | 4cb8841196d0625dfa3825aa326f071cd27c7b8b (patch) | |
| tree | 1682a647d4463397c119183369ae6f750d5fdcff /src/mongo/watchdog | |
| parent | aa03c6362cbaa767638e6eed9b031d86dd2643d1 (diff) | |
| parent | 8f0827553e09872941945a093b647a4211a9db7f (diff) | |
Update upstream source from tag 'upstream/6.0.0'master
Update to upstream version '6.0.0'
with Debian dir 5604a80ec1c96ca76f25f40d78e6ef855abec322
Diffstat (limited to 'src/mongo/watchdog')
| -rw-r--r-- | src/mongo/watchdog/SConscript | 10 | ||||
| -rw-r--r-- | src/mongo/watchdog/watchdog.cpp | 94 | ||||
| -rw-r--r-- | src/mongo/watchdog/watchdog.h | 111 | ||||
| -rw-r--r-- | src/mongo/watchdog/watchdog_mock.cpp | 60 | ||||
| -rw-r--r-- | src/mongo/watchdog/watchdog_mock.h | 65 | ||||
| -rw-r--r-- | src/mongo/watchdog/watchdog_mongod.cpp | 33 | ||||
| -rw-r--r-- | src/mongo/watchdog/watchdog_test.cpp | 56 |
7 files changed, 63 insertions, 366 deletions
diff --git a/src/mongo/watchdog/SConscript b/src/mongo/watchdog/SConscript index acbab927fb5..102c548c689 100644 --- a/src/mongo/watchdog/SConscript +++ b/src/mongo/watchdog/SConscript @@ -36,16 +36,6 @@ env.Library( ], ) -env.Library( - target='watchdog_mock', - source=[ - 'watchdog_mock.cpp', - ], - LIBDEPS=[ - '$BUILD_DIR/mongo/db/service_context', - ], -) - env.CppUnitTest( target='watchdog_test', source=[ diff --git a/src/mongo/watchdog/watchdog.cpp b/src/mongo/watchdog/watchdog.cpp index f969ab10fe8..ae3528dd364 100644 --- a/src/mongo/watchdog/watchdog.cpp +++ b/src/mongo/watchdog/watchdog.cpp @@ -52,19 +52,11 @@ #include "mongo/util/exit.h" #include "mongo/util/exit_code.h" #include "mongo/util/hex.h" -#include "mongo/util/testing_proctor.h" #include "mongo/util/timer.h" namespace mongo { -namespace { - -const auto getWatchdogMonitorInterface = - ServiceContext::declareDecoration<std::unique_ptr<WatchdogMonitorInterface>>(); - -} // namespace - WatchdogPeriodicThread::WatchdogPeriodicThread(Milliseconds period, StringData threadName) : _period(period), _enabled(true), _threadName(threadName.toString()) {} @@ -210,37 +202,26 @@ std::int64_t WatchdogCheckThread::getGeneration() { void WatchdogCheckThread::resetState() {} -void WatchdogCheckThread::setShouldRunChecks(const bool shouldRunChecks) { - _shouldRunChecks.store(shouldRunChecks); -} - void WatchdogCheckThread::run(OperationContext* opCtx) { for (auto& check : _checks) { Timer timer(opCtx->getServiceContext()->getTickSource()); - if (_shouldRunChecks.load()) { - check->run(opCtx); - Microseconds micros = timer.elapsed(); - - LOGV2_DEBUG(8350803, - 1, - "Watchdog test checked '{check_getDescriptionForLogging}' took " - "{duration_cast_Milliseconds_micros}", - "check_getDescriptionForLogging"_attr = check->getDescriptionForLogging(), - "duration_cast_Milliseconds_micros"_attr = - duration_cast<Milliseconds>(micros)); - } else { - LOGV2_DEBUG(8350802, - 1, - "Watchdog skipping running check", - "check_getDescriptionForLogging"_attr = check->getDescriptionForLogging()); - } + check->run(opCtx); + Microseconds micros = timer.elapsed(); + + LOGV2_DEBUG(23407, + 1, + "Watchdog test '{check_getDescriptionForLogging}' took " + "{duration_cast_Milliseconds_micros}", + "check_getDescriptionForLogging"_attr = check->getDescriptionForLogging(), + "duration_cast_Milliseconds_micros"_attr = duration_cast<Milliseconds>(micros)); // We completed a check, bump the generation counter. _checkGeneration.fetchAndAdd(1); } } + WatchdogMonitorThread::WatchdogMonitorThread(WatchdogCheckThread* checkThread, WatchdogDeathCallback callback, Milliseconds interval) @@ -259,7 +240,6 @@ void WatchdogMonitorThread::resetState() { } void WatchdogMonitorThread::run(OperationContext* opCtx) { - _monitorGeneration.fetchAndAdd(1); auto currentGeneration = _checkThread->getGeneration(); if (currentGeneration != _lastSeenGeneration) { @@ -269,34 +249,12 @@ void WatchdogMonitorThread::run(OperationContext* opCtx) { } } -WatchdogMonitorInterface* WatchdogMonitorInterface::get(ServiceContext* service) { - return getWatchdogMonitorInterface(service).get(); -} - -WatchdogMonitorInterface* WatchdogMonitorInterface::get(OperationContext* ctx) { - return getWatchdogMonitorInterface(ctx->getClient()->getServiceContext()).get(); -} - -WatchdogMonitorInterface* WatchdogMonitorInterface::getGlobalWatchdogMonitorInterface() { - if (!hasGlobalServiceContext()) { - return nullptr; - } - return getWatchdogMonitorInterface(getGlobalServiceContext()).get(); -}; - -void WatchdogMonitorInterface::set( - ServiceContext* service, std::unique_ptr<WatchdogMonitorInterface> watchdogMonitorInterface) { - auto& coordinator = getWatchdogMonitorInterface(service); - coordinator = std::move(watchdogMonitorInterface); -} - WatchdogMonitor::WatchdogMonitor(std::vector<std::unique_ptr<WatchdogCheck>> checks, Milliseconds checkPeriod, Milliseconds monitorPeriod, WatchdogDeathCallback callback) - : WatchdogMonitorInterface(), - _checkPeriod(checkPeriod), + : _checkPeriod(checkPeriod), _watchdogCheckThread(std::move(checks), checkPeriod), _watchdogMonitorThread(&_watchdogCheckThread, callback, monitorPeriod) { invariant(checkPeriod < monitorPeriod); @@ -318,30 +276,6 @@ void WatchdogMonitor::start() { } } -void WatchdogMonitor::pauseChecks() { - { - stdx::lock_guard<Latch> lock(_mutex); - if (_state == State::kStarted || _state == State::kShutdownRequested) { - LOGV2(8350800, "WatchdogMonitor pausing watchdog checks"); - _watchdogCheckThread.setShouldRunChecks(false); - } - } -} - -void WatchdogMonitor::unpauseChecks() { - { - stdx::lock_guard<Latch> lock(_mutex); - if (_state == State::kStarted || _state == State::kShutdownRequested) { - LOGV2(8350801, "WatchdogMonitor unpausing watchdog checks"); - _watchdogCheckThread.setShouldRunChecks(true); - } - } -} - -bool WatchdogMonitor::getShouldRunChecks_forTest() { - MONGO_UNREACHABLE; -} - void WatchdogMonitor::setPeriod(Milliseconds duration) { { stdx::lock_guard<Latch> lock(_mutex); @@ -351,9 +285,7 @@ void WatchdogMonitor::setPeriod(Milliseconds duration) { // Make sure that we monitor runs more frequently then checks // 2 feels like an arbitrary good minimum. - invariant((TestingProctor::instance().isInitialized() && - TestingProctor::instance().isEnabled()) || - duration >= 2 * _checkPeriod); + invariant(duration >= 2 * _checkPeriod); _watchdogCheckThread.setPeriod(_checkPeriod); _watchdogMonitorThread.setPeriod(duration); @@ -678,7 +610,7 @@ void DirectoryCheck::run(OperationContext* opCtx) { } std::string DirectoryCheck::getDescriptionForLogging() { - return str::stream() << " directory '" << _directory.generic_string() << "'"; + return str::stream() << "checked directory '" << _directory.generic_string() << "'"; } } // namespace mongo diff --git a/src/mongo/watchdog/watchdog.h b/src/mongo/watchdog/watchdog.h index 6d324d2fd97..d7b6c74580f 100644 --- a/src/mongo/watchdog/watchdog.h +++ b/src/mongo/watchdog/watchdog.h @@ -34,7 +34,6 @@ #include <string> #include <vector> -#include "mongo/db/service_context.h" #include "mongo/platform/atomic_word.h" #include "mongo/platform/mutex.h" #include "mongo/stdx/condition_variable.h" @@ -44,7 +43,6 @@ namespace mongo { class OperationContext; -class ServiceContext; /** * WatchdogDeathCallback is used by the watchdog component to terminate the process. It is expected @@ -224,11 +222,6 @@ public: */ std::int64_t getGeneration(); - /** - * Sets _shouldRunChecks. - */ - void setShouldRunChecks(bool shouldRunChecks); - private: void run(OperationContext* opCtx) final; void resetState() final; @@ -240,9 +233,6 @@ private: // A counter that is incremented for each watchdog check completed, and monitored to ensure it // does not remain at the same value for too long. AtomicWord<long long> _checkGeneration{0}; - - // If _shouldRunChecks is false, make each check a no-op. - AtomicWord<bool> _shouldRunChecks{true}; }; /** @@ -279,72 +269,6 @@ private: std::int64_t _lastSeenGeneration{-1}; }; -/** - * An interface for using the watchdog monitor. - */ -class WatchdogMonitorInterface { -public: - WatchdogMonitorInterface() = default; - virtual ~WatchdogMonitorInterface() = default; - - static WatchdogMonitorInterface* get(ServiceContext* service); - static WatchdogMonitorInterface* get(OperationContext* ctx); - static WatchdogMonitorInterface* getGlobalWatchdogMonitorInterface(); - - static void set(ServiceContext* service, - std::unique_ptr<WatchdogMonitorInterface> watchdogMonitorInterface); - - /** - * Starts the watchdog threads. - */ - virtual void start() = 0; - - /** - * Updates the watchdog monitor period. The goal is to detect a failure in the time of the - * period. - * - * Does nothing if watchdog is not started. If watchdog was started, it changes the monitor - * period, but not the check period. - * - * Accepts Milliseconds for testing purposes while the setParameter only works with seconds. - */ - virtual void setPeriod(Milliseconds duration) = 0; - - /** - * Shutdown the watchdog. - */ - virtual void shutdown() = 0; - - /** - * Returns the current generation number of the checks. - * - * Incremented after each round of checks is run. - */ - virtual std::int64_t getCheckGeneration() = 0; - - /** - * Returns the current generation number of the checks. - * - * Incremented after each round of checks is run. - */ - virtual std::int64_t getMonitorGeneration() = 0; - - /** - * Pauses the watchdog checks by making each check a no-op. - */ - virtual void pauseChecks() = 0; - - /** - * Unpauses the watchdog checks - */ - virtual void unpauseChecks() = 0; - - /** - * Gets whether checks are paused or not. For testing purposes only. - */ - virtual bool getShouldRunChecks_forTest() = 0; -}; - /** * WatchdogMonitor @@ -362,7 +286,7 @@ public: * fails to make process, WatchdogMonitor calls a callback. The callback is not * expected to do any I/O and minimize the system calls it makes. */ -class WatchdogMonitor final : public WatchdogMonitorInterface { +class WatchdogMonitor { public: /** * Create the watchdog with specified period. @@ -375,24 +299,41 @@ public: Milliseconds monitorPeriod, WatchdogDeathCallback callback); - ~WatchdogMonitor() = default; - + /** + * Starts the watchdog threads. + */ void start(); + /** + * Updates the watchdog monitor period. The goal is to detect a failure in the time of the + * period. + * + * Does nothing if watchdog is not started. If watchdog was started, it changes the monitor + * period, but not the check period. + * + * Accepts Milliseconds for testing purposes while the setParameter only works with seconds. + */ void setPeriod(Milliseconds duration); + /** + * Shutdown the watchdog. + */ void shutdown(); + /** + * Returns the current generation number of the checks. + * + * Incremented after each round of checks is run. + */ std::int64_t getCheckGeneration(); + /** + * Returns the current generation number of the checks. + * + * Incremented after each round of checks is run. + */ std::int64_t getMonitorGeneration(); - void pauseChecks(); - - void unpauseChecks(); - - bool getShouldRunChecks_forTest(); - private: /** * Private enum to track state. diff --git a/src/mongo/watchdog/watchdog_mock.cpp b/src/mongo/watchdog/watchdog_mock.cpp deleted file mode 100644 index 2199fedca7f..00000000000 --- a/src/mongo/watchdog/watchdog_mock.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Copyright (C) 2024-present MongoDB, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the Server Side Public License, version 1, - * as published by MongoDB, Inc. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * Server Side Public License for more details. - * - * You should have received a copy of the Server Side Public License - * along with this program. If not, see - * <http://www.mongodb.com/licensing/server-side-public-license>. - * - * As a special exception, the copyright holders give permission to link the - * code of portions of this program with the OpenSSL library under certain - * conditions as described in each individual source file and distribute - * linked combinations including the program with the OpenSSL library. You - * must comply with the Server Side Public License in all respects for - * all of the code used other than as permitted herein. If you modify file(s) - * with this exception, you may extend this exception to your version of the - * file(s), but you are not obligated to do so. If you do not wish to do so, - * delete this exception statement from your version. If you delete this - * exception statement from all source files in the program, then also delete - * it in the license file. - */ - -#include "mongo/watchdog/watchdog_mock.h" - -namespace mongo { - -void WatchdogMonitorMock::pauseChecks() { - _shouldRunChecks.store(false); -} - -void WatchdogMonitorMock::unpauseChecks() { - _shouldRunChecks.store(true); -} - -void WatchdogMonitorMock::start() {} - -void WatchdogMonitorMock::setPeriod(Milliseconds duration) {} - -void WatchdogMonitorMock::shutdown() {} - -std::int64_t WatchdogMonitorMock::getCheckGeneration() { - return 0; -} - -std::int64_t WatchdogMonitorMock::getMonitorGeneration() { - return 0; -} - -bool WatchdogMonitorMock::getShouldRunChecks_forTest() { - return _shouldRunChecks.load(); -} - -} // namespace mongo diff --git a/src/mongo/watchdog/watchdog_mock.h b/src/mongo/watchdog/watchdog_mock.h deleted file mode 100644 index 773cd2abeec..00000000000 --- a/src/mongo/watchdog/watchdog_mock.h +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Copyright (C) 2024-present MongoDB, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the Server Side Public License, version 1, - * as published by MongoDB, Inc. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * Server Side Public License for more details. - * - * You should have received a copy of the Server Side Public License - * along with this program. If not, see - * <http://www.mongodb.com/licensing/server-side-public-license>. - * - * As a special exception, the copyright holders give permission to link the - * code of portions of this program with the OpenSSL library under certain - * conditions as described in each individual source file and distribute - * linked combinations including the program with the OpenSSL library. You - * must comply with the Server Side Public License in all respects for - * all of the code used other than as permitted herein. If you modify file(s) - * with this exception, you may extend this exception to your version of the - * file(s), but you are not obligated to do so. If you do not wish to do so, - * delete this exception statement from your version. If you delete this - * exception statement from all source files in the program, then also delete - * it in the license file. - */ - -#pragma once -#include "mongo/platform/atomic_word.h" -#include "mongo/watchdog/watchdog.h" - -namespace mongo { - -/** - * A mock WatchdogMonitor for use in C++ unit tests. - * - */ -class WatchdogMonitorMock final : public WatchdogMonitorInterface { -public: - WatchdogMonitorMock() = default; - ~WatchdogMonitorMock() = default; - - void pauseChecks(); - - void unpauseChecks(); - - void start(); - - void setPeriod(Milliseconds duration); - - void shutdown(); - - std::int64_t getCheckGeneration(); - - std::int64_t getMonitorGeneration(); - - bool getShouldRunChecks_forTest(); - -private: - AtomicWord<bool> _shouldRunChecks{true}; -}; - -} // namespace mongo diff --git a/src/mongo/watchdog/watchdog_mongod.cpp b/src/mongo/watchdog/watchdog_mongod.cpp index 6eeabc0d558..07ad1c93f5e 100644 --- a/src/mongo/watchdog/watchdog_mongod.cpp +++ b/src/mongo/watchdog/watchdog_mongod.cpp @@ -46,7 +46,6 @@ #include "mongo/logv2/log.h" #include "mongo/util/clock_source.h" #include "mongo/util/clock_source_mock.h" -#include "mongo/util/testing_proctor.h" #include "mongo/util/tick_source_mock.h" #include "mongo/watchdog/watchdog.h" #include "mongo/watchdog/watchdog_mongod_gen.h" @@ -58,16 +57,26 @@ namespace { // Run the watchdog checks at a fixed interval regardless of user choice for monitoring period. constexpr Seconds watchdogCheckPeriod = Seconds{10}; +const auto getWatchdogMonitor = + ServiceContext::declareDecoration<std::unique_ptr<WatchdogMonitor>>(); + // A boolean variable to track whether the watchdog was enabled at startup. // Defaults to true because set parameters are handled before we start the watchdog if needed. bool watchdogEnabled{true}; +WatchdogMonitor* getGlobalWatchdogMonitor() { + if (!hasGlobalServiceContext()) { + return nullptr; + } + + return getWatchdogMonitor(getGlobalServiceContext()).get(); +} + } // namespace Status validateWatchdogPeriodSeconds(const int& value) { - const bool shouldSkipValidateForTest = - TestingProctor::instance().isInitialized() && TestingProctor::instance().isEnabled(); - if (!shouldSkipValidateForTest && value < 60 && value != -1) { + if (value < 60 && value != -1) { + return {ErrorCodes::BadValue, "watchdogPeriodSeconds must be greater than or equal to 60s"}; } @@ -81,7 +90,7 @@ Status validateWatchdogPeriodSeconds(const int& value) { } Status onUpdateWatchdogPeriodSeconds(const int& value) { - auto monitor = WatchdogMonitorInterface::getGlobalWatchdogMonitorInterface(); + auto monitor = getGlobalWatchdogMonitor(); if (monitor) { monitor->setPeriod(Seconds(value)); } @@ -112,8 +121,7 @@ public: } BSONObjBuilder result; - WatchdogMonitorInterface* watchdog = - WatchdogMonitorInterface::get(opCtx->getServiceContext()); + WatchdogMonitor* watchdog = getWatchdogMonitor(opCtx->getServiceContext()).get(); invariant(watchdog); result.append("checkGeneration", watchdog->getCheckGeneration()); @@ -183,13 +191,14 @@ void startWatchdog(ServiceContext* service) { checks.push_back(std::move(auditCheck)); } - WatchdogMonitorInterface::set( - service, - std::make_unique<WatchdogMonitor>( - std::move(checks), watchdogCheckPeriod, period, watchdogTerminate)); + auto monitor = std::make_unique<WatchdogMonitor>( + std::move(checks), watchdogCheckPeriod, period, watchdogTerminate); // Install the new WatchdogMonitor - auto staticMonitor = WatchdogMonitorInterface::get(service); + auto& staticMonitor = getWatchdogMonitor(service); + + staticMonitor = std::move(monitor); + staticMonitor->start(); } diff --git a/src/mongo/watchdog/watchdog_test.cpp b/src/mongo/watchdog/watchdog_test.cpp index 73ee6d6d3ab..178fa9a3411 100644 --- a/src/mongo/watchdog/watchdog_test.cpp +++ b/src/mongo/watchdog/watchdog_test.cpp @@ -320,19 +320,11 @@ TEST_F(WatchdogMonitorThreadTest, Basic) { WatchdogMonitorThread monitorThread(&checkThread, deathCallback, Milliseconds(5)); - // Check and monitor thread should not have run yet. - ASSERT_EQ(checkThread.getGeneration(), 0); - ASSERT_EQ(monitorThread.getGeneration(), 0); - monitorThread.start(); deathEvent.wait(); monitorThread.shutdown(); - // Check generation should be 0 since check thread never started. - // Monitor thread should have run at least once in order to call the deathCallback. - ASSERT_EQ(checkThread.getGeneration(), 0); - ASSERT_GTE(monitorThread.getGeneration(), 1); } /** @@ -373,26 +365,15 @@ TEST_F(WatchdogMonitorThreadTest, SleepyHungCheck) { WatchdogMonitorThread monitorThread(&checkThread, deathCallback, Milliseconds(100)); - // Check and monitor thread should not have run yet. - ASSERT_EQ(checkThread.getGeneration(), 0); - ASSERT_EQ(monitorThread.getGeneration(), 0); - checkThread.start(); monitorThread.start(); - sleepmillis(100); - deathEvent.wait(); monitorThread.shutdown(); checkThread.shutdown(); - - // Check generation should have run and hung. - // Monitor thread should have run at least once in order to call the deathCallback. - ASSERT_GTE(checkThread.getGeneration(), 1); - ASSERT_GTE(monitorThread.getGeneration(), 1); } class WatchdogMonitorTest : public LockerNoopServiceContextTest {}; @@ -411,21 +392,12 @@ TEST_F(WatchdogMonitorTest, SleepyHungCheck) { checks.push_back(std::move(sleepyCheck)); WatchdogMonitor monitor(std::move(checks), Milliseconds(1), Milliseconds(5), deathCallback); - // Check and monitor thread should not have run yet. - ASSERT_EQ(monitor.getCheckGeneration(), 0); - ASSERT_EQ(monitor.getMonitorGeneration(), 0); monitor.start(); - sleepmillis(100); - deathEvent.wait(); monitor.shutdown(); - // Check generation should have run and be hung. - // Monitor thread should have run at least once in order to call the deathCallback. - ASSERT_GTE(monitor.getCheckGeneration(), 1); - ASSERT_GTE(monitor.getMonitorGeneration(), 1); } // Positive: Make sure watchdog monitor terminates the process if a check is unresponsive @@ -460,10 +432,7 @@ TEST_F(WatchdogMonitorTest, PauseAndResume) { WatchdogMonitor monitor(std::move(checks), Milliseconds(1), Milliseconds(1001), deathCallback); - ASSERT_EQ(0, monitor.getCheckGeneration()); - ASSERT_EQ(0, monitor.getMonitorGeneration()); - auto counterCheckCount = 5; - counterCheckPtr->setSignalOnCount(counterCheckCount); + counterCheckPtr->setSignalOnCount(5); monitor.start(); @@ -472,10 +441,6 @@ TEST_F(WatchdogMonitorTest, PauseAndResume) { // Pause the monitor monitor.setPeriod(Milliseconds(-1)); - // Check generation should have increased. - auto lastCheckGeneration = monitor.getCheckGeneration(); - ASSERT_GTE(lastCheckGeneration, 1); - // Check the counter after it is shutdown and make sure it does not change. std::uint32_t pauseCounter = counterCheckPtr->getCounter(); @@ -485,40 +450,25 @@ TEST_F(WatchdogMonitorTest, PauseAndResume) { // We could have had one more run of the loop as we paused - allow for that case // but no other runs of the thread. ASSERT_GTE(pauseCounter + 1, counterCheckPtr->getCounter()); - ASSERT_GTE(lastCheckGeneration + 1, monitor.getCheckGeneration()); // Resume the monitor std::uint32_t baseCounter = counterCheckPtr->getCounter(); - counterCheckCount = baseCounter + 5; - counterCheckPtr->setSignalOnCount(counterCheckCount); + counterCheckPtr->setSignalOnCount(baseCounter + 5); // Restart the monitor with a different interval. - monitor.setPeriod(Milliseconds(57)); + monitor.setPeriod(Milliseconds(1007)); counterCheckPtr->waitForCount(); - // Wait for monitor to run at least once. - while (monitor.getMonitorGeneration() < 1) { - sleepmillis(100); - } monitor.shutdown(); - // Check generation and monitor generation should have both increased. - auto lastMonitorGeneration = monitor.getMonitorGeneration(); - ASSERT_GT(monitor.getCheckGeneration(), lastCheckGeneration); - ASSERT_GTE(lastMonitorGeneration, 1); - // Check the counter after it is shutdown and make sure it does not change. std::uint32_t lastCounter = counterCheckPtr->getCounter(); - lastCheckGeneration = monitor.getCheckGeneration(); - // This is racey but it should only produce false negatives sleepmillis(100); ASSERT_EQ(lastCounter, counterCheckPtr->getCounter()); - ASSERT_EQ(lastCheckGeneration, monitor.getCheckGeneration()); - ASSERT_EQ(lastMonitorGeneration, monitor.getMonitorGeneration()); } class DirectoryCheckTest : public LockerNoopServiceContextTest {}; |
