mirror of
https://github.com/ansible-collections/community.mysql.git
synced 2025-04-05 10:10:32 -07:00
Deduplicate tests between main and new task file
This commit is contained in:
parent
a066a1749d
commit
0b8a416af0
1 changed files with 47 additions and 8 deletions
|
@ -13,15 +13,16 @@
|
||||||
block:
|
block:
|
||||||
|
|
||||||
# ================================ Prepare ==============================
|
# ================================ Prepare ==============================
|
||||||
- name: Mysql_info users_info | Create databases
|
- name: Mysql_info databases | Prepare | Create databases
|
||||||
community.mysql.mysql_db:
|
community.mysql.mysql_db:
|
||||||
name:
|
name:
|
||||||
- db_tables_count_empty
|
- db_tables_count_empty
|
||||||
- db_tables_count_1
|
- db_tables_count_1
|
||||||
- db_tables_count_2
|
- db_tables_count_2
|
||||||
|
- db_only_views # https://github.com/ansible-Getions/community.mysql/issues/204
|
||||||
state: present
|
state: present
|
||||||
|
|
||||||
- name: Mysql_info users_info | Create tables
|
- name: Mysql_info databases | Prepare | Create tables
|
||||||
community.mysql.mysql_query:
|
community.mysql.mysql_query:
|
||||||
query:
|
query:
|
||||||
- >-
|
- >-
|
||||||
|
@ -33,10 +34,12 @@
|
||||||
- >-
|
- >-
|
||||||
CREATE TABLE IF NOT EXISTS db_tables_count_2.t2
|
CREATE TABLE IF NOT EXISTS db_tables_count_2.t2
|
||||||
(id int, name1 varchar(9))
|
(id int, name1 varchar(9))
|
||||||
|
- >-
|
||||||
|
CREATE VIEW db_only_views.v_today (today) AS SELECT CURRENT_DATE
|
||||||
|
|
||||||
# ================================== Tests ==============================
|
# ================================== Tests ==============================
|
||||||
|
|
||||||
- name: Mysql_info users_info | Collect all non-empty databases fields
|
- name: Mysql_info databases | Get all non-empty databases fields
|
||||||
community.mysql.mysql_info:
|
community.mysql.mysql_info:
|
||||||
filter:
|
filter:
|
||||||
- databases
|
- databases
|
||||||
|
@ -47,10 +50,11 @@
|
||||||
result.databases['db_tables_count_1'].tables != 1 or
|
result.databases['db_tables_count_1'].tables != 1 or
|
||||||
result.databases['db_tables_count_2'].size != 32768 or
|
result.databases['db_tables_count_2'].size != 32768 or
|
||||||
result.databases['db_tables_count_2'].tables != 2 or
|
result.databases['db_tables_count_2'].tables != 2 or
|
||||||
|
result.databases['db_only_views'].size != 0 or
|
||||||
'db_tables_count_empty' in result.databases | dict2items
|
'db_tables_count_empty' in result.databases | dict2items
|
||||||
| map(attribute='key')
|
| map(attribute='key')
|
||||||
|
|
||||||
- name: Mysql_info users_info | Collect all databases fields except db_size
|
- name: Mysql_info databases | Get all dbs fields except db_size
|
||||||
community.mysql.mysql_info:
|
community.mysql.mysql_info:
|
||||||
filter:
|
filter:
|
||||||
- databases
|
- databases
|
||||||
|
@ -64,7 +68,25 @@
|
||||||
'db_tables_count_empty' in result.databases | dict2items
|
'db_tables_count_empty' in result.databases | dict2items
|
||||||
| map(attribute='key')
|
| map(attribute='key')
|
||||||
|
|
||||||
- name: Mysql_info users_info | Collect all databases fields except tables
|
# 'unsupported' element is passed to check that an unsupported value
|
||||||
|
# won't break anything (will be ignored regarding to the module's
|
||||||
|
# documentation).
|
||||||
|
- name: Mysql_info databases | Get all dbs fields with unsupported value
|
||||||
|
community.mysql.mysql_info:
|
||||||
|
filter:
|
||||||
|
- databases
|
||||||
|
exclude_fields:
|
||||||
|
- db_size
|
||||||
|
- unsupported
|
||||||
|
register: result
|
||||||
|
failed_when:
|
||||||
|
- >
|
||||||
|
result.databases['db_tables_count_1'].size is defined or
|
||||||
|
result.databases['db_tables_count_2'].size is defined or
|
||||||
|
'db_tables_count_empty' in result.databases | dict2items
|
||||||
|
| map(attribute='key')
|
||||||
|
|
||||||
|
- name: Mysql_info databases | Get all dbs fields except tables
|
||||||
community.mysql.mysql_info:
|
community.mysql.mysql_info:
|
||||||
filter:
|
filter:
|
||||||
- databases
|
- databases
|
||||||
|
@ -78,7 +100,7 @@
|
||||||
'db_tables_count_empty' in result.databases | dict2items
|
'db_tables_count_empty' in result.databases | dict2items
|
||||||
| map(attribute='key')
|
| map(attribute='key')
|
||||||
|
|
||||||
- name: Mysql_info users_info | Collect all databases even empty ones
|
- name: Mysql_info databases | Get all dbs even empty ones
|
||||||
community.mysql.mysql_info:
|
community.mysql.mysql_info:
|
||||||
filter:
|
filter:
|
||||||
- databases
|
- databases
|
||||||
|
@ -93,12 +115,29 @@
|
||||||
result.databases['db_tables_count_empty'].size != 0 or
|
result.databases['db_tables_count_empty'].size != 0 or
|
||||||
result.databases['db_tables_count_empty'].tables != 0
|
result.databases['db_tables_count_empty'].tables != 0
|
||||||
|
|
||||||
|
- name: Mysql_info databases | Get all dbs even empty ones without size
|
||||||
|
community.mysql.mysql_info:
|
||||||
|
filter:
|
||||||
|
- databases
|
||||||
|
exclude_fields:
|
||||||
|
- db_size
|
||||||
|
return_empty_dbs: true
|
||||||
|
register: result
|
||||||
|
failed_when:
|
||||||
|
- >
|
||||||
|
result.databases['db_tables_count_1'].size is defined or
|
||||||
|
result.databases['db_tables_count_1'].tables != 1 or
|
||||||
|
result.databases['db_tables_count_2'].size is defined or
|
||||||
|
result.databases['db_tables_count_2'].tables != 2 or
|
||||||
|
result.databases['db_tables_count_empty'].size is defined or
|
||||||
|
result.databases['db_tables_count_empty'].tables != 0
|
||||||
|
|
||||||
# ================================== Cleanup ============================
|
# ================================== Cleanup ============================
|
||||||
|
|
||||||
- name: Mysql_info users_info | Cleanup databases
|
- name: Mysql_info databases | Cleanup databases
|
||||||
community.mysql.mysql_db:
|
community.mysql.mysql_db:
|
||||||
name:
|
name:
|
||||||
- db_tables_count_empty
|
- db_tables_count_empty
|
||||||
- db_tables_count_1
|
- db_tables_count_1
|
||||||
- db_tables_count_2
|
- db_tables_count_2
|
||||||
state: present
|
- db_only_views
|
||||||
|
|
Loading…
Add table
Reference in a new issue