From 53ba3c46ccb01757c038ac939c8e5a82246d07b0 Mon Sep 17 00:00:00 2001 From: Andrey Klychkov Date: Wed, 25 Sep 2019 16:03:48 +0300 Subject: [PATCH] postgresql: move CI test to separate targets (#62823) --- .../aliases | 0 .../defaults/main.yml | 6 ----- .../meta/main.yml | 0 .../tasks/main.yml | 9 ------- .../tasks/pg_authid_not_readable.yml | 0 .../tasks/postgresql_db.yml | 0 .../tasks/postgresql_privs.yml | 0 .../tasks/postgresql_user.yml | 0 .../tasks/session_role.yml | 0 .../tasks/state_dump_restore.yml | 0 .../tasks/test_no_password_change.yml | 0 .../tasks/test_password.yml | 0 .../tasks/test_target_role.yml | 0 .../tasks/unsorted.yml | 0 .../tasks/postgresql_ping_initial.yml | 23 ++++++++++++++++++ .../setup_postgresql_db/defaults/main.yml | 6 +++++ .../setup_postgresql_db/tasks/main.yml | 9 +++++++ .../tasks/ssl.yml | 24 ------------------- 18 files changed, 38 insertions(+), 39 deletions(-) rename test/integration/targets/{postgresql => postgresql_db_user_privs}/aliases (100%) rename test/integration/targets/{postgresql => postgresql_db_user_privs}/defaults/main.yml (85%) rename test/integration/targets/{postgresql => postgresql_db_user_privs}/meta/main.yml (100%) rename test/integration/targets/{postgresql => postgresql_db_user_privs}/tasks/main.yml (76%) rename test/integration/targets/{postgresql => postgresql_db_user_privs}/tasks/pg_authid_not_readable.yml (100%) rename test/integration/targets/{postgresql => postgresql_db_user_privs}/tasks/postgresql_db.yml (100%) rename test/integration/targets/{postgresql => postgresql_db_user_privs}/tasks/postgresql_privs.yml (100%) rename test/integration/targets/{postgresql => postgresql_db_user_privs}/tasks/postgresql_user.yml (100%) rename test/integration/targets/{postgresql => postgresql_db_user_privs}/tasks/session_role.yml (100%) rename test/integration/targets/{postgresql => postgresql_db_user_privs}/tasks/state_dump_restore.yml (100%) rename test/integration/targets/{postgresql => postgresql_db_user_privs}/tasks/test_no_password_change.yml (100%) rename test/integration/targets/{postgresql => postgresql_db_user_privs}/tasks/test_password.yml (100%) rename test/integration/targets/{postgresql => postgresql_db_user_privs}/tasks/test_target_role.yml (100%) rename test/integration/targets/{postgresql => postgresql_db_user_privs}/tasks/unsorted.yml (100%) rename test/integration/targets/{postgresql => setup_postgresql_db}/tasks/ssl.yml (81%) diff --git a/test/integration/targets/postgresql/aliases b/test/integration/targets/postgresql_db_user_privs/aliases similarity index 100% rename from test/integration/targets/postgresql/aliases rename to test/integration/targets/postgresql_db_user_privs/aliases diff --git a/test/integration/targets/postgresql/defaults/main.yml b/test/integration/targets/postgresql_db_user_privs/defaults/main.yml similarity index 85% rename from test/integration/targets/postgresql/defaults/main.yml rename to test/integration/targets/postgresql_db_user_privs/defaults/main.yml index 9a0adb34b5c..3f58d7eecb9 100644 --- a/test/integration/targets/postgresql/defaults/main.yml +++ b/test/integration/targets/postgresql_db_user_privs/defaults/main.yml @@ -32,9 +32,3 @@ pg_hba_test_ips: - source: '172.16.0.0' netmask: '255.255.0.0' method: trust - -# defaults for test SSL -ssl_db: 'ssl_db' -ssl_user: 'ssl_user' -ssl_pass: 'ssl_pass' -ssl_rootcert: '~{{ pg_user }}/root.crt' diff --git a/test/integration/targets/postgresql/meta/main.yml b/test/integration/targets/postgresql_db_user_privs/meta/main.yml similarity index 100% rename from test/integration/targets/postgresql/meta/main.yml rename to test/integration/targets/postgresql_db_user_privs/meta/main.yml diff --git a/test/integration/targets/postgresql/tasks/main.yml b/test/integration/targets/postgresql_db_user_privs/tasks/main.yml similarity index 76% rename from test/integration/targets/postgresql/tasks/main.yml rename to test/integration/targets/postgresql_db_user_privs/tasks/main.yml index c734057846b..86c89d31b6a 100644 --- a/test/integration/targets/postgresql/tasks/main.yml +++ b/test/integration/targets/postgresql_db_user_privs/tasks/main.yml @@ -1,15 +1,6 @@ # Unsorted tests that were moved from here to unsorted.yml - import_tasks: unsorted.yml -# Test ssl. -# Restricted using Debian family because of there are errors on other distributions -# that not related with PostgreSQL or psycopg2 SSL support. -# The tests' key point is to be sure that ssl options work in general -- import_tasks: ssl.yml - when: - - ansible_os_family == 'Debian' - - postgres_version_resp.stdout is version('9.4', '>=') - - include_tasks: '{{ loop_item }}' loop: # Test postgresql_user module diff --git a/test/integration/targets/postgresql/tasks/pg_authid_not_readable.yml b/test/integration/targets/postgresql_db_user_privs/tasks/pg_authid_not_readable.yml similarity index 100% rename from test/integration/targets/postgresql/tasks/pg_authid_not_readable.yml rename to test/integration/targets/postgresql_db_user_privs/tasks/pg_authid_not_readable.yml diff --git a/test/integration/targets/postgresql/tasks/postgresql_db.yml b/test/integration/targets/postgresql_db_user_privs/tasks/postgresql_db.yml similarity index 100% rename from test/integration/targets/postgresql/tasks/postgresql_db.yml rename to test/integration/targets/postgresql_db_user_privs/tasks/postgresql_db.yml diff --git a/test/integration/targets/postgresql/tasks/postgresql_privs.yml b/test/integration/targets/postgresql_db_user_privs/tasks/postgresql_privs.yml similarity index 100% rename from test/integration/targets/postgresql/tasks/postgresql_privs.yml rename to test/integration/targets/postgresql_db_user_privs/tasks/postgresql_privs.yml diff --git a/test/integration/targets/postgresql/tasks/postgresql_user.yml b/test/integration/targets/postgresql_db_user_privs/tasks/postgresql_user.yml similarity index 100% rename from test/integration/targets/postgresql/tasks/postgresql_user.yml rename to test/integration/targets/postgresql_db_user_privs/tasks/postgresql_user.yml diff --git a/test/integration/targets/postgresql/tasks/session_role.yml b/test/integration/targets/postgresql_db_user_privs/tasks/session_role.yml similarity index 100% rename from test/integration/targets/postgresql/tasks/session_role.yml rename to test/integration/targets/postgresql_db_user_privs/tasks/session_role.yml diff --git a/test/integration/targets/postgresql/tasks/state_dump_restore.yml b/test/integration/targets/postgresql_db_user_privs/tasks/state_dump_restore.yml similarity index 100% rename from test/integration/targets/postgresql/tasks/state_dump_restore.yml rename to test/integration/targets/postgresql_db_user_privs/tasks/state_dump_restore.yml diff --git a/test/integration/targets/postgresql/tasks/test_no_password_change.yml b/test/integration/targets/postgresql_db_user_privs/tasks/test_no_password_change.yml similarity index 100% rename from test/integration/targets/postgresql/tasks/test_no_password_change.yml rename to test/integration/targets/postgresql_db_user_privs/tasks/test_no_password_change.yml diff --git a/test/integration/targets/postgresql/tasks/test_password.yml b/test/integration/targets/postgresql_db_user_privs/tasks/test_password.yml similarity index 100% rename from test/integration/targets/postgresql/tasks/test_password.yml rename to test/integration/targets/postgresql_db_user_privs/tasks/test_password.yml diff --git a/test/integration/targets/postgresql/tasks/test_target_role.yml b/test/integration/targets/postgresql_db_user_privs/tasks/test_target_role.yml similarity index 100% rename from test/integration/targets/postgresql/tasks/test_target_role.yml rename to test/integration/targets/postgresql_db_user_privs/tasks/test_target_role.yml diff --git a/test/integration/targets/postgresql/tasks/unsorted.yml b/test/integration/targets/postgresql_db_user_privs/tasks/unsorted.yml similarity index 100% rename from test/integration/targets/postgresql/tasks/unsorted.yml rename to test/integration/targets/postgresql_db_user_privs/tasks/unsorted.yml diff --git a/test/integration/targets/postgresql_ping/tasks/postgresql_ping_initial.yml b/test/integration/targets/postgresql_ping/tasks/postgresql_ping_initial.yml index c2105ee25bf..346134eb4e8 100644 --- a/test/integration/targets/postgresql_ping/tasks/postgresql_ping_initial.yml +++ b/test/integration/targets/postgresql_ping/tasks/postgresql_ping_initial.yml @@ -33,3 +33,26 @@ - result.is_available == false - result.server_version == {} - result is not changed + +- name: postgresql_ping - ping DB with SSL + become_user: "{{ pg_user }}" + become: yes + postgresql_ping: + db: "{{ ssl_db }}" + login_user: "{{ ssl_user }}" + login_password: "{{ ssl_pass }}" + login_host: 127.0.0.1 + login_port: 5432 + ssl_mode: require + ca_cert: '{{ ssl_rootcert }}' + register: result + when: + - ansible_os_family == 'Debian' + - postgres_version_resp.stdout is version('9.4', '>=') + +- assert: + that: + - result.is_available == true + when: + - ansible_os_family == 'Debian' + - postgres_version_resp.stdout is version('9.4', '>=') diff --git a/test/integration/targets/setup_postgresql_db/defaults/main.yml b/test/integration/targets/setup_postgresql_db/defaults/main.yml index 83055f7787e..aea02442807 100644 --- a/test/integration/targets/setup_postgresql_db/defaults/main.yml +++ b/test/integration/targets/setup_postgresql_db/defaults/main.yml @@ -9,3 +9,9 @@ pg_group: root locale_latin_suffix: locale_utf8_suffix: + +# defaults for test SSL +ssl_db: 'ssl_db' +ssl_user: 'ssl_user' +ssl_pass: 'ssl_pass' +ssl_rootcert: '~{{ pg_user }}/root.crt' diff --git a/test/integration/targets/setup_postgresql_db/tasks/main.yml b/test/integration/targets/setup_postgresql_db/tasks/main.yml index 25b7b4bccda..9b43a7bd205 100644 --- a/test/integration/targets/setup_postgresql_db/tasks/main.yml +++ b/test/integration/targets/setup_postgresql_db/tasks/main.yml @@ -190,3 +190,12 @@ - name: Print PostgreSQL server version debug: msg: "{{ postgres_version_resp.stdout }}" + +# SSL configuration. +# Restricted using Debian family because of there are errors on other distributions +# that not related with PostgreSQL or psycopg2 SSL support. +# The tests key point is to be sure that ssl options work in general +- import_tasks: ssl.yml + when: + - ansible_os_family == 'Debian' + - postgres_version_resp.stdout is version('9.4', '>=') diff --git a/test/integration/targets/postgresql/tasks/ssl.yml b/test/integration/targets/setup_postgresql_db/tasks/ssl.yml similarity index 81% rename from test/integration/targets/postgresql/tasks/ssl.yml rename to test/integration/targets/setup_postgresql_db/tasks/ssl.yml index 3a5e5e4da08..bc45ec6f4b4 100644 --- a/test/integration/targets/postgresql/tasks/ssl.yml +++ b/test/integration/targets/setup_postgresql_db/tasks/ssl.yml @@ -79,27 +79,3 @@ service: name: "{{ postgresql_service }}" state: reloaded - -############### -# Do main tests - -- name: postgresql SSL - ping DB with SSL - become_user: "{{ pg_user }}" - become: yes - postgresql_ping: - db: "{{ ssl_db }}" - login_user: "{{ ssl_user }}" - login_password: "{{ ssl_pass }}" - login_host: 127.0.0.1 - login_port: 5432 - ssl_mode: require - ca_cert: '{{ ssl_rootcert }}' - register: result - -- assert: - that: - - result.is_available == true - -################################################### -# I decided not to clean ssl_db, ssl_user and certs -# for testing options related with SSL in other modules