From 9e693c972b23efa968c9f64abcbe46f1f3dc0f11 Mon Sep 17 00:00:00 2001 From: qrort <31865255+qrort@users.noreply.github.com> Date: Tue, 27 Feb 2024 14:57:11 +0300 Subject: [PATCH] resolves #1917: fix, add, unmute pgwire tests (#2213) --- .github/config/muted_functest.txt | 1 - .github/config/muted_ya.txt | 1 - .../functional/postgresql/cases/int8.out | 140 ------------------ .../functional/postgresql/cases/int8.sql | 33 ----- .../cases/{int4.out => withtable.out} | 45 ------ .../cases/{int4.sql => withtable.sql} | 15 -- .../functional/postgresql/test_postgres.py | 11 +- ydb/tests/library/harness/kikimr_config.py | 5 + 8 files changed, 12 insertions(+), 239 deletions(-) delete mode 100644 ydb/tests/functional/postgresql/cases/int8.out delete mode 100644 ydb/tests/functional/postgresql/cases/int8.sql rename ydb/tests/functional/postgresql/cases/{int4.out => withtable.out} (65%) rename ydb/tests/functional/postgresql/cases/{int4.sql => withtable.sql} (70%) diff --git a/.github/config/muted_functest.txt b/.github/config/muted_functest.txt index f14ce2afff3f..be9a39bcc9c3 100644 --- a/.github/config/muted_functest.txt +++ b/.github/config/muted_functest.txt @@ -1,4 +1,3 @@ -ydb/tests/functional/postgresql::test_postgres.py.TestPostgresSuite.test_postgres_suite* ydb/tests/functional/tenants/test_dynamic_tenants.py::* ydb/tests/functional/tenants/test_storage_config.py::TestStorageConfig::* ydb/tests/functional/tenants/test_tenants.py::* diff --git a/.github/config/muted_ya.txt b/.github/config/muted_ya.txt index ef1592a52dd6..d3ee0b97b117 100644 --- a/.github/config/muted_ya.txt +++ b/.github/config/muted_ya.txt @@ -90,7 +90,6 @@ ydb/tests/functional/clickbench test.py.test_plans* ydb/tests/functional/clickbench test.py.test_run* ydb/tests/functional/kqp/kqp_indexes ConsistentIndexRead.InteractiveTx ydb/tests/functional/kqp/kqp_query_session KqpQuerySession.NoLocalAttach -ydb/tests/functional/postgresql test_postgres.py.TestPostgresSuite.test_postgres_suite* ydb/tests/functional/restarts test_restarts.py.* ydb/tests/functional/serverless test_serverless.py.test_database_with_disk_quotas[enable_alter_database_create_hive_first--*] ydb/tests/functional/sqs/cloud test_common.py.TestCommonSqsYandexCloudMode.test_private_create_queue[tables_format_v0-std] diff --git a/ydb/tests/functional/postgresql/cases/int8.out b/ydb/tests/functional/postgresql/cases/int8.out deleted file mode 100644 index 58c5041f953e..000000000000 --- a/ydb/tests/functional/postgresql/cases/int8.out +++ /dev/null @@ -1,140 +0,0 @@ --- --- INT8 --- Test int8 64-bit integers. --- -CREATE TABLE INT8_TBL(q1 int8, q2 int8, primary key (q1, q2)); -INSERT INTO INT8_TBL (q1, q2) VALUES(' 123 ',' 456'); -INSERT INTO INT8_TBL (q1, q2) VALUES('123 ','4567890123456789'); -INSERT INTO INT8_TBL (q1, q2) VALUES('4567890123456789','123'); -INSERT INTO INT8_TBL (q1, q2) VALUES(+4567890123456789,'4567890123456789'); -INSERT INTO INT8_TBL (q1, q2) VALUES('+4567890123456789','-4567890123456789'); --- bad inputs -INSERT INTO INT8_TBL(q1) VALUES (' '); -ERROR: invalid input syntax for type bigint: " " -LINE 1: INSERT INTO INT8_TBL(q1) VALUES (' '); - ^ -INSERT INTO INT8_TBL(q1) VALUES ('xxx'); -ERROR: invalid input syntax for type bigint: "xxx" -LINE 1: INSERT INTO INT8_TBL(q1) VALUES ('xxx'); - ^ -INSERT INTO INT8_TBL(q1) VALUES ('3908203590239580293850293850329485'); -ERROR: value "3908203590239580293850293850329485" is out of range for type bigint -LINE 1: INSERT INTO INT8_TBL(q1) VALUES ('39082035902395802938502938... - ^ -INSERT INTO INT8_TBL(q1) VALUES ('-1204982019841029840928340329840934'); -ERROR: value "-1204982019841029840928340329840934" is out of range for type bigint -LINE 1: INSERT INTO INT8_TBL(q1) VALUES ('-1204982019841029840928340... - ^ -INSERT INTO INT8_TBL(q1) VALUES ('- 123'); -ERROR: invalid input syntax for type bigint: "- 123" -LINE 1: INSERT INTO INT8_TBL(q1) VALUES ('- 123'); - ^ -INSERT INTO INT8_TBL(q1) VALUES (' 345 5'); -ERROR: invalid input syntax for type bigint: " 345 5" -LINE 1: INSERT INTO INT8_TBL(q1) VALUES (' 345 5'); - ^ -INSERT INTO INT8_TBL(q1) VALUES (''); -ERROR: invalid input syntax for type bigint: "" -LINE 1: INSERT INTO INT8_TBL(q1) VALUES (''); - ^ -SELECT * FROM INT8_TBL; - q1 | q2 -------------------+------------------- - 123 | 456 - 123 | 4567890123456789 - 4567890123456789 | -4567890123456789 - 4567890123456789 | 123 - 4567890123456789 | 4567890123456789 -(5 rows) - --- int8/int8 cmp -SELECT * FROM INT8_TBL WHERE q2 = 4567890123456789; - q1 | q2 -------------------+------------------ - 123 | 4567890123456789 - 4567890123456789 | 4567890123456789 -(2 rows) - -SELECT * FROM INT8_TBL WHERE q2 <> 4567890123456789; - q1 | q2 -------------------+------------------- - 123 | 456 - 4567890123456789 | -4567890123456789 - 4567890123456789 | 123 -(3 rows) - -SELECT * FROM INT8_TBL WHERE q2 < 4567890123456789; - q1 | q2 -------------------+------------------- - 123 | 456 - 4567890123456789 | -4567890123456789 - 4567890123456789 | 123 -(3 rows) - -SELECT * FROM INT8_TBL WHERE q2 > 4567890123456789; - q1 | q2 -----+---- -(0 rows) - -SELECT * FROM INT8_TBL WHERE q2 <= 4567890123456789; - q1 | q2 -------------------+------------------- - 123 | 456 - 123 | 4567890123456789 - 4567890123456789 | -4567890123456789 - 4567890123456789 | 123 - 4567890123456789 | 4567890123456789 -(5 rows) - -SELECT * FROM INT8_TBL WHERE q2 >= 4567890123456789; - q1 | q2 -------------------+------------------ - 123 | 4567890123456789 - 4567890123456789 | 4567890123456789 -(2 rows) - --- int8/int4 cmp -SELECT * FROM INT8_TBL WHERE q2 = 456; - q1 | q2 ------+----- - 123 | 456 -(1 row) - -SELECT * FROM INT8_TBL WHERE q2 <> 456; - q1 | q2 -------------------+------------------- - 123 | 4567890123456789 - 4567890123456789 | -4567890123456789 - 4567890123456789 | 123 - 4567890123456789 | 4567890123456789 -(4 rows) - -SELECT * FROM INT8_TBL WHERE q2 < 456; - q1 | q2 -------------------+------------------- - 4567890123456789 | -4567890123456789 - 4567890123456789 | 123 -(2 rows) - -SELECT * FROM INT8_TBL WHERE q2 > 456; - q1 | q2 -------------------+------------------ - 123 | 4567890123456789 - 4567890123456789 | 4567890123456789 -(2 rows) - -SELECT * FROM INT8_TBL WHERE q2 <= 456; - q1 | q2 -------------------+------------------- - 123 | 456 - 4567890123456789 | -4567890123456789 - 4567890123456789 | 123 -(3 rows) - -SELECT * FROM INT8_TBL WHERE q2 >= 456; - q1 | q2 -------------------+------------------ - 123 | 456 - 123 | 4567890123456789 - 4567890123456789 | 4567890123456789 -(3 rows) diff --git a/ydb/tests/functional/postgresql/cases/int8.sql b/ydb/tests/functional/postgresql/cases/int8.sql deleted file mode 100644 index 3e3cf95d666a..000000000000 --- a/ydb/tests/functional/postgresql/cases/int8.sql +++ /dev/null @@ -1,33 +0,0 @@ --- --- INT8 --- Test int8 64-bit integers. --- -CREATE TABLE INT8_TBL(q1 int8, q2 int8, primary key (q1, q2)); -INSERT INTO INT8_TBL (q1, q2) VALUES(' 123 ',' 456'); -INSERT INTO INT8_TBL (q1, q2) VALUES('123 ','4567890123456789'); -INSERT INTO INT8_TBL (q1, q2) VALUES('4567890123456789','123'); -INSERT INTO INT8_TBL (q1, q2) VALUES(+4567890123456789,'4567890123456789'); -INSERT INTO INT8_TBL (q1, q2) VALUES('+4567890123456789','-4567890123456789'); --- bad inputs -INSERT INTO INT8_TBL(q1) VALUES (' '); -INSERT INTO INT8_TBL(q1) VALUES ('xxx'); -INSERT INTO INT8_TBL(q1) VALUES ('3908203590239580293850293850329485'); -INSERT INTO INT8_TBL(q1) VALUES ('-1204982019841029840928340329840934'); -INSERT INTO INT8_TBL(q1) VALUES ('- 123'); -INSERT INTO INT8_TBL(q1) VALUES (' 345 5'); -INSERT INTO INT8_TBL(q1) VALUES (''); -SELECT * FROM INT8_TBL; --- int8/int8 cmp -SELECT * FROM INT8_TBL WHERE q2 = 4567890123456789; -SELECT * FROM INT8_TBL WHERE q2 <> 4567890123456789; -SELECT * FROM INT8_TBL WHERE q2 < 4567890123456789; -SELECT * FROM INT8_TBL WHERE q2 > 4567890123456789; -SELECT * FROM INT8_TBL WHERE q2 <= 4567890123456789; -SELECT * FROM INT8_TBL WHERE q2 >= 4567890123456789; --- int8/int4 cmp -SELECT * FROM INT8_TBL WHERE q2 = 456; -SELECT * FROM INT8_TBL WHERE q2 <> 456; -SELECT * FROM INT8_TBL WHERE q2 < 456; -SELECT * FROM INT8_TBL WHERE q2 > 456; -SELECT * FROM INT8_TBL WHERE q2 <= 456; -SELECT * FROM INT8_TBL WHERE q2 >= 456; diff --git a/ydb/tests/functional/postgresql/cases/int4.out b/ydb/tests/functional/postgresql/cases/withtable.out similarity index 65% rename from ydb/tests/functional/postgresql/cases/int4.out rename to ydb/tests/functional/postgresql/cases/withtable.out index b40e01733c3d..0fab722c255b 100644 --- a/ydb/tests/functional/postgresql/cases/int4.out +++ b/ydb/tests/functional/postgresql/cases/withtable.out @@ -5,42 +5,9 @@ CREATE TABLE INT4_TBL(f1 int4 primary key); INSERT INTO INT4_TBL(f1) VALUES (' 0 '); INSERT INTO INT4_TBL(f1) VALUES ('123456 '); INSERT INTO INT4_TBL(f1) VALUES (' -123456'); -INSERT INTO INT4_TBL(f1) VALUES ('34.5'); -ERROR: invalid input syntax for type integer: "34.5" -LINE 1: INSERT INTO INT4_TBL(f1) VALUES ('34.5'); - ^ -- largest and smallest values INSERT INTO INT4_TBL(f1) VALUES ('2147483647'); INSERT INTO INT4_TBL(f1) VALUES ('-2147483647'); --- bad input values -- should give errors -INSERT INTO INT4_TBL(f1) VALUES ('1000000000000'); -ERROR: value "1000000000000" is out of range for type integer -LINE 1: INSERT INTO INT4_TBL(f1) VALUES ('1000000000000'); - ^ -INSERT INTO INT4_TBL(f1) VALUES ('asdf'); -ERROR: invalid input syntax for type integer: "asdf" -LINE 1: INSERT INTO INT4_TBL(f1) VALUES ('asdf'); - ^ -INSERT INTO INT4_TBL(f1) VALUES (' '); -ERROR: invalid input syntax for type integer: " " -LINE 1: INSERT INTO INT4_TBL(f1) VALUES (' '); - ^ -INSERT INTO INT4_TBL(f1) VALUES (' asdf '); -ERROR: invalid input syntax for type integer: " asdf " -LINE 1: INSERT INTO INT4_TBL(f1) VALUES (' asdf '); - ^ -INSERT INTO INT4_TBL(f1) VALUES ('- 1234'); -ERROR: invalid input syntax for type integer: "- 1234" -LINE 1: INSERT INTO INT4_TBL(f1) VALUES ('- 1234'); - ^ -INSERT INTO INT4_TBL(f1) VALUES ('123 5'); -ERROR: invalid input syntax for type integer: "123 5" -LINE 1: INSERT INTO INT4_TBL(f1) VALUES ('123 5'); - ^ -INSERT INTO INT4_TBL(f1) VALUES (''); -ERROR: invalid input syntax for type integer: "" -LINE 1: INSERT INTO INT4_TBL(f1) VALUES (''); - ^ SELECT * FROM INT4_TBL; f1 ------------- @@ -157,8 +124,6 @@ SELECT i.* FROM INT4_TBL i WHERE (i.f1 % int4 '2') = int2 '0'; 123456 (3 rows) -SELECT i.f1, i.f1 * int2 '2' AS x FROM INT4_TBL i; -ERROR: integer out of range SELECT i.f1, i.f1 * int2 '2' AS x FROM INT4_TBL i WHERE abs(f1) < 1073741824; f1 | x @@ -168,8 +133,6 @@ WHERE abs(f1) < 1073741824; 123456 | 246912 (3 rows) -SELECT i.f1, i.f1 * int4 '2' AS x FROM INT4_TBL i; -ERROR: integer out of range SELECT i.f1, i.f1 * int4 '2' AS x FROM INT4_TBL i WHERE abs(f1) < 1073741824; f1 | x @@ -179,8 +142,6 @@ WHERE abs(f1) < 1073741824; 123456 | 246912 (3 rows) -SELECT i.f1, i.f1 + int2 '2' AS x FROM INT4_TBL i; -ERROR: integer out of range SELECT i.f1, i.f1 + int2 '2' AS x FROM INT4_TBL i WHERE f1 < 2147483646; f1 | x @@ -191,8 +152,6 @@ WHERE f1 < 2147483646; 123456 | 123458 (4 rows) -SELECT i.f1, i.f1 + int4 '2' AS x FROM INT4_TBL i; -ERROR: integer out of range SELECT i.f1, i.f1 + int4 '2' AS x FROM INT4_TBL i WHERE f1 < 2147483646; f1 | x @@ -203,8 +162,6 @@ WHERE f1 < 2147483646; 123456 | 123458 (4 rows) -SELECT i.f1, i.f1 - int2 '2' AS x FROM INT4_TBL i; -ERROR: integer out of range SELECT i.f1, i.f1 - int2 '2' AS x FROM INT4_TBL i WHERE f1 > -2147483647; f1 | x @@ -215,8 +172,6 @@ WHERE f1 > -2147483647; 2147483647 | 2147483645 (4 rows) -SELECT i.f1, i.f1 - int4 '2' AS x FROM INT4_TBL i; -ERROR: integer out of range SELECT i.f1, i.f1 - int4 '2' AS x FROM INT4_TBL i WHERE f1 > -2147483647; f1 | x diff --git a/ydb/tests/functional/postgresql/cases/int4.sql b/ydb/tests/functional/postgresql/cases/withtable.sql similarity index 70% rename from ydb/tests/functional/postgresql/cases/int4.sql rename to ydb/tests/functional/postgresql/cases/withtable.sql index 4c7a7b6ffea5..8cc0f6fc8d82 100644 --- a/ydb/tests/functional/postgresql/cases/int4.sql +++ b/ydb/tests/functional/postgresql/cases/withtable.sql @@ -5,18 +5,9 @@ CREATE TABLE INT4_TBL(f1 int4 primary key); INSERT INTO INT4_TBL(f1) VALUES (' 0 '); INSERT INTO INT4_TBL(f1) VALUES ('123456 '); INSERT INTO INT4_TBL(f1) VALUES (' -123456'); -INSERT INTO INT4_TBL(f1) VALUES ('34.5'); -- largest and smallest values INSERT INTO INT4_TBL(f1) VALUES ('2147483647'); INSERT INTO INT4_TBL(f1) VALUES ('-2147483647'); --- bad input values -- should give errors -INSERT INTO INT4_TBL(f1) VALUES ('1000000000000'); -INSERT INTO INT4_TBL(f1) VALUES ('asdf'); -INSERT INTO INT4_TBL(f1) VALUES (' '); -INSERT INTO INT4_TBL(f1) VALUES (' asdf '); -INSERT INTO INT4_TBL(f1) VALUES ('- 1234'); -INSERT INTO INT4_TBL(f1) VALUES ('123 5'); -INSERT INTO INT4_TBL(f1) VALUES (''); SELECT * FROM INT4_TBL; SELECT i.* FROM INT4_TBL i WHERE i.f1 <> int2 '0'; SELECT i.* FROM INT4_TBL i WHERE i.f1 <> int4 '0'; @@ -34,22 +25,16 @@ SELECT i.* FROM INT4_TBL i WHERE i.f1 >= int4 '0'; SELECT i.* FROM INT4_TBL i WHERE (i.f1 % int2 '2') = int2 '1'; -- any evens SELECT i.* FROM INT4_TBL i WHERE (i.f1 % int4 '2') = int2 '0'; -SELECT i.f1, i.f1 * int2 '2' AS x FROM INT4_TBL i; SELECT i.f1, i.f1 * int2 '2' AS x FROM INT4_TBL i WHERE abs(f1) < 1073741824; -SELECT i.f1, i.f1 * int4 '2' AS x FROM INT4_TBL i; SELECT i.f1, i.f1 * int4 '2' AS x FROM INT4_TBL i WHERE abs(f1) < 1073741824; -SELECT i.f1, i.f1 + int2 '2' AS x FROM INT4_TBL i; SELECT i.f1, i.f1 + int2 '2' AS x FROM INT4_TBL i WHERE f1 < 2147483646; -SELECT i.f1, i.f1 + int4 '2' AS x FROM INT4_TBL i; SELECT i.f1, i.f1 + int4 '2' AS x FROM INT4_TBL i WHERE f1 < 2147483646; -SELECT i.f1, i.f1 - int2 '2' AS x FROM INT4_TBL i; SELECT i.f1, i.f1 - int2 '2' AS x FROM INT4_TBL i WHERE f1 > -2147483647; -SELECT i.f1, i.f1 - int4 '2' AS x FROM INT4_TBL i; SELECT i.f1, i.f1 - int4 '2' AS x FROM INT4_TBL i WHERE f1 > -2147483647; SELECT i.f1, i.f1 / int2 '2' AS x FROM INT4_TBL i; diff --git a/ydb/tests/functional/postgresql/test_postgres.py b/ydb/tests/functional/postgresql/test_postgres.py index 6ec4593759fd..1529c75597de 100644 --- a/ydb/tests/functional/postgresql/test_postgres.py +++ b/ydb/tests/functional/postgresql/test_postgres.py @@ -14,7 +14,6 @@ arcadia_root = yatest.common.source_path('') DATA_PATH = os.path.join(arcadia_root, yatest.common.test_source_path('cases')) -pm = yatest.common.network.PortManager() def get_unique_path_case(sub_folder, file): @@ -47,7 +46,7 @@ def execute_binary(binary_name, cmd, stdin_string=None): stdout = get_unique_path_case('psql', 'stdout') with open(stdout, 'w') as stdout_file: - process = yatest.common.execute( + yatest.common.execute( cmd, stdout=stdout_file, stderr=stdout_file, @@ -60,6 +59,8 @@ def execute_binary(binary_name, cmd, stdin_string=None): class BasePostgresTest(object): @classmethod def setup_class(cls): + cls.pm = yatest.common.network.PortManager() + cls.pgport = cls.pm.get_port() cls.cluster = kikimr_cluster_factory(KikimrConfigGenerator( additional_log_configs={ 'LOCAL_PGWIRE': LogLevels.DEBUG, @@ -68,13 +69,15 @@ def setup_class(cls): 'KQP_COMPILE_REQUEST': LogLevels.DEBUG, 'KQP_PROXY': LogLevels.DEBUG }, - extra_feature_flags=['enable_table_pg_types', 'enable_temp_tables'] + extra_feature_flags=['enable_table_pg_types', 'enable_temp_tables'], + pgwire_port=cls.pgport )) cls.cluster.start() @classmethod def teardown_class(cls): cls.cluster.stop() + cls.pm.release() class TestPostgresSuite(BasePostgresTest): @@ -82,7 +85,7 @@ class TestPostgresSuite(BasePostgresTest): def test_postgres_suite(self, sql, out): stdout_file = execute_binary( 'psql', - [psql_binary_path(), 'postgresql://root:1234@localhost:5432/Root', '-w', '-a', '-f', sql] + [psql_binary_path(), 'postgresql://root:1234@localhost:{}/Root'.format(self.pgport), '-w', '-a', '-f', sql] ) with open(stdout_file, 'rb') as stdout_data: diff --git a/ydb/tests/library/harness/kikimr_config.py b/ydb/tests/library/harness/kikimr_config.py index 17f20055b437..c4375953b6a4 100644 --- a/ydb/tests/library/harness/kikimr_config.py +++ b/ydb/tests/library/harness/kikimr_config.py @@ -162,6 +162,7 @@ def __init__( default_user_sid=None, pg_compatible_expirement=False, generic_connector_config=None, # typing.Optional[TGenericConnectorConfig] + pgwire_port=None, ): if extra_feature_flags is None: extra_feature_flags = [] @@ -253,6 +254,10 @@ def __init__( self.yaml_config["local_pg_wire_config"] = {} self.yaml_config["local_pg_wire_config"]["listening_port"] = os.getenv('PGWIRE_LISTENING_PORT') + if pgwire_port: + self.yaml_config["local_pg_wire_config"] = {} + self.yaml_config["local_pg_wire_config"]["listening_port"] = pgwire_port + if disable_iterator_reads: self.yaml_config["table_service_config"]["enable_kqp_scan_query_source_read"] = False self.yaml_config["table_service_config"]["enable_kqp_data_query_source_read"] = False