summaryrefslogtreecommitdiffstats
path: root/ansible
diff options
context:
space:
mode:
authorSamuli Silvius <s.silvius@partner.samsung.com>2019-04-21 19:24:18 +0300
committerMichal Ptacek <m.ptacek@partner.samsung.com>2019-05-29 10:44:06 +0000
commit2353ca7b38acbd7246adbf23b7d92723bc083dcf (patch)
tree577e2a90e67954778f757d1a25bab2eaaba9d4e4 /ansible
parent14f47a0f47990a7e51123fcabd6c124285ebdc45 (diff)
Molecule test for infrastructure playbook.
These tests execute the whole infrastructure playbook. Issue-ID: OOM-1816 Change-Id: I793191e05cb0b527c3da6d820c1916231e69d865 Signed-off-by: Samuli Silvius <s.silvius@partner.samsung.com> Signed-off-by: Michal Zegan <m.zegan@samsung.com>
Diffstat (limited to 'ansible')
-rw-r--r--ansible/test/play-infrastructure/.yamllint11
-rw-r--r--ansible/test/play-infrastructure/molecule/default/molecule.yml73
-rw-r--r--ansible/test/play-infrastructure/molecule/default/playbook.yml11
-rw-r--r--ansible/test/play-infrastructure/molecule/default/prepare.yml25
-rw-r--r--ansible/test/play-infrastructure/molecule/default/tests/test_nodes.py11
-rw-r--r--ansible/test/play-infrastructure/molecule/default/vars.yml24
6 files changed, 155 insertions, 0 deletions
diff --git a/ansible/test/play-infrastructure/.yamllint b/ansible/test/play-infrastructure/.yamllint
new file mode 100644
index 00000000..ad0be760
--- /dev/null
+++ b/ansible/test/play-infrastructure/.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/test/play-infrastructure/molecule/default/molecule.yml b/ansible/test/play-infrastructure/molecule/default/molecule.yml
new file mode 100644
index 00000000..894ab804
--- /dev/null
+++ b/ansible/test/play-infrastructure/molecule/default/molecule.yml
@@ -0,0 +1,73 @@
+---
+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
+ restart_policy: unless-stopped
+ volumes:
+ - /var/lib/docker
+ - /opt/onap
+ groups:
+ - infrastructure
+ networks:
+ - name: infrastructure-net
+ purge_networks: true
+
+ - name: kubernetes-node-1
+ image: molecule-${PREBUILD_PLATFORM_DISTRO:-centos}:${PREBUILD_DISTRO_VERSION:-centos7.6}
+ pre_build_image: true
+ privileged: true
+ override_command: false
+ restart_policy: unless-stopped
+ env:
+ container: docker
+ volumes:
+ - /var/lib/docker
+ groups:
+ - kubernetes
+ networks:
+ - name: infrastructure-net
+ purge_networks: true
+
+provisioner:
+ name: ansible
+ env:
+ ANSIBLE_ROLES_PATH: ../../../roles:../../../../roles/
+ ANSIBLE_LIBRARY: ../../../../library
+ inventory:
+ links:
+ group_vars: ../../../../group_vars
+ 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:
+ # * [infrastructure-server -> 10.0.2.15] => certificates : Generate an OpenSSL CSR.
+ # * [infrastructure-server -> 10.0.2.15] => certificates : Generate root CA certificate
+ - side_effect
+ - verify
+ - cleanup
+ - destroy
+verifier:
+ name: testinfra
+ lint:
+ name: flake8
diff --git a/ansible/test/play-infrastructure/molecule/default/playbook.yml b/ansible/test/play-infrastructure/molecule/default/playbook.yml
new file mode 100644
index 00000000..26b3c15d
--- /dev/null
+++ b/ansible/test/play-infrastructure/molecule/default/playbook.yml
@@ -0,0 +1,11 @@
+---
+- name: Common setup for all hosts
+ hosts: all
+ tasks:
+ - name: Set cluster_ip variable
+ set_fact:
+ cluster_ip: "{{ ansible_default_ipv4.address }}"
+ - name: Include variables
+ include_vars: vars.yml
+
+- import_playbook: ../../../../infrastructure.yml
diff --git a/ansible/test/play-infrastructure/molecule/default/prepare.yml b/ansible/test/play-infrastructure/molecule/default/prepare.yml
new file mode 100644
index 00000000..86e25b48
--- /dev/null
+++ b/ansible/test/play-infrastructure/molecule/default/prepare.yml
@@ -0,0 +1,25 @@
+---
+- name: Prepare infra
+ hosts: infrastructure
+ roles:
+ - prepare-package-repository
+ - prepare-chrony
+ - prepare-vncserver
+ - prepare-nginx
+ - prepare-nexus
+ - prepare-dns
+ - prepare-firewall
+ vars_files:
+ - vars.yml
+ - ../../../../roles/nginx/defaults/main.yml
+ - ../../../../roles/vncserver/defaults/main.yml
+ - ../../../../roles/nexus/defaults/main.yml
+ - ../../../../roles/dns/defaults/main.yml
+
+- name: Prepare kubernetes
+ hosts: kubernetes
+ roles:
+ - prepare-chrony
+ - prepare-firewall
+ vars_files:
+ - vars.yml
diff --git a/ansible/test/play-infrastructure/molecule/default/tests/test_nodes.py b/ansible/test/play-infrastructure/molecule/default/tests/test_nodes.py
new file mode 100644
index 00000000..c0ce64f2
--- /dev/null
+++ b/ansible/test/play-infrastructure/molecule/default/tests/test_nodes.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('kubernetes')
+
+
+def test_registry_access(host):
+ assert host.run(
+ 'docker login -u admin -p admin123 nexus3.onap.org:10001').rc == 0
diff --git a/ansible/test/play-infrastructure/molecule/default/vars.yml b/ansible/test/play-infrastructure/molecule/default/vars.yml
new file mode 100644
index 00000000..e91eadb2
--- /dev/null
+++ b/ansible/test/play-infrastructure/molecule/default/vars.yml
@@ -0,0 +1,24 @@
+---
+vnc_passwd: molecule
+certificates:
+ organization_name: Molecule Testers
+ state_or_province_name: Finland
+ country_name: FI
+ locality_name: Tampere
+app_name: onap
+app_data_path: "/opt/{{ app_name }}"
+
+nexus_come_up_wait_retries: 60
+populate_nexus: true # Different from default, molecule tests also nexus's configure.yml
+
+molecule_test_registry: nexus3.onap.org:10001
+# Different from default i.e. also additional images population is tested with molecule
+runtime_images:
+ busybox:
+ registry: "{{ molecule_test_registry }}"
+ path: "/onap/components/busybox"
+ tag: "latest"
+ aaionap-haproxy:
+ registry: "{{ molecule_test_registry }}"
+ path: "/onap/components/aaionap/haproxy"
+ tag: "1.2.4"