Automatic testcases selection for 'auto' tier
This change request adds a new test tire named 'auto' for healthcheck testsuite
along with functionality to generate testcases.yaml for this tire containing testscases
only of the ONAP components which are currently enabled in the setup.
Signed-off-by: eprasad <prasad.mukhedkar@est.tech>
Change-Id: I98ef342571fd437a55ee378da9380dd6a6198415
diff --git a/playbooks/roles/prepare-testframework/tasks/prepare-xtesting-healthcheck.yaml b/playbooks/roles/prepare-testframework/tasks/prepare-xtesting-healthcheck.yaml
index 461c34c..895af93 100644
--- a/playbooks/roles/prepare-testframework/tasks/prepare-xtesting-healthcheck.yaml
+++ b/playbooks/roles/prepare-testframework/tasks/prepare-xtesting-healthcheck.yaml
@@ -22,7 +22,6 @@
testfw_workdir: "{{ test_cache }}/{{ test_framework }}/{{ test_type }}"
testfw_configdir: "{{ config_path }}/{{ test_framework }}"
testfw_resultdir: "{{ test_cache }}/{{ test_framework }}/{{ test_type }}/results"
-
- name: Ensure {{ testfw_workdir }} exists and empty
file:
path: "{{ testfw_workdir }}"
@@ -53,17 +52,34 @@
- directory
become: true
-- name: Delete healthcheck job
- k8s:
- state: absent
- api: batch/v1
- kind: Job
- namespace: onap
- name: "xtesting-onap-{{ test_type }}"
+- name: Get the list of ONAP componants installed and enabled in the setup
+ shell: "helm ls --deployed --namespace onap -c --output yaml | grep Name: | sed 's/.* //g' | awk -F '-' '{print $2}' | egrep -v '{{ healthcheck_test_ignore_list }}' | awk /./ | sed -e 's/^/- health-/'" # noqa 204
+ register: onap_enabled_services
-- name: Construct and Save healthcheck deployment to file
+- name: Generate testcases.yaml file
template:
- src: "healthcheck_deployment.j2"
+ src: healthcheck-testcases.yaml.j2
+ dest: "{{ testfw_configdir }}/testcases.yaml"
+
+- name: Delete existing {{ healthcheck_config_map }}
+ k8s:
+ name: "{{ healthcheck_config_map }}"
+ kind: ConfigMap
+ api_version: v1
+ state: absent
+ namespace: onap
+
+- name: Create xtesting healthcheck testcases ConfigMap - {{ healthcheck_config_map }}
+ shell: kubectl create configmap {{ healthcheck_config_map }} --from-file "{{ testfw_configdir }}/testcases.yaml"
+
+# eprasad: there is bug in ansible k8s module, removing a job doest not remove pods assisated with it hence using shell here.
+- name: Delete healthcheck job
+ shell: "kubectl delete job xtesting-onap-{{ test_type }} -n onap"
+ ignore_errors: yes
+
+- name: Construct and save healthcheck testsuite deployment to file
+ template:
+ src: "healthcheck_deployment.yaml.j2"
dest: "{{ testfw_configdir }}/healthcheck-{{ test_type }}.yaml"
# vim: set ts=2 sw=2 expandtab:
diff --git a/playbooks/roles/prepare-testframework/templates/healthcheck-testcases.yaml.j2 b/playbooks/roles/prepare-testframework/templates/healthcheck-testcases.yaml.j2
new file mode 100644
index 0000000..1ce9d7f
--- /dev/null
+++ b/playbooks/roles/prepare-testframework/templates/healthcheck-testcases.yaml.j2
@@ -0,0 +1,144 @@
+---
+tiers:
+ -
+ name: healthcheck
+ order: 1
+ ci_loop: '(daily)|(weekly)!(gating)'
+ description: >-
+ Set of basic Functional tests to validate the ONAP installation.
+ testcases:
+ -
+ case_name: auto
+ project_name: integration
+ criteria: 100
+ blocking: false
+ description: >-
+ This test runs a set of basic healthcheck tests to verify only components presently enabled.
+ run:
+ name: 'robotframework'
+ args:
+ suites:
+ - /var/opt/ONAP/robot/testsuites/health-check.robot
+ include:
+{% for item in onap_enabled_services.stdout_lines %}
+{{ item | indent( width=28, indentfirst=True) }}
+{% endfor %}
+ variablefile:
+ - '/share/config/robot_properties.py'
+ -
+ name: healthcheck
+ order: 1
+ ci_loop: '(daily)|(weekly)!(gating)'
+ description: >-
+ Set of basic Functional tests to validate the ONAP installation.
+ testcases:
+ -
+ case_name: core
+ project_name: integration
+ criteria: 100
+ blocking: false
+ description: >-
+ This test case verifies the API of core ONAP components
+ aai, dmap, portal, sdc, sdnc, so, robot
+ run:
+ name: 'robotframework'
+ args:
+ suites:
+ - /var/opt/ONAP/robot/testsuites/health-check.robot
+ include:
+ - core
+ variablefile:
+ - '/share/config/robot_properties.py'
+ -
+ case_name: small
+ project_name: integration
+ criteria: 100
+ blocking: false
+ description: >-
+ This test case verifies the API of the components
+ aai, dmap, portal, sdc, sdnc, so, robot,
+ AAF, APPC, CLI, COnsul, ESR, Log, MSB, Multicloud, NBI, VID
+ run:
+ name: 'robotframework'
+ args:
+ suites:
+ - /var/opt/ONAP/robot/testsuites/health-check.robot
+ include:
+ - core
+ - small
+ variablefile:
+ - '/share/config/robot_properties.py'
+ -
+ case_name: medium
+ project_name: integration
+ criteria: 100
+ blocking: false
+ description: >-
+ This test case verifies the API of the components
+ aai, dmap, portal, sdc, sdnc, so, robot,
+ AAF, APPC, CLI, COnsul, ESR, Log, MSB, Multicloud, NBI, VID,
+ CLAMP, DCAE, OOF, POLICY, UUI, SNIRO
+ run:
+ name: 'robotframework'
+ args:
+ suites:
+ - /var/opt/ONAP/robot/testsuites/health-check.robot
+ include:
+ - core
+ - small
+ - medium
+ variablefile:
+ - '/share/config/robot_properties.py'
+ -
+ case_name: full
+ project_name: integration
+ criteria: 100
+ blocking: false
+ description: >-
+ This test case verifies all the healthcheck Robot tests
+ based on the default robot tests
+ run:
+ name: 'robotframework'
+ args:
+ suites:
+ - /var/opt/ONAP/robot/testsuites/health-check.robot
+ include:
+ - health
+ variablefile:
+ - '/share/config/robot_properties.py'
+ -
+ case_name: postinstall
+ project_name: integration
+ criteria: 100
+ blocking: false
+ description: >-
+ This test runs a set of test to verify some components at
+ the end of the installation: DMAAP Message Router ACL
+ Update Test and AAI Service Design Models Size Test
+ run:
+ name: 'robotframework'
+ args:
+ suites:
+ - /var/opt/ONAP/robot/testsuites/post-install-tests.robot
+ include:
+ - postinstall
+ variablefile:
+ - '/share/config/robot_properties.py'
+ -
+ case_name: healthdist
+ project_name: integration
+ criteria: 100
+ blocking: false
+ description: >-
+ This test case verifies that the vFW model is properly
+ distributed. At the end the csar file shall be downloaded
+ from the sdc
+ run:
+ name: 'robotframework'
+ args:
+ suites:
+ - /var/opt/ONAP/robot/testsuites/health-check.robot
+ include:
+ - healthdist
+ variablefile:
+ - '/share/config/robot_properties.py'
diff --git a/playbooks/roles/prepare-testframework/templates/healthcheck_deployment.yaml.j2 b/playbooks/roles/prepare-testframework/templates/healthcheck_deployment.yaml.j2
new file mode 100644
index 0000000..1a44f5f
--- /dev/null
+++ b/playbooks/roles/prepare-testframework/templates/healthcheck_deployment.yaml.j2
@@ -0,0 +1,53 @@
+apiVersion: batch/v1
+kind: Job
+metadata:
+ name: "xtesting-onap-{{ test_type }}"
+ namespace: onap
+spec:
+ template:
+ spec:
+ containers:
+ - env:
+ - name: INSTALLER_TYPE
+ value: kubespray-oom
+ - name: DEPLOY_SCENARIO
+ value: "{{ deploy_scenario }}"
+ - name: NODE_NAME
+ value: {{ lookup('env', 'POD_NAME') | default('noname', true) }}
+ - name: TEST_DB_URL
+ value: http://testresults.opnfv.org/onap/api/v1/results
+ - name: BUILD_TAG
+ value: "{{ lookup('env', 'BUILD_TAG') | default('notag', true) }}"
+ - name: TAG
+ value: "{{ test_type }}"
+ image: "{{ testfw_image_name }}@sha256:{{ testfw_image_version }}"
+ imagePullPolicy: IfNotPresent
+ name: xtesting-onap
+ volumeMounts:
+ - mountPath: /etc/localtime
+ name: localtime
+ readOnly: true
+ - mountPath: /share/config
+ name: robot-eteshare
+ - mountPath: /var/lib/xtesting/results/
+ name: robot-save-results
+ - mountPath: /usr/lib/python3.7/site-packages/xtesting/ci/testcases.yaml
+ subPath: testcases.yaml
+ name: "{{ healthcheck_config_map }}"
+ restartPolicy: OnFailure
+ volumes:
+ - hostPath:
+ path: /etc/localtime
+ name: localtime
+ - configMap:
+ defaultMode: 493
+ name: onapdep-robot-eteshare-configmap
+ name: robot-eteshare
+ - configMap:
+ defaultMode: 493
+ name: "{{ healthcheck_config_map }}"
+ name: "{{ healthcheck_config_map }}"
+ - hostPath:
+ path: "{{ testfw_resultdir }}"
+ type: DirectoryOrCreate
+ name: robot-save-results
diff --git a/playbooks/roles/prepare-testframework/vars/main.yaml b/playbooks/roles/prepare-testframework/vars/main.yaml
index 3ddeaae..4efb6d9 100644
--- a/playbooks/roles/prepare-testframework/vars/main.yaml
+++ b/playbooks/roles/prepare-testframework/vars/main.yaml
@@ -17,3 +17,4 @@
# SPDX-License-Identifier: Apache-2.0
# ============LICENSE_END=========================================================
testcase: all
+healthcheck_config_map: xtesting-healthcheck-testsuit-config-map
diff --git a/playbooks/roles/run-tests/tasks/healthcheck.yaml b/playbooks/roles/run-tests/tasks/healthcheck.yaml
index 34df2ff..736f6d2 100644
--- a/playbooks/roles/run-tests/tasks/healthcheck.yaml
+++ b/playbooks/roles/run-tests/tasks/healthcheck.yaml
@@ -43,7 +43,7 @@
- name: Save healthcheck testsuite output on jumphost
copy:
- content: healthcheck_log.stdout_lines
+ content: "{{ healthcheck_log.stdout }}"
dest: "{{ test_cache }}/xtesting/{{ test_type }}/results/xtesting.log"
- name: Determine the test verdict