diff options
author | mokhotskii <mokhotskii@ydb.tech> | 2023-01-23 17:45:36 +0300 |
---|---|---|
committer | mokhotskii <mokhotskii@ydb.tech> | 2023-01-23 17:45:36 +0300 |
commit | e69e6b68dfdde79a2a5181c9bcb0de2933786aa7 (patch) | |
tree | 2526733d18b7e78747515b4aba6073d27a7afd49 | |
parent | db3ac1ca828c3f6b79f1f6832e4a52900a696ebe (diff) | |
download | ydb-e69e6b68dfdde79a2a5181c9bcb0de2933786aa7.tar.gz |
Make sys_view tests medium again
Make tests small
-rw-r--r-- | ydb/core/sys_view/processor/db_counters.cpp | 25 | ||||
-rw-r--r-- | ydb/core/sys_view/service/sysview_service.cpp | 3 | ||||
-rw-r--r-- | ydb/core/sys_view/ut_kqp/CMakeLists.darwin.txt | 4 | ||||
-rw-r--r-- | ydb/core/sys_view/ut_kqp/CMakeLists.linux-aarch64.txt | 4 | ||||
-rw-r--r-- | ydb/core/sys_view/ut_kqp/CMakeLists.linux.txt | 4 | ||||
-rw-r--r-- | ydb/core/sys_view/ut_labeled.cpp | 94 | ||||
-rw-r--r-- | ydb/core/tablet/labeled_counters_merger.h | 16 |
7 files changed, 58 insertions, 92 deletions
diff --git a/ydb/core/sys_view/processor/db_counters.cpp b/ydb/core/sys_view/processor/db_counters.cpp index 97f38eb4c5..9cb9a63232 100644 --- a/ydb/core/sys_view/processor/db_counters.cpp +++ b/ydb/core/sys_view/processor/db_counters.cpp @@ -146,16 +146,27 @@ static void ResetLabeledCounters(NKikimrLabeledCounters::TTabletLabeledCounters* auto labeledSize = dst->LabeledCounterSize(); auto* to = dst->MutableLabeledCounter(); for (size_t i = 0; i < labeledSize; ++i) { - auto aggrFunc = (*to)[i].GetAggregateFunc(); + auto& counter = (*to)[i]; + TLabeledCounterOptions::ECounterType type(counter.GetType()); + TLabeledCounterOptions::EAggregateFunc aggrFunc(counter.GetAggregateFunc()); + const bool switchResetValue = (type == TLabeledCounterOptions::CT_TIMELAG); switch (aggrFunc) { - case static_cast<int>(TTabletLabeledCountersBase::EAggregateFunc::EAF_MIN): - (*to)[i].SetValue(std::numeric_limits<ui64>::max()); + case TLabeledCounterOptions::EAF_MIN: + if (switchResetValue) { + counter.SetValue(0); + } else { + counter.SetValue(std::numeric_limits<ui64>::max()); + } break; - case static_cast<int>(TTabletLabeledCountersBase::EAggregateFunc::EAF_MAX): - (*to)[i].SetValue(0); + case TLabeledCounterOptions::EAF_MAX: + if (switchResetValue) { + counter.SetValue(std::numeric_limits<ui64>::max()); + } else { + counter.SetValue(0); + } break; - case static_cast<int>(TTabletLabeledCountersBase::EAggregateFunc::EAF_SUM): - (*to)[i].SetValue(0); + case TLabeledCounterOptions::EAF_SUM: + counter.SetValue(0); break; default: Y_FAIL("bad aggrFunc value"); diff --git a/ydb/core/sys_view/service/sysview_service.cpp b/ydb/core/sys_view/service/sysview_service.cpp index 8514ff6182..c979784fa0 100644 --- a/ydb/core/sys_view/service/sysview_service.cpp +++ b/ydb/core/sys_view/service/sysview_service.cpp @@ -322,6 +322,7 @@ public: , TotalInterval(TDuration::Seconds(processorMode == EProcessorMode::FAST ? 6 : 60)) , CollectInterval(TDuration::Seconds(processorMode == EProcessorMode::FAST ? 3 : 30)) , SendInterval(TDuration::Seconds(processorMode == EProcessorMode::FAST ? 2 : 20)) + , ProcessLabeledCountersInterval(TDuration::Seconds(processorMode == EProcessorMode::FAST ? 5 : 60)) {} void Bootstrap(const TActorContext &ctx) { @@ -1110,6 +1111,7 @@ private: const TDuration TotalInterval; const TDuration CollectInterval; const TDuration SendInterval; + const TDuration ProcessLabeledCountersInterval; template <typename TInterval> struct TDbWindow { @@ -1208,7 +1210,6 @@ private: static constexpr size_t SummaryRetryAttempts = 5; static constexpr TDuration ProcessCountersInterval = TDuration::Seconds(5); - static constexpr TDuration ProcessLabeledCountersInterval = TDuration::Minutes(1); }; THolder<IActor> CreateSysViewService( diff --git a/ydb/core/sys_view/ut_kqp/CMakeLists.darwin.txt b/ydb/core/sys_view/ut_kqp/CMakeLists.darwin.txt index 5ac917e59d..fe6b95d71b 100644 --- a/ydb/core/sys_view/ut_kqp/CMakeLists.darwin.txt +++ b/ydb/core/sys_view/ut_kqp/CMakeLists.darwin.txt @@ -65,7 +65,7 @@ set_yunittest_property( ydb-core-sys_view-ut_kqp PROPERTY LABELS - LARGE + MEDIUM ) set_yunittest_property( TEST @@ -79,6 +79,6 @@ set_yunittest_property( ydb-core-sys_view-ut_kqp PROPERTY TIMEOUT - 1000 + 600 ) vcs_info(ydb-core-sys_view-ut_kqp) diff --git a/ydb/core/sys_view/ut_kqp/CMakeLists.linux-aarch64.txt b/ydb/core/sys_view/ut_kqp/CMakeLists.linux-aarch64.txt index 28fb7f7c23..df68c0f566 100644 --- a/ydb/core/sys_view/ut_kqp/CMakeLists.linux-aarch64.txt +++ b/ydb/core/sys_view/ut_kqp/CMakeLists.linux-aarch64.txt @@ -68,7 +68,7 @@ set_yunittest_property( ydb-core-sys_view-ut_kqp PROPERTY LABELS - LARGE + MEDIUM ) set_yunittest_property( TEST @@ -82,6 +82,6 @@ set_yunittest_property( ydb-core-sys_view-ut_kqp PROPERTY TIMEOUT - 1000 + 600 ) vcs_info(ydb-core-sys_view-ut_kqp) diff --git a/ydb/core/sys_view/ut_kqp/CMakeLists.linux.txt b/ydb/core/sys_view/ut_kqp/CMakeLists.linux.txt index 644202a1c1..847436e4fe 100644 --- a/ydb/core/sys_view/ut_kqp/CMakeLists.linux.txt +++ b/ydb/core/sys_view/ut_kqp/CMakeLists.linux.txt @@ -70,7 +70,7 @@ set_yunittest_property( ydb-core-sys_view-ut_kqp PROPERTY LABELS - LARGE + MEDIUM ) set_yunittest_property( TEST @@ -84,6 +84,6 @@ set_yunittest_property( ydb-core-sys_view-ut_kqp PROPERTY TIMEOUT - 1000 + 600 ) vcs_info(ydb-core-sys_view-ut_kqp) diff --git a/ydb/core/sys_view/ut_labeled.cpp b/ydb/core/sys_view/ut_labeled.cpp index 53093bc7ff..02acea4916 100644 --- a/ydb/core/sys_view/ut_labeled.cpp +++ b/ydb/core/sys_view/ut_labeled.cpp @@ -43,6 +43,7 @@ bool CheckCounter(::NMonitoring::TDynamicCounterPtr group, const char* sensorNam bool CheckLtCounter(::NMonitoring::TDynamicCounterPtr group, const char* sensorName, ui32 refValue, bool isDerivative) { auto value = group->GetNamedCounter("name", sensorName, isDerivative)->Val(); + Cerr << "CHECK COUNTER " << sensorName << " wait less than " << refValue << " got " << value << "\n"; return (value <= refValue); } @@ -108,8 +109,8 @@ Y_UNIT_TEST_SUITE(LabeledDbCounters) { auto check = [](::NMonitoring::TDynamicCounterPtr topicGroup) { bool isGood{true}; - isGood &= CheckCounter(topicGroup, "topic.partitions.alive_count", partitionsN, false); - isGood &= CheckCounter(topicGroup, "topic.partitions.write_speed_bytes_per_second", 50'000'000, false); + isGood &= CheckCounter(topicGroup, "topic.partition.alive_count", partitionsN, false); + isGood &= CheckCounter(topicGroup, "topic.partition.write.speed_limit_bytes_per_second", 50'000'000, false); isGood &= CheckCounter(topicGroup, "topic.producers_count", 0, false); return isGood; @@ -118,7 +119,6 @@ Y_UNIT_TEST_SUITE(LabeledDbCounters) { CreateDatabase(env, databaseName); NPQ::PQTabletPrepare({.partitions=partitionsN}, {}, *env.GetServer().GetRuntime(), env.GetPqTabletIds()[0], edge); - Sleep(TDuration::Minutes(1)); GetCounters(env, databaseName, databasePath, check); } @@ -142,28 +142,27 @@ Y_UNIT_TEST_SUITE(LabeledDbCounters) { Cerr << ss.Str() << Endl; } - isGood &= CheckCounter(topicGroup, "topic.partitions.alive_count", partitionsN, false); - isGood &= CheckCounter(topicGroup, "topic.partitions.write_speed_bytes_per_second", 50'000'000, false); + isGood &= CheckCounter(topicGroup, "topic.partition.alive_count", partitionsN, false); + isGood &= CheckCounter(topicGroup, "topic.partition.write.speed_limit_bytes_per_second", 50'000'000, false); isGood &= CheckCounter(topicGroup, "topic.producers_count", 0, false); return isGood; }; - Sleep(TDuration::Minutes(1)); GetCounters(env, databaseName, databasePath, check); } + Sleep(TDuration::Seconds(60)); env.GetServer().GetRuntime()->Register(CreateTabletKiller(env.GetPqTabletIds()[0])); { auto check = [](::NMonitoring::TDynamicCounterPtr topicGroup) { bool isGood{true}; - isGood &= CheckLtCounter(topicGroup, "topic.max_partition_uptime_milliseconds", - TDuration::Minutes(1).MilliSeconds() + 200, false); - isGood &= CheckCounter(topicGroup, "topic.partitions.alive_count", partitionsN, false); + isGood &= CheckLtCounter(topicGroup, "topic.partition.uptime_milliseconds_min", + TDuration::Seconds(60).MilliSeconds() + 200, false); + isGood &= CheckCounter(topicGroup, "topic.partition.alive_count", partitionsN, false); return isGood; }; - Sleep(TDuration::Minutes(1)); GetCounters(env, databaseName, databasePath, check); } } @@ -175,8 +174,8 @@ Y_UNIT_TEST_SUITE(LabeledDbCounters) { auto check = [](::NMonitoring::TDynamicCounterPtr topicGroup) { bool isGood{true}; - isGood &= CheckCounter(topicGroup, "topic.partitions.alive_count", partitionsN*2, false); - isGood &= CheckCounter(topicGroup, "topic.partitions.write_speed_bytes_per_second", 50'000'000, false); + isGood &= CheckCounter(topicGroup, "topic.partition.alive_count", partitionsN*2, false); + isGood &= CheckCounter(topicGroup, "topic.partition.write.speed_limit_bytes_per_second", 50'000'000, false); isGood &= CheckCounter(topicGroup, "topic.producers_count", 0, false); return isGood; @@ -188,7 +187,6 @@ Y_UNIT_TEST_SUITE(LabeledDbCounters) { tbId, env.GetServer().GetRuntime()->AllocateEdgeActor()); } - Sleep(TDuration::Minutes(1)); GetCounters(env, databaseName, databasePath, check); } @@ -207,14 +205,13 @@ Y_UNIT_TEST_SUITE(LabeledDbCounters) { auto check = [](::NMonitoring::TDynamicCounterPtr topicGroup) { bool isGood{true}; - isGood &= CheckCounter(topicGroup, "topic.partitions.alive_count", partitionsN*2, false); - isGood &= CheckCounter(topicGroup, "topic.partitions.write_speed_bytes_per_second", 50'000'000, false); + isGood &= CheckCounter(topicGroup, "topic.partition.alive_count", partitionsN*2, false); + isGood &= CheckCounter(topicGroup, "topic.partition.write.speed_limit_bytes_per_second", 50'000'000, false); isGood &= CheckCounter(topicGroup, "topic.producers_count", 0, false); return isGood; }; - Sleep(TDuration::Minutes(1)); GetCounters(env, databaseName, databasePath, check); } @@ -227,12 +224,11 @@ Y_UNIT_TEST_SUITE(LabeledDbCounters) { auto check = [](::NMonitoring::TDynamicCounterPtr topicGroup) { bool isGood{true}; - isGood &= CheckCounter(topicGroup, "topic.partitions.alive_count", partitionsN, false); + isGood &= CheckCounter(topicGroup, "topic.partition.alive_count", partitionsN, false); return isGood; }; - Sleep(TDuration::Seconds(30)); GetCounters(env, databaseName, databasePath, check); } } @@ -252,79 +248,37 @@ Y_UNIT_TEST_SUITE(LabeledDbCounters) { auto check = [](::NMonitoring::TDynamicCounterPtr topicGroup) { bool isGood{true}; - isGood &= CheckCounter(topicGroup, "topic.partitions.alive_count", partitionsN*2, false); - isGood &= CheckCounter(topicGroup, "topic.partitions.write_speed_bytes_per_second", 50'000'000, false); + isGood &= CheckCounter(topicGroup, "topic.partition.alive_count", partitionsN*2, false); + isGood &= CheckCounter(topicGroup, "topic.partition.write.speed_limit_bytes_per_second", 50'000'000, false); isGood &= CheckCounter(topicGroup, "topic.producers_count", 0, false); return isGood; }; - Sleep(TDuration::Minutes(1)); - GetCounters(env, databaseName, databasePath, check); - } - - env.GetServer().GetRuntime()->DisconnectNodes(0, 1, false); - env.GetServer().GetRuntime()->DisconnectNodes(0, 2, false); - - { - auto check = [](::NMonitoring::TDynamicCounterPtr topicGroup) { - bool isGood{true}; - - isGood &= CheckCounter(topicGroup, "topic.partitions.alive_count", partitionsN*2, false); - - return isGood; - }; - - Sleep(TDuration::Minutes(1)); - GetCounters(env, databaseName, databasePath, check); - } - } - - Y_UNIT_TEST(TwoTabletsDisconnectOneNodeHardWay) { - TTestEnv env(1, 2, 0, 2, true); - const TString databaseName = NPQ::TTabletPreparationParameters().databaseId; - const TString databasePath = NPQ::TTabletPreparationParameters().databasePath; - auto edge = env.GetServer().GetRuntime()->AllocateEdgeActor(); - CreateDatabase(env, databaseName); - for (auto& tbId : env.GetPqTabletIds()) { - NPQ::PQTabletPrepare({.partitions=partitionsN}, {}, *env.GetServer().GetRuntime(), - tbId, edge); - } - - { - auto check = [](::NMonitoring::TDynamicCounterPtr topicGroup) { - bool isGood{true}; - - isGood &= CheckCounter(topicGroup, "topic.partitions.alive_count", partitionsN*2, false); - isGood &= CheckCounter(topicGroup, "topic.partitions.write_speed_bytes_per_second", 50'000'000, false); - isGood &= CheckCounter(topicGroup, "topic.producers_count", 0, false); - - return isGood; - }; - - Sleep(TDuration::Minutes(1)); GetCounters(env, databaseName, databasePath, check); } for (ui32 i = 0; i < env.GetServer().StaticNodes() + env.GetServer().DynamicNodes(); i++) { env.GetClient().MarkNodeInHive(env.GetServer().GetRuntime(), i, false); } - - env.GetServer().GetRuntime()->DisconnectNodes(0, 1, true); - env.GetServer().GetRuntime()->DisconnectNodes(0, 2, true); + env.GetServer().GetRuntime()->DisconnectNodes(0, 1, false); + env.GetServer().GetRuntime()->DisconnectNodes(1, 0, false); + env.GetServer().GetRuntime()->DisconnectNodes(0, 2, false); + env.GetServer().GetRuntime()->DisconnectNodes(2, 0, false); { auto check = [](::NMonitoring::TDynamicCounterPtr topicGroup) { bool isGood{true}; - isGood &= CheckCounter(topicGroup, "topic.partitions.alive_count", partitionsN, false); - isGood &= CheckCounter(topicGroup, "topic.partitions.total_count", partitionsN, false); + isGood &= CheckCounter(topicGroup, "topic.partition.alive_count", partitionsN, false); + isGood &= CheckCounter(topicGroup, "topic.partition.total_count", partitionsN, false); return isGood; }; - Sleep(TDuration::Minutes(1)); GetCounters(env, databaseName, databasePath, check); } + + env.GetServer().GetRuntime()->Register(CreateTabletKiller(env.GetPqTabletIds()[0])); } } diff --git a/ydb/core/tablet/labeled_counters_merger.h b/ydb/core/tablet/labeled_counters_merger.h index 097696b9d2..6e92a4bc79 100644 --- a/ydb/core/tablet/labeled_counters_merger.h +++ b/ydb/core/tablet/labeled_counters_merger.h @@ -14,17 +14,17 @@ public: NKikimrLabeledCounters::TTabletLabeledCounter& target) { ui64 value(source.GetValue()); TLabeledCounterOptions::ECounterType type(source.GetType()); - NKikimr::TLabeledCounterOptions::EAggregateFunc func(source.GetAggregateFunc()); + TLabeledCounterOptions::EAggregateFunc func(source.GetAggregateFunc()); if (type == TLabeledCounterOptions::CT_TIMELAG) { type = TLabeledCounterOptions::CT_SIMPLE; auto now = TInstant::Now().MilliSeconds(); value = now > value ? now - value : 0; switch (func) { - case NKikimr::TLabeledCounterOptions::EAF_MIN: - func = NKikimr::TLabeledCounterOptions::EAF_MAX; + case TLabeledCounterOptions::EAF_MIN: + func = TLabeledCounterOptions::EAF_MAX; break; - case NKikimr::TLabeledCounterOptions::EAF_MAX: - func = NKikimr::TLabeledCounterOptions::EAF_MIN; + case TLabeledCounterOptions::EAF_MAX: + func = TLabeledCounterOptions::EAF_MIN; break; default: break; @@ -32,13 +32,13 @@ public: } if (target.HasValue()) { switch (func) { - case NKikimr::TLabeledCounterOptions::EAF_MIN: + case TLabeledCounterOptions::EAF_MIN: target.SetValue(std::min(target.GetValue(), value)); break; - case NKikimr::TLabeledCounterOptions::EAF_MAX: + case TLabeledCounterOptions::EAF_MAX: target.SetValue(std::max(target.GetValue(), value)); break; - case NKikimr::TLabeledCounterOptions::EAF_SUM: + case TLabeledCounterOptions::EAF_SUM: target.SetValue(target.GetValue() + value); break; } |