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

Method test_query_end_time

tests/query_test/test_observability.py:980–1013  ·  view source on GitHub ↗

Test that verifies that the end time of a query with a coordinator is set once the coordinator releases its admission control resources. This ensures that the duration of the query will be determined by the time taken to do real work rather than the duration for which the query remains

(self)

Source from the content-addressed store, hash-verified

978
979 @pytest.mark.execute_serially
980 def test_query_end_time(self):
981 """ Test that verifies that the end time of a query with a coordinator is set once
982 the coordinator releases its admission control resources. This ensures that the
983 duration of the query will be determined by the time taken to do real work rather
984 than the duration for which the query remains open. On the other hand, for queries
985 without coordinators, the End Time is set only when UnregisterQuery() is called."""
986 # Test the end time of a query with a coordinator.
987 query = "select 1"
988 handle = self.hs2_client.execute_async(query)
989 result = self.hs2_client.fetch(query, handle)
990 # Ensure that the query returns a non-empty result set.
991 assert result is not None
992 # Once the results have been fetched, the query End Time must be set.
993 tree = self.hs2_client.get_runtime_profile(handle, TRuntimeProfileFormat.THRIFT)
994 end_time = tree.nodes[1].info_strings["End Time"]
995 assert end_time
996 self.hs2_client.close_query(handle)
997
998 # Test the end time of a query without a coordinator.
999 query = "describe functional.alltypes"
1000 handle = self.hs2_client.execute_async(query)
1001 result = self.hs2_client.fetch(query, handle)
1002 # Ensure that the query returns a non-empty result set.
1003 assert result
1004 # The query End Time must not be set until the query is unregisterted
1005 tree = self.hs2_client.get_runtime_profile(handle, TRuntimeProfileFormat.THRIFT)
1006 end_time = tree.nodes[1].info_strings["End Time"]
1007 assert len(end_time) == 0, end_time
1008 # Save the last operation to be able to retrieve the profile after closing the query
1009 last_op = handle.get_handle()._last_operation
1010 self.hs2_client.close_query(handle)
1011 tree = last_op.get_profile(TRuntimeProfileFormat.THRIFT)
1012 end_time = tree.nodes[1].info_strings["End Time"]
1013 assert end_time is not None
1014
1015 def test_dml_end_time(self, unique_database):
1016 """Same as the above test but verifies the end time of DML is set only after the work

Callers

nothing calls this directly

Calls 5

get_handleMethod · 0.80
execute_asyncMethod · 0.45
fetchMethod · 0.45
get_runtime_profileMethod · 0.45
close_queryMethod · 0.45

Tested by

no test coverage detected