mirror of
https://github.com/apache/impala.git
synced 2025-12-19 18:12:08 -05:00
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>
94 lines
4.0 KiB
Python
94 lines
4.0 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
|
|
import time
|
|
|
|
from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
|
|
from tests.common.skip import SkipIfNotHdfsMinicluster
|
|
from subprocess import check_call
|
|
from tests.util.filesystem_utils import IS_OZONE
|
|
from tests.util.shell_util import exec_process
|
|
|
|
|
|
@SkipIfNotHdfsMinicluster.tuned_for_minicluster
|
|
class TestHdfsTimeouts(CustomClusterTestSuite):
|
|
"""Test to verify that HDFS operations time out correctly."""
|
|
|
|
@pytest.mark.execute_serially
|
|
@CustomClusterTestSuite.with_args(
|
|
impalad_args="--hdfs_operation_timeout_sec=5 --max_cached_file_handles=0")
|
|
def test_hdfs_open_timeout(self, vector):
|
|
"""This verifies that hdfsOpenFile times out appropriately. It tests this by
|
|
halting the NameNode, running a query that needs to do hdfsOpenFile,
|
|
and verifying that it times out and throws an error."""
|
|
|
|
# Find the NameNode's pid via pgrep. This would raise an error if it did not
|
|
# find a pid, so there is at least one match.
|
|
data_api_name = 'OzoneManager' if IS_OZONE else 'namenode.NameNode'
|
|
rc, pgrep_output, stderr = exec_process("pgrep -f {}".format(data_api_name))
|
|
assert rc == 0, \
|
|
"Error finding NameNode pid\nstdout={0}\nstderr={1}".format(pgrep_output, stderr)
|
|
# In our test environment, this should only match one pid
|
|
assert(pgrep_output.count("\n") == 1)
|
|
namenode_pid = pgrep_output.strip()
|
|
|
|
# Run a query successfully. This fetches metadata from the NameNode,
|
|
# and since this will be cached, a subsequent run will not ask the NameNode
|
|
# for metadata. This means a subsequent execution will only talk to the NameNode
|
|
# for file open.
|
|
self.execute_query_expect_success(self.client,
|
|
"select count(*) from functional.alltypes", vector=vector)
|
|
|
|
# Stop the NameNode and execute the query again. Since the file handle cache is off,
|
|
# the query will do hdfsOpenFile calls and talk to the NameNode. Since the NameNode
|
|
# is stopped, those calls will hang, testing the timeout functionality.
|
|
ex = None
|
|
result = None
|
|
try:
|
|
# Stop the NameNode
|
|
check_call(["kill", "-STOP", namenode_pid])
|
|
start_time = time.time()
|
|
result = self.execute_query("select count(*) from functional.alltypes",
|
|
vector=vector)
|
|
end_time = time.time()
|
|
except Exception as e:
|
|
ex = e
|
|
finally:
|
|
end_time = time.time()
|
|
# Always resume the NameNode
|
|
check_call(["kill", "-CONT", namenode_pid])
|
|
|
|
# The query should have failed, which raises an exception
|
|
if ex is None:
|
|
assert False, "Query should have failed, but instead returned {0}".format(result)
|
|
|
|
# The exception should contain the appropriate error message
|
|
error_pattern = "hdfsOpenFile\(\) for.*at backend.*"
|
|
"failed to finish before the 5 second timeout"
|
|
assert len(re.findall(error_pattern, str(ex))) > 0
|
|
|
|
# The timeout is 5 seconds and seems to be enforced within about 20 seconds, so it
|
|
# would be unusual if this query does not finish in 60 seconds.
|
|
assert (end_time - start_time) < 60.0
|
|
|
|
# Execute the query a final time to verify that the system recovers.
|
|
self.execute_query_expect_success(self.client,
|
|
"select count(*) from functional.alltypes", vector=vector)
|