mirror of
https://github.com/apache/impala.git
synced 2025-12-19 18:12:08 -05:00
IMPALA-13959: (addendum) Let test pass regardless of JDK version.
This patch modify test_change_parquet_column_type to let it pass regardless of the test JDK version. The assertion is changed from using string match to regex. Testing: Run and pass the test with both JDK8 and JDK17. Change-Id: I5bd3eebe7b1e52712033dda488f0c19882207f9d Reviewed-on: http://gerrit.cloudera.org:8080/22874 Reviewed-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com> Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
This commit is contained in:
committed by
Impala Public Jenkins
parent
be16a02fa8
commit
a3146ca722
@@ -25,9 +25,9 @@
|
|||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
from builtins import range
|
from builtins import range
|
||||||
import os
|
|
||||||
import pytest
|
import pytest
|
||||||
import random
|
import random
|
||||||
|
import re
|
||||||
import string
|
import string
|
||||||
|
|
||||||
from tests.common.environ import HIVE_MAJOR_VERSION
|
from tests.common.environ import HIVE_MAJOR_VERSION
|
||||||
@@ -282,7 +282,7 @@ class TestHmsIntegration(ImpalaTestSuite):
|
|||||||
return ''.join([random.choice(string.ascii_lowercase)
|
return ''.join([random.choice(string.ascii_lowercase)
|
||||||
for i in range(0, 16)])
|
for i in range(0, 16)])
|
||||||
|
|
||||||
def assert_sql_error(self, engine, command, *strs_in_error):
|
def assert_sql_error(self, engine, command, str_re_in_error):
|
||||||
"""
|
"""
|
||||||
Passes 'command' to 'engine' callable (e.g. execute method of a BeeswaxConnection
|
Passes 'command' to 'engine' callable (e.g. execute method of a BeeswaxConnection
|
||||||
object) and makes sure that it raises an exception.
|
object) and makes sure that it raises an exception.
|
||||||
@@ -296,11 +296,12 @@ class TestHmsIntegration(ImpalaTestSuite):
|
|||||||
try:
|
try:
|
||||||
engine(command)
|
engine(command)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
for str_in_error in strs_in_error:
|
str_e = str(e)
|
||||||
assert str_in_error in str(e)
|
assert re.search(str_re_in_error, str_e), "{} not found in {}".format(
|
||||||
|
str_re_in_error, str_e)
|
||||||
else:
|
else:
|
||||||
assert False, '%s should have triggered an error containing %s' % (
|
assert False, '%s should have triggered an error containing %s' % (
|
||||||
command, strs_in_error)
|
command, str_re_in_error)
|
||||||
|
|
||||||
@pytest.mark.execute_serially
|
@pytest.mark.execute_serially
|
||||||
def test_hive_db_hive_table_add_partition(self):
|
def test_hive_db_hive_table_add_partition(self):
|
||||||
@@ -784,14 +785,12 @@ class TestHmsIntegration(ImpalaTestSuite):
|
|||||||
# Modify HMS table metadata again, change the type of column 'y' back to INT.
|
# Modify HMS table metadata again, change the type of column 'y' back to INT.
|
||||||
self.run_stmt_in_hive('alter table %s change y y int' % table_name)
|
self.run_stmt_in_hive('alter table %s change y y int' % table_name)
|
||||||
# Neither Hive 2 and 3, nor Impala converts STRINGs to INTs implicitly.
|
# Neither Hive 2 and 3, nor Impala converts STRINGs to INTs implicitly.
|
||||||
err_msg = ("{0}org.apache.hadoop.io.Text cannot be "
|
|
||||||
"cast to {0}org.apache.hadoop.io.IntWritable")
|
|
||||||
# The error message is different in newer Javas than in 17
|
# The error message is different in newer Javas than in 17
|
||||||
# TODO: find out which version changed it exactly
|
# TODO: find out which version changed it exactly
|
||||||
err_msg = err_msg.format(
|
err_msgs = (r".*org.apache.hadoop.io.Text cannot be cast to "
|
||||||
"class " if int(os.environ.get('IMPALA_JDK_VERSION_NUM')) >= 17 else "")
|
r".*org.apache.hadoop.io.IntWritable")
|
||||||
self.assert_sql_error(
|
self.assert_sql_error(
|
||||||
self.run_stmt_in_hive, 'select * from %s' % table_name, err_msg)
|
self.run_stmt_in_hive, 'select * from %s' % table_name, err_msgs)
|
||||||
self.client.execute('invalidate metadata %s' % table_name)
|
self.client.execute('invalidate metadata %s' % table_name)
|
||||||
self.assert_sql_error(
|
self.assert_sql_error(
|
||||||
self.client.execute, 'select * from %s' % table_name,
|
self.client.execute, 'select * from %s' % table_name,
|
||||||
|
|||||||
Reference in New Issue
Block a user