mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-07-31 00:51:25 -07:00
[PR #427/0a68bb27 backport][stable-2] CI is changed (#429)
* Is changed (#427)
* Refactor tests to use "is" and "is not" changed
* Refactor tests to use is succeeded or is failed
* Reformat indentation
* Add filter "bool" to prevent issues
(cherry picked from commit 0a68bb270f
)
* Fix error message verification
I don't know why this works on main, but in stable-1, the error message
is "invalid privileges string: Invalid privileges specified:
frozenset({'INVALID'})"
* Add filter for test that won't work with mariadb
* Add test databases cleanup
* Backport small diff from main
This commit is contained in:
parent
4aa166ec13
commit
58b850f217
20 changed files with 457 additions and 193 deletions
|
@ -14,6 +14,18 @@
|
|||
#
|
||||
# ==========================================================================
|
||||
# Initial check - To confirm that database does not exist before executing check mode tasks
|
||||
- name: Drop databases before test
|
||||
mysql_db:
|
||||
login_user: '{{ mysql_user }}'
|
||||
login_password: '{{ mysql_password }}'
|
||||
login_host: 127.0.0.1
|
||||
login_port: '{{ mysql_primary_port }}'
|
||||
name:
|
||||
- '{{ db1_name }}'
|
||||
- '{{ db2_name }}'
|
||||
- '{{ db3_name }}'
|
||||
state: absent
|
||||
|
||||
- name: run command to list databases like specified database name
|
||||
command: "{{ mysql_command }} \"-e show databases like 'database%'\""
|
||||
register: mysql_result
|
||||
|
@ -44,7 +56,7 @@
|
|||
- name: assert successful completion of create database using check_mode since databases does not exist prior
|
||||
assert:
|
||||
that:
|
||||
- check_mode_result.changed == true
|
||||
- check_mode_result is changed
|
||||
|
||||
- name: run command to list databases like specified database name
|
||||
command: "{{ mysql_command }} \"-e show databases like 'database%'\""
|
||||
|
@ -75,7 +87,7 @@
|
|||
- name: assert successful completion of create database
|
||||
assert:
|
||||
that:
|
||||
- result.changed == true
|
||||
- result is changed
|
||||
- result.db_list == ['{{ db1_name }}', '{{ db2_name }}', '{{ db3_name }}']
|
||||
|
||||
- name: run command to list databases like specified database name
|
||||
|
@ -108,7 +120,7 @@
|
|||
- name: assert that recreation of existing databases does not make change (since recreated using check mode)
|
||||
assert:
|
||||
that:
|
||||
- check_mode_result.changed == false
|
||||
- check_mode_result is not changed
|
||||
|
||||
- name: run command to list databases like specified database name
|
||||
command: "{{ mysql_command }} \"-e show databases like 'database%'\""
|
||||
|
@ -139,7 +151,7 @@
|
|||
- name: assert that recreation of existing databases does not make change
|
||||
assert:
|
||||
that:
|
||||
- result.changed == false
|
||||
- result is not changed
|
||||
|
||||
- name: run command to list databases like specified database name
|
||||
command: "{{ mysql_command }} \"-e show databases like 'database%'\""
|
||||
|
@ -168,7 +180,7 @@
|
|||
- name: assert successful completion of deleting database
|
||||
assert:
|
||||
that:
|
||||
- result.changed == true
|
||||
- result is changed
|
||||
|
||||
- name: run command to list databases like specified database name
|
||||
command: "{{ mysql_command }} \"-e show databases like 'database%'\""
|
||||
|
@ -200,7 +212,7 @@
|
|||
- name: assert successful completion of recreation of partially existing database using check mode
|
||||
assert:
|
||||
that:
|
||||
- check_mode_result.changed == true
|
||||
- check_mode_result is changed
|
||||
|
||||
- name: run command to list databases like specified database name
|
||||
command: "{{ mysql_command }} \"-e show databases like 'database%'\""
|
||||
|
@ -231,7 +243,7 @@
|
|||
- name: assert successful completion of create database
|
||||
assert:
|
||||
that:
|
||||
- result.changed == true
|
||||
- result is changed
|
||||
|
||||
- name: run command to list databases like specified database name
|
||||
command: "{{ mysql_command }} \"-e show databases like 'database%'\""
|
||||
|
@ -272,7 +284,7 @@
|
|||
- name: assert successful completion of dump operation using check mode
|
||||
assert:
|
||||
that:
|
||||
- check_mode_dump_result.changed == true
|
||||
- check_mode_dump_result is changed
|
||||
|
||||
- name: run command to list databases like specified database name
|
||||
command: "{{ mysql_command }} \"-e show databases like 'database%'\""
|
||||
|
@ -389,7 +401,7 @@
|
|||
- name: assert successful completion of dump operation
|
||||
assert:
|
||||
that:
|
||||
- dump_result.changed == true
|
||||
- dump_result is changed
|
||||
- dump_result.db_list == ['{{ db1_name }}', '{{ db2_name }}', '{{ db3_name }}']
|
||||
|
||||
- name: run command to list databases like specified database name
|
||||
|
@ -439,7 +451,7 @@
|
|||
- name: assert successful completion of dump operation
|
||||
assert:
|
||||
that:
|
||||
- dump_result.changed == true
|
||||
- dump_result is changed
|
||||
|
||||
- name: run command to list databases like specified database name
|
||||
command: "{{ mysql_command }} \"-e show databases like 'database%'\""
|
||||
|
@ -479,7 +491,7 @@
|
|||
- name: assert successful completion of delete databases which already exists using check mode
|
||||
assert:
|
||||
that:
|
||||
- check_mode_result.changed == true
|
||||
- check_mode_result is changed
|
||||
|
||||
- name: run command to test state=absent for a database name
|
||||
command: "{{ mysql_command }} \"-e show databases like 'database%'\""
|
||||
|
@ -508,7 +520,7 @@
|
|||
- name: assert successful completion of deleting database
|
||||
assert:
|
||||
that:
|
||||
- result.changed == true
|
||||
- result is changed
|
||||
- result.db_list == ['{{ db2_name }}', '{{ db3_name }}']
|
||||
|
||||
- name: run command to list databases like specified database name
|
||||
|
@ -539,7 +551,7 @@
|
|||
- name: assert that deletion of non existing databases does not make change (using check mode)
|
||||
assert:
|
||||
that:
|
||||
- check_mode_result.changed == false
|
||||
- check_mode_result is not changed
|
||||
|
||||
- name: run command to test state=absent for a database name
|
||||
command: "{{ mysql_command }} \"-e show databases like 'database%'\""
|
||||
|
@ -568,7 +580,7 @@
|
|||
- name: assert that deletion of non existing databases does not make change
|
||||
assert:
|
||||
that:
|
||||
- result.changed == false
|
||||
- result is not changed
|
||||
|
||||
- name: run command to list databases like specified database name
|
||||
command: "{{ mysql_command }} \"-e show databases like 'database%'\""
|
||||
|
@ -600,7 +612,7 @@
|
|||
- name: assert successful completion of deleting database
|
||||
assert:
|
||||
that:
|
||||
- result.changed == true
|
||||
- result is changed
|
||||
|
||||
- name: run command to list databases like specified database name
|
||||
command: "{{ mysql_command }} \"-e show databases like 'database%'\""
|
||||
|
|
|
@ -159,7 +159,7 @@
|
|||
- name: assert successful completion of dump operation (with multiple databases in list form) via check mode
|
||||
assert:
|
||||
that:
|
||||
- "dump_result.changed == true"
|
||||
- dump_result is changed
|
||||
|
||||
- name: database dump file2 should not exist
|
||||
stat:
|
||||
|
@ -187,7 +187,7 @@
|
|||
- name: assert successful completion of dump operation (with multiple databases in list form)
|
||||
assert:
|
||||
that:
|
||||
- "dump_result2.changed == true"
|
||||
- dump_result2 is changed
|
||||
|
||||
- name: state dump - dump file2 should exist
|
||||
file:
|
||||
|
@ -249,7 +249,7 @@
|
|||
- name: assert output message restored a database from dump file1
|
||||
assert:
|
||||
that:
|
||||
- "import_result.changed == true"
|
||||
- import_result is changed
|
||||
|
||||
- name: remove database
|
||||
mysql_db:
|
||||
|
@ -284,7 +284,7 @@
|
|||
- name: assert output message restored a database from dump file2 (check mode)
|
||||
assert:
|
||||
that:
|
||||
- "check_import_result.changed == true"
|
||||
- check_import_result is changed
|
||||
|
||||
- name: run command to list databases
|
||||
command: "{{ mysql_command }} \"-e show databases like 'data%'\""
|
||||
|
@ -309,7 +309,7 @@
|
|||
- name: assert output message restored a database from dump file2
|
||||
assert:
|
||||
that:
|
||||
- import_result2.changed == true
|
||||
- import_result2 is changed
|
||||
- import_result2.db_list == ['{{ db_name2 }}']
|
||||
|
||||
- name: run command to list databases
|
||||
|
@ -335,7 +335,7 @@
|
|||
- name: assert output message backup the database
|
||||
assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- result is changed
|
||||
- "result.db =='{{ db_name }}'"
|
||||
|
||||
# - name: assert database was backed up successfully
|
||||
|
@ -364,7 +364,7 @@
|
|||
- name: assert output message restore the database
|
||||
assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- result is changed
|
||||
|
||||
- name: select data from table employee
|
||||
command: "{{ mysql_command }} {{ db_name }} \"-e select * from employee\""
|
||||
|
@ -398,7 +398,7 @@
|
|||
|
||||
- assert:
|
||||
that:
|
||||
- result.failed == true
|
||||
- result is failed
|
||||
|
||||
- name: try to import with force parameter
|
||||
mysql_db:
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
# ============================================================
|
||||
- name: remove database if it exists
|
||||
command: >
|
||||
"{{ mysql_command }} -sse 'drop database {{ db_name }}'"
|
||||
ignore_errors: True
|
||||
"{{ mysql_command }} -sse 'DROP DATABASE IF EXISTS {{ db_name }}'"
|
||||
ignore_errors: true
|
||||
|
||||
- name: make sure the test database is not there
|
||||
command: "{{ mysql_command }} {{ db_name }}"
|
||||
|
@ -95,7 +95,7 @@
|
|||
- name: assert test mysql_db encoding param not valid - issue 8075 (failed=true)
|
||||
assert:
|
||||
that:
|
||||
- "result.failed == true"
|
||||
- result is failed
|
||||
- "'Traceback' not in result.msg"
|
||||
- "'Unknown character set' in result.msg"
|
||||
|
||||
|
@ -196,7 +196,7 @@
|
|||
- name: assert output message that database was created
|
||||
assert:
|
||||
that:
|
||||
- "result.changed == true"
|
||||
- result is changed
|
||||
|
||||
- name: run command to test database was created using user1
|
||||
command: "{{ mysql_command }} -e \"show databases like '{{ db_user1 | regex_replace(\"([%_\\\\])\", \"\\\\\\1\") }}'\""
|
||||
|
@ -233,7 +233,7 @@
|
|||
- name: assert output message that database was not created using dbuser2
|
||||
assert:
|
||||
that:
|
||||
- "result.failed == true"
|
||||
- result is failed
|
||||
- "'Access denied' in result.msg"
|
||||
|
||||
- name: run command to test that database was not created
|
||||
|
@ -260,7 +260,7 @@
|
|||
- name: assert output message that database was not deleted using dbuser2
|
||||
assert:
|
||||
that:
|
||||
- "result.failed == true"
|
||||
- result is failed
|
||||
- "'Access denied' in result.msg"
|
||||
|
||||
- name: run command to test database was not deleted
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue