From 0530a08b675341bd14b7deb6a3a0a7147cbfdb0d Mon Sep 17 00:00:00 2001 From: Andrey Klychkov Date: Mon, 23 Sep 2019 11:28:52 +0300 Subject: [PATCH] postgresql: move CI tests to separate targets (#62732) --- test/integration/targets/postgresql/aliases | 3 -- .../targets/postgresql/tasks/main.yml | 10 ------ .../targets/postgresql_sequence/aliases | 4 +++ .../postgresql_sequence/defaults/main.yml | 5 +++ .../targets/postgresql_sequence/meta/main.yml | 3 ++ .../postgresql_sequence/tasks/main.yml | 3 ++ .../tasks/postgresql_sequence_initial.yml} | 32 +++++++++++++------ .../targets/postgresql_set/aliases | 4 +++ .../targets/postgresql_set/meta/main.yml | 3 ++ .../targets/postgresql_set/tasks/main.yml | 3 ++ .../tasks/postgresql_set_initial.yml} | 0 .../targets/postgresql_table/aliases | 4 +++ .../targets/postgresql_table/meta/main.yml | 3 ++ .../targets/postgresql_table/tasks/main.yml | 2 ++ .../tasks/postgresql_table_initial.yml} | 26 +++++++++++++++ 15 files changed, 82 insertions(+), 23 deletions(-) create mode 100644 test/integration/targets/postgresql_sequence/aliases create mode 100644 test/integration/targets/postgresql_sequence/defaults/main.yml create mode 100644 test/integration/targets/postgresql_sequence/meta/main.yml create mode 100644 test/integration/targets/postgresql_sequence/tasks/main.yml rename test/integration/targets/{postgresql/tasks/postgresql_sequence.yml => postgresql_sequence/tasks/postgresql_sequence_initial.yml} (98%) create mode 100644 test/integration/targets/postgresql_set/aliases create mode 100644 test/integration/targets/postgresql_set/meta/main.yml create mode 100644 test/integration/targets/postgresql_set/tasks/main.yml rename test/integration/targets/{postgresql/tasks/postgresql_set.yml => postgresql_set/tasks/postgresql_set_initial.yml} (100%) create mode 100644 test/integration/targets/postgresql_table/aliases create mode 100644 test/integration/targets/postgresql_table/meta/main.yml create mode 100644 test/integration/targets/postgresql_table/tasks/main.yml rename test/integration/targets/{postgresql/tasks/postgresql_table.yml => postgresql_table/tasks/postgresql_table_initial.yml} (97%) diff --git a/test/integration/targets/postgresql/aliases b/test/integration/targets/postgresql/aliases index f33cab1a6a1..5d89a661e88 100644 --- a/test/integration/targets/postgresql/aliases +++ b/test/integration/targets/postgresql/aliases @@ -5,8 +5,5 @@ postgresql_lang postgresql_pg_hba postgresql_privs postgresql_schema -postgresql_sequence -postgresql_set -postgresql_table postgresql_user skip/osx diff --git a/test/integration/targets/postgresql/tasks/main.yml b/test/integration/targets/postgresql/tasks/main.yml index 73172e789d7..9e11fd03f1c 100644 --- a/test/integration/targets/postgresql/tasks/main.yml +++ b/test/integration/targets/postgresql/tasks/main.yml @@ -10,9 +10,6 @@ - ansible_os_family == 'Debian' - postgres_version_resp.stdout is version('9.4', '>=') -- include_tasks: postgresql_set.yml - when: postgres_version_resp.stdout is version('9.4', '>=') - - include_tasks: '{{ loop_item }}' loop: # Test postgresql_user module @@ -30,9 +27,6 @@ # Test postgresql_schema module - postgresql_schema.yml - # Test postgresql_table module - - postgresql_table.yml - # Test postgres_pg_hba module - postgresql_pg_hba.yml loop_control: @@ -42,10 +36,6 @@ - import_tasks: test_target_role.yml when: postgres_version_resp.stdout is version('9.1', '>=') -# Test postgresql_sequence module -- import_tasks: postgresql_sequence.yml - when: postgres_version_resp.stdout is version('9.0', '>=') - # Test postgresql_lang module. # To implement tests, it needs to install some additional packages # that may cause problems on different distributions, diff --git a/test/integration/targets/postgresql_sequence/aliases b/test/integration/targets/postgresql_sequence/aliases new file mode 100644 index 00000000000..d5dcfcf3431 --- /dev/null +++ b/test/integration/targets/postgresql_sequence/aliases @@ -0,0 +1,4 @@ +destructive +shippable/posix/group4 +postgresql_sequence +skip/osx diff --git a/test/integration/targets/postgresql_sequence/defaults/main.yml b/test/integration/targets/postgresql_sequence/defaults/main.yml new file mode 100644 index 00000000000..049b5531f60 --- /dev/null +++ b/test/integration/targets/postgresql_sequence/defaults/main.yml @@ -0,0 +1,5 @@ +--- +db_name: 'ansible_db' +db_user1: 'ansible_db_user1' +db_user2: 'ansible_db_user2' +db_default: 'postgres' diff --git a/test/integration/targets/postgresql_sequence/meta/main.yml b/test/integration/targets/postgresql_sequence/meta/main.yml new file mode 100644 index 00000000000..f3345cb6151 --- /dev/null +++ b/test/integration/targets/postgresql_sequence/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: +- setup_postgresql_db diff --git a/test/integration/targets/postgresql_sequence/tasks/main.yml b/test/integration/targets/postgresql_sequence/tasks/main.yml new file mode 100644 index 00000000000..0ff427e9a10 --- /dev/null +++ b/test/integration/targets/postgresql_sequence/tasks/main.yml @@ -0,0 +1,3 @@ +# Initial CI tests of postgresql_sequence module +- import_tasks: postgresql_sequence_initial.yml + when: postgres_version_resp.stdout is version('9.0', '>=') diff --git a/test/integration/targets/postgresql/tasks/postgresql_sequence.yml b/test/integration/targets/postgresql_sequence/tasks/postgresql_sequence_initial.yml similarity index 98% rename from test/integration/targets/postgresql/tasks/postgresql_sequence.yml rename to test/integration/targets/postgresql_sequence/tasks/postgresql_sequence_initial.yml index 4d8d8a4e062..29507391d88 100644 --- a/test/integration/targets/postgresql/tasks/postgresql_sequence.yml +++ b/test/integration/targets/postgresql_sequence/tasks/postgresql_sequence_initial.yml @@ -2,15 +2,6 @@ # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # Preparation for tests. -- name: postgresql_sequence - create DB - become_user: "{{ pg_user }}" - become: yes - postgresql_db: - state: present - name: "{{ db_name }}" - owner: "{{ db_user1 }}" - login_user: "{{ pg_user }}" - - name: postgresql_sequence - create a user to be owner of a database become_user: "{{ pg_user }}" become: yes @@ -20,7 +11,16 @@ encrypted: yes password: password role_attr_flags: LOGIN - db: "{{ db_name }}" + db: "{{ db_default }}" + login_user: "{{ pg_user }}" + +- name: postgresql_sequence - create DB + become_user: "{{ pg_user }}" + become: yes + postgresql_db: + state: present + name: "{{ db_name }}" + owner: "{{ db_user1 }}" login_user: "{{ pg_user }}" - name: Create a user to be owner of a sequence @@ -694,3 +694,15 @@ state: absent name: "{{ db_name }}" login_user: "{{ pg_user }}" + +- name: remove test roles + become_user: "{{ pg_user }}" + become: yes + postgresql_user: + state: absent + login_db: "{{ db_default }}" + login_user: "{{ pg_user }}" + name: "{{ item }}" + loop: + - "{{ db_user1 }}" + - "{{ db_user2 }}" diff --git a/test/integration/targets/postgresql_set/aliases b/test/integration/targets/postgresql_set/aliases new file mode 100644 index 00000000000..269d653bf44 --- /dev/null +++ b/test/integration/targets/postgresql_set/aliases @@ -0,0 +1,4 @@ +destructive +shippable/posix/group4 +postgresql_set +skip/osx diff --git a/test/integration/targets/postgresql_set/meta/main.yml b/test/integration/targets/postgresql_set/meta/main.yml new file mode 100644 index 00000000000..f3345cb6151 --- /dev/null +++ b/test/integration/targets/postgresql_set/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: +- setup_postgresql_db diff --git a/test/integration/targets/postgresql_set/tasks/main.yml b/test/integration/targets/postgresql_set/tasks/main.yml new file mode 100644 index 00000000000..33879be5434 --- /dev/null +++ b/test/integration/targets/postgresql_set/tasks/main.yml @@ -0,0 +1,3 @@ +# Initial CI tests of postgresql_initial module +- include_tasks: postgresql_set_initial.yml + when: postgres_version_resp.stdout is version('9.4', '>=') diff --git a/test/integration/targets/postgresql/tasks/postgresql_set.yml b/test/integration/targets/postgresql_set/tasks/postgresql_set_initial.yml similarity index 100% rename from test/integration/targets/postgresql/tasks/postgresql_set.yml rename to test/integration/targets/postgresql_set/tasks/postgresql_set_initial.yml diff --git a/test/integration/targets/postgresql_table/aliases b/test/integration/targets/postgresql_table/aliases new file mode 100644 index 00000000000..6b05d5230aa --- /dev/null +++ b/test/integration/targets/postgresql_table/aliases @@ -0,0 +1,4 @@ +destructive +shippable/posix/group4 +postgresql_table +skip/osx diff --git a/test/integration/targets/postgresql_table/meta/main.yml b/test/integration/targets/postgresql_table/meta/main.yml new file mode 100644 index 00000000000..f3345cb6151 --- /dev/null +++ b/test/integration/targets/postgresql_table/meta/main.yml @@ -0,0 +1,3 @@ +--- +dependencies: +- setup_postgresql_db diff --git a/test/integration/targets/postgresql_table/tasks/main.yml b/test/integration/targets/postgresql_table/tasks/main.yml new file mode 100644 index 00000000000..4d45389fa01 --- /dev/null +++ b/test/integration/targets/postgresql_table/tasks/main.yml @@ -0,0 +1,2 @@ +# Initial CI tests of postgresql_table module +- import_tasks: postgresql_table_initial.yml diff --git a/test/integration/targets/postgresql/tasks/postgresql_table.yml b/test/integration/targets/postgresql_table/tasks/postgresql_table_initial.yml similarity index 97% rename from test/integration/targets/postgresql/tasks/postgresql_table.yml rename to test/integration/targets/postgresql_table/tasks/postgresql_table_initial.yml index 919c145a444..aceee5fa603 100644 --- a/test/integration/targets/postgresql/tasks/postgresql_table.yml +++ b/test/integration/targets/postgresql_table/tasks/postgresql_table_initial.yml @@ -852,3 +852,29 @@ that: - result is changed - result.queries == ['ALTER TABLE "public"."test_schema_table" RENAME TO "new_test_schema_table"'] + +# +# Clean up +# +- name: postgresql_table - drop test schema + become_user: "{{ pg_user }}" + become: yes + postgresql_schema: + database: postgres + login_user: "{{ pg_user }}" + name: acme + state: absent + cascade_drop: yes + +- name: postgresql_table - drop test role + become_user: "{{ pg_user }}" + become: yes + postgresql_user: + db: postgres + login_user: "{{ pg_user }}" + name: "{{ item }}" + state: absent + loop: + - test_user + - alice + ignore_errors: yes