Skip to content

Commit

Permalink
resolves #1917: fix, add, unmute pgwire tests (#2213)
Browse files Browse the repository at this point in the history
  • Loading branch information
qrort authored Feb 27, 2024
1 parent cc1ad2e commit 9e693c9
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 239 deletions.
1 change: 0 additions & 1 deletion .github/config/muted_functest.txt
Original file line number Diff line number Diff line change
@@ -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::*
Expand Down
1 change: 0 additions & 1 deletion .github/config/muted_ya.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
140 changes: 0 additions & 140 deletions ydb/tests/functional/postgresql/cases/int8.out

This file was deleted.

33 changes: 0 additions & 33 deletions ydb/tests/functional/postgresql/cases/int8.sql

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
-------------
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand Down
11 changes: 7 additions & 4 deletions ydb/tests/functional/postgresql/test_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -68,21 +69,23 @@ 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):
@pytest.mark.parametrize(['sql', 'out'], get_tests(), ids=get_ids())
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:
Expand Down
5 changes: 5 additions & 0 deletions ydb/tests/library/harness/kikimr_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 9e693c9

Please sign in to comment.