diff options
author | Sergey Polovko <sergey@polovko.me> | 2022-02-10 16:47:02 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:47:02 +0300 |
commit | 3e0b762a82514bac89c1dd6ea7211e381d8aa248 (patch) | |
tree | c2d1b379ecaf05ca8f11ed0b5da9d1a950e6e554 /library/cpp/monlib/metrics/metric_sub_registry_ut.cpp | |
parent | ab3783171cc30e262243a0227c86118f7080c896 (diff) | |
download | ydb-3e0b762a82514bac89c1dd6ea7211e381d8aa248.tar.gz |
Restoring authorship annotation for Sergey Polovko <sergey@polovko.me>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/monlib/metrics/metric_sub_registry_ut.cpp')
-rw-r--r-- | library/cpp/monlib/metrics/metric_sub_registry_ut.cpp | 130 |
1 files changed, 65 insertions, 65 deletions
diff --git a/library/cpp/monlib/metrics/metric_sub_registry_ut.cpp b/library/cpp/monlib/metrics/metric_sub_registry_ut.cpp index 0c5d48b876..af6d4fa462 100644 --- a/library/cpp/monlib/metrics/metric_sub_registry_ut.cpp +++ b/library/cpp/monlib/metrics/metric_sub_registry_ut.cpp @@ -1,65 +1,65 @@ -#include "metric_sub_registry.h" - -#include <library/cpp/testing/unittest/registar.h> - -using namespace NMonitoring; - -Y_UNIT_TEST_SUITE(TMetricSubRegistryTest) { - Y_UNIT_TEST(WrapRegistry) { - TMetricRegistry registry; - - { - TMetricSubRegistry subRegistry{{{"common", "label"}}, ®istry}; - IIntGauge* g = subRegistry.IntGauge(MakeLabels({{"my", "gauge"}})); - UNIT_ASSERT(g); - g->Set(42); - } - - TIntGauge* g = registry.IntGauge({{"my", "gauge"}, {"common", "label"}}); - UNIT_ASSERT(g); - UNIT_ASSERT_VALUES_EQUAL(g->Get(), 42); - } - - Y_UNIT_TEST(CommonLabelsDoNotOverrideGeneralLabel) { - TMetricRegistry registry; - - { - TMetricSubRegistry subRegistry{{{"common", "label"}, {"my", "notOverride"}}, ®istry}; - IIntGauge* g = subRegistry.IntGauge(MakeLabels({{"my", "gauge"}})); - UNIT_ASSERT(g); - g->Set(1234); - } - - TIntGauge* knownGauge = registry.IntGauge({{"my", "gauge"}, {"common", "label"}}); - UNIT_ASSERT(knownGauge); - UNIT_ASSERT_VALUES_EQUAL(knownGauge->Get(), 1234); - - TIntGauge* newGauge = registry.IntGauge({{"common", "label"}, {"my", "notOverride"}}); - UNIT_ASSERT(newGauge); - UNIT_ASSERT_VALUES_EQUAL(newGauge->Get(), 0); - } - - Y_UNIT_TEST(RemoveMetric) { - TMetricRegistry registry; - - { - TMetricSubRegistry subRegistry{{{"common", "label"}}, ®istry}; - IIntGauge* g = subRegistry.IntGauge(MakeLabels({{"my", "gauge"}})); - UNIT_ASSERT(g); - g->Set(1234); - } - - IIntGauge* g1 = registry.IntGauge({{"my", "gauge"}, {"common", "label"}}); - UNIT_ASSERT(g1); - UNIT_ASSERT_VALUES_EQUAL(g1->Get(), 1234); - - { - TMetricSubRegistry subRegistry{{{"common", "label"}}, ®istry}; - subRegistry.RemoveMetric(TLabels{{"my", "gauge"}}); - } - - IIntGauge* g2 = registry.IntGauge({{"my", "gauge"}, {"common", "label"}}); - UNIT_ASSERT(g2); - UNIT_ASSERT_VALUES_EQUAL(g2->Get(), 0); - } -} +#include "metric_sub_registry.h" + +#include <library/cpp/testing/unittest/registar.h> + +using namespace NMonitoring; + +Y_UNIT_TEST_SUITE(TMetricSubRegistryTest) { + Y_UNIT_TEST(WrapRegistry) { + TMetricRegistry registry; + + { + TMetricSubRegistry subRegistry{{{"common", "label"}}, ®istry}; + IIntGauge* g = subRegistry.IntGauge(MakeLabels({{"my", "gauge"}})); + UNIT_ASSERT(g); + g->Set(42); + } + + TIntGauge* g = registry.IntGauge({{"my", "gauge"}, {"common", "label"}}); + UNIT_ASSERT(g); + UNIT_ASSERT_VALUES_EQUAL(g->Get(), 42); + } + + Y_UNIT_TEST(CommonLabelsDoNotOverrideGeneralLabel) { + TMetricRegistry registry; + + { + TMetricSubRegistry subRegistry{{{"common", "label"}, {"my", "notOverride"}}, ®istry}; + IIntGauge* g = subRegistry.IntGauge(MakeLabels({{"my", "gauge"}})); + UNIT_ASSERT(g); + g->Set(1234); + } + + TIntGauge* knownGauge = registry.IntGauge({{"my", "gauge"}, {"common", "label"}}); + UNIT_ASSERT(knownGauge); + UNIT_ASSERT_VALUES_EQUAL(knownGauge->Get(), 1234); + + TIntGauge* newGauge = registry.IntGauge({{"common", "label"}, {"my", "notOverride"}}); + UNIT_ASSERT(newGauge); + UNIT_ASSERT_VALUES_EQUAL(newGauge->Get(), 0); + } + + Y_UNIT_TEST(RemoveMetric) { + TMetricRegistry registry; + + { + TMetricSubRegistry subRegistry{{{"common", "label"}}, ®istry}; + IIntGauge* g = subRegistry.IntGauge(MakeLabels({{"my", "gauge"}})); + UNIT_ASSERT(g); + g->Set(1234); + } + + IIntGauge* g1 = registry.IntGauge({{"my", "gauge"}, {"common", "label"}}); + UNIT_ASSERT(g1); + UNIT_ASSERT_VALUES_EQUAL(g1->Get(), 1234); + + { + TMetricSubRegistry subRegistry{{{"common", "label"}}, ®istry}; + subRegistry.RemoveMetric(TLabels{{"my", "gauge"}}); + } + + IIntGauge* g2 = registry.IntGauge({{"my", "gauge"}, {"common", "label"}}); + UNIT_ASSERT(g2); + UNIT_ASSERT_VALUES_EQUAL(g2->Get(), 0); + } +} |