diff --git a/tests/integration/targets/test_mysql_info/tasks/filter_databases.yml b/tests/integration/targets/test_mysql_info/tasks/filter_databases.yml index 6b88dee..3064eaa 100644 --- a/tests/integration/targets/test_mysql_info/tasks/filter_databases.yml +++ b/tests/integration/targets/test_mysql_info/tasks/filter_databases.yml @@ -13,15 +13,16 @@ block: # ================================ Prepare ============================== - - name: Mysql_info users_info | Create databases + - name: Mysql_info databases | Prepare | Create databases community.mysql.mysql_db: name: - db_tables_count_empty - db_tables_count_1 - db_tables_count_2 + - db_only_views # https://github.com/ansible-Getions/community.mysql/issues/204 state: present - - name: Mysql_info users_info | Create tables + - name: Mysql_info databases | Prepare | Create tables community.mysql.mysql_query: query: - >- @@ -33,10 +34,12 @@ - >- CREATE TABLE IF NOT EXISTS db_tables_count_2.t2 (id int, name1 varchar(9)) + - >- + CREATE VIEW db_only_views.v_today (today) AS SELECT CURRENT_DATE # ================================== 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: filter: - databases @@ -47,10 +50,11 @@ result.databases['db_tables_count_1'].tables != 1 or result.databases['db_tables_count_2'].size != 32768 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 | 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: filter: - databases @@ -64,7 +68,25 @@ 'db_tables_count_empty' in result.databases | dict2items | 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: filter: - databases @@ -78,7 +100,7 @@ 'db_tables_count_empty' in result.databases | dict2items | 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: filter: - databases @@ -93,12 +115,29 @@ result.databases['db_tables_count_empty'].size != 0 or 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 ============================ - - name: Mysql_info users_info | Cleanup databases + - name: Mysql_info databases | Cleanup databases community.mysql.mysql_db: name: - db_tables_count_empty - db_tables_count_1 - db_tables_count_2 - state: present + - db_only_views