From 8bb0e97880957147e280ce3dbd384778b659ebe7 Mon Sep 17 00:00:00 2001 From: Alexey Masterov Date: Fri, 6 Sep 2024 11:03:29 +0200 Subject: [PATCH] Some refactoring --- .../cloud_regress/test_cloud_regress.py | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/test_runner/cloud_regress/test_cloud_regress.py b/test_runner/cloud_regress/test_cloud_regress.py index a59050c895..66835c7590 100644 --- a/test_runner/cloud_regress/test_cloud_regress.py +++ b/test_runner/cloud_regress/test_cloud_regress.py @@ -10,33 +10,25 @@ import psycopg2 import pytest from fixtures.log_helper import log from fixtures.neon_fixtures import RemotePostgres +from fixtures.pg_version import PgVersion @pytest.mark.timeout(7200) @pytest.mark.remote_cluster -def test_cloud_regress(remote_pg: RemotePostgres): +def test_cloud_regress(remote_pg: RemotePostgres, pg_version: PgVersion): """ Run the regression tests """ - cur_test = os.environ.get("PYTEST_CURRENT_TEST") - assert cur_test - pg_version_match = re.search(r"\-pg(\d+)\]", cur_test) - assert pg_version_match - pg_version = int(pg_version_match.group(1)) with psycopg2.connect(remote_pg.connstr()) as conn: with conn.cursor() as cur: cur = conn.cursor() - cur.execute("SELECT COUNT(*) FROM pg_extension WHERE extname = 'regress_so'") - for r in cur: - num_ext = r[0] - assert int(num_ext) < 2 - if num_ext == 1: - log.info("The extension is found") - else: - log.info("Creating the extension") - cur.execute("CREATE EXTENSION regress_so") - conn.commit() + log.info("Creating the extension") + cur.execute("CREATE EXTENSION IF NOT EXISTS regress_so") + conn.commit() + # This is also a workaround for the full path problem + # If we specify the full path in the command, the library won't be downloaded + # So we specify the name only for the first time log.info("Creating a C function to check availability of regress.so") cur.execute( "CREATE FUNCTION get_columns_length(oid[]) "