mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-17 20:02:05 +00:00
Adjust integration test to exception messages
This commit is contained in:
parent
57b5c0e1e5
commit
55d12a497c
@ -76,13 +76,13 @@ def _check_exception(exception, expected_tries=3):
|
||||
|
||||
for i, line in enumerate(lines[3:3 + expected_tries]):
|
||||
expected_lines = (
|
||||
'Code: 209, ' + EXCEPTION_NETWORK + EXCEPTION_TIMEOUT,
|
||||
'Code: 209, ' + EXCEPTION_NETWORK + EXCEPTION_CONNECT,
|
||||
'Code: 209. ' + EXCEPTION_NETWORK + EXCEPTION_TIMEOUT,
|
||||
'Code: 209. ' + EXCEPTION_NETWORK + EXCEPTION_CONNECT,
|
||||
EXCEPTION_TIMEOUT,
|
||||
)
|
||||
|
||||
assert any(line.startswith(expected) for expected in expected_lines), \
|
||||
'Unexpected exception at one of the connection attempts'
|
||||
'Unexpected exception "{}" at one of the connection attempts'.format(line)
|
||||
|
||||
assert lines[3 + expected_tries] == '', 'Wrong number of connect attempts'
|
||||
|
||||
|
@ -95,8 +95,11 @@ def test_mysql_client(started_cluster):
|
||||
'''.format(host=started_cluster.get_instance_ip('node'), port=server_port), demux=True)
|
||||
|
||||
assert stdout.decode() == 'count()\n1\n'
|
||||
assert stderr[0:182].decode() == "mysql: [Warning] Using a password on the command line interface can be insecure.\n" \
|
||||
"ERROR 81 (00000) at line 1: Code: 81, e.displayText() = DB::Exception: Database system2 doesn't exist"
|
||||
expected_msg = '\n'.join([
|
||||
"mysql: [Warning] Using a password on the command line interface can be insecure.",
|
||||
"ERROR 81 (00000) at line 1: Code: 81. DB::Exception: Database system2 doesn't exist",
|
||||
])
|
||||
assert stderr[:len(expected_msg)].decode() == expected_msg
|
||||
|
||||
code, (stdout, stderr) = started_cluster.mysql_client_container.exec_run('''
|
||||
mysql --protocol tcp -h {host} -P {port} default -u default --password=123
|
||||
@ -122,8 +125,11 @@ def test_mysql_client_exception(started_cluster):
|
||||
-e "CREATE TABLE default.t1_remote_mysql AS mysql('127.0.0.1:10086','default','t1_local','default','');"
|
||||
'''.format(host=started_cluster.get_instance_ip('node'), port=server_port), demux=True)
|
||||
|
||||
assert stderr[0:258].decode() == "mysql: [Warning] Using a password on the command line interface can be insecure.\n" \
|
||||
"ERROR 1000 (00000) at line 1: Poco::Exception. Code: 1000, e.code() = 0, e.displayText() = Exception: Connections to all replicas failed: default@127.0.0.1:10086 as user default"
|
||||
expected_msg = '\n'.join([
|
||||
"mysql: [Warning] Using a password on the command line interface can be insecure.",
|
||||
"ERROR 1000 (00000) at line 1: Poco::Exception. Code: 1000, e.code() = 0, Exception: Connections to all replicas failed: default@127.0.0.1:10086 as user default",
|
||||
])
|
||||
assert stderr[:len(expected_msg)].decode() == expected_msg
|
||||
|
||||
|
||||
def test_mysql_affected_rows(started_cluster):
|
||||
@ -328,8 +334,7 @@ def test_python_client(started_cluster):
|
||||
with pytest.raises(pymysql.InternalError) as exc_info:
|
||||
client.query('select name from tables')
|
||||
|
||||
assert exc_info.value.args[1][
|
||||
0:77] == "Code: 60, e.displayText() = DB::Exception: Table default.tables doesn't exist"
|
||||
assert exc_info.value.args[1].startswith("Code: 60. DB::Exception: Table default.tables doesn't exist"), exc_info.value.args[1]
|
||||
|
||||
cursor = client.cursor(pymysql.cursors.DictCursor)
|
||||
cursor.execute("select 1 as a, 'тест' as b")
|
||||
@ -348,8 +353,7 @@ def test_python_client(started_cluster):
|
||||
with pytest.raises(pymysql.InternalError) as exc_info:
|
||||
client.query('select name from tables')
|
||||
|
||||
assert exc_info.value.args[1][
|
||||
0:77] == "Code: 60, e.displayText() = DB::Exception: Table default.tables doesn't exist"
|
||||
assert exc_info.value.args[1].startswith("Code: 60. DB::Exception: Table default.tables doesn't exist"), exc_info.value.args[1]
|
||||
|
||||
cursor = client.cursor(pymysql.cursors.DictCursor)
|
||||
cursor.execute("select 1 as a, 'тест' as b")
|
||||
@ -360,7 +364,7 @@ def test_python_client(started_cluster):
|
||||
with pytest.raises(pymysql.InternalError) as exc_info:
|
||||
client.select_db('system2')
|
||||
|
||||
assert exc_info.value.args[1][0:73] == "Code: 81, e.displayText() = DB::Exception: Database system2 doesn't exist"
|
||||
assert exc_info.value.args[1].startswith("Code: 81. DB::Exception: Database system2 doesn't exist"), exc_info.value.args[1]
|
||||
|
||||
cursor = client.cursor(pymysql.cursors.DictCursor)
|
||||
cursor.execute('CREATE DATABASE x')
|
||||
|
Loading…
Reference in New Issue
Block a user