From 8fb8ec57ead74dfe65d104a5fa349a04bf1bb509 Mon Sep 17 00:00:00 2001 From: Alexey Masterov Date: Fri, 30 Aug 2024 16:39:07 +0200 Subject: [PATCH] Add python script, rename patch file --- .../{i1.patch => cloud_regress_pg16.patch} | 0 .../cloud_regress/test_cloud_regress.py | 57 +++++++++++++++++++ 2 files changed, 57 insertions(+) rename patches/{i1.patch => cloud_regress_pg16.patch} (100%) create mode 100644 test_runner/cloud_regress/test_cloud_regress.py diff --git a/patches/i1.patch b/patches/cloud_regress_pg16.patch similarity index 100% rename from patches/i1.patch rename to patches/cloud_regress_pg16.patch diff --git a/test_runner/cloud_regress/test_cloud_regress.py b/test_runner/cloud_regress/test_cloud_regress.py new file mode 100644 index 0000000000..21cb69a77e --- /dev/null +++ b/test_runner/cloud_regress/test_cloud_regress.py @@ -0,0 +1,57 @@ +""" +Run the regression tests on the cloud instance of Neon +""" +import os +import re +import psycopg2 +import pytest +from fixtures.log_helper import log +from fixtures.neon_fixtures import RemotePostgres + + +@pytest.mark.timeout(7200) +@pytest.mark.remote_cluster +def test_cloud_regress(remote_pg: RemotePostgres): + """ + Run the regression tests + """ + pg_version = re.search(r"\-pg(\d+)\]", os.environ.get('PYTEST_CURRENT_TEST')).group(1) + log.info(pg_version) + conn = psycopg2.connect(remote_pg.connstr()) + cur = conn.cursor() + cur.execute("SELECT COUNT(*) FROM pg_extension WHERE extname = 'regress_so'") + num_ext = cur.fetchone()[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 a C function to check availability of regress.so') + cur.execute("CREATE FUNCTION get_columns_length(oid[]) " + "RETURNS int AS 'regress.so' LANGUAGE C STRICT STABLE PARALLEL SAFE;") + conn.rollback() + neondir = os.path.abspath(os.path.join(os.path.dirname(os.path.relpath(__file__)), '../../')) + runpath = f'{neondir}/vendor/postgres-v{pg_version}/src/test/regress' + binpath = f'{neondir}/pg_install/v{pg_version}/bin' + + log.info(os.path.relpath(__file__)) + env_vars = { + 'PGHOST': remote_pg.default_options['host'], + 'PGPORT': str(remote_pg.default_options['port'] if 'port' in remote_pg.default_options else 5432), + 'PGUSER': remote_pg.default_options['user'], + 'PGPASSWORD': remote_pg.default_options['password'], + 'PGDATABASE': remote_pg.default_options['dbname'] + } + regress_cmd = [ + f'{runpath}/pg_regress', + '--inputdir=.', + f"--bindir={binpath}", + "--dlpath=/usr/local/lib", + "--max-concurrent-tests=20", + "--schedule=./parallel_schedule", + "--max-connections=5" + ] + remote_pg.pg_bin.run(regress_cmd, env=env_vars, cwd=runpath)