From d69eb94d90db6ef7d9d6c363f4f3f4719bd4f21c Mon Sep 17 00:00:00 2001 From: Sergio Oliveira Campos <seocam@seocam.com> Date: Mon, 3 Aug 2020 12:00:25 -0300 Subject: [PATCH] Reorg tests setup and add teardown/cleanup Perform clean up at the end of the tests. Also reorganized setup/teardown in env_* files in a similar way proposed in dnsrecord module. --- tests/dnszone/env_cleanup.yml | 13 +++++++++++ tests/dnszone/env_setup.yml | 3 +++ tests/dnszone/env_teardown.yml | 3 +++ tests/dnszone/test_dnszone.yml | 11 +++++---- tests/dnszone/test_dnszone_mod.yml | 11 +++++---- tests/dnszone/test_dnszone_name_from_ip.yml | 26 +++++---------------- 6 files changed, 37 insertions(+), 30 deletions(-) create mode 100644 tests/dnszone/env_cleanup.yml create mode 100644 tests/dnszone/env_setup.yml create mode 100644 tests/dnszone/env_teardown.yml diff --git a/tests/dnszone/env_cleanup.yml b/tests/dnszone/env_cleanup.yml new file mode 100644 index 00000000..76996092 --- /dev/null +++ b/tests/dnszone/env_cleanup.yml @@ -0,0 +1,13 @@ +--- +- name: Ensure zone is absent. + ipadnszone: + ipaadmin_password: SomeADMINpassword + name: + - testzone.local + - test1.testzone.local + - test2.testzone.local + - test3.testzone.local + - 2.0.192.in-addr.arpa. + - 0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.f.ip6.arpa. + - 1.0.0.0.e.f.a.c.8.b.d.0.1.0.0.2.ip6.arpa. + state: absent diff --git a/tests/dnszone/env_setup.yml b/tests/dnszone/env_setup.yml new file mode 100644 index 00000000..ce437811 --- /dev/null +++ b/tests/dnszone/env_setup.yml @@ -0,0 +1,3 @@ +--- +- name: Cleanup test environment. + include_tasks: env_cleanup.yml diff --git a/tests/dnszone/env_teardown.yml b/tests/dnszone/env_teardown.yml new file mode 100644 index 00000000..ce437811 --- /dev/null +++ b/tests/dnszone/env_teardown.yml @@ -0,0 +1,3 @@ +--- +- name: Cleanup test environment. + include_tasks: env_cleanup.yml diff --git a/tests/dnszone/test_dnszone.yml b/tests/dnszone/test_dnszone.yml index bd820dfa..1c299748 100644 --- a/tests/dnszone/test_dnszone.yml +++ b/tests/dnszone/test_dnszone.yml @@ -7,11 +7,8 @@ tasks: # Setup - - name: Ensure zone is absent. - ipadnszone: - ipaadmin_password: SomeADMINpassword - name: testzone.local - state: absent + - name: Setup testing environment + include_tasks: env_setup.yml # Tests - name: Ensure zone is present. @@ -186,3 +183,7 @@ state: absent register: result failed_when: result.changed + + # Teardown + - name: Teardown testing environment + include_tasks: env_teardown.yml diff --git a/tests/dnszone/test_dnszone_mod.yml b/tests/dnszone/test_dnszone_mod.yml index e4b503ae..4cff8ee3 100644 --- a/tests/dnszone/test_dnszone_mod.yml +++ b/tests/dnszone/test_dnszone_mod.yml @@ -7,11 +7,8 @@ tasks: # Setup - - name: Ensure zone is absent. - ipadnszone: - ipaadmin_password: SomeADMINpassword - name: testzone.local - state: absent + - name: Setup testing environment + include_tasks: env_setup.yml # Tests - name: Ensure zone is present. @@ -317,3 +314,7 @@ admin_email: admin2@example.com register: result failed_when: result.changed + + # Teardown + - name: Teardown testing environment + include_tasks: env_teardown.yml diff --git a/tests/dnszone/test_dnszone_name_from_ip.yml b/tests/dnszone/test_dnszone_name_from_ip.yml index 9bd2eb0d..fb1086d6 100644 --- a/tests/dnszone/test_dnszone_name_from_ip.yml +++ b/tests/dnszone/test_dnszone_name_from_ip.yml @@ -7,17 +7,10 @@ tasks: # Setup - - name: Ensure zone is absent. - ipadnszone: - ipaadmin_password: SomeADMINpassword - name: "{{ item }}" - state: absent - with_items: - - 2.0.192.in-addr.arpa. - - 0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.f.ip6.arpa. - - 1.0.0.0.e.f.a.c.8.b.d.0.1.0.0.2.ip6.arpa. + - name: Setup testing environment + include_tasks: env_setup.yml - # tests + # Tests - name: Ensure zone exists for reverse IP. ipadnszone: ipaadmin_password: SomeADMINpassword @@ -100,13 +93,6 @@ register: result failed_when: result.changed - # Cleanup - - name: Ensure zone is absent. - ipadnszone: - ipaadmin_password: SomeADMINpassword - name: "{{ item }}" - state: absent - with_items: - - "{{ ipv6_zone.dnszone.name }}" - - "{{ ipv6_sec_zone.dnszone.name }}" - - "{{ ipv4_zone.dnszone.name }}" + # Teardown + - name: Teardown testing environment + include_tasks: env_teardown.yml -- GitLab