From ae39a0515e9ce2f7d0a13934237b396372f7f062 Mon Sep 17 00:00:00 2001 From: Bartek Grzybowski Date: Tue, 4 Jan 2022 13:51:54 +0100 Subject: [MOLECULE] Add molecule setup for kube_prometheus.yml playbook nfs_mount_path in kube-prometheus-stack role is coerced to global value from group_vars to allow direct verifier test reuse in playbook run. Change-Id: I125355f2b65b57ae6782b9eafcb6d6b58a7444e0 Issue-ID: OOM-2908 Signed-off-by: Bartek Grzybowski --- .../molecule/default/molecule.yml | 2 +- .../molecule/default/tests/test_default.py | 4 ++-- ansible/test/play-kube_prometheus/.yamllint | 12 +++++++++++ .../molecule/default/converge.yml | 8 ++++++++ .../molecule/default/molecule.yml | 24 ++++++++++++++++++++++ .../molecule/default/prepare.yml | 10 +++++++++ .../play-kube_prometheus/molecule/default/vars.yml | 5 +++++ 7 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 ansible/test/play-kube_prometheus/.yamllint create mode 100644 ansible/test/play-kube_prometheus/molecule/default/converge.yml create mode 100644 ansible/test/play-kube_prometheus/molecule/default/molecule.yml create mode 100644 ansible/test/play-kube_prometheus/molecule/default/prepare.yml create mode 100644 ansible/test/play-kube_prometheus/molecule/default/vars.yml (limited to 'ansible') diff --git a/ansible/roles/kube-prometheus-stack/molecule/default/molecule.yml b/ansible/roles/kube-prometheus-stack/molecule/default/molecule.yml index c1eafa3b..bf9ed856 100644 --- a/ansible/roles/kube-prometheus-stack/molecule/default/molecule.yml +++ b/ansible/roles/kube-prometheus-stack/molecule/default/molecule.yml @@ -23,6 +23,6 @@ provisioner: all: app_name: onap app_data_path: "/opt/{{ app_name }}" - nfs_mount_path: "/nfs" + nfs_mount_path: "/dockerdata-nfs" verifier: name: testinfra diff --git a/ansible/roles/kube-prometheus-stack/molecule/default/tests/test_default.py b/ansible/roles/kube-prometheus-stack/molecule/default/tests/test_default.py index ad2d90c3..18da24e8 100644 --- a/ansible/roles/kube-prometheus-stack/molecule/default/tests/test_default.py +++ b/ansible/roles/kube-prometheus-stack/molecule/default/tests/test_default.py @@ -26,7 +26,7 @@ def test_helm_values_file(host): def test_grafana_dashboards(host): - assert host.file('/nfs/kube-prometheus/kube-prometheus-grafana/' + assert host.file('/dockerdata-nfs/kube-prometheus/kube-prometheus-grafana/' 'dashboards/custom/grafana_dashboard.json').exists - assert host.file('/nfs/kube-prometheus/kube-prometheus-grafana/' + assert host.file('/dockerdata-nfs/kube-prometheus/kube-prometheus-grafana/' 'dashboards/grafana_home.json').exists diff --git a/ansible/test/play-kube_prometheus/.yamllint b/ansible/test/play-kube_prometheus/.yamllint new file mode 100644 index 00000000..c5ae64be --- /dev/null +++ b/ansible/test/play-kube_prometheus/.yamllint @@ -0,0 +1,12 @@ +--- +extends: default + +rules: + braces: + max-spaces-inside: 1 + level: error + brackets: + max-spaces-inside: 1 + level: error + line-length: disable + truthy: disable diff --git a/ansible/test/play-kube_prometheus/molecule/default/converge.yml b/ansible/test/play-kube_prometheus/molecule/default/converge.yml new file mode 100644 index 00000000..f47c622f --- /dev/null +++ b/ansible/test/play-kube_prometheus/molecule/default/converge.yml @@ -0,0 +1,8 @@ +--- +- name: Initialize + hosts: all + tasks: + - name: Include variables + include_vars: vars.yml + +- import_playbook: ../../../../kube_prometheus.yml diff --git a/ansible/test/play-kube_prometheus/molecule/default/molecule.yml b/ansible/test/play-kube_prometheus/molecule/default/molecule.yml new file mode 100644 index 00000000..a21bf1ec --- /dev/null +++ b/ansible/test/play-kube_prometheus/molecule/default/molecule.yml @@ -0,0 +1,24 @@ +--- +dependency: + name: galaxy +driver: + name: docker +lint: | + set -e + yamllint . + ansible-lint . + flake8 +platforms: + - name: infrastructure-play-kube-prometheus + image: molecule-${PREBUILD_PLATFORM_DISTRO:-centos}:${PREBUILD_DISTRO_VERSION:-centos7.9} + pre_build_image: true + groups: + - infrastructure +provisioner: + name: ansible + env: + ANSIBLE_ROLES_PATH: ../../../../test/roles + ANSIBLE_LIBRARY: ../../../../library +verifier: + name: testinfra + directory: ../../../../roles/kube-prometheus-stack/molecule/default/tests/ diff --git a/ansible/test/play-kube_prometheus/molecule/default/prepare.yml b/ansible/test/play-kube_prometheus/molecule/default/prepare.yml new file mode 100644 index 00000000..1a1a298c --- /dev/null +++ b/ansible/test/play-kube_prometheus/molecule/default/prepare.yml @@ -0,0 +1,10 @@ +--- +- name: Prepare infra + hosts: infrastructure + pre_tasks: + - name: Include infrastructure group variables + include_vars: ../../../../group_vars/infrastructure.yml + - name: Include test setup variables + include_vars: vars.yml + roles: + - prepare-kube-prometheus-stack diff --git a/ansible/test/play-kube_prometheus/molecule/default/vars.yml b/ansible/test/play-kube_prometheus/molecule/default/vars.yml new file mode 100644 index 00000000..1256ac42 --- /dev/null +++ b/ansible/test/play-kube_prometheus/molecule/default/vars.yml @@ -0,0 +1,5 @@ +--- +k8s_volumes: [] +app_name: onap +app_data_path: "/opt/{{ app_name }}" +nfs_mount_path: "/dockerdata-nfs" -- cgit 1.2.3-korg