MCPcopy Create free account
hub / github.com/apache/impala / assertQueryState

Function assertQueryState

be/src/service/internal-server-test.cc:76–113  ·  view source on GitHub ↗

Retrieves the json representation of the coordinator's queries and asserts the state of the specified query matches the provided expected state.

Source from the content-addressed store, hash-verified

74// Retrieves the json representation of the coordinator's queries and asserts the state
75// of the specified query matches the provided expected state.
76void assertQueryState(const TUniqueId& query_id, const string& expected_state) {
77 // Give the Impala web server a second to refresh its completed queries list.
78 SleepForMs(1000);
79
80 // Retrieve the list of queries from the test's coordinator. Results contain the raw
81 // http response including headers.
82 Document queries;
83 stringstream contents;
84 ASSERT_OK(HttpGet("localhost", FLAGS_webserver_port, "/queries?json", &contents));
85 string contents_str = contents.str();
86
87 // Locate the start of the response body.
88 size_t header_end = contents_str.find("\r\n\r\n", 0);
89 ASSERT_NE(string::npos, header_end);
90
91 // Parse the json queries response.
92 ASSERT_FALSE(queries.Parse(contents_str.substr(header_end+2,
93 contents_str.length()).c_str()).HasParseError());
94 ASSERT_TRUE(queries.IsObject());
95
96 // Locate the completed query matching the provided query_id.
97 const Value& completed_queries = queries["completed_queries"];
98 const string query_id_str = PrintId(query_id);
99 string found_state;
100 ASSERT_TRUE(completed_queries.IsArray());
101 for (SizeType i=0; i<completed_queries.Size(); i++) {
102 const Value& query = completed_queries[i];
103 ASSERT_TRUE(query.IsObject());
104 if (query_id_str == query["query_id"].GetString()) {
105 found_state = query["state"].GetString();
106 break;
107 }
108 }
109
110 // Assert the completed query has the expected state. If expected_state is empty, then
111 // the query was not found.
112 ASSERT_EQ(expected_state, found_state);
113} // assertQueryState
114
115// Helper class to set up a uniquely named database. Not every test will need its own
116// database, thus an instance of this class must be instantiated in every test that needs

Callers 3

DatabaseTestMethod · 0.85
TESTFunction · 0.85
runTestQueriesFunction · 0.85

Calls 9

HttpGetFunction · 0.85
PrintIdFunction · 0.85
substrMethod · 0.80
strMethod · 0.45
findMethod · 0.45
ParseMethod · 0.45
lengthMethod · 0.45
SizeMethod · 0.45
GetStringMethod · 0.45

Tested by

no test coverage detected