Files
impala/tests/unittests/test_command.py
Riza Suminto c08aff420d IMPALA-13672: Migrate query_test/test_kudu.py to use hs2 protocol
This patch migrate query_test/test_kudu.py to use hs2 client protocol.
Here are the steps taken:

- Override default_test_protocol() to return 'hs2'.
  See documentation in ImpalaTestSuite about what this method does.
- Remove usage of deprecated cursor and unique_cursor fixture.
- Replace all direct ImpalaTestSuite.client usage with helper
  function call such as execute_query() or execute_query_using_vector().
- Remove all "SET" query invocation and replace it with passing
  exec_option dictionary to helper method.
- Replace veryfing kudu modified / inserted rows from reading query
  output to reading runtime profile counters.
- Add HS2_TYPES section at test cases where only TYPES exist.
- Remove all drop_impala_table_after_context() calls and replace it with
  proper use of unique_database fixture.

KuduTestSuite is fixed with hs2 protocol dimension. Meanwhile,
CustomKuduTest is fixed to use beeswax protocol dimension until proper
migration can be done.

Added following convenience methods:
- ImpalaTestSuite.default_test_protocol() to allow individual test
  class to override its default test procol.
- ImpylaHS2ResultSet.tuples() to access the raw HS2 result set that is
  a list of tuples.

This patch also added several literal constants around test vector
dimension to help with traceability.

Fixed a bug where "SHOW PARTITIONS" via hs2 over kudu table will shows
NULL number of #Replicas because TResultRowBuilder does not have
overload for int type value. Adjust numFiles variable inside
HdfsTable.getTableStats() from int to long to match Type.BIGINT of
column '#Files'.

Fixed py.test classes that does not inherit BaseTestSuite. Fixed flake8
issues in test_statestore.py.

Testing:
- Run and pass all tests extended from KuduTestSuite in exhaustive mode.

Change-Id: I5f38baf5a0bbde1a1ad0bb4666c300f4f3cabd33
Reviewed-on: http://gerrit.cloudera.org:8080/22358
Reviewed-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
2025-02-07 11:57:59 +00:00

50 lines
1.9 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.
#
# Unit tests for collect_diagnostics.Command
from __future__ import absolute_import, division, print_function
import os
import sys
from tests.common.base_test_suite import BaseTestSuite
# Update the sys.path to include the modules from bin/diagnostics.
sys.path.insert(0,
os.path.abspath(os.path.join(os.path.dirname(__file__), '../../bin/diagnostics')))
from collect_diagnostics import Command
class TestCommand(BaseTestSuite):
""" Unit tests for the Command class"""
def test_simple_commands(self):
# Successful command
c = Command(["echo", "foo"], 1000)
assert c.run() == 0, "Command expected to succeed, but failed"
assert c.stdout.strip("\n") == "foo"
# Failed command, check return code
c = Command(["false"], 1000)
assert c.run() == 1
def test_command_timer(self):
# Try to run a command that sleeps for 1000s and set a
# timer for 1 second. The command should timed out.
c = Command(["sleep", "1000"], 1)
assert c.run() != 0, "Command expected to timeout but succeeded."
assert c.child_killed_by_timeout, "Command didn't timeout as expected."