diff options
author | hiddenpath <hiddenpath@yandex-team.com> | 2025-03-11 16:04:38 +0300 |
---|---|---|
committer | hiddenpath <hiddenpath@yandex-team.com> | 2025-03-11 16:54:53 +0300 |
commit | 1ff4a6b6b09b97c5238b953716b18ef6d2ba92bc (patch) | |
tree | 6b8b75987a693d9b11633ad9446b07fc7d842530 | |
parent | 2fc37acd05605e86ab293883cc1b739aa60da68f (diff) | |
download | ydb-1ff4a6b6b09b97c5238b953716b18ef6d2ba92bc.tar.gz |
Do not fail upon negative job counters receiving
commit_hash:668ef57d392be32298dea16386d7d7e78aca248d
-rw-r--r-- | yt/cpp/mapreduce/http_client/ut/raw_requests_ut.cpp | 20 | ||||
-rw-r--r-- | yt/cpp/mapreduce/interface/job_counters.cpp | 16 | ||||
-rw-r--r-- | yt/cpp/mapreduce/interface/job_counters.h | 12 | ||||
-rw-r--r-- | yt/cpp/mapreduce/interface/operation.h | 14 | ||||
-rw-r--r-- | yt/cpp/mapreduce/interface/ut/job_counters_ut.cpp | 68 |
5 files changed, 65 insertions, 65 deletions
diff --git a/yt/cpp/mapreduce/http_client/ut/raw_requests_ut.cpp b/yt/cpp/mapreduce/http_client/ut/raw_requests_ut.cpp index 59fee2be61..533bee5642 100644 --- a/yt/cpp/mapreduce/http_client/ut/raw_requests_ut.cpp +++ b/yt/cpp/mapreduce/http_client/ut/raw_requests_ut.cpp @@ -143,8 +143,8 @@ TEST(TOperationsApiParsingTest, ParseOperationAttributes) EXPECT_EQ(*attrs.FinishTime - *attrs.StartTime, TDuration::Days(1)); EXPECT_TRUE(attrs.BriefProgress); - EXPECT_EQ(attrs.BriefProgress->Completed, 84u); - EXPECT_EQ(attrs.BriefProgress->Failed, 1u); + EXPECT_EQ(attrs.BriefProgress->Completed, 84); + EXPECT_EQ(attrs.BriefProgress->Failed, 1); EXPECT_TRUE(attrs.BriefSpec); EXPECT_EQ((*attrs.BriefSpec)["title"].AsString(), "some-title"); @@ -156,13 +156,13 @@ TEST(TOperationsApiParsingTest, ParseOperationAttributes) EXPECT_TRUE(!attrs.Result->Error); EXPECT_TRUE(attrs.Progress); - EXPECT_EQ(attrs.Progress->JobStatistics.JobState({}).GetStatistics("data/input/row_count").Sum(), 85u); - EXPECT_EQ(attrs.Progress->JobCounters.GetCompletedInterrupted().GetTotal(), 2u); - EXPECT_EQ(attrs.Progress->JobCounters.GetAbortedNonScheduled().GetTotal(), 3u); - EXPECT_EQ(attrs.Progress->JobCounters.GetAbortedScheduled().GetTotal(), 4u); - EXPECT_EQ(attrs.Progress->JobCounters.GetAborted().GetTotal(), 7u); - EXPECT_EQ(attrs.Progress->JobCounters.GetFailed().GetTotal(), 7u); - EXPECT_EQ(attrs.Progress->JobCounters.GetTotal(), 66u); + EXPECT_EQ(attrs.Progress->JobStatistics.JobState({}).GetStatistics("data/input/row_count").Sum(), 85); + EXPECT_EQ(attrs.Progress->JobCounters.GetCompletedInterrupted().GetTotal(), 2); + EXPECT_EQ(attrs.Progress->JobCounters.GetAbortedNonScheduled().GetTotal(), 3); + EXPECT_EQ(attrs.Progress->JobCounters.GetAbortedScheduled().GetTotal(), 4); + EXPECT_EQ(attrs.Progress->JobCounters.GetAborted().GetTotal(), 7); + EXPECT_EQ(attrs.Progress->JobCounters.GetFailed().GetTotal(), 7); + EXPECT_EQ(attrs.Progress->JobCounters.GetTotal(), 66); EXPECT_EQ(*attrs.Progress->BuildTime, TInstant::ParseIso8601("2018-01-01T00:00:00.000000Z")); EXPECT_TRUE(attrs.Events); @@ -186,6 +186,6 @@ TEST(TOperationsApiParsingTest, EmptyProgress) EXPECT_TRUE(attrs.Progress); EXPECT_EQ(attrs.Progress->JobStatistics.JobState({}).GetStatisticsNames(), TVector<TString>{}); - EXPECT_EQ(attrs.Progress->JobCounters.GetTotal(), 0u); + EXPECT_EQ(attrs.Progress->JobCounters.GetTotal(), 0); EXPECT_TRUE(!attrs.Progress->BuildTime); } diff --git a/yt/cpp/mapreduce/interface/job_counters.cpp b/yt/cpp/mapreduce/interface/job_counters.cpp index 2d0284e2b1..6468e0e6d0 100644 --- a/yt/cpp/mapreduce/interface/job_counters.cpp +++ b/yt/cpp/mapreduce/interface/job_counters.cpp @@ -5,20 +5,20 @@ namespace NYT { //////////////////////////////////////////////////////////////////////////////// namespace { - ui64 CountTotal(const TNode& data) + i64 CountTotal(const TNode& data) { if (data.IsMap()) { if (auto totalPtr = data.AsMap().FindPtr("total")) { - return data["total"].IntCast<ui64>(); + return data["total"].IntCast<i64>(); } else { - ui64 total = 0; + i64 total = 0; for (const auto& keyVal: data.AsMap()) { total += CountTotal(keyVal.second); } return total; } } else { - return data.IntCast<ui64>(); + return data.IntCast<i64>(); } } @@ -41,16 +41,16 @@ TJobCounter::TJobCounter(TNode data) } } -TJobCounter::TJobCounter(ui64 total) +TJobCounter::TJobCounter(i64 total) : Total_(total) { } -ui64 TJobCounter::GetTotal() const +i64 TJobCounter::GetTotal() const { return Total_; } -ui64 TJobCounter::GetValue(const TStringBuf key) const +i64 TJobCounter::GetValue(const TStringBuf key) const { if (Data_.HasValue()) { return CountTotal(Data_[key]); @@ -154,7 +154,7 @@ const TJobCounter& TJobCounters::GetBlocked() const return Blocked_; } -ui64 TJobCounters::GetTotal() const +i64 TJobCounters::GetTotal() const { return Total_; } diff --git a/yt/cpp/mapreduce/interface/job_counters.h b/yt/cpp/mapreduce/interface/job_counters.h index 24efddd7d0..475fc152eb 100644 --- a/yt/cpp/mapreduce/interface/job_counters.h +++ b/yt/cpp/mapreduce/interface/job_counters.h @@ -10,17 +10,17 @@ class TJobCounter { private: TNode Data_; - ui64 Total_ = 0; + i64 Total_ = 0; public: TJobCounter() = default; TJobCounter(TNode data); - TJobCounter(ui64 total); + TJobCounter(i64 total); - ui64 GetTotal() const; + i64 GetTotal() const; - ui64 GetValue(const TStringBuf key) const; + i64 GetValue(const TStringBuf key) const; }; /// Class representing a collection of job counters. @@ -49,10 +49,10 @@ public: const TJobCounter& GetPending() const; const TJobCounter& GetBlocked() const; - ui64 GetTotal() const; + i64 GetTotal() const; private: - ui64 Total_ = 0; + i64 Total_ = 0; TJobCounter Aborted_; TJobCounter AbortedScheduled_; diff --git a/yt/cpp/mapreduce/interface/operation.h b/yt/cpp/mapreduce/interface/operation.h index a498e5b59e..923b11b6a0 100644 --- a/yt/cpp/mapreduce/interface/operation.h +++ b/yt/cpp/mapreduce/interface/operation.h @@ -2456,13 +2456,13 @@ struct TOperationProgress /// @brief Brief operation progress (numbers of jobs in these states). struct TOperationBriefProgress { - ui64 Aborted = 0; - ui64 Completed = 0; - ui64 Failed = 0; - ui64 Lost = 0; - ui64 Pending = 0; - ui64 Running = 0; - ui64 Total = 0; + i64 Aborted = 0; + i64 Completed = 0; + i64 Failed = 0; + i64 Lost = 0; + i64 Pending = 0; + i64 Running = 0; + i64 Total = 0; }; /// diff --git a/yt/cpp/mapreduce/interface/ut/job_counters_ut.cpp b/yt/cpp/mapreduce/interface/ut/job_counters_ut.cpp index 9972637aff..1c887b37e1 100644 --- a/yt/cpp/mapreduce/interface/ut/job_counters_ut.cpp +++ b/yt/cpp/mapreduce/interface/ut/job_counters_ut.cpp @@ -42,28 +42,28 @@ TEST(TJobCountersTest, Full) TJobCounters counters(NodeFromYsonString(input)); - EXPECT_EQ(counters.GetTotal(), 105u); + EXPECT_EQ(counters.GetTotal(), 105); - 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.GetCompleted().GetTotal(), 6); + EXPECT_EQ(counters.GetCompletedNonInterrupted().GetTotal(), 1); + EXPECT_EQ(counters.GetCompletedInterrupted().GetTotal(), 5); + EXPECT_EQ(counters.GetAborted().GetTotal(), 22); + EXPECT_EQ(counters.GetAbortedNonScheduled().GetTotal(), 9); + EXPECT_EQ(counters.GetAbortedScheduled().GetTotal(), 13); + EXPECT_EQ(counters.GetLost().GetTotal(), 8); + EXPECT_EQ(counters.GetInvalidated().GetTotal(), 9); + EXPECT_EQ(counters.GetFailed().GetTotal(), 10); + EXPECT_EQ(counters.GetRunning().GetTotal(), 11); + EXPECT_EQ(counters.GetSuspended().GetTotal(), 12); + EXPECT_EQ(counters.GetPending().GetTotal(), 13); + EXPECT_EQ(counters.GetBlocked().GetTotal(), 14); - 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_EQ(counters.GetCompletedInterrupted().GetValue("whatever_interrupted"), 2); + EXPECT_EQ(counters.GetCompletedInterrupted().GetValue("whatever_else_interrupted"), 3); + EXPECT_EQ(counters.GetAbortedNonScheduled().GetValue("whatever_non_scheduled"), 4); + EXPECT_EQ(counters.GetAbortedNonScheduled().GetValue("whatever_else_non_scheduled"), 5); + EXPECT_EQ(counters.GetAbortedScheduled().GetValue("whatever_scheduled"), 6); + EXPECT_EQ(counters.GetAbortedScheduled().GetValue("whatever_else_scheduled"), 7); EXPECT_THROW(counters.GetCompletedInterrupted().GetValue("Nothingness"), yexception); } @@ -74,21 +74,21 @@ TEST(TJobCountersTest, Empty) TJobCounters counters(NodeFromYsonString(input)); - EXPECT_EQ(counters.GetTotal(), 0u); + EXPECT_EQ(counters.GetTotal(), 0); - 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); + EXPECT_EQ(counters.GetCompleted().GetTotal(), 0); + EXPECT_EQ(counters.GetCompletedNonInterrupted().GetTotal(), 0); + EXPECT_EQ(counters.GetCompletedInterrupted().GetTotal(), 0); + EXPECT_EQ(counters.GetAborted().GetTotal(), 0); + EXPECT_EQ(counters.GetAbortedNonScheduled().GetTotal(), 0); + EXPECT_EQ(counters.GetAbortedScheduled().GetTotal(), 0); + EXPECT_EQ(counters.GetLost().GetTotal(), 0); + EXPECT_EQ(counters.GetInvalidated().GetTotal(), 0); + EXPECT_EQ(counters.GetFailed().GetTotal(), 0); + EXPECT_EQ(counters.GetRunning().GetTotal(), 0); + EXPECT_EQ(counters.GetSuspended().GetTotal(), 0); + EXPECT_EQ(counters.GetPending().GetTotal(), 0); + EXPECT_EQ(counters.GetBlocked().GetTotal(), 0); } TEST(TJobCountersTest, Broken) |