Files
impala/tests/authorization/test_provider.py
Riza Suminto 9c87cf41bf IMPALA-13396: Unify tmp dir management in CustomClusterTestSuite
There are many custom cluster tests that require creating temporary
directory. The temporary directory typically live within a scope of test
method and cleaned afterwards. However, some test do create temporary
directory directly and forgot to clean them afterwards, leaving junk
dirs under /tmp/ or $LOG_DIR.

This patch unify the temporary directory management inside
CustomClusterTestSuite. It introduce new 'tmp_dir_placeholders' arg in
CustomClusterTestSuite.with_args() that list tmp dirs to create.
'impalad_args', 'catalogd_args', and 'impala_log_dir' now accept
formatting pattern that is replaceable by a temporary dir path, defined
through 'tmp_dir_placeholders'.

There are few occurrences where mkdtemp is called and not replaceable by
this work, such as tests/comparison/cluster.py. In that case, this patch
change them to supply prefix arg so that developer knows that it comes
from Impala test script.

This patch also addressed several flake8 errors in modified files.

Testing:
- Pass custom cluster tests in exhaustive mode.
- Manually run few modified tests and observe that the temporary dirs
  are created and removed under logs/custom_cluster_tests/ as the tests
  go.

Change-Id: I8dd665e8028b3f03e5e33d572c5e188f85c3bdf5
Reviewed-on: http://gerrit.cloudera.org:8080/21836
Reviewed-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
2024-10-02 01:25:39 +00:00

63 lines
2.4 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.
#
# Client tests for SQL statement authorization
from __future__ import absolute_import, division, print_function
import pytest
from tests.common.file_utils import assert_file_in_dir_contains
from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
class TestAuthorizationProvider(CustomClusterTestSuite):
"""
Tests for failed authorization_provider flag.
All test cases in this testsuite
are expected to fail cluster startup and will swallow exceptions thrown during
setup_method().
"""
BAD_FLAG = "foobar"
LOG_DIR = "invalid_provider_flag"
MINIDUMP_PATH = "invalid_provider_flag_minidump"
pre_test_cores = None
@pytest.mark.execute_serially
@CustomClusterTestSuite.with_args(
expect_cores=True,
impala_log_dir="{" + LOG_DIR + "}",
impalad_args="--minidump_path={" + MINIDUMP_PATH + "} "
"--server-name=server1 "
"--ranger_service_type=hive "
"--ranger_app_id=impala "
"--authorization_provider=" + BAD_FLAG,
catalogd_args="--minidump_path={" + MINIDUMP_PATH + "} "
"--server-name=server1 "
"--ranger_service_type=hive "
"--ranger_app_id=impala "
"--authorization_provider=" + BAD_FLAG,
tmp_dir_placeholders=[LOG_DIR, MINIDUMP_PATH])
def test_invalid_provider_flag(self):
# parse log file for expected exception
assert_file_in_dir_contains(self.get_tmp_dir(self.LOG_DIR),
"InternalException: Could not parse "
"authorization_provider flag: {0}"
.format(self.BAD_FLAG))