Adjust test_mysql_protocol and others for analyzer

This commit is contained in:
vdimir 2023-03-13 13:59:00 +00:00 committed by Vladimir C
parent ebd71f226c
commit c2f0583dc6
3 changed files with 26 additions and 20 deletions

View File

@ -1,6 +1,7 @@
# coding: utf-8
import datetime
import fnmatch
import math
import os
import time
@ -149,7 +150,7 @@ def java_container():
def test_mysql_client(started_cluster):
# type: (Container, str) -> None
# type: (ClickHouseCluster) -> None
code, (stdout, stderr) = started_cluster.mysql_client_container.exec_run(
"""
mysql --protocol tcp -h {host} -P {port} default -u user_with_double_sha1 --password=abacaba
@ -365,7 +366,10 @@ def test_mysql_replacement_query(started_cluster):
demux=True,
)
assert code == 0
assert stdout.decode() == "currentDatabase()\ndefault\n"
assert stdout.decode().lower() in [
"currentdatabase()\ndefault\n",
"database()\ndefault\n",
]
code, (stdout, stderr) = started_cluster.mysql_client_container.exec_run(
"""
@ -377,7 +381,10 @@ def test_mysql_replacement_query(started_cluster):
demux=True,
)
assert code == 0
assert stdout.decode() == "currentDatabase()\ndefault\n"
assert stdout.decode().lower() in [
"currentdatabase()\ndefault\n",
"database()\ndefault\n",
]
def test_mysql_select_user(started_cluster):
@ -391,7 +398,7 @@ def test_mysql_select_user(started_cluster):
demux=True,
)
assert code == 0
assert stdout.decode() == "currentUser()\ndefault\n"
assert stdout.decode() in ["currentUser()\ndefault\n", "user()\ndefault\n"]
def test_mysql_explain(started_cluster):
@ -568,9 +575,8 @@ 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].startswith(
"Code: 60. DB::Exception: Table default.tables doesn't exist"
), exc_info.value.args[1]
resp = exc_info.value.args[1]
assert fnmatch.fnmatch(resp, "*DB::Exception:*system.part_log*UNKNOWN_TABLE*"), resp
cursor = client.cursor(pymysql.cursors.DictCursor)
cursor.execute("select 1 as a, 'тест' as b")
@ -602,9 +608,8 @@ 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].startswith(
"Code: 60. DB::Exception: Table default.tables doesn't exist"
), exc_info.value.args[1]
resp = exc_info.value.args[1]
assert fnmatch.fnmatch(resp, "*DB::Exception:*system.part_log*UNKNOWN_TABLE*"), resp
cursor = client.cursor(pymysql.cursors.DictCursor)
cursor.execute("select 1 as a, 'тест' as b")

View File

@ -1,4 +1,5 @@
import pytest
import fnmatch
from helpers.cluster import ClickHouseCluster
@ -27,20 +28,20 @@ def start_cluster():
def test_config_without_part_log(start_cluster):
assert "Table system.part_log doesn't exist" in node1.query_and_get_error(
"SELECT * FROM system.part_log"
)
resp = node1.query_and_get_error("SELECT * FROM system.part_log")
assert fnmatch.fnmatch(resp, "*DB::Exception:*system.part_log*UNKNOWN_TABLE*"), resp
node1.query(
"CREATE TABLE test_table(word String, value UInt64) ENGINE=MergeTree() ORDER BY value"
)
assert "Table system.part_log doesn't exist" in node1.query_and_get_error(
"SELECT * FROM system.part_log"
)
resp = node1.query_and_get_error("SELECT * FROM system.part_log")
assert fnmatch.fnmatch(resp, "*DB::Exception:*system.part_log*UNKNOWN_TABLE*"), resp
node1.query("INSERT INTO test_table VALUES ('name', 1)")
node1.query("SYSTEM FLUSH LOGS")
assert "Table system.part_log doesn't exist" in node1.query_and_get_error(
"SELECT * FROM system.part_log"
)
resp = node1.query_and_get_error("SELECT * FROM system.part_log")
assert fnmatch.fnmatch(resp, "*DB::Exception:*system.part_log*UNKNOWN_TABLE*"), resp
# Note: if part_log is defined, we cannot say when the table will be created - because of metric_log, trace_log, text_log, query_log...

View File

@ -203,7 +203,7 @@ def test_remove_table_from_replication(started_cluster):
table_name = "postgresql_replica_4"
instance.query(f"DETACH TABLE test_database.{table_name} PERMANENTLY")
result = instance.query_and_get_error(f"SELECT * FROM test_database.{table_name}")
assert "doesn't exist" in result
assert "UNKNOWN_TABLE" in result
result = instance.query("SHOW TABLES FROM test_database")
assert (