aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorqrort <qrort@yandex-team.com>2023-08-24 11:49:52 +0300
committerqrort <qrort@yandex-team.com>2023-08-24 12:04:57 +0300
commit10525b5f618b3f44ed3285dc6ca6ea78f516928d (patch)
tree4375482287e55aaf5a5cc40483d677bbc23f7ff5
parent42c2d9c8d8eb9f477b0f1933f64cd14678c00bc3 (diff)
downloadydb-10525b5f618b3f44ed3285dc6ca6ea78f516928d.tar.gz
fix 'port is already in use' flap
-rw-r--r--ydb/tests/functional/postgresql/common/differ.py5
-rw-r--r--ydb/tests/functional/postgresql/test_postgres.py11
-rw-r--r--ydb/tests/functional/postgresql/ya.make2
3 files changed, 13 insertions, 5 deletions
diff --git a/ydb/tests/functional/postgresql/common/differ.py b/ydb/tests/functional/postgresql/common/differ.py
index 3c05160c5d..a96cff2f55 100644
--- a/ydb/tests/functional/postgresql/common/differ.py
+++ b/ydb/tests/functional/postgresql/common/differ.py
@@ -16,7 +16,10 @@ class Differ:
__reErr = re.compile(b'(^ERROR: [^\n]+)(?:\nLINE \\d+: [^\n]+(?:\n\\s*\\^\\s*)?)?(?:\n(?:HINT|DETAIL|CONTEXT): [^\n]+)*(?:\n|$)',
re.MULTILINE)
- __reYdbErr = re.compile(b'(^psql:[^\n]+\nIssues: \n)(?: *<main>:[^\n]+\n)*( *<main>:(\\d+:\\d+:)? Error: ([^\n]+)\n)(?:(?:HINT|DETAIL|CONTEXT): [^\n]+\n?)*\n?(?:\n|$)', re.MULTILINE)
+ __reYdbErr = re.compile(
+ b'(^psql:[^\n]+\nIssues: \n)(?: *<main>:[^\n]+\n)*( *<main>:(\\d+:\\d+:)? Error: ([^\n]+)\n)(?:(?:HINT|DETAIL|CONTEXT): [^\n]+\n?)*\n?(?:\n|$)(, code: [0-9]+)?',
+ re.MULTILINE
+ )
@classmethod
def __remove_pg_error_msgs(cls, s):
diff --git a/ydb/tests/functional/postgresql/test_postgres.py b/ydb/tests/functional/postgresql/test_postgres.py
index 350a4f140b..0d3e616d8f 100644
--- a/ydb/tests/functional/postgresql/test_postgres.py
+++ b/ydb/tests/functional/postgresql/test_postgres.py
@@ -10,9 +10,12 @@ import yatest.common
import os
import pytest
import re
+import time
+
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):
@@ -94,11 +97,13 @@ class TestPgwireSidecar(object):
cls.cluster = kikimr_cluster_factory()
cls.cluster.start()
cls.endpoint = '%s:%s' % (cls.cluster.nodes[1].host, cls.cluster.nodes[1].port)
+ cls.pgwireListenPort = pm.get_port()
cls.pgwire, _, _, _ = execute_binary(
'pgwire',
- [pgwire_binary_path(), '--endpoint={}'.format(cls.endpoint), '--stderr'],
+ [pgwire_binary_path(), '--endpoint={}'.format(cls.endpoint), '--port={}'.format(cls.pgwireListenPort), '--stderr'],
wait=False
)
+ time.sleep(1)
@classmethod
def teardown_class(cls):
@@ -109,7 +114,7 @@ class TestPgwireSidecar(object):
def test_pgwire_sidecar(self, sql, out):
_, _, psql_stderr, psql_stdout = 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.pgwireListenPort), '-w', '-a', '-f', sql],
wait=True,
join_stderr=True
)
@@ -123,7 +128,7 @@ class TestPostgresSuite(BasePostgresTest):
def test_postgres_suite(self, sql, out):
_, _, psql_stderr, psql_stdout = execute_binary(
'psql',
- [psql_binary_path(), 'host=localhost port=5432 dbname=Root user=root password=1234', '-w', '-a', '-f', sql],
+ [psql_binary_path(), 'postgresql://root:1234@localhost:5432/Root', '-w', '-a', '-f', sql],
wait=True,
join_stderr=True
)
diff --git a/ydb/tests/functional/postgresql/ya.make b/ydb/tests/functional/postgresql/ya.make
index 88b4fb368b..e05855fdf9 100644
--- a/ydb/tests/functional/postgresql/ya.make
+++ b/ydb/tests/functional/postgresql/ya.make
@@ -2,7 +2,7 @@ PY3TEST()
DATA(
arcadia/ydb/tests/functional/postgresql/cases
- sbr://4298147653=psql
+ sbr://4966407557=psql
)
DEPENDS(