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

Method test_catalog_operation_fields

tests/webserver/test_web_pages.py:1148–1204  ·  view source on GitHub ↗

Verify the CREATE_DATABASE operation is consistent with the statement shown in the /queries page of impalad.

(self, unique_database)

Source from the content-addressed store, hash-verified

1146 assert page.status_code == requests.codes.ok
1147
1148 def test_catalog_operation_fields(self, unique_database):
1149 """Verify the CREATE_DATABASE operation is consistent with the statement shown in the
1150 /queries page of impalad."""
1151 catalog_operations_page = requests.get("http://localhost:25020/operations?json").text
1152 catalog_operations = json.loads(catalog_operations_page)
1153 assert "finished_catalog_operations" in catalog_operations
1154
1155 queries_page = requests.get("http://localhost:25000/queries?json").text
1156 queries = json.loads(queries_page)
1157 assert "completed_queries" in queries
1158
1159 # Find the CREATE_DATABASE operation in catalogd
1160 ts_format = "%Y-%m-%d %H:%M:%S.%f"
1161 found = False
1162 for op in catalog_operations["finished_catalog_operations"]:
1163 if op["target_name"] == unique_database \
1164 and op["catalog_op_name"] == "CREATE_DATABASE":
1165 catalog_op_query_id = op["query_id"]
1166 catalog_op_user = op["user"]
1167 catalog_op_start_time = datetime.strptime(op["start_time"], ts_format)
1168 catalog_op_end_time = datetime.strptime(op["finish_time"], ts_format)
1169 catalog_op_duration = parse_duration_string_ms(op["duration"])
1170 found = True
1171 LOG.info("Found query id in catalog operations: " + catalog_op_query_id)
1172 break
1173 assert found
1174
1175 def verify_query_record(query):
1176 assert "CREATE DATABASE" in query["stmt"]
1177 assert unique_database in query["stmt"]
1178 assert catalog_op_user == query["effective_user"]
1179 assert datetime.strptime(query["start_time"], ts_format) <= catalog_op_start_time
1180 assert datetime.strptime(query["end_time"], ts_format) >= catalog_op_end_time
1181 assert parse_duration_string_ms(query["duration"]) >= catalog_op_duration
1182
1183 # Find the query in impalad
1184 matched = False
1185 for query in queries["completed_queries"]:
1186 if query["query_id"] == catalog_op_query_id:
1187 verify_query_record(query)
1188 matched = True
1189 if not matched:
1190 LOG.info("Query id {0} not found in the completed queries list".format(
1191 catalog_op_query_id))
1192 # Try to find the query in the in-flight queries list. It could be waiting to
1193 # be closed.
1194 for query in queries["in_flight_queries"]:
1195 if query["query_id"] == catalog_op_query_id:
1196 verify_query_record(query)
1197 matched = True
1198
1199 # Dump web pages for debug
1200 if not matched:
1201 LOG.info("Query id {0} not found in queries page!".format(catalog_op_query_id))
1202 LOG.info("Catalog operations: " + catalog_operations_page)
1203 LOG.info("Queries: " + queries_page)
1204 assert matched
1205

Callers

nothing calls this directly

Calls 3

parse_duration_string_msFunction · 0.90
getMethod · 0.65
formatMethod · 0.45

Tested by

no test coverage detected