blob: f62662b1c85a87863091f7c7604a859028f9896e [file] [log] [blame]
eprasadef12f102020-11-25 08:57:22 +00001---
2# ============LICENSE_START=======================================================
3# Copyright (C) 2020 The Nordix Foundation. All rights reserved.
4# ================================================================================
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17# SPDX-License-Identifier: Apache-2.0
18# ============LICENSE_END=========================================================
19
20- name: Set test work and result directories
21 set_fact:
eprasad81108dc2020-12-29 11:49:10 +000022 testfw_workdir: "{{ test_cache }}/{{ test_framework }}/{{ healthcheck_test_tier }}"
eprasadef12f102020-11-25 08:57:22 +000023 testfw_configdir: "{{ config_path }}/{{ test_framework }}"
eprasad81108dc2020-12-29 11:49:10 +000024 testfw_resultdir: "{{ test_cache }}/{{ test_framework }}/{{ healthcheck_test_tier }}/results"
25
eprasadef12f102020-11-25 08:57:22 +000026- name: Ensure {{ testfw_workdir }} exists and empty
27 file:
28 path: "{{ testfw_workdir }}"
29 state: "{{ item }}"
30 mode: 0755
31 with_items:
32 - absent
33 - directory
34 become: true
35
36- name: Ensure {{ testfw_configdir }} exists and empty
37 file:
38 path: "{{ testfw_configdir }}"
39 state: "{{ item }}"
40 mode: 0755
41 with_items:
42 - absent
43 - directory
44 become: true
45
46- name: Ensure {{ testfw_resultdir }} exists and empty
47 file:
48 path: "{{ testfw_resultdir }}"
49 state: "{{ item }}"
50 mode: 0755
51 with_items:
52 - absent
53 - directory
54 become: true
55
eprasadada6d5b2020-12-07 17:18:33 +000056- name: Get the list of ONAP componants installed and enabled in the setup
Akash Rajgurua5e57642021-06-02 14:40:39 +010057 shell: |
58 set -o pipefail && \
59 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
60 args:
61 executable: "/bin/bash"
62 changed_when: false
eprasadada6d5b2020-12-07 17:18:33 +000063 register: onap_enabled_services
eprasadef12f102020-11-25 08:57:22 +000064
Akash Rajgurua5e57642021-06-02 14:40:39 +010065
eprasadada6d5b2020-12-07 17:18:33 +000066- name: Generate testcases.yaml file
eprasadef12f102020-11-25 08:57:22 +000067 template:
eprasadada6d5b2020-12-07 17:18:33 +000068 src: healthcheck-testcases.yaml.j2
69 dest: "{{ testfw_configdir }}/testcases.yaml"
70
Akash Rajgurua5e57642021-06-02 14:40:39 +010071- name: Create cmd.sh file
eprasad81108dc2020-12-29 11:49:10 +000072 copy:
73 dest: "{{ testfw_configdir }}/cmd.sh"
74 content: |
75 #!/bin/sh
Akash Rajgurua5e57642021-06-02 14:40:39 +010076 run_tests -t ${TAG} || true
eprasad81108dc2020-12-29 11:49:10 +000077
78- name: Delete existing {{ healthcheck_cm_testcases }}
eprasadada6d5b2020-12-07 17:18:33 +000079 k8s:
eprasad81108dc2020-12-29 11:49:10 +000080 name: "{{ healthcheck_cm_testcases }}"
eprasadada6d5b2020-12-07 17:18:33 +000081 kind: ConfigMap
82 api_version: v1
83 state: absent
84 namespace: onap
85
eprasad81108dc2020-12-29 11:49:10 +000086- name: Delete existing {{ healthcheck_cm_run }}
87 k8s:
88 name: "{{ healthcheck_cm_run }}"
89 kind: ConfigMap
90 api_version: v1
91 state: absent
92 namespace: onap
Akash Rajgurua5e57642021-06-02 14:40:39 +010093
eprasad81108dc2020-12-29 11:49:10 +000094
95- name: Create ConfigMap - {{ healthcheck_cm_testcases }}
Akash Rajgurua5e57642021-06-02 14:40:39 +010096 shell: |
97 kubectl -n {{ onap_namespace }} create configmap {{ healthcheck_cm_testcases }} --from-file "{{ testfw_configdir }}/testcases.yaml"
98 args:
99 executable: "/bin/bash"
100 changed_when: false
eprasad81108dc2020-12-29 11:49:10 +0000101
102- name: Create ConfigMap - {{ healthcheck_cm_run }}
Akash Rajgurua5e57642021-06-02 14:40:39 +0100103 shell: |
104 kubectl -n {{ onap_namespace }} create configmap {{ healthcheck_cm_run }} --from-file "{{ testfw_configdir }}/cmd.sh"
105 args:
106 executable: "/bin/bash"
107 changed_when: false
eprasad81108dc2020-12-29 11:49:10 +0000108
eprasadada6d5b2020-12-07 17:18:33 +0000109
110# eprasad: there is bug in ansible k8s module, removing a job doest not remove pods assisated with it hence using shell here.
111- name: Delete healthcheck job
Akash Rajgurua5e57642021-06-02 14:40:39 +0100112 shell: |
113 "kubectl -n {{ onap_namespace }} delete job xtesting-onap-{{ healthcheck_test_tier }}"
114 args:
115 executable: "/bin/bash"
116 changed_when: false
117 ignore_errors: yes # yamllint disable-line rule:truthy
eprasadada6d5b2020-12-07 17:18:33 +0000118
119- name: Construct and save healthcheck testsuite deployment to file
120 template:
121 src: "healthcheck_deployment.yaml.j2"
eprasad81108dc2020-12-29 11:49:10 +0000122 dest: "{{ testfw_configdir }}/healthcheck-{{ healthcheck_test_tier }}.yaml"
eprasadef12f102020-11-25 08:57:22 +0000123
124# vim: set ts=2 sw=2 expandtab: