18
18
#include " presto_cpp/main/common/tests/test_json.h"
19
19
#include " presto_cpp/main/connectors/PrestoToVeloxConnector.h"
20
20
21
- using namespace facebook ;
22
- using namespace facebook ::presto::protocol;
21
+ using namespace facebook ::presto;
23
22
24
- class TaskInfoTest : public ::testing::Test {};
23
+ class TaskInfoTest : public ::testing::Test {
24
+ protected:
25
+ void SetUp () override {
26
+ registerPrestoToVeloxConnector (
27
+ std::make_unique<facebook::presto::HivePrestoToVeloxConnector>(" hive" ));
28
+ }
29
+
30
+ void TearDown () override {
31
+ unregisterPrestoToVeloxConnector (" hive" );
32
+ }
33
+ };
25
34
26
35
const std::string BASE_DATA_PATH = " /github/presto-trunk/presto-native-execution/presto_cpp/main/tests/data/" ;
27
36
28
37
TEST_F (TaskInfoTest, duration) {
29
38
double thrift = 0 ;
30
- facebook::presto:: thrift::toThrift (Duration (123 , TimeUnit::MILLISECONDS), thrift);
39
+ thrift::toThrift (protocol:: Duration (123 , protocol:: TimeUnit::MILLISECONDS), thrift);
31
40
ASSERT_EQ (thrift, 123 );
32
41
}
33
42
34
43
TEST_F (TaskInfoTest, binaryMetadataUpdates) {
35
44
std::string str = slurp (getDataPath (BASE_DATA_PATH, " MetadataUpdates.json" ));
36
45
json j = json::parse (str);
37
- registerPrestoToVeloxConnector (std::make_unique<facebook::presto::HivePrestoToVeloxConnector>(" hive" ));
38
- MetadataUpdates metadataUpdates = j;
46
+ protocol::MetadataUpdates metadataUpdates = j;
39
47
std::unique_ptr<std::string> thriftMetadataUpdates = std::make_unique<std::string>();
40
- facebook::presto:: thrift::toThrift (metadataUpdates, *thriftMetadataUpdates);
48
+ thrift::toThrift (metadataUpdates, *thriftMetadataUpdates);
41
49
42
50
json thriftJson = json::parse (*thriftMetadataUpdates);
43
51
ASSERT_EQ (j, thriftJson);
44
-
45
- presto::unregisterPrestoToVeloxConnector (" hive" );
46
52
}
47
53
48
54
TEST_F (TaskInfoTest, taskInfo) {
49
55
std::string str = slurp (getDataPath (BASE_DATA_PATH, " TaskInfo.json" ));
50
56
json j = json::parse (str);
51
- registerPrestoToVeloxConnector (std::make_unique<facebook::presto::HivePrestoToVeloxConnector>(" hive" ));
52
- TaskInfo taskInfo = j;
53
- facebook::presto::thrift::TaskInfo thriftTaskInfo;
54
- facebook::presto::thrift::toThrift (taskInfo, thriftTaskInfo);
57
+ protocol::TaskInfo taskInfo = j;
58
+ thrift::TaskInfo thriftTaskInfo;
59
+ thrift::toThrift (taskInfo, thriftTaskInfo);
55
60
56
61
json thriftJson = json::parse (*thriftTaskInfo.metadataUpdates ()->metadataUpdates ());
57
62
ASSERT_EQ (taskInfo.metadataUpdates , thriftJson);
58
63
ASSERT_EQ (thriftTaskInfo.needsPlan (), false );
59
64
ASSERT_EQ (thriftTaskInfo.outputBuffers ()->buffers ()->size (), 2 );
60
65
ASSERT_EQ (thriftTaskInfo.outputBuffers ()->buffers ()[0 ].bufferId ()->id (), 100 );
61
66
ASSERT_EQ (thriftTaskInfo.outputBuffers ()->buffers ()[1 ].bufferId ()->id (), 200 );
62
- ASSERT_EQ (thriftTaskInfo.stats ()->blockedReasons ()->count (facebook::presto:: thrift::BlockedReason::WAITING_FOR_MEMORY), 1 );
67
+ ASSERT_EQ (thriftTaskInfo.stats ()->blockedReasons ()->count (thrift::BlockedReason::WAITING_FOR_MEMORY), 1 );
63
68
ASSERT_EQ (thriftTaskInfo.stats ()->runtimeStats ()->metrics ()->size (), 2 );
64
69
ASSERT_EQ (thriftTaskInfo.stats ()->runtimeStats ()->metrics ()[" test_metric1" ].sum (), 123 );
65
70
ASSERT_EQ (thriftTaskInfo.stats ()->runtimeStats ()->metrics ()[" test_metric2" ].name (), " test_metric2" );
66
-
67
- presto::unregisterPrestoToVeloxConnector (" hive" );
68
71
}
69
72
70
73
TEST_F (TaskInfoTest, taskId) {
71
- TaskId taskId = " queryId.1.2.3.4" ;
72
- facebook::presto:: thrift::TaskId thriftTaskId;
73
- facebook::presto:: thrift::toThrift (taskId, thriftTaskId);
74
+ protocol:: TaskId taskId = " queryId.1.2.3.4" ;
75
+ thrift::TaskId thriftTaskId;
76
+ thrift::toThrift (taskId, thriftTaskId);
74
77
75
78
ASSERT_EQ (thriftTaskId.stageExecutionId ()->stageId ()->queryId (), " queryId" );
76
79
ASSERT_EQ (thriftTaskId.stageExecutionId ()->stageId ()->id (), 1 );
@@ -83,9 +86,9 @@ TEST_F(TaskInfoTest, taskId) {
83
86
TEST_F (TaskInfoTest, operatorStatsEmptyBlockedReason) {
84
87
std::string str = slurp (getDataPath (BASE_DATA_PATH, " OperatorStatsEmptyBlockedReason.json" ));
85
88
json j = json::parse (str);
86
- OperatorStats operatorStats = j;
87
- facebook::presto:: thrift::OperatorStats thriftOperatorStats;
88
- facebook::presto:: thrift::toThrift (operatorStats, thriftOperatorStats);
89
+ protocol:: OperatorStats operatorStats = j;
90
+ thrift::OperatorStats thriftOperatorStats;
91
+ thrift::toThrift (operatorStats, thriftOperatorStats);
89
92
90
93
ASSERT_EQ (thriftOperatorStats.blockedReason ().has_value (), false );
91
94
ASSERT_EQ (thriftOperatorStats.blockedWall (), 80 );
@@ -95,9 +98,9 @@ TEST_F(TaskInfoTest, operatorStatsEmptyBlockedReason) {
95
98
TEST_F (TaskInfoTest, operatorStats) {
96
99
std::string str = slurp (getDataPath (BASE_DATA_PATH, " OperatorStats.json" ));
97
100
json j = json::parse (str);
98
- OperatorStats operatorStats = j;
99
- facebook::presto:: thrift::OperatorStats thriftOperatorStats;
100
- facebook::presto:: thrift::toThrift (operatorStats, thriftOperatorStats);
101
+ protocol:: OperatorStats operatorStats = j;
102
+ thrift::OperatorStats thriftOperatorStats;
103
+ thrift::toThrift (operatorStats, thriftOperatorStats);
101
104
102
- ASSERT_EQ (thriftOperatorStats.blockedReason (), facebook::presto:: thrift::BlockedReason::WAITING_FOR_MEMORY);
105
+ ASSERT_EQ (thriftOperatorStats.blockedReason (), thrift::BlockedReason::WAITING_FOR_MEMORY);
103
106
}
0 commit comments