mysql_replication: remove mode values and ret values containing master / slave (#252)

* mysql_replication: remove mode values containing master / slave

* Add tests
This commit is contained in:
Andrew Klychkov 2021-12-01 09:56:53 +03:00 committed by GitHub
commit 1f796d9e81
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 57 additions and 101 deletions

View file

@ -64,11 +64,11 @@
- mysql_primary_status is not changed
# Test startreplica fails without changeprimary first. This needs fail_on_error
- name: Start replica (using deprecated startslave choice) and fail because primary is not specified; failing on error as requested
- name: Start replica and fail because primary is not specified; failing on error as requested
mysql_replication:
<<: *mysql_params
login_port: '{{ mysql_replica1_port }}'
mode: startslave
mode: startreplica
fail_on_error: yes
register: result
ignore_errors: yes
@ -139,11 +139,11 @@
- result.queries == ["START SLAVE"] or result.queries == ["START REPLICA"]
# Test getreplica mode:
- name: Get replica status using deprecated getslave choice
- name: Get replica status
mysql_replication:
<<: *mysql_params
login_port: '{{ mysql_replica1_port }}'
mode: getslave
mode: getreplica
register: replica_status
- assert:
@ -159,7 +159,7 @@
- assert:
that:
- replica_status.Is_Slave == true
- 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 }}
@ -216,11 +216,11 @@
when: (pymysql_version.stdout | default('1000', true)) is version('0.9.3', '<=')
# Test stopreplica mode:
- name: Stop replica using deprecated stopslave choice
- name: Stop replica
mysql_replication:
<<: *mysql_params
login_port: '{{ mysql_replica1_port }}'
mode: stopslave
mode: stopreplica
register: result
- assert:
@ -241,3 +241,19 @@
that:
- result is not changed
when: (pymysql_version.stdout | default('1000', true)) is version('0.9.3', '<=')
# master / slave related choices were removed in 3.0.0
# https://github.com/ansible-collections/community.mysql/pull/252
- name: Test invoking the module with unsupported choice
mysql_replication:
<<: *mysql_params
login_port: '{{ mysql_replica1_port }}'
mode: stopslave
fail_on_error: true
register: result
ignore_errors: yes
- assert:
that:
- result.msg == "value of mode must be one of{{ ":" }} getprimary, getreplica, changeprimary, stopreplica, startreplica, resetprimary, resetreplica, resetreplicaall, got{{ ":" }} stopslave"
- result is failed