Squarespace / pgbedrock

Manage a Postgres cluster's roles, role memberships, schema ownership, and privileges
https://pgbedrock.readthedocs.io/en/latest/
Other
311 stars 35 forks source link

Add tests against latest stable releases of Postgres 11, 12, & 13 #67

Open richardmcmillen opened 3 years ago

richardmcmillen commented 3 years ago

TLDR; Add tests against latest stable releases of Postgres 11, 12, & 13

Thanks to this PR #59 for giving me a head start. However, I didn't end up integrating some of the changes in their diff. Unless I am missing something I believe it was how the test failures manifested which led them down the path of having to do the except ownership but I don't think this is necessary.

Although it should be restated that the tool probably does work fine on versions 11, 12, 13 and this change is more about allowing the project to prove this officially by updating the expectations in tests.

Diff explanation

The changes in the tests were driven by two things:

Concretely the differences can be seen by generating a spec from freshly initialized Postgres clusters. This uses parts of the Makefile already in the repository.

make create_network

for version in 10.4 11.11 12.6 13.2
do
  export POSTGRES_VERSION="$version"
  make start_postgres
  make wait_for_postgres
  docker run -it \
    --net pgbedrock_network \
    quay.io/squarespace/pgbedrock generate \
    -h pgbedrock_postgres \
    -p 5432 \
    -d test_db \
    -U test_user \
    -w test_password | tee "/tmp/postgres-$version.yml"
done

make stop_postgres remove_network

I will put the contents of each version here but the main difference is between 10.4 and 11.11. It appears that since version 11 the postgres superuser isn't created when given an alternative user through the POSTGRES_USER environment variable. As a consequence of this the user provided owns all the items which the postgres superuser would have before.

In addition to these changes, you can see that version 11 also introduces some new roles not existing in older versions.

postgres-10.4.yml ```yml # postgres-10.4.yml pg_monitor: member_of: - pg_read_all_settings - pg_read_all_stats - pg_stat_scan_tables pg_read_all_settings: pg_read_all_stats: pg_stat_scan_tables: postgres: attributes: - BYPASSRLS - CREATEDB - CREATEROLE - REPLICATION can_login: true is_superuser: true owns: schemas: - information_schema - pg_catalog - public tables: - information_schema.* - pg_catalog.* privileges: schemas: write: - information_schema - pg_catalog - public test_user: attributes: - PASSWORD "{{ env['TEST_USER_PASSWORD'] }}" can_login: true is_superuser: true ```
postgres-11.11.yml ```yml # postgres-11.11.yml pg_execute_server_program: pg_monitor: member_of: - pg_read_all_settings - pg_read_all_stats - pg_stat_scan_tables pg_read_all_settings: pg_read_all_stats: pg_read_server_files: pg_stat_scan_tables: pg_write_server_files: test_user: attributes: - BYPASSRLS - CREATEDB - CREATEROLE - PASSWORD "{{ env['TEST_USER_PASSWORD'] }}" - REPLICATION can_login: true is_superuser: true owns: schemas: - information_schema - pg_catalog - public tables: - information_schema.* - pg_catalog.* privileges: schemas: write: - information_schema - pg_catalog - public ```
postgres-12.6.yml ```yml # postgres-12.6.yml pg_execute_server_program: pg_monitor: member_of: - pg_read_all_settings - pg_read_all_stats - pg_stat_scan_tables pg_read_all_settings: pg_read_all_stats: pg_read_server_files: pg_stat_scan_tables: pg_write_server_files: test_user: attributes: - BYPASSRLS - CREATEDB - CREATEROLE - PASSWORD "{{ env['TEST_USER_PASSWORD'] }}" - REPLICATION can_login: true is_superuser: true owns: schemas: - information_schema - pg_catalog - public tables: - information_schema.* - pg_catalog.* privileges: schemas: write: - information_schema - pg_catalog - public ```
postgres-13.2.yml ```yml # postgres-13.2.yml pg_execute_server_program: pg_monitor: member_of: - pg_read_all_settings - pg_read_all_stats - pg_stat_scan_tables pg_read_all_settings: pg_read_all_stats: pg_read_server_files: pg_stat_scan_tables: pg_write_server_files: test_user: attributes: - BYPASSRLS - CREATEDB - CREATEROLE - PASSWORD "{{ env['TEST_USER_PASSWORD'] }}" - REPLICATION can_login: true is_superuser: true owns: schemas: - information_schema - pg_catalog - public tables: - information_schema.* - pg_catalog.* privileges: schemas: write: - information_schema - pg_catalog - public ```

Summary

The changes I have made here a very brute force attempt at getting everything working here so maybe there is a more elegant way to address these changes. For now, all the commits are marked WIP and I intend to tidy them up, squash them, update the docs, and add more code comments if the maintainers of the repository are interested in having this submission. It's just at this juncture I am unsure about the maintainer status of the project and so I don't want to sink too much time in unless there is a chance of getting things merged.

A general sidenote just to say that I love the idea of this project and it would be great to use if I can address some of the other issues (#3, #49, #17) which I am fairly motivated to do. Once again, many thanks. :)

coveralls commented 3 years ago

Pull Request Test Coverage Report for Build 228


Totals Coverage Status
Change from base Build 224: 0%
Covered Lines: 1278
Relevant Lines: 1322

💛 - Coveralls