summaryrefslogtreecommitdiffstats
path: root/ansible/roles/kubectl
diff options
context:
space:
mode:
authorMichal Zegan <m.zegan@samsung.com>2019-06-04 17:11:59 +0200
committerMichal Zegan <m.zegan@samsung.com>2019-06-05 13:24:08 +0200
commit049151d457861eca1d9fd2568a5aaf1d85f6c790 (patch)
tree23667362fcc5a0bfce19d2265d8647e4807a5a44 /ansible/roles/kubectl
parent551e2682c6c473bdb96aa59ddc18612a436e4b46 (diff)
Add molecule tests for kubectl role
This commit adds molecule tests for kubectl role. That includes verification for kubectl to be installed and runnable. Change-Id: I4cb0679ed6826555a6d1f6cff4542ae52869f404 Issue-ID: OOM-1908 Signed-off-by: Michal Zegan <m.zegan@samsung.com>
Diffstat (limited to 'ansible/roles/kubectl')
-rw-r--r--ansible/roles/kubectl/.yamllint11
-rw-r--r--ansible/roles/kubectl/molecule/default/molecule.yml31
-rw-r--r--ansible/roles/kubectl/molecule/default/playbook.yml5
-rw-r--r--ansible/roles/kubectl/molecule/default/prepare.yml5
-rw-r--r--ansible/roles/kubectl/molecule/default/tests/test_default.py11
5 files changed, 63 insertions, 0 deletions
diff --git a/ansible/roles/kubectl/.yamllint b/ansible/roles/kubectl/.yamllint
new file mode 100644
index 00000000..ad0be760
--- /dev/null
+++ b/ansible/roles/kubectl/.yamllint
@@ -0,0 +1,11 @@
+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/roles/kubectl/molecule/default/molecule.yml b/ansible/roles/kubectl/molecule/default/molecule.yml
new file mode 100644
index 00000000..bffb29e6
--- /dev/null
+++ b/ansible/roles/kubectl/molecule/default/molecule.yml
@@ -0,0 +1,31 @@
+---
+dependency:
+ name: galaxy
+driver:
+ name: docker
+lint:
+ name: yamllint
+platforms:
+ - name: infrastructure-server
+ image: molecule-${PREBUILD_PLATFORM_DISTRO:-centos}:${PREBUILD_DISTRO_VERSION:-centos7.6}
+ pre_build_image: True
+ privileged: true
+ override_command: False
+ groups:
+ - infrastructure
+provisioner:
+ name: ansible
+ lint:
+ name: ansible-lint
+ env:
+ ANSIBLE_ROLES_PATH: ../../../../test/roles
+ ANSIBLE_LIBRARY: ../../../../library
+ inventory:
+ group_vars:
+ all:
+ app_name: onap
+ app_data_path: "/opt/{{ app_name }}"
+verifier:
+ name: testinfra
+ lint:
+ name: flake8
diff --git a/ansible/roles/kubectl/molecule/default/playbook.yml b/ansible/roles/kubectl/molecule/default/playbook.yml
new file mode 100644
index 00000000..ab9c08a8
--- /dev/null
+++ b/ansible/roles/kubectl/molecule/default/playbook.yml
@@ -0,0 +1,5 @@
+---
+- name: Converge
+ hosts: all
+ roles:
+ - kubectl
diff --git a/ansible/roles/kubectl/molecule/default/prepare.yml b/ansible/roles/kubectl/molecule/default/prepare.yml
new file mode 100644
index 00000000..ec17626a
--- /dev/null
+++ b/ansible/roles/kubectl/molecule/default/prepare.yml
@@ -0,0 +1,5 @@
+---
+- name: Prepare for kubectl tests
+ hosts: all
+ roles:
+ - prepare-kubectl
diff --git a/ansible/roles/kubectl/molecule/default/tests/test_default.py b/ansible/roles/kubectl/molecule/default/tests/test_default.py
new file mode 100644
index 00000000..4f799b95
--- /dev/null
+++ b/ansible/roles/kubectl/molecule/default/tests/test_default.py
@@ -0,0 +1,11 @@
+import os
+
+import testinfra.utils.ansible_runner
+
+testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
+ os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
+
+
+def test_kubectl(host):
+ assert host.file('/usr/local/bin/kubectl').exists
+ assert host.run('kubectl').rc != 127