From 464ac374b9c38d3cb2e1910853b4a890bbacf35c Mon Sep 17 00:00:00 2001 From: Bartek Grzybowski Date: Wed, 5 Jun 2019 09:32:29 +0200 Subject: Add custom patch role scenario to 'application' role This adds test case for when application_pre_install_role and application_post_install_role are set to custom role; by default they are empty. Code condition coverage is increased. Change-Id: I14e59e15cf3ead0459374b5777f8ee03fe75d7bd Issue-ID: OOM-1910 Signed-off-by: Bartek Grzybowski --- .../roles/prepare-application/defaults/main.yml | 4 +++- .../test/roles/prepare-application/tasks/main.yml | 25 +++++++++++++++------- 2 files changed, 20 insertions(+), 9 deletions(-) (limited to 'ansible/test/roles') diff --git a/ansible/test/roles/prepare-application/defaults/main.yml b/ansible/test/roles/prepare-application/defaults/main.yml index 227bd4f0..c3883c65 100644 --- a/ansible/test/roles/prepare-application/defaults/main.yml +++ b/ansible/test/roles/prepare-application/defaults/main.yml @@ -1,4 +1,6 @@ --- simulate_helm: true app_helm_charts_install_directory: application/helm_charts -helm_simulation_output_file: /tmp/helm_simu_output \ No newline at end of file +helm_simulation_output_file: /tmp/helm_simu_output +application_pre_install_role: application/test-patch-role +application_post_install_role: application/test-patch-role diff --git a/ansible/test/roles/prepare-application/tasks/main.yml b/ansible/test/roles/prepare-application/tasks/main.yml index 2f143a07..75abb802 100644 --- a/ansible/test/roles/prepare-application/tasks/main.yml +++ b/ansible/test/roles/prepare-application/tasks/main.yml @@ -1,9 +1,14 @@ --- -- name: Create Application helm charts directory +- name: Create application role mocked artifacts directories file: - path: "{{ app_helm_charts_install_directory }}" + path: "{{ item }}" state: directory delegate_to: localhost + loop: + - "{{ app_helm_charts_install_directory }}" + - certs + - "{{ application_pre_install_role + '/tasks/' }}" + - "{{ application_post_install_role + '/tasks/' }}" - name: Create Makefile to simulate helm charts dir and make building copy: @@ -33,15 +38,19 @@ name: make state: present -- name: Create local certs dir for dummy certs - file: - path: certs - state: directory - delegate_to: localhost - - name: Create dummy cert file to simulate offline server certificates in helm install with override.yml file copy: content: | this is dummy server certificate value dest: certs/rootCA.crt delegate_to: localhost + +- name: Create test patch role files + copy: + content: | + --- + - name: Mocked up patch role + debug: + msg: "Noop task to mock up patch role" + dest: application/test-patch-role/tasks/main.yml + delegate_to: localhost -- cgit 1.2.3-korg From e75226b2645bb4f0ea8382023c73a21235e50a2b Mon Sep 17 00:00:00 2001 From: Bartek Grzybowski Date: Wed, 5 Jun 2019 10:10:55 +0200 Subject: Clean application role mocked artifacts directories Directories created by Molecule tests were left in files tree and not cleaned up. This patch adds a task to shred them after test invocation. Change-Id: If745cfc45de2f73db5be1696a16a185ff2a625bf Issue-ID: OOM-1910 Signed-off-by: Bartek Grzybowski --- ansible/roles/application/.gitignore | 1 - ansible/roles/application/molecule/custom_role/molecule.yml | 1 + ansible/roles/application/molecule/default/cleanup.yml | 6 ++++++ ansible/test/roles/cleanup-application/tasks/main.yml | 9 +++++++++ 4 files changed, 16 insertions(+), 1 deletion(-) delete mode 100644 ansible/roles/application/.gitignore create mode 100644 ansible/roles/application/molecule/default/cleanup.yml create mode 100644 ansible/test/roles/cleanup-application/tasks/main.yml (limited to 'ansible/test/roles') diff --git a/ansible/roles/application/.gitignore b/ansible/roles/application/.gitignore deleted file mode 100644 index 155cbb20..00000000 --- a/ansible/roles/application/.gitignore +++ /dev/null @@ -1 +0,0 @@ -application/ diff --git a/ansible/roles/application/molecule/custom_role/molecule.yml b/ansible/roles/application/molecule/custom_role/molecule.yml index 5356b197..f9b29d92 100644 --- a/ansible/roles/application/molecule/custom_role/molecule.yml +++ b/ansible/roles/application/molecule/custom_role/molecule.yml @@ -34,6 +34,7 @@ provisioner: playbooks: prepare: ../default/prepare.yml converge: ../default/playbook.yml + cleanup: ../default/cleanup.yml scenario: name: custom_role test_sequence: diff --git a/ansible/roles/application/molecule/default/cleanup.yml b/ansible/roles/application/molecule/default/cleanup.yml new file mode 100644 index 00000000..996acaf1 --- /dev/null +++ b/ansible/roles/application/molecule/default/cleanup.yml @@ -0,0 +1,6 @@ +--- +- name: Cleanup infra + hosts: all + ignore_unreachable: true + roles: + - cleanup-application diff --git a/ansible/test/roles/cleanup-application/tasks/main.yml b/ansible/test/roles/cleanup-application/tasks/main.yml new file mode 100644 index 00000000..cbb8d521 --- /dev/null +++ b/ansible/test/roles/cleanup-application/tasks/main.yml @@ -0,0 +1,9 @@ +--- +- name: Clean application role mocked artifacts directories + file: + path: "{{ item }}" + state: absent + delegate_to: localhost + loop: + - certs + - application -- cgit 1.2.3-korg