aboutsummaryrefslogtreecommitdiffstats
path: root/yt/cpp/mapreduce/interface/ut/job_counters_ut.cpp
diff options
context:
space:
mode:
authornadya73 <nadya73@yandex-team.com>2024-07-02 23:10:50 +0300
committernadya73 <nadya73@yandex-team.com>2024-07-02 23:21:03 +0300
commit5ea9afc5ee7edc24efa5f45b3a15e184872b0854 (patch)
tree4ccc339d97575cba8b3ed47b6f0615326bdb5324 /yt/cpp/mapreduce/interface/ut/job_counters_ut.cpp
parent96b239778766d32d5158aca805e08199b3c0a743 (diff)
downloadydb-5ea9afc5ee7edc24efa5f45b3a15e184872b0854.tar.gz
[yt/cpp/mapreduce] YT-21595: Use gtest instead of ytest in all mapreduce tests
85671f0cf4f45b4f015fa2cc0d195b81c16c6e8a
Diffstat (limited to 'yt/cpp/mapreduce/interface/ut/job_counters_ut.cpp')
-rw-r--r--yt/cpp/mapreduce/interface/ut/job_counters_ut.cpp100
1 files changed, 100 insertions, 0 deletions
diff --git a/yt/cpp/mapreduce/interface/ut/job_counters_ut.cpp b/yt/cpp/mapreduce/interface/ut/job_counters_ut.cpp
new file mode 100644
index 0000000000..9972637aff
--- /dev/null
+++ b/yt/cpp/mapreduce/interface/ut/job_counters_ut.cpp
@@ -0,0 +1,100 @@
+#include <yt/cpp/mapreduce/interface/job_counters.h>
+#include <yt/cpp/mapreduce/interface/operation.h>
+
+#include <library/cpp/yson/node/node_io.h>
+
+#include <library/cpp/testing/gtest/gtest.h>
+
+using namespace NYT;
+
+TEST(TJobCountersTest, Full)
+{
+ const TString input = R"""(
+ {
+ "completed" = {
+ "total" = 6;
+ "non-interrupted" = 1;
+ "interrupted" = {
+ "whatever_interrupted" = 2;
+ "whatever_else_interrupted" = 3;
+ };
+ };
+ "aborted" = {
+ "non_scheduled" = {
+ "whatever_non_scheduled" = 4;
+ "whatever_else_non_scheduled" = 5;
+ };
+ "scheduled" = {
+ "whatever_scheduled" = 6;
+ "whatever_else_scheduled" = 7;
+ };
+ "total" = 22;
+ };
+ "lost" = 8;
+ "invalidated" = 9;
+ "failed" = 10;
+ "running" = 11;
+ "suspended" = 12;
+ "pending" = 13;
+ "blocked" = 14;
+ "total" = 105;
+ })""";
+
+ TJobCounters counters(NodeFromYsonString(input));
+
+ EXPECT_EQ(counters.GetTotal(), 105u);
+
+ EXPECT_EQ(counters.GetCompleted().GetTotal(), 6u);
+ EXPECT_EQ(counters.GetCompletedNonInterrupted().GetTotal(), 1u);
+ EXPECT_EQ(counters.GetCompletedInterrupted().GetTotal(), 5u);
+ EXPECT_EQ(counters.GetAborted().GetTotal(), 22u);
+ EXPECT_EQ(counters.GetAbortedNonScheduled().GetTotal(), 9u);
+ EXPECT_EQ(counters.GetAbortedScheduled().GetTotal(), 13u);
+ EXPECT_EQ(counters.GetLost().GetTotal(), 8u);
+ EXPECT_EQ(counters.GetInvalidated().GetTotal(), 9u);
+ EXPECT_EQ(counters.GetFailed().GetTotal(), 10u);
+ EXPECT_EQ(counters.GetRunning().GetTotal(), 11u);
+ EXPECT_EQ(counters.GetSuspended().GetTotal(), 12u);
+ EXPECT_EQ(counters.GetPending().GetTotal(), 13u);
+ EXPECT_EQ(counters.GetBlocked().GetTotal(), 14u);
+
+ EXPECT_EQ(counters.GetCompletedInterrupted().GetValue("whatever_interrupted"), 2u);
+ EXPECT_EQ(counters.GetCompletedInterrupted().GetValue("whatever_else_interrupted"), 3u);
+ EXPECT_EQ(counters.GetAbortedNonScheduled().GetValue("whatever_non_scheduled"), 4u);
+ EXPECT_EQ(counters.GetAbortedNonScheduled().GetValue("whatever_else_non_scheduled"), 5u);
+ EXPECT_EQ(counters.GetAbortedScheduled().GetValue("whatever_scheduled"), 6u);
+ EXPECT_EQ(counters.GetAbortedScheduled().GetValue("whatever_else_scheduled"), 7u);
+
+ EXPECT_THROW(counters.GetCompletedInterrupted().GetValue("Nothingness"), yexception);
+}
+
+TEST(TJobCountersTest, Empty)
+{
+ const TString input = "{}";
+
+ TJobCounters counters(NodeFromYsonString(input));
+
+ EXPECT_EQ(counters.GetTotal(), 0u);
+
+ EXPECT_EQ(counters.GetCompleted().GetTotal(), 0u);
+ EXPECT_EQ(counters.GetCompletedNonInterrupted().GetTotal(), 0u);
+ EXPECT_EQ(counters.GetCompletedInterrupted().GetTotal(), 0u);
+ EXPECT_EQ(counters.GetAborted().GetTotal(), 0u);
+ EXPECT_EQ(counters.GetAbortedNonScheduled().GetTotal(), 0u);
+ EXPECT_EQ(counters.GetAbortedScheduled().GetTotal(), 0u);
+ EXPECT_EQ(counters.GetLost().GetTotal(), 0u);
+ EXPECT_EQ(counters.GetInvalidated().GetTotal(), 0u);
+ EXPECT_EQ(counters.GetFailed().GetTotal(), 0u);
+ EXPECT_EQ(counters.GetRunning().GetTotal(), 0u);
+ EXPECT_EQ(counters.GetSuspended().GetTotal(), 0u);
+ EXPECT_EQ(counters.GetPending().GetTotal(), 0u);
+ EXPECT_EQ(counters.GetBlocked().GetTotal(), 0u);
+}
+
+TEST(TJobCountersTest, Broken)
+{
+ EXPECT_THROW_MESSAGE_HAS_SUBSTR((TJobCounters(TNode())), yexception, "TJobCounters");
+ EXPECT_THROW_MESSAGE_HAS_SUBSTR((TJobCounters(TNode(1))), yexception, "TJobCounters");
+ EXPECT_THROW_MESSAGE_HAS_SUBSTR((TJobCounters(TNode(1.0))), yexception, "TJobCounters");
+ EXPECT_THROW_MESSAGE_HAS_SUBSTR((TJobCounters(TNode("Whatever"))), yexception, "TJobCounters");
+}