mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 12:50:22 -07:00
Initial commit
This commit is contained in:
commit
aebc1b03fd
4861 changed files with 812621 additions and 0 deletions
7
tests/integration/targets/postgresql_info/tasks/main.yml
Normal file
7
tests/integration/targets/postgresql_info/tasks/main.yml
Normal file
|
@ -0,0 +1,7 @@
|
|||
# For testing getting publication and subscription info
|
||||
- import_tasks: setup_publication.yml
|
||||
when: ansible_distribution == 'Ubuntu' and ansible_distribution_major_version >= '18'
|
||||
|
||||
# Initial CI tests of postgresql_info module
|
||||
- import_tasks: postgresql_info_initial.yml
|
||||
when: ansible_distribution == 'Ubuntu' and ansible_distribution_major_version >= '18'
|
|
@ -0,0 +1,154 @@
|
|||
# Copyright: (c) 2020, Andrew Klychkov (@Andersson007) <aaklychkov@mail.ru>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
- vars:
|
||||
task_parameters: &task_parameters
|
||||
become_user: '{{ pg_user }}'
|
||||
become: yes
|
||||
register: result
|
||||
pg_parameters: &pg_parameters
|
||||
login_user: '{{ pg_user }}'
|
||||
login_db: '{{ db_default }}'
|
||||
|
||||
block:
|
||||
|
||||
- name: Create test subscription
|
||||
<<: *task_parameters
|
||||
postgresql_subscription:
|
||||
<<: *pg_parameters
|
||||
login_port: '{{ replica_port }}'
|
||||
name: '{{ test_subscription }}'
|
||||
login_db: '{{ test_db }}'
|
||||
state: present
|
||||
publications: '{{ test_pub }}'
|
||||
connparams:
|
||||
host: 127.0.0.1
|
||||
port: '{{ master_port }}'
|
||||
user: '{{ replication_role }}'
|
||||
password: '{{ replication_pass }}'
|
||||
dbname: '{{ test_db }}'
|
||||
|
||||
- name: Create test subscription
|
||||
<<: *task_parameters
|
||||
postgresql_subscription:
|
||||
<<: *pg_parameters
|
||||
login_port: '{{ replica_port }}'
|
||||
name: '{{ test_subscription2 }}'
|
||||
login_db: '{{ test_db }}'
|
||||
state: present
|
||||
publications: '{{ test_pub2 }}'
|
||||
connparams:
|
||||
host: 127.0.0.1
|
||||
port: '{{ master_port }}'
|
||||
user: '{{ replication_role }}'
|
||||
password: '{{ replication_pass }}'
|
||||
dbname: '{{ test_db }}'
|
||||
|
||||
- name: postgresql_info - create role to check session_role
|
||||
<<: *task_parameters
|
||||
postgresql_user:
|
||||
<<: *pg_parameters
|
||||
login_port: '{{ replica_port }}'
|
||||
login_user: "{{ pg_user }}"
|
||||
name: session_superuser
|
||||
role_attr_flags: SUPERUSER
|
||||
|
||||
- name: postgresql_info - test return values and session_role param
|
||||
<<: *task_parameters
|
||||
postgresql_info:
|
||||
<<: *pg_parameters
|
||||
login_port: '{{ replica_port }}'
|
||||
session_role: session_superuser
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.version != {}
|
||||
- result.databases.{{ db_default }}.collate
|
||||
- result.databases.{{ db_default }}.languages
|
||||
- result.databases.{{ db_default }}.namespaces
|
||||
- result.databases.{{ db_default }}.extensions
|
||||
- result.databases.{{ test_db }}.subscriptions.{{ test_subscription }}
|
||||
- result.databases.{{ test_db }}.subscriptions.{{ test_subscription2 }}
|
||||
- result.settings
|
||||
- result.tablespaces
|
||||
- result.roles
|
||||
|
||||
- name: postgresql_info - check filter param passed by list
|
||||
<<: *task_parameters
|
||||
postgresql_info:
|
||||
<<: *pg_parameters
|
||||
login_port: '{{ replica_port }}'
|
||||
filter:
|
||||
- ver*
|
||||
- rol*
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.version != {}
|
||||
- result.roles
|
||||
- result.databases == {}
|
||||
- result.repl_slots == {}
|
||||
- result.replications == {}
|
||||
- result.settings == {}
|
||||
- result.tablespaces == {}
|
||||
|
||||
- name: postgresql_info - check filter param passed by string
|
||||
<<: *task_parameters
|
||||
postgresql_info:
|
||||
<<: *pg_parameters
|
||||
filter: ver*,role*
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.version != {}
|
||||
- result.roles
|
||||
- result.databases == {}
|
||||
- result.repl_slots == {}
|
||||
- result.replications == {}
|
||||
- result.settings == {}
|
||||
- result.tablespaces == {}
|
||||
|
||||
- name: postgresql_info - check filter param passed by string
|
||||
<<: *task_parameters
|
||||
postgresql_info:
|
||||
<<: *pg_parameters
|
||||
filter: ver*
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.version
|
||||
- result.roles == {}
|
||||
|
||||
- name: postgresql_info - check excluding filter param passed by list
|
||||
<<: *task_parameters
|
||||
postgresql_info:
|
||||
<<: *pg_parameters
|
||||
filter:
|
||||
- "!ver*"
|
||||
- "!rol*"
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.version == {}
|
||||
- result.roles == {}
|
||||
- result.databases
|
||||
|
||||
- name: postgresql_info - test return publication info
|
||||
<<: *task_parameters
|
||||
postgresql_info:
|
||||
<<: *pg_parameters
|
||||
login_db: '{{ test_db }}'
|
||||
login_port: '{{ master_port }}'
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.version != {}
|
||||
- result.databases.{{ db_default }}.collate
|
||||
- result.databases.{{ db_default }}.languages
|
||||
- result.databases.{{ db_default }}.namespaces
|
||||
- result.databases.{{ db_default }}.extensions
|
||||
- result.databases.{{ test_db }}.publications.{{ test_pub }}.ownername == '{{ pg_user }}'
|
||||
- result.databases.{{ test_db }}.publications.{{ test_pub2 }}.puballtables == true
|
||||
- result.settings
|
||||
- result.tablespaces
|
||||
- result.roles
|
|
@ -0,0 +1,61 @@
|
|||
# Copyright: (c) 2019, Andrew Klychkov (@Andersson007) <aaklychkov@mail.ru>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
# Preparation for further tests of postgresql_subscription module.
|
||||
|
||||
- vars:
|
||||
task_parameters: &task_parameters
|
||||
become_user: '{{ pg_user }}'
|
||||
become: yes
|
||||
register: result
|
||||
pg_parameters: &pg_parameters
|
||||
login_user: '{{ pg_user }}'
|
||||
login_db: '{{ test_db }}'
|
||||
|
||||
block:
|
||||
- name: Create test db
|
||||
<<: *task_parameters
|
||||
postgresql_db:
|
||||
login_user: '{{ pg_user }}'
|
||||
login_port: '{{ master_port }}'
|
||||
maintenance_db: '{{ db_default }}'
|
||||
name: '{{ test_db }}'
|
||||
|
||||
- name: Create test role
|
||||
<<: *task_parameters
|
||||
postgresql_user:
|
||||
<<: *pg_parameters
|
||||
login_port: '{{ master_port }}'
|
||||
name: '{{ replication_role }}'
|
||||
password: '{{ replication_pass }}'
|
||||
role_attr_flags: LOGIN,REPLICATION
|
||||
|
||||
- name: Create test table
|
||||
<<: *task_parameters
|
||||
postgresql_table:
|
||||
<<: *pg_parameters
|
||||
login_port: '{{ master_port }}'
|
||||
name: '{{ test_table1 }}'
|
||||
columns:
|
||||
- id int
|
||||
|
||||
- name: Master - dump schema
|
||||
<<: *task_parameters
|
||||
shell: pg_dumpall -p '{{ master_port }}' -s > /tmp/schema.sql
|
||||
|
||||
- name: Replicat restore schema
|
||||
<<: *task_parameters
|
||||
shell: psql -p '{{ replica_port }}' -f /tmp/schema.sql
|
||||
|
||||
- name: Create publication
|
||||
<<: *task_parameters
|
||||
postgresql_publication:
|
||||
<<: *pg_parameters
|
||||
login_port: '{{ master_port }}'
|
||||
name: '{{ test_pub }}'
|
||||
|
||||
- name: Create publication
|
||||
<<: *task_parameters
|
||||
postgresql_publication:
|
||||
<<: *pg_parameters
|
||||
login_port: '{{ master_port }}'
|
||||
name: '{{ test_pub2 }}'
|
Loading…
Add table
Add a link
Reference in a new issue