summaryrefslogtreecommitdiffstats
path: root/ansible/roles/application/molecule
diff options
context:
space:
mode:
Diffstat (limited to 'ansible/roles/application/molecule')
-rw-r--r--ansible/roles/application/molecule/default/Dockerfile.j214
-rw-r--r--ansible/roles/application/molecule/default/molecule.yml60
-rw-r--r--ansible/roles/application/molecule/default/playbook.yml5
-rw-r--r--ansible/roles/application/molecule/default/prepare.yml5
-rw-r--r--ansible/roles/application/molecule/default/tests/test_default.py29
5 files changed, 113 insertions, 0 deletions
diff --git a/ansible/roles/application/molecule/default/Dockerfile.j2 b/ansible/roles/application/molecule/default/Dockerfile.j2
new file mode 100644
index 00000000..e6aa95d3
--- /dev/null
+++ b/ansible/roles/application/molecule/default/Dockerfile.j2
@@ -0,0 +1,14 @@
+# Molecule managed
+
+{% if item.registry is defined %}
+FROM {{ item.registry.url }}/{{ item.image }}
+{% else %}
+FROM {{ item.image }}
+{% endif %}
+
+RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
+ elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash && dnf clean all; \
+ elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
+ elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml && zypper clean -a; \
+ elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; \
+ elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates && xbps-remove -O; fi
diff --git a/ansible/roles/application/molecule/default/molecule.yml b/ansible/roles/application/molecule/default/molecule.yml
new file mode 100644
index 00000000..8f19d7ff
--- /dev/null
+++ b/ansible/roles/application/molecule/default/molecule.yml
@@ -0,0 +1,60 @@
+---
+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_post_install_role:
+ lint:
+ name: ansible-lint
+scenario:
+ name: default
+ test_sequence:
+ - lint
+ - cleanup
+ - destroy
+ - dependency
+ - syntax
+ - create
+ - prepare
+ - converge
+ # - idempotence
+ # --> Action: 'idempotence'
+ # ERROR: Idempotence test failed because of the following tasks:
+ # * [instance] => application : Get helm dir
+ # * [instance] => application : Helm init and upgrade
+ # * [instance] => application : Helm Serve
+ # * [instance] => application : Helm Add Repo
+ # * [instance] => application : Helm Install application moleculetestapp
+ - side_effect
+ - verify
+ - cleanup
+ - destroy
+verifier:
+ name: testinfra
+ lint:
+ name: flake8
diff --git a/ansible/roles/application/molecule/default/playbook.yml b/ansible/roles/application/molecule/default/playbook.yml
new file mode 100644
index 00000000..4121f124
--- /dev/null
+++ b/ansible/roles/application/molecule/default/playbook.yml
@@ -0,0 +1,5 @@
+---
+- name: Helm charts available
+ hosts: all
+ roles:
+ - application
diff --git a/ansible/roles/application/molecule/default/prepare.yml b/ansible/roles/application/molecule/default/prepare.yml
new file mode 100644
index 00000000..8a5288dd
--- /dev/null
+++ b/ansible/roles/application/molecule/default/prepare.yml
@@ -0,0 +1,5 @@
+---
+- name: Prepare infra
+ hosts: all
+ roles:
+ - prepare-application
diff --git a/ansible/roles/application/molecule/default/tests/test_default.py b/ansible/roles/application/molecule/default/tests/test_default.py
new file mode 100644
index 00000000..3e0cbb42
--- /dev/null
+++ b/ansible/roles/application/molecule/default/tests/test_default.py
@@ -0,0 +1,29 @@
+import os
+
+import testinfra.utils.ansible_runner
+
+testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
+ os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
+
+
+def test_helm_commands(host):
+ fc = host.file('/tmp/helm_simu_output').content_string
+ expected_content = """home
+init --upgrade --skip-refresh
+version --tiller-connection-timeout 10
+repo list
+serve
+repo list
+repo add local http://127.0.0.1:8879
+install --name moleculetestapp local/moleculetestapp --namespace \
+moleculetestapp -f /opt/moleculetestapp/override.yaml"""
+ assert fc == expected_content
+
+
+def test_helm_override_file(host):
+ fc = host.file('/opt/moleculetestapp/override.yaml').content_string
+ expected_content = """global:
+ cacert: 'this is dummy server certificate value
+
+ '"""
+ assert fc == expected_content