aboutsummaryrefslogtreecommitdiffstats
path: root/yt/cpp/mapreduce/http_client/ut/raw_requests_ut.cpp
diff options
context:
space:
mode:
authorhiddenpath <hiddenpath@yandex-team.com>2025-01-22 08:47:22 +0300
committerhiddenpath <hiddenpath@yandex-team.com>2025-01-22 09:04:11 +0300
commit044fc00c5520ec73b6146427ce9f1cf80ec6a95f (patch)
tree6d8b56e510374542ad49e5588c25d95701d7cf02 /yt/cpp/mapreduce/http_client/ut/raw_requests_ut.cpp
parent8f9ae59afa6108d373d287e973a7597c0a89143e (diff)
downloadydb-044fc00c5520ec73b6146427ce9f1cf80ec6a95f.tar.gz
YT-23616: Rename raw_client to http_client
commit_hash:df330f3a0c0ca36d9bcf801fd96b964f1be6383a
Diffstat (limited to 'yt/cpp/mapreduce/http_client/ut/raw_requests_ut.cpp')
-rw-r--r--yt/cpp/mapreduce/http_client/ut/raw_requests_ut.cpp191
1 files changed, 191 insertions, 0 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
new file mode 100644
index 0000000000..59fee2be61
--- /dev/null
+++ b/yt/cpp/mapreduce/http_client/ut/raw_requests_ut.cpp
@@ -0,0 +1,191 @@
+#include <yt/cpp/mapreduce/http_client/raw_requests.h>
+
+#include <library/cpp/yson/node/node_io.h>
+
+#include <library/cpp/testing/gtest/gtest.h>
+
+using namespace NYT;
+using namespace NYT::NDetail;
+using namespace NYT::NDetail::NRawClient;
+
+TEST(TOperationsApiParsingTest, ParseOperationAttributes)
+{
+ auto response = TStringBuf(R"""({
+ "id" = "1-2-3-4";
+ "authenticated_user" = "some-user";
+ "start_time" = "2018-01-01T00:00:00.0Z";
+ "weight" = 1.;
+ "state" = "completed";
+ "suspended" = %false;
+ "finish_time" = "2018-01-02T00:00:00.0Z";
+ "brief_progress" = {
+ "jobs" = {
+ "lost" = 0;
+ "pending" = 0;
+ "failed" = 1;
+ "aborted" = 0;
+ "total" = 84;
+ "running" = 0;
+ "completed" = 84;
+ };
+ };
+ "result" = {
+ "error" = {
+ "attributes" = {};
+ "code" = 0;
+ "message" = "";
+ };
+ };
+ "brief_spec" = {
+ "input_table_paths" = <
+ "count" = 1;
+ > [
+ "//some-input";
+ ];
+ "pool" = "some-pool";
+ "scheduling_info_per_pool_tree" = {
+ "physical" = {
+ "pool" = "some-pool";
+ };
+ };
+ "title" = "some-title";
+ "output_table_paths" = <
+ "count" = 1;
+ > [
+ "//some-output";
+ ];
+ "mapper" = {
+ "command" = "some-command";
+ };
+ };
+ "type" = "map";
+ "pool" = "some-pool";
+ "progress" = {
+ "build_time" = "2018-01-01T00:00:00.000000Z";
+ "job_statistics" = {
+ "data" = {
+ "input" = {
+ "row_count" = {
+ "$" = {
+ "failed" = {
+ "map" = {
+ "max" = 1;
+ "count" = 1;
+ "sum" = 1;
+ "min" = 1;
+ };
+ };
+ "completed" = {
+ "map" = {
+ "max" = 1;
+ "count" = 84;
+ "sum" = 84;
+ "min" = 1;
+ };
+ };
+ };
+ };
+ };
+ };
+ };
+ "total_job_counter" = {
+ "completed" = {
+ "total" = 3;
+ "non-interrupted" = 1;
+ "interrupted" = {
+ "whatever_interrupted" = 2;
+ };
+ };
+ "aborted" = {
+ "non_scheduled" = {
+ "whatever_non_scheduled" = 3;
+ };
+ "scheduled" = {
+ "whatever_scheduled" = 4;
+ };
+ "total" = 7;
+ };
+ "lost" = 5;
+ "invalidated" = 6;
+ "failed" = 7;
+ "running" = 8;
+ "suspended" = 9;
+ "pending" = 10;
+ "blocked" = 11;
+ "total" = 66;
+ };
+ };
+ "events" = [
+ {"state" = "pending"; "time" = "2018-01-01T00:00:00.000000Z";};
+ {"state" = "materializing"; "time" = "2018-01-02T00:00:00.000000Z";};
+ {"state" = "running"; "time" = "2018-01-03T00:00:00.000000Z";};
+ ];
+ })""");
+ auto attrs = ParseOperationAttributes(NodeFromYsonString(response));
+
+ EXPECT_TRUE(attrs.Id);
+ EXPECT_EQ(GetGuidAsString(*attrs.Id), "1-2-3-4");
+
+ EXPECT_TRUE(attrs.Type);
+ EXPECT_EQ(*attrs.Type, EOperationType::Map);
+
+ EXPECT_TRUE(attrs.State);
+ EXPECT_EQ(*attrs.State, "completed");
+
+ EXPECT_TRUE(attrs.BriefState);
+ EXPECT_EQ(*attrs.BriefState, EOperationBriefState::Completed);
+
+ EXPECT_TRUE(attrs.AuthenticatedUser);
+ EXPECT_EQ(*attrs.AuthenticatedUser, "some-user");
+
+ EXPECT_TRUE(attrs.StartTime);
+ EXPECT_TRUE(attrs.FinishTime);
+ 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_TRUE(attrs.BriefSpec);
+ EXPECT_EQ((*attrs.BriefSpec)["title"].AsString(), "some-title");
+
+ EXPECT_TRUE(attrs.Suspended);
+ EXPECT_EQ(*attrs.Suspended, false);
+
+ EXPECT_TRUE(attrs.Result);
+ 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->BuildTime, TInstant::ParseIso8601("2018-01-01T00:00:00.000000Z"));
+
+ EXPECT_TRUE(attrs.Events);
+ EXPECT_EQ((*attrs.Events)[1].State, "materializing");
+ EXPECT_EQ((*attrs.Events)[1].Time, TInstant::ParseIso8601("2018-01-02T00:00:00.000000Z"));
+}
+
+TEST(TOperationsApiParsingTest, EmptyProgress)
+{
+ auto response = TStringBuf(R"""({
+ "id" = "1-2-3-4";
+ "brief_progress" = {};
+ "progress" = {};
+ })""");
+ auto attrs = ParseOperationAttributes(NodeFromYsonString(response));
+
+ EXPECT_TRUE(attrs.Id);
+ EXPECT_EQ(GetGuidAsString(*attrs.Id), "1-2-3-4");
+
+ EXPECT_TRUE(!attrs.BriefProgress);
+
+ EXPECT_TRUE(attrs.Progress);
+ EXPECT_EQ(attrs.Progress->JobStatistics.JobState({}).GetStatisticsNames(), TVector<TString>{});
+ EXPECT_EQ(attrs.Progress->JobCounters.GetTotal(), 0u);
+ EXPECT_TRUE(!attrs.Progress->BuildTime);
+}