From a01f1471083b31a8277cc708569c3809876c6b57 Mon Sep 17 00:00:00 2001 From: Josh Holbrook Date: Fri, 13 Dec 2019 13:47:14 -0500 Subject: [PATCH] WIP - support/testing for postgres 11 and 12 --- Makefile | 2 +- pgbedrock/spec_inspector.py | 2 +- tests/conftest.py | 23 ++++++++++++++++++++--- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 3881845..4702642 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ .PHONY: attach build build_tester clean coverage create_network docs psql release_pypi release_pypitest release_quay remove_network start_postgres stop_postgres test test_one_pg_version test27 test36 view_docs wait_for_postgres -SUPPORTED_PG_VERSIONS ?= 9.5.13 9.6.4 10.4 +SUPPORTED_PG_VERSIONS ?= 9.5.13 9.6.4 10.4 11.6 12.1 # The default Postgres that will be used in individual targets POSTGRES_VERSION ?= 10.4 diff --git a/pgbedrock/spec_inspector.py b/pgbedrock/spec_inspector.py index 93463e9..996795e 100644 --- a/pgbedrock/spec_inspector.py +++ b/pgbedrock/spec_inspector.py @@ -490,4 +490,4 @@ def ensure_no_except_on_schema(spec): if config and config.get('privileges'): if config['privileges'].get('schemas') and config['privileges']['schemas'].get('except') and config['privileges']['schemas']['excepted']: error_messages.append(EXCEPTED_SCHEMAS_MSG.format(rolename)) - return error_messages \ No newline at end of file + return error_messages diff --git a/tests/conftest.py b/tests/conftest.py index 4da78df..09d8c54 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -67,7 +67,9 @@ def drop_users_and_objects(cursor): WHERE rolname NOT IN ( 'test_user', 'postgres', 'pg_signal_backend', -- Roles introduced in Postgres 10: - 'pg_monitor', 'pg_read_all_settings', 'pg_read_all_stats', 'pg_stat_scan_tables' + 'pg_monitor', 'pg_read_all_settings', 'pg_read_all_stats', 'pg_stat_scan_tables', + -- Roles introduced in Postgres 11: + 'pg_execute_server_program', 'pg_read_server_files', 'pg_write_server_files' ); """) users = [u[0] for u in cursor.fetchall()] @@ -96,12 +98,19 @@ def base_spec(cursor): tables: - information_schema.* - pg_catalog.* + privileges: schemas: write: - information_schema - pg_catalog - public + tables: + write: + - information_schema.* + except: + - information_schema.pg_replication_origin + - information_schema.sql_languages test_user: attributes: @@ -112,8 +121,8 @@ def base_spec(cursor): # Postgres 10 introduces several new roles that we have to account for cursor.execute("SELECT substring(version from 'PostgreSQL ([0-9.]*) ') FROM version()") - pg_version = cursor.fetchone()[0] - if pg_version.startswith('10.'): + pg_version = int(cursor.fetchone()[0].split('.')[0]) + if pg_version >= 10: spec += dedent(""" pg_read_all_settings: @@ -128,6 +137,14 @@ def base_spec(cursor): - pg_stat_scan_tables - pg_read_all_stats """) + if pg_version >= 11: + spec += dedent(""" + pg_execute_server_program: + + pg_read_server_files: + + pg_write_server_files: + """) return spec