From 5ed8661e6ec8e5f705391a80bb55432811ff2beb Mon Sep 17 00:00:00 2001 From: Laurent Indermuehle Date: Mon, 20 Jun 2022 15:22:09 +0200 Subject: [PATCH] Add tests for full dump with and without compression --- .../tasks/issue_256_mysqldump_errors.yml | 52 ++++++++++++++++++- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/tests/integration/targets/test_mysql_db/tasks/issue_256_mysqldump_errors.yml b/tests/integration/targets/test_mysql_db/tasks/issue_256_mysqldump_errors.yml index 3c3b53e..8a0936f 100644 --- a/tests/integration/targets/test_mysql_db/tasks/issue_256_mysqldump_errors.yml +++ b/tests/integration/targets/test_mysql_db/tasks/issue_256_mysqldump_errors.yml @@ -13,16 +13,64 @@ block: - - name: Setup test - Create 2 schemas + - name: Check dumps errors | Setup test | Create 2 schemas community.mysql.mysql_db: name: - "db1" - "db2" state: present - - name: Setup test - Create 2 tables + - name: Check dumps errors | Setup test | Create 2 tables community.mysql.mysql_query: query: - "CREATE TABLE db1.t1 (id int)" - "CREATE TABLE db1.t2 (id int)" - "CREATE VIEW db2.v1 AS SELECT id from db1.t1" + + - name: Check dumps errors | Full dump without compression + community.mysql.mysql_db: + state: dump + name: all + target: /tmp/full-dump.sql + register: full_dump + + - name: Check dumps errors | Full dump with gunzip + community.mysql.mysql_db: + state: dump + name: all + target: /tmp/full-dump.sql.gz + register: full_dump_gz + + - name: Check dumps errors | Check full dumps are changed + ansible.builtin.assert: + that: + - full_dump is changed + - full_dump_gz is changed + + # Now db2.v1 targets an inexistant table so mysqldump will fail + - name: Check dumps errors | Drop t1 + community.mysql.mysql_query: + query: + - "DROP TABLE db1.t1" + + - name: Check dumps errors | Full dump after drop t1 without compression + community.mysql.mysql_db: + state: dump + name: all + target: /tmp/full-dump-without-t1.sql + register: full_dump_without_t1 + ignore_errors: true + + - name: Check dumps errors | Full dump after drop t1 with gzip + community.mysql.mysql_db: + state: dump + name: all + target: /tmp/full-dump-without-t1.sql.gz + register: full_dump_without_t1_gz + ignore_errors: true + + - name: Check dumps errors | Check full dump + ansible.builtin.assert: + that: + - full_dump_without_t1 is failed + - full_dump_without_t1_gz is failed