mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-04-28 05:11:26 -07:00
Add unique test names
This commit is contained in:
parent
a646e76e87
commit
91e76d190e
2 changed files with 90 additions and 77 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
# Copyright: (c) 2019, Andrew Klychkov (@Andersson007) <aaklychkov@mail.ru>
|
# 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)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
|
@ -85,7 +86,8 @@
|
||||||
mode: getprimary
|
mode: getprimary
|
||||||
register: mysql_primary_status
|
register: mysql_primary_status
|
||||||
|
|
||||||
- assert:
|
- name: Assert that primary is in expected state
|
||||||
|
assert:
|
||||||
that:
|
that:
|
||||||
- mysql_primary_status.Is_Primary == true
|
- mysql_primary_status.Is_Primary == true
|
||||||
- mysql_primary_status.Position != 0
|
- mysql_primary_status.Position != 0
|
||||||
|
@ -102,7 +104,8 @@
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
|
|
||||||
- assert:
|
- name: Assert that startreplica is failed
|
||||||
|
assert:
|
||||||
that:
|
that:
|
||||||
- result is failed
|
- result is failed
|
||||||
|
|
||||||
|
@ -115,7 +118,8 @@
|
||||||
fail_on_error: no
|
fail_on_error: no
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert that startreplica succeeded
|
||||||
|
assert:
|
||||||
that:
|
that:
|
||||||
- result is not failed
|
- result is not failed
|
||||||
|
|
||||||
|
@ -128,7 +132,8 @@
|
||||||
mode: startreplica
|
mode: startreplica
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert that start replica succeeded again
|
||||||
|
assert:
|
||||||
that:
|
that:
|
||||||
- result is not failed
|
- result is not failed
|
||||||
|
|
||||||
|
@ -150,7 +155,8 @@
|
||||||
primary_ssl: no
|
primary_ssl: no
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert that changeprimmary is changed and return expected query
|
||||||
|
assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
- result.queries == ["CHANGE MASTER TO MASTER_HOST='{{ mysql_host }}',MASTER_USER='{{ replication_user }}',MASTER_PASSWORD='********',MASTER_PORT={{ mysql_primary_port }},MASTER_LOG_FILE='{{ mysql_primary_status.File }}',MASTER_LOG_POS={{ mysql_primary_status.Position }},MASTER_SSL=0,MASTER_SSL_CA=''"]
|
- result.queries == ["CHANGE MASTER TO MASTER_HOST='{{ mysql_host }}',MASTER_USER='{{ replication_user }}',MASTER_PASSWORD='********',MASTER_PORT={{ mysql_primary_port }},MASTER_LOG_FILE='{{ mysql_primary_status.File }}',MASTER_LOG_POS={{ mysql_primary_status.Position }},MASTER_SSL=0,MASTER_SSL_CA=''"]
|
||||||
|
@ -163,7 +169,8 @@
|
||||||
mode: startreplica
|
mode: startreplica
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert that startreplica is changed and returns expected query
|
||||||
|
assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
- result.queries == ["START SLAVE"] or result.queries == ["START REPLICA"]
|
- result.queries == ["START SLAVE"] or result.queries == ["START REPLICA"]
|
||||||
|
@ -176,7 +183,8 @@
|
||||||
mode: getreplica
|
mode: getreplica
|
||||||
register: replica_status
|
register: replica_status
|
||||||
|
|
||||||
- assert:
|
- name: Assert that getreplica returns expected values for MySQL older than 8.0.22 and Mariadb
|
||||||
|
assert:
|
||||||
that:
|
that:
|
||||||
- replica_status.Is_Replica == true
|
- replica_status.Is_Replica == true
|
||||||
- replica_status.Master_Host == '{{ mysql_host }}'
|
- replica_status.Master_Host == '{{ mysql_host }}'
|
||||||
|
@ -187,7 +195,8 @@
|
||||||
- replica_status is not changed
|
- replica_status is not changed
|
||||||
when: mysql8022_and_higher == false
|
when: mysql8022_and_higher == false
|
||||||
|
|
||||||
- assert:
|
- name: Assert that getreplica returns expected values for MySQL newer than 8.0.22
|
||||||
|
assert:
|
||||||
that:
|
that:
|
||||||
- replica_status.Is_Replica == true
|
- replica_status.Is_Replica == true
|
||||||
- replica_status.Source_Host == '{{ mysql_host }}'
|
- replica_status.Source_Host == '{{ mysql_host }}'
|
||||||
|
@ -219,19 +228,18 @@
|
||||||
|
|
||||||
# mysql_primary_status.Position is not actual and it has been changed by the prev step,
|
# mysql_primary_status.Position is not actual and it has been changed by the prev step,
|
||||||
# so replica_status.Exec_Master_Log_Pos must be different:
|
# so replica_status.Exec_Master_Log_Pos must be different:
|
||||||
- assert:
|
- name: Assert that getreplica Log_Pos is different for MySQL older than 8.0.22 and MariaDB
|
||||||
|
assert:
|
||||||
that:
|
that:
|
||||||
- replica_status.Exec_Master_Log_Pos != mysql_primary_status.Position
|
- replica_status.Exec_Master_Log_Pos != mysql_primary_status.Position
|
||||||
when: mysql8022_and_higher == false
|
when: mysql8022_and_higher == false
|
||||||
|
|
||||||
- assert:
|
- name: Assert that getreplica Log_Pos is different for MySQL newer than 8.0.22
|
||||||
|
assert:
|
||||||
that:
|
that:
|
||||||
- replica_status.Exec_Source_Log_Pos != mysql_primary_status.Position
|
- replica_status.Exec_Source_Log_Pos != mysql_primary_status.Position
|
||||||
when: mysql8022_and_higher == true
|
when: mysql8022_and_higher == true
|
||||||
|
|
||||||
- shell: pip show pymysql | awk '/Version/ {print $2}'
|
|
||||||
register: pymysql_version
|
|
||||||
|
|
||||||
- name: Start replica that is already running
|
- name: Start replica that is already running
|
||||||
mysql_replication:
|
mysql_replication:
|
||||||
<<: *mysql_params
|
<<: *mysql_params
|
||||||
|
@ -241,7 +249,8 @@
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
# mysqlclient 2.0.1 always return "changed"
|
# mysqlclient 2.0.1 always return "changed"
|
||||||
- assert:
|
- name: Assert that startreplica is not changed
|
||||||
|
assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
when:
|
when:
|
||||||
|
@ -255,7 +264,8 @@
|
||||||
mode: stopreplica
|
mode: stopreplica
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert that stopreplica is changed and returns expected query
|
||||||
|
assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
- result.queries == ["STOP SLAVE"] or result.queries == ["STOP REPLICA"]
|
- result.queries == ["STOP SLAVE"] or result.queries == ["STOP REPLICA"]
|
||||||
|
@ -274,7 +284,8 @@
|
||||||
fail_on_error: true
|
fail_on_error: true
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- name: Assert that stopreplica is not changed
|
||||||
|
assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
when:
|
when:
|
||||||
|
@ -291,7 +302,8 @@
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
|
|
||||||
- assert:
|
- name: Assert that stopslave returns expected error message
|
||||||
|
assert:
|
||||||
that:
|
that:
|
||||||
- result.msg == "value of mode must be one of{{ ":" }} getprimary, getreplica, changeprimary, stopreplica, startreplica, resetprimary, resetreplica, resetreplicaall, got{{ ":" }} stopslave"
|
- result.msg == "value of mode must be one of{{ ":" }} getprimary, getreplica, changeprimary, stopreplica, startreplica, resetprimary, resetreplica, resetreplicaall, got{{ ":" }} stopslave"
|
||||||
- result is failed
|
- result is failed
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
---
|
||||||
# Test code for mysql_role module
|
# Test code for mysql_role module
|
||||||
|
|
||||||
- vars:
|
- vars:
|
||||||
|
@ -32,8 +33,8 @@
|
||||||
when:
|
when:
|
||||||
- srv['version']['major'] < 8
|
- srv['version']['major'] < 8
|
||||||
|
|
||||||
# Skip unsupported versions
|
- name: Skip unsupported versions
|
||||||
- meta: end_play
|
meta: end_play
|
||||||
when: srv['version']['major'] < 8
|
when: srv['version']['major'] < 8
|
||||||
|
|
||||||
#########
|
#########
|
||||||
|
@ -83,7 +84,7 @@
|
||||||
- '{{ user0 }}@{{ gateway_addr }}'
|
- '{{ user0 }}@{{ gateway_addr }}'
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
|
|
||||||
- name: Check
|
- name: Assert that create role0 is changed
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
@ -94,13 +95,13 @@
|
||||||
<<: *mysql_params
|
<<: *mysql_params
|
||||||
query: "SELECT 1 FROM mysql.user WHERE User = '{{ role0 }}'"
|
query: "SELECT 1 FROM mysql.user WHERE User = '{{ role0 }}'"
|
||||||
|
|
||||||
- name: Check
|
- name: Assert that user is not in mysql.user
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result.rowcount.0 == 0
|
- result.rowcount.0 == 0
|
||||||
|
|
||||||
# It must fail because of check_mode
|
# It must fail because of check_mode
|
||||||
- name: Check in DB, if not granted, the query will fail
|
- name: Check in DB, if not granted, the query will fail (expect failure)
|
||||||
<<: *task_params
|
<<: *task_params
|
||||||
mysql_query:
|
mysql_query:
|
||||||
<<: *mysql_params
|
<<: *mysql_params
|
||||||
|
@ -108,7 +109,7 @@
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
when: db_engine == 'mysql'
|
when: db_engine == 'mysql'
|
||||||
|
|
||||||
- name: Check
|
- name: Assert that show grants is failed
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result is failed
|
- result is failed
|
||||||
|
@ -121,13 +122,13 @@
|
||||||
query: "SELECT count(User) as user_roles FROM mysql.roles_mapping WHERE User = '{{ user0 }}' AND Host = '{{ gateway_addr }}' AND Role = '{{ role0 }}'"
|
query: "SELECT count(User) as user_roles FROM mysql.roles_mapping WHERE User = '{{ user0 }}' AND Host = '{{ gateway_addr }}' AND Role = '{{ role0 }}'"
|
||||||
when: db_engine == 'mariadb'
|
when: db_engine == 'mariadb'
|
||||||
|
|
||||||
- name: Check (mariadb)
|
- name: Assert that user is not in mysql.roles_mapping (mariadb)
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result.query_result.0.0['user_roles'] == 0
|
- result.query_result.0.0['user_roles'] == 0
|
||||||
when: db_engine == 'mariadb'
|
when: db_engine == 'mariadb'
|
||||||
|
|
||||||
#=====================
|
# =====================
|
||||||
|
|
||||||
- name: Check that the user have no active roles
|
- name: Check that the user have no active roles
|
||||||
<<: *task_params
|
<<: *task_params
|
||||||
|
@ -138,7 +139,7 @@
|
||||||
login_port: '{{ mysql_primary_port }}'
|
login_port: '{{ mysql_primary_port }}'
|
||||||
query: 'SELECT COALESCE(current_role(), "NONE") as "current_role()"'
|
query: 'SELECT COALESCE(current_role(), "NONE") as "current_role()"'
|
||||||
|
|
||||||
- name: Check
|
- name: Assert that the user have no active roles
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result.query_result.0.0["current_role()"] == "NONE"
|
- result.query_result.0.0["current_role()"] == "NONE"
|
||||||
|
@ -152,7 +153,7 @@
|
||||||
members:
|
members:
|
||||||
- '{{ user0 }}@{{ gateway_addr }}'
|
- '{{ user0 }}@{{ gateway_addr }}'
|
||||||
|
|
||||||
- name: Check
|
- name: Assert that create role is changed
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result is changed
|
- result is changed
|
||||||
|
@ -163,7 +164,7 @@
|
||||||
<<: *mysql_params
|
<<: *mysql_params
|
||||||
query: "SELECT 1 FROM mysql.user WHERE User = '{{ role0 }}'"
|
query: "SELECT 1 FROM mysql.user WHERE User = '{{ role0 }}'"
|
||||||
|
|
||||||
- name: Check
|
- name: Assert that tu role is in mysql.user
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result.rowcount.0 == 1
|
- result.rowcount.0 == 1
|
||||||
|
@ -175,7 +176,7 @@
|
||||||
query: "SHOW GRANTS FOR {{ user0 }}@{{ gateway_addr }} USING '{{ role0 }}'"
|
query: "SHOW GRANTS FOR {{ user0 }}@{{ gateway_addr }} USING '{{ role0 }}'"
|
||||||
when: db_engine == 'mysql'
|
when: db_engine == 'mysql'
|
||||||
|
|
||||||
- name: Check
|
- name: Assert that show grants is succeeded (mysql)
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result is succeeded
|
- result is succeeded
|
||||||
|
@ -188,7 +189,7 @@
|
||||||
query: "SELECT count(User) as user_roles FROM mysql.roles_mapping WHERE User = '{{ user0 }}' AND Host = '{{ gateway_addr }}' AND Role = '{{ role0 }}'"
|
query: "SELECT count(User) as user_roles FROM mysql.roles_mapping WHERE User = '{{ user0 }}' AND Host = '{{ gateway_addr }}' AND Role = '{{ role0 }}'"
|
||||||
when: db_engine == 'mariadb'
|
when: db_engine == 'mariadb'
|
||||||
|
|
||||||
- name: Check (mariadb)
|
- name: Assert that role is in mysql.roles_mapping (mariadb)
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result.query_result.0.0['user_roles'] == 1
|
- result.query_result.0.0['user_roles'] == 1
|
||||||
|
@ -204,7 +205,7 @@
|
||||||
query: 'SELECT current_role()'
|
query: 'SELECT current_role()'
|
||||||
when: db_engine == 'mysql'
|
when: db_engine == 'mysql'
|
||||||
|
|
||||||
- name: Check
|
- name: Assert that current_role() returns role0
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- "'{{ role0 }}' in result.query_result.0.0['current_role()']"
|
- "'{{ role0 }}' in result.query_result.0.0['current_role()']"
|
||||||
|
@ -222,13 +223,13 @@
|
||||||
- 'SELECT current_role()'
|
- 'SELECT current_role()'
|
||||||
when: db_engine == 'mariadb'
|
when: db_engine == 'mariadb'
|
||||||
|
|
||||||
- name: Check (mariadb)
|
- name: Assert that role is active (mariadb)
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- "'{{ role0 }}' in result.query_result.1.0['current_role()']"
|
- "'{{ role0 }}' in result.query_result.1.0['current_role()']"
|
||||||
when: db_engine == 'mariadb'
|
when: db_engine == 'mariadb'
|
||||||
|
|
||||||
#========================
|
# ========================
|
||||||
|
|
||||||
- name: Create role {{ role0 }} again in check_mode
|
- name: Create role {{ role0 }} again in check_mode
|
||||||
<<: *task_params
|
<<: *task_params
|
||||||
|
@ -238,7 +239,7 @@
|
||||||
state: present
|
state: present
|
||||||
check_mode: yes
|
check_mode: yes
|
||||||
|
|
||||||
- name: Check
|
- name: Assert that create role role0 again is not changed
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result is not changed
|
- result is not changed
|
||||||
|
@ -249,7 +250,7 @@
|
||||||
<<: *mysql_params
|
<<: *mysql_params
|
||||||
query: "SELECT 1 FROM mysql.user WHERE User = '{{ role0 }}'"
|
query: "SELECT 1 FROM mysql.user WHERE User = '{{ role0 }}'"
|
||||||
|
|
||||||
- name: Check
|
- name: Assert that role role0 is present in the database
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- result.rowcount.0 == 1
|
- result.rowcount.0 == 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue