mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-07-30 08:31:29 -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>
|
||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||
|
||||
|
@ -85,7 +86,8 @@
|
|||
mode: getprimary
|
||||
register: mysql_primary_status
|
||||
|
||||
- assert:
|
||||
- name: Assert that primary is in expected state
|
||||
assert:
|
||||
that:
|
||||
- mysql_primary_status.Is_Primary == true
|
||||
- mysql_primary_status.Position != 0
|
||||
|
@ -102,9 +104,10 @@
|
|||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
- name: Assert that startreplica is failed
|
||||
assert:
|
||||
that:
|
||||
- result is failed
|
||||
- result is failed
|
||||
|
||||
# Test startreplica doesn't fail if fail_on_error: no
|
||||
- name: Start replica and fail without propagating it to ansible as we were asked not to
|
||||
|
@ -115,9 +118,10 @@
|
|||
fail_on_error: no
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
- name: Assert that startreplica succeeded
|
||||
assert:
|
||||
that:
|
||||
- result is not failed
|
||||
- result is not failed
|
||||
|
||||
# Test startreplica doesn't fail if there is no fail_on_error.
|
||||
# This is suboptimal because nothing happens, but it's the old behavior.
|
||||
|
@ -128,9 +132,10 @@
|
|||
mode: startreplica
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
- name: Assert that start replica succeeded again
|
||||
assert:
|
||||
that:
|
||||
- result is not failed
|
||||
- result is not failed
|
||||
|
||||
# Test changeprimary mode:
|
||||
# primary_ssl_ca will be set as '' to check the module's behaviour for #23976,
|
||||
|
@ -150,10 +155,11 @@
|
|||
primary_ssl: no
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
- name: Assert that changeprimmary is changed and return expected query
|
||||
assert:
|
||||
that:
|
||||
- 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 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=''"]
|
||||
|
||||
# Test startreplica mode:
|
||||
- name: Start replica
|
||||
|
@ -163,10 +169,11 @@
|
|||
mode: startreplica
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
- name: Assert that startreplica is changed and returns expected query
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- result.queries == ["START SLAVE"] or result.queries == ["START REPLICA"]
|
||||
- result is changed
|
||||
- result.queries == ["START SLAVE"] or result.queries == ["START REPLICA"]
|
||||
|
||||
# Test getreplica mode:
|
||||
- name: Get replica status
|
||||
|
@ -176,26 +183,28 @@
|
|||
mode: getreplica
|
||||
register: replica_status
|
||||
|
||||
- assert:
|
||||
- name: Assert that getreplica returns expected values for MySQL older than 8.0.22 and Mariadb
|
||||
assert:
|
||||
that:
|
||||
- replica_status.Is_Replica == true
|
||||
- replica_status.Master_Host == '{{ mysql_host }}'
|
||||
- replica_status.Exec_Master_Log_Pos == mysql_primary_status.Position
|
||||
- replica_status.Master_Port == {{ mysql_primary_port }}
|
||||
- replica_status.Last_IO_Errno == 0
|
||||
- replica_status.Last_IO_Error == ''
|
||||
- replica_status is not changed
|
||||
- replica_status.Is_Replica == true
|
||||
- replica_status.Master_Host == '{{ mysql_host }}'
|
||||
- replica_status.Exec_Master_Log_Pos == mysql_primary_status.Position
|
||||
- replica_status.Master_Port == {{ mysql_primary_port }}
|
||||
- replica_status.Last_IO_Errno == 0
|
||||
- replica_status.Last_IO_Error == ''
|
||||
- replica_status is not changed
|
||||
when: mysql8022_and_higher == false
|
||||
|
||||
- assert:
|
||||
- name: Assert that getreplica returns expected values for MySQL newer than 8.0.22
|
||||
assert:
|
||||
that:
|
||||
- replica_status.Is_Replica == true
|
||||
- replica_status.Source_Host == '{{ mysql_host }}'
|
||||
- replica_status.Exec_Source_Log_Pos == mysql_primary_status.Position
|
||||
- replica_status.Source_Port == {{ mysql_primary_port }}
|
||||
- replica_status.Last_IO_Errno == 0
|
||||
- replica_status.Last_IO_Error == ''
|
||||
- replica_status is not changed
|
||||
- replica_status.Is_Replica == true
|
||||
- replica_status.Source_Host == '{{ mysql_host }}'
|
||||
- replica_status.Exec_Source_Log_Pos == mysql_primary_status.Position
|
||||
- replica_status.Source_Port == {{ mysql_primary_port }}
|
||||
- replica_status.Last_IO_Errno == 0
|
||||
- replica_status.Last_IO_Error == ''
|
||||
- replica_status is not changed
|
||||
when: mysql8022_and_higher == true
|
||||
|
||||
# Create test table and add data to it:
|
||||
|
@ -219,19 +228,18 @@
|
|||
|
||||
# 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:
|
||||
- assert:
|
||||
- name: Assert that getreplica Log_Pos is different for MySQL older than 8.0.22 and MariaDB
|
||||
assert:
|
||||
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
|
||||
|
||||
- assert:
|
||||
- name: Assert that getreplica Log_Pos is different for MySQL newer than 8.0.22
|
||||
assert:
|
||||
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
|
||||
|
||||
- shell: pip show pymysql | awk '/Version/ {print $2}'
|
||||
register: pymysql_version
|
||||
|
||||
- name: Start replica that is already running
|
||||
mysql_replication:
|
||||
<<: *mysql_params
|
||||
|
@ -241,7 +249,8 @@
|
|||
register: result
|
||||
|
||||
# mysqlclient 2.0.1 always return "changed"
|
||||
- assert:
|
||||
- name: Assert that startreplica is not changed
|
||||
assert:
|
||||
that:
|
||||
- result is not changed
|
||||
when:
|
||||
|
@ -255,10 +264,11 @@
|
|||
mode: stopreplica
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
- name: Assert that stopreplica is changed and returns expected query
|
||||
assert:
|
||||
that:
|
||||
- result is changed
|
||||
- result.queries == ["STOP SLAVE"] or result.queries == ["STOP REPLICA"]
|
||||
- result is changed
|
||||
- result.queries == ["STOP SLAVE"] or result.queries == ["STOP REPLICA"]
|
||||
|
||||
- name: Pause for 2 seconds to let the replication stop
|
||||
ansible.builtin.wait_for:
|
||||
|
@ -274,7 +284,8 @@
|
|||
fail_on_error: true
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
- name: Assert that stopreplica is not changed
|
||||
assert:
|
||||
that:
|
||||
- result is not changed
|
||||
when:
|
||||
|
@ -291,7 +302,8 @@
|
|||
register: result
|
||||
ignore_errors: yes
|
||||
|
||||
- assert:
|
||||
- name: Assert that stopslave returns expected error message
|
||||
assert:
|
||||
that:
|
||||
- result.msg == "value of mode must be one of{{ ":" }} getprimary, getreplica, changeprimary, stopreplica, startreplica, resetprimary, resetreplica, resetreplicaall, got{{ ":" }} stopslave"
|
||||
- result is failed
|
||||
- result.msg == "value of mode must be one of{{ ":" }} getprimary, getreplica, changeprimary, stopreplica, startreplica, resetprimary, resetreplica, resetreplicaall, got{{ ":" }} stopslave"
|
||||
- result is failed
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue