Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Postgresql modules: tidying up of CI tests #59099

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
964 changes: 85 additions & 879 deletions test/integration/targets/postgresql/tasks/main.yml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- name: "Admin user is allowed to access pg_authid relation: password comparison will succeed, password won't be updated"
become_user: "{{ pg_user }}"
become: True
become: yes
postgresql_user:
name: "{{ db_user1 }}"
encrypted: 'yes'
Expand All @@ -21,7 +21,7 @@
shell: 'psql -c "select * from pg_authid;" {{ db_name }} {{ db_user1 }}'
environment:
PGPASSWORD: '{{ db_password }}'
ignore_errors: True
ignore_errors: yes
register: pg_authid

- assert:
Expand All @@ -31,7 +31,7 @@

- name: "Normal user isn't allowed to access pg_authid relation: password comparison will fail, password will be updated"
become_user: "{{ pg_user }}"
become: True
become: yes
postgresql_user:
name: "{{ db_user1 }}"
encrypted: 'yes'
Expand Down
16 changes: 8 additions & 8 deletions test/integration/targets/postgresql/tasks/postgresql_copy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
data_file_csv: /tmp/data.csv
task_parameters: &task_parameters
become_user: '{{ pg_user }}'
become: True
become: yes
register: result
pg_parameters: &pg_parameters
login_user: '{{ pg_user }}'
Expand Down Expand Up @@ -55,7 +55,7 @@

- assert:
that:
- result.changed == true
- result is changed

# check that nothing changed after the previous step:
- name: postgresql_copy - check that data_file_txt doesn't exist
Expand All @@ -79,7 +79,7 @@

- assert:
that:
- result.changed == true
- result is changed

# check that nothing changed after the previous step:
- name: postgresql_copy - check that test table continue to have one row
Expand Down Expand Up @@ -116,7 +116,7 @@

- assert:
that:
- result.changed == true
- result is changed
- result.queries == ["COPY \"{{ test_table }}\" TO '{{ data_file_txt }}'"]
- result.src == '{{ test_table }}'
- result.dst == '{{ data_file_txt }}'
Expand Down Expand Up @@ -145,7 +145,7 @@

- assert:
that:
- result.changed == true
- result is changed
- result.queries == ["COPY \"{{ test_table }}\" (id,name) TO '{{ data_file_csv }}' (format csv)"]
- result.src == '{{ test_table }}'
- result.dst == '{{ data_file_csv }}'
Expand Down Expand Up @@ -173,7 +173,7 @@

- assert:
that:
- result.changed == true
- result is changed
- result.queries == ["COPY \"{{ test_table }}\" (id,name) FROM '{{ data_file_csv }}' (format csv)"]
- result.dst == '{{ test_table }}'
- result.src == '{{ data_file_csv }}'
Expand Down Expand Up @@ -202,7 +202,7 @@

- assert:
that:
- result.changed == true
- result is changed
- result.queries == ["COPY \"{{ test_table }}\" (id, name) TO PROGRAM '/bin/true' (delimiter '|')"]
- result.src == '{{ test_table }}'
- result.dst == '/bin/true'
Expand All @@ -221,7 +221,7 @@

- assert:
that:
- result.changed == true
- result is changed
- result.queries == ["COPY \"{{ test_table }}\" (id, name) FROM PROGRAM 'echo 1,first' (delimiter ',')"]
- result.dst == '{{ test_table }}'
- result.src == 'echo 1,first'
Expand Down
12 changes: 6 additions & 6 deletions test/integration/targets/postgresql/tasks/postgresql_db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
db_name: acme
block_parameters: &block_parameters
become_user: "{{ pg_user }}"
become: True
become: yes
task_parameters: &task_parameters
register: result
pg_parameters: &pg_parameters
Expand Down Expand Up @@ -37,7 +37,7 @@

- assert:
that:
- result.changed == true
- result is changed

- name: postgresql_db_tablespace - Check actual DB tablespace, rowcount must be 0 because actually nothing changed
<<: *task_parameters
Expand All @@ -64,7 +64,7 @@

- assert:
that:
- result.changed == true
- result is changed

- name: postgresql_db_tablespace - Check actual DB tablespace, rowcount must be 1
<<: *task_parameters
Expand All @@ -91,7 +91,7 @@

- assert:
that:
- result.changed == false
- result is not changed

# Try to change tablespace in check_mode:
- name: postgresql_db_tablespace - Change tablespace in check_mode
Expand All @@ -105,7 +105,7 @@

- assert:
that:
- result.changed == true
- result is changed

- name: postgresql_db_tablespace - Check actual DB tablespace, rowcount must be 1 because actually nothing changed
<<: *task_parameters
Expand All @@ -132,7 +132,7 @@

- assert:
that:
- result.changed == true
- result is changed

- name: postgresql_db_tablespace - Check actual DB tablespace, rowcount must be 1
<<: *task_parameters
Expand Down
12 changes: 6 additions & 6 deletions test/integration/targets/postgresql/tasks/postgresql_ext.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

- assert:
that:
- result.changed == true
- result is changed
- result.queries == []

# Check that extension doesn't exist after the previous step, rowcount must be 0
Expand Down Expand Up @@ -73,7 +73,7 @@

- assert:
that:
- result.changed == true
- result is changed
- result.queries == ['CREATE EXTENSION "postgis"']

# Check that extension exists after the previous step, rowcount must be 1
Expand Down Expand Up @@ -103,7 +103,7 @@

- assert:
that:
- result.changed == true
- result is changed
- result.queries == ['DROP EXTENSION "postgis"']

# Check that extension doesn't exist after the previous step, rowcount must be 0
Expand Down Expand Up @@ -133,7 +133,7 @@

- assert:
that:
- result.changed == true
- result is changed
- result.queries == ['CREATE EXTENSION "postgis" WITH SCHEMA "schema1"']

# Check that extension exists after the previous step, rowcount must be 1
Expand Down Expand Up @@ -174,7 +174,7 @@

- assert:
that:
- result.changed == true
- result is changed
- result.queries == ['DROP EXTENSION "postgis" CASCADE']

# Check that extension doesn't exist after the previous step, rowcount must be 0
Expand Down Expand Up @@ -206,7 +206,7 @@

- assert:
that:
- result.changed == true
- result is changed
- result.queries == ['CREATE EXTENSION "postgis" CASCADE"']
when: postgres_version_resp.stdout is version('9.6', '<=')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
test_schema: schema1
task_parameters: &task_parameters
become_user: '{{ pg_user }}'
become: True
become: yes
register: result
pg_parameters: &pg_parameters
login_user: '{{ pg_user }}'
Expand All @@ -28,12 +28,12 @@
<<: *pg_parameters
name: "{{ test_ext }}"
schema: "{{ test_schema }}"
version: 1.0
version: '1.0'
check_mode: yes

- assert:
that:
- result.changed == true
- result is changed

- name: postgresql_ext_version - check that nothing was actually changed
<<: *task_parameters
Expand All @@ -51,11 +51,11 @@
<<: *pg_parameters
name: "{{ test_ext }}"
schema: "{{ test_schema }}"
version: 1.0
version: '1.0'

- assert:
that:
- result.changed == true
- result is changed
- result.queries == ["CREATE EXTENSION \"{{ test_ext }}\" WITH SCHEMA \"{{ test_schema }}\" VERSION '1.0'"]

- name: postgresql_ext_version - check
Expand All @@ -74,12 +74,12 @@
<<: *pg_parameters
name: "{{ test_ext }}"
schema: "{{ test_schema }}"
version: 1.0
version: '1.0'
check_mode: yes

- assert:
that:
- result.changed == false
- result is not changed

- name: postgresql_ext_version - check
<<: *task_parameters
Expand All @@ -97,11 +97,11 @@
<<: *pg_parameters
name: "{{ test_ext }}"
schema: "{{ test_schema }}"
version: 1.0
version: '1.0'

- assert:
that:
- result.changed == false
- result is not changed

- name: postgresql_ext_version - check
<<: *task_parameters
Expand All @@ -119,12 +119,12 @@
<<: *pg_parameters
name: "{{ test_ext }}"
schema: "{{ test_schema }}"
version: 2.0
version: '2.0'
check_mode: yes

- assert:
that:
- result.changed == true
- result is changed

- name: postgresql_ext_version - check, the version must be 1.0
<<: *task_parameters
Expand All @@ -142,11 +142,11 @@
<<: *pg_parameters
name: "{{ test_ext }}"
schema: "{{ test_schema }}"
version: 2.0
version: '2.0'

- assert:
that:
- result.changed == true
- result is changed
- result.queries == ["ALTER EXTENSION \"{{ test_ext }}\" UPDATE TO '2.0'"]

- name: postgresql_ext_version - check, the version must be 2.0
Expand All @@ -168,7 +168,7 @@

- assert:
that:
- result.changed == false
- result is not changed

- name: postgresql_ext_version - check, the version must be 2.0
<<: *task_parameters
Expand All @@ -190,7 +190,7 @@

- assert:
that:
- result.changed == true
- result is changed
- result.queries == ["ALTER EXTENSION \"{{ test_ext }}\" UPDATE TO '3.0'"]

- name: postgresql_ext_version - check
Expand All @@ -213,15 +213,15 @@

- assert:
that:
- result.changed == false
- result is not changed

- name: postgresql_ext_version - try to downgrade the extension version, must fail
<<: *task_parameters
postgresql_ext:
<<: *pg_parameters
name: "{{ test_ext }}"
schema: "{{ test_schema }}"
version: 1.0
version: '1.0'
ignore_errors: yes

- assert:
Expand All @@ -238,7 +238,7 @@

- assert:
that:
- result.changed == true
- result is changed

- name: postgresql_ext_version - check that extension exists
<<: *task_parameters
Expand All @@ -259,7 +259,7 @@

- assert:
that:
- result.changed == true
- result is changed

- name: postgresql_ext_version - check that extension doesn't exist after the prev step
<<: *task_parameters
Expand All @@ -280,7 +280,7 @@

- assert:
that:
- result.changed == false
- result is not changed

- name: postgresql_ext_version - create the extension without passing version
<<: *task_parameters
Expand All @@ -290,7 +290,7 @@

- assert:
that:
- result.changed == true
- result is changed
- result.queries == ["CREATE EXTENSION \"{{ test_ext }}\""]

- name: postgresql_ext_version - check
Expand Down