Add custom patch role scenario to 'application' role 52/89252/3
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>
Wed, 5 Jun 2019 07:32:29 +0000 (09:32 +0200)
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>
Wed, 5 Jun 2019 07:44:18 +0000 (09:44 +0200)
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 <b.grzybowski@partner.samsung.com>
ansible/roles/application/molecule/custom_role/Dockerfile.j2 [new symlink]
ansible/roles/application/molecule/custom_role/molecule.yml [new file with mode: 0644]
ansible/roles/application/molecule/custom_role/tests [new symlink]
ansible/roles/application/molecule/default/molecule.yml
ansible/test/roles/prepare-application/defaults/main.yml
ansible/test/roles/prepare-application/tasks/main.yml

diff --git a/ansible/roles/application/molecule/custom_role/Dockerfile.j2 b/ansible/roles/application/molecule/custom_role/Dockerfile.j2
new file mode 120000 (symlink)
index 0000000..867ec5c
--- /dev/null
@@ -0,0 +1 @@
+../default/Dockerfile.j2
\ No newline at end of file
diff --git a/ansible/roles/application/molecule/custom_role/molecule.yml b/ansible/roles/application/molecule/custom_role/molecule.yml
new file mode 100644 (file)
index 0000000..5356b19
--- /dev/null
@@ -0,0 +1,54 @@
+---
+dependency:
+  name: galaxy
+driver:
+  name: docker
+lint:
+  name: yamllint
+platforms:
+  - name: instance
+    image: centos:7
+provisioner:
+  name: ansible
+  env:
+    ANSIBLE_ROLES_PATH: ../../../../test/roles
+  inventory:
+    group_vars:
+      all:
+        app_name: moleculetestapp
+        app_data_path: "/opt/{{ app_name }}"
+        app_helm_release_name: "{{ app_name }}"
+        app_kubernetes_namespace: "{{ app_name }}"
+        app_helm_charts_install_directory: application/helm_charts
+        app_helm_plugins_directory: "{{ app_helm_charts_install_directory}}/helm/plugins/"
+        app_helm_charts_infra_directory: "{{ app_data_path }}/helm_charts"
+        helm_bin_dir: /usr/local/bin
+        app_helm_build_targets:
+          - all
+          - onap
+        app_helm_chart_name: "{{ app_name }}"
+        application_pre_install_role: application/test-patch-role
+        application_post_install_role: application/test-patch-role
+  lint:
+    name: ansible-lint
+  playbooks:
+    prepare: ../default/prepare.yml
+    converge: ../default/playbook.yml
+scenario:
+  name: custom_role
+  test_sequence:
+    - lint
+    - cleanup
+    - destroy
+    - dependency
+    - syntax
+    - create
+    - prepare
+    - converge
+    - verify
+    - cleanup
+    - destroy
+verifier:
+  name: testinfra
+  lint:
+    name: flake8
diff --git a/ansible/roles/application/molecule/custom_role/tests b/ansible/roles/application/molecule/custom_role/tests
new file mode 120000 (symlink)
index 0000000..b8ac440
--- /dev/null
@@ -0,0 +1 @@
+../default/tests/
\ No newline at end of file
index 8f19d7f..30c752e 100644 (file)
@@ -27,8 +27,6 @@ provisioner:
           - all
           - onap
         app_helm_chart_name: "{{ app_name }}"
-        application_pre_install_role:
-        application_post_install_role:
   lint:
     name: ansible-lint
 scenario:
index 227bd4f..c3883c6 100644 (file)
@@ -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
index 2f143a0..75abb80 100644 (file)
@@ -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:
     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