Files
impala/tests/query_test/test_rows_availability.py
Csaba Ringhofer f98b697c7b IMPALA-13929: Make 'functional-query' the default workload in tests
This change adds get_workload() to ImpalaTestSuite and removes it
from all test suites that already returned 'functional-query'.
get_workload() is also removed from CustomClusterTestSuite which
used to return 'tpch'.

All other changes besides impala_test_suite.py and
custom_cluster_test_suite.py are just mass removals of
get_workload() functions.

The behavior is only changed in custom cluster tests that didn't
override get_workload(). By returning 'functional-query' instead
of 'tpch', exploration_strategy() will no longer return 'core' in
'exhaustive' test runs. See IMPALA-3947 on why workload affected
exploration_strategy. An example for affected test is
TestCatalogHMSFailures which was skipped both in core and exhaustive
runs before this change.

get_workload() functions that return a different workload than
'functional-query' are not changed - it is possible that some of
these also don't handle exploration_strategy() as expected, but
individually checking these tests is out of scope in this patch.

Change-Id: I9ec6c41ffb3a30e1ea2de773626d1485c69fe115
Reviewed-on: http://gerrit.cloudera.org:8080/22726
Reviewed-by: Riza Suminto <riza.suminto@cloudera.com>
Reviewed-by: Daniel Becker <daniel.becker@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
2025-04-08 07:12:55 +00:00

104 lines
5.1 KiB
Python

# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from __future__ import absolute_import, division, print_function
import pytest
import re
from tests.common.impala_test_suite import ImpalaTestSuite
from tests.common.test_vector import ImpalaTestDimension
from tests.common.impala_connection import FINISHED
from tests.util.parse_util import parse_duration_string_ms
class TestRowsAvailability(ImpalaTestSuite):
"""Tests that the 'Rows available' timeline event is marked only after rows are
truly available. We mark the 'Rows available' event once we advance the query
status to a 'ready' state; this signals to the client that rows can be fetched.
Long fetch times can trigger client timeouts at various levels (socket, app, etc.).
This is a regression test against IMPALA-924."""
# These queries are chosen to have different plan roots in the coordinator's fragment.
# The WHERE clause is carefully crafted to control when result rows become available at
# the coordinator. The selected partition of 'functional.alltypestiny' has exactly
# two rows stored in a single file. In the scan node we sleep one second for each
# result row. Therefore, result rows can become available no earlier that after 2s.
TABLE = 'functional.alltypestiny'
WHERE_CLAUSE = 'where month = 1 and bool_col = sleep(1000)'
QUERIES = ['select * from %s %s' % (TABLE, WHERE_CLAUSE),
'select * from %s %s order by id limit 1' % (TABLE, WHERE_CLAUSE),
'select * from %s %s order by id' % (TABLE, WHERE_CLAUSE),
'select count(*) from %s %s' % (TABLE, WHERE_CLAUSE),
'select 1 union all select count(*) from %s %s' % (TABLE, WHERE_CLAUSE),
'select count(*) over () from %s %s' % (TABLE, WHERE_CLAUSE)]
ROWS_AVAIL_LOWER_BOUND_MS = 2000
@classmethod
def add_test_dimensions(cls):
super(TestRowsAvailability, cls).add_test_dimensions()
cls.ImpalaTestMatrix.add_dimension(ImpalaTestDimension('query', *cls.QUERIES))
cls.ImpalaTestMatrix.add_constraint(lambda v: cls.__is_valid_test_vector(v))
@classmethod
def __is_valid_test_vector(cls, vector):
return vector.get_value('table_format').file_format == 'text' and\
vector.get_value('table_format').compression_codec == 'none' and\
vector.get_value('exec_option')['batch_size'] == 0 and\
vector.get_value('exec_option')['disable_codegen'] is False and\
vector.get_value('exec_option')['num_nodes'] == 0
@pytest.mark.execute_serially
def test_rows_availability(self, vector):
# This test is run serially because it requires the query to come back within
# some amount of time. Running this with other tests makes it hard to bound
# that time.
query = vector.get_value('query')
# Execute async to get a handle. Wait until the query has completed.
handle = self.execute_query_async(query, vector.get_value('exec_option'))
self.client.wait_for_impala_state(handle, FINISHED, 20)
profile = self.client.get_runtime_profile(handle)
start_time_ms = None
rows_avail_time_ms = None
for line in profile.split("\n"):
if "Ready to start on" in line:
start_time_ms = parse_duration_string_ms(self.__find_time(line))
elif "Rows available:" in line:
rows_avail_time_ms = parse_duration_string_ms(self.__find_time(line))
if start_time_ms is None:
assert False, "Failed to find the 'Ready to start' timeline event in the " \
"query profile:\n%s" % profile
if rows_avail_time_ms is None:
assert False, "Failed to find the 'Rows available' timeline event in the " \
"query profile:\n%s" % profile
time_diff = rows_avail_time_ms - start_time_ms
assert time_diff >= self.ROWS_AVAIL_LOWER_BOUND_MS,\
"The 'Rows available' timeline event was marked prematurely %sms after the "\
"'Ready to start' event.\nExpected the event to be marked no earlier than "\
"%sms after the 'Ready to start' event.\nQuery: %s"\
% (time_diff, self.ROWS_AVAIL_LOWER_BOUND_MS, query)
self.close_query(handle)
@staticmethod
def __find_time(line):
"""Find event time point in a line from the runtime profile timeline."""
# Given line "- Rows available: 3s311ms (2s300ms)", this function returns "3s311ms"
match = re.search(r': (.*) \(', line)
if match is None:
assert False, "Failed to find time in runtime profile"
return match.group(1)