diff options
author | Francis Dupont <fdupont@isc.org> | 2021-10-11 16:40:48 +0200 |
---|---|---|
committer | Francis Dupont <fdupont@isc.org> | 2021-10-11 17:36:57 +0200 |
commit | b7a3c2d9b0869b51c87c29f1bb49598532d8b064 (patch) | |
tree | ac19f30ce92cd00fd29c3a9ef31dd2ef74d6c5e9 /src/lib/d2srv | |
parent | [#2125] Typos (diff) | |
download | kea-b7a3c2d9b0869b51c87c29f1bb49598532d8b064.tar.xz kea-b7a3c2d9b0869b51c87c29f1bb49598532d8b064.zip |
[#2129] Made stat test tools more generic
Diffstat (limited to 'src/lib/d2srv')
-rw-r--r-- | src/lib/d2srv/testutils/stats_test_utils.cc | 17 | ||||
-rw-r--r-- | src/lib/d2srv/testutils/stats_test_utils.h | 50 |
2 files changed, 17 insertions, 50 deletions
diff --git a/src/lib/d2srv/testutils/stats_test_utils.cc b/src/lib/d2srv/testutils/stats_test_utils.cc index c01c461cfd..262879b421 100644 --- a/src/lib/d2srv/testutils/stats_test_utils.cc +++ b/src/lib/d2srv/testutils/stats_test_utils.cc @@ -26,22 +26,7 @@ D2StatTest::~D2StatTest() { } void -D2StatTest::checkStat(const string& name, const int64_t expected_value) { - ObservationPtr obs = StatsMgr::instance().getObservation(name); - ASSERT_TRUE(obs) << " stat: " << name << " not found "; - ASSERT_EQ(expected_value, obs->getInteger().first) - << " stat: " << name << " value wrong"; -} - -void -D2StatTest::checkStats(const StatMap& expected_stats) { - for (const auto& it : expected_stats) { - checkStat(it.first, it.second); - } -} - -void -D2StatTest::checkStats(const string& key_name, const StatMap& expected_stats) { +checkStats(const string& key_name, const StatMap& expected_stats) { StatMap key_stats; for (const auto& it : expected_stats) { const string& stat_name = diff --git a/src/lib/d2srv/testutils/stats_test_utils.h b/src/lib/d2srv/testutils/stats_test_utils.h index 4b32b9c090..ccdad02acb 100644 --- a/src/lib/d2srv/testutils/stats_test_utils.h +++ b/src/lib/d2srv/testutils/stats_test_utils.h @@ -4,13 +4,13 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. -#ifndef STATS_TEST_UTILS_H -#define STATS_TEST_UTILS_H +#ifndef D2_STATS_TEST_UTILS_H +#define D2_STATS_TEST_UTILS_H #include <cc/data.h> #include <d2srv/d2_stats.h> #include <d2srv/d2_tsig_key.h> -#include <stats/stats_mgr.h> +#include <stats/testutils/stats_test_utils.h> #include <gtest/gtest.h> @@ -18,8 +18,10 @@ namespace isc { namespace d2 { namespace test { -/// @brief Type of name x value for statistics. -typedef std::map<std::string, int64_t> StatMap; +/// @brief Import statistic test utils. +using isc::stats::test::StatMap; +using isc::stats::test::checkStat; +using isc::stats::test::checkStats; /// @brief Test class with utility functions to test statistics. class D2StatTest { @@ -29,38 +31,18 @@ public: /// @brief Destructor. virtual ~D2StatTest(); - - /// @brief Compares a statistic to an expected value. - /// - /// Attempt to fetch the named statistic from the StatsMgr and if - /// found, compare its observed value to the given value. - /// Fails if the stat is not found or if the values do not match. - /// - /// @param name StatsMgr name for the statistic to check. - /// @param expected_value expected value of the statistic. - void checkStat(const std::string& name, const int64_t expected_value); - - /// @brief Compares StatsMgr statistics against expected values. - /// - /// Iterates over a list of statistic names and expected values, attempting - /// to fetch each from the StatsMgr and if found, compare its observed - /// value to the expected value. Fails if any of the expected stats are not - /// found or if the values do not match. - /// - /// @param expected_stats Map of expected static names and values. - void checkStats(const StatMap& expected_stats); - - /// @brief Compares StatsMgr key statistics against expected values. - /// - /// Prepend key part of names before calling checkStats simpler variant. - /// - /// @param key_name Name of the key. - /// @param expected_stats Map of expected static names and values. - void checkStats(const std::string& key_name, const StatMap& expected_stats); }; +/// @brief Compares StatsMgr key statistics against expected values. +/// +/// Prepend key part of names before calling checkStats simpler variant. +/// +/// @param key_name Name of the key. +/// @param expected_stats Map of expected static names and values. +void checkStats(const std::string& key_name, const StatMap& expected_stats); + } } } -#endif // STATS_TEST_UTILS_H +#endif // D2_STATS_TEST_UTILS_H |