Skip to content

Commit 9462904

Browse files
drosenfedanpawlik
authored andcommitted
Add a new custom service validation
The validation verifies that an edpm custom service may be created. After creation it is verified that deployments containing ansibleTags, ansibleSkipTags, ansibleLimit, and ansibleExtraVars are processed correctly.
1 parent 0a01b47 commit 9462904

File tree

2 files changed

+256
-1
lines changed

2 files changed

+256
-1
lines changed

roles/validations/defaults/main.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ cifmw_validations_default_path: "{{ role_path }}/tasks"
3535

3636
# cifmw_validations_edpm_check_node is the node that we will validate for edpm jobs. We
3737
# achieve this by delegating_to the check node and executing the required commands to
38-
# validate that our desired state change has been achieved.
38+
# validate that our desired state change has been achieved. A second check node is also
39+
# available.
3940
cifmw_validations_edpm_check_node: compute-0
41+
cifmw_validations_edpm_second_check_node: compute-1
4042

4143
cifmw_validations_basedir: "{{ cifmw_basedir | default(ansible_user_dir ~ '/ci-framework-data') }}"
4244

Lines changed: 253 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,253 @@
1+
- name: Determine name of deployed NodeSet
2+
environment:
3+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
4+
PATH: "{{ cifmw_path }}"
5+
cifmw.general.ci_script:
6+
output_dir: "{{ cifmw_validations_basedir }}/artifacts"
7+
script: >-
8+
oc get -n {{ cifmw_validations_namespace }} osdpns --no-headers -o custom-columns=":metadata.name"
9+
register: deployed_nodeset_name
10+
11+
# Define a custom service named hello-world. The service has tasks with tags helloworld
12+
# and byeworld. Subsequent tests will use this service to verify that only tasks with
13+
# the proper label are executed.
14+
- name: Create hello-world custom service
15+
environment:
16+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
17+
PATH: "{{ cifmw_path }}"
18+
cifmw.general.ci_script:
19+
output_dir: "{{ cifmw_validations_basedir }}/artifacts"
20+
script: |
21+
oc apply -f - <<EOF
22+
apiVersion: dataplane.openstack.org/v1beta1
23+
kind: OpenStackDataPlaneService
24+
metadata:
25+
name: hello-world
26+
namespace: {{ cifmw_validations_namespace }}
27+
spec:
28+
playbookContents: |
29+
- hosts: all
30+
vars:
31+
target: "World"
32+
become: true
33+
tasks:
34+
{% raw %}
35+
- name: Hello {{ target }}
36+
ansible.builtin.shell:
37+
cmd: >-
38+
echo Hello {{ target }}
39+
tags: helloworld
40+
- name: Bye {{ target }}
41+
ansible.builtin.shell:
42+
cmd: >-
43+
echo Bye {{ target }}
44+
tags: byeworld
45+
{% endraw %}
46+
EOF
47+
48+
# Create a deployment that uses custom service hello-world and only executes
49+
# ansible tasks with tags helloworld
50+
- name: Create openstackdataplanedeployment for ansible tag test
51+
environment:
52+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
53+
PATH: "{{ cifmw_path }}"
54+
cifmw.general.ci_script:
55+
output_dir: "{{ cifmw_validations_basedir }}/artifacts"
56+
script: |
57+
oc apply -f - <<EOF
58+
apiVersion: dataplane.openstack.org/v1beta1
59+
kind: OpenStackDataPlaneDeployment
60+
metadata:
61+
name: hello-world-ansible-tag
62+
namespace: {{ cifmw_validations_namespace }}
63+
spec:
64+
nodeSets:
65+
- "{{ deployed_nodeset_name.stdout | trim }}"
66+
ansibleTags: helloworld
67+
servicesOverride:
68+
- hello-world
69+
EOF
70+
71+
- name: Wait for ansible tag test deployment to be complete
72+
environment:
73+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
74+
PATH: "{{ cifmw_path }}"
75+
cifmw.general.ci_script:
76+
output_dir: "{{ cifmw_validations_basedir }}/artifacts"
77+
script: >-
78+
oc wait openstackdataplanedeployment hello-world-ansible-tag
79+
--namespace={{ cifmw_validations_namespace }}
80+
--for=condition=ready
81+
--timeout={{ cifmw_validations_timeout }}s
82+
83+
- name: Get the ansible tag test log
84+
environment:
85+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
86+
PATH: "{{ cifmw_path }}"
87+
cifmw.general.ci_script:
88+
output_dir: "{{ cifmw_validations_basedir }}/artifacts"
89+
script: >-
90+
oc logs --namespace={{ cifmw_validations_namespace }} job.batch/hello-world-hello-world-ansible-tag-openstack-edpm
91+
register: ansible_tag_test_log
92+
93+
# Need failure msg for xml results file
94+
- name: Verify the ansible tag test log
95+
ansible.builtin.fail:
96+
msg: "Bye World in ansible tag test log or Hello World not in ansible tag test log"
97+
when: "'Bye World' in ansible_tag_test_log.stdout or 'Hello World' not in ansible_tag_test_log.stdout"
98+
99+
# Create a deployment that uses custom service hello-world and skips
100+
# ansible tasks with tags helloworld
101+
- name: Create openstackdataplanedeployment for ansible skip tags test
102+
environment:
103+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
104+
PATH: "{{ cifmw_path }}"
105+
cifmw.general.ci_script:
106+
output_dir: "{{ cifmw_validations_basedir }}/artifacts"
107+
script: |
108+
oc apply -f - <<EOF
109+
apiVersion: dataplane.openstack.org/v1beta1
110+
kind: OpenStackDataPlaneDeployment
111+
metadata:
112+
name: hello-world-skip-tag
113+
namespace: {{ cifmw_validations_namespace }}
114+
spec:
115+
nodeSets:
116+
- "{{ deployed_nodeset_name.stdout | trim }}"
117+
ansibleSkipTags:
118+
helloworld
119+
servicesOverride:
120+
- hello-world
121+
EOF
122+
123+
- name: Wait for ansible skip tag deployment to be complete
124+
environment:
125+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
126+
PATH: "{{ cifmw_path }}"
127+
cifmw.general.ci_script:
128+
output_dir: "{{ cifmw_validations_basedir }}/artifacts"
129+
script: >-
130+
oc wait openstackdataplanedeployment hello-world-skip-tag
131+
--namespace={{ cifmw_validations_namespace }}
132+
--for=condition=ready
133+
--timeout={{ cifmw_validations_timeout }}m
134+
135+
- name: Get the ansible skip tag test log
136+
environment:
137+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
138+
PATH: "{{ cifmw_path }}"
139+
cifmw.general.ci_script:
140+
output_dir: "{{ cifmw_validations_basedir }}/artifacts"
141+
script: >-
142+
oc logs --namespace={{ cifmw_validations_namespace }} job.batch/hello-world-hello-world-skip-tag-openstack-edpm
143+
register: ansible_skip_tag_test_log
144+
145+
# Need failure msg for xml results file
146+
- name: Verify the ansible skip tag test log
147+
ansible.builtin.fail:
148+
msg: "Hello World in ansible skip tag test log or Bye World not in ansible skip tag test log"
149+
when: "'Hello World' in ansible_skip_tag_test_log.stdout or 'Bye World' not in ansible_skip_tag_test_log.stdout"
150+
151+
# Create a deployment that uses custom service hello-world and limits
152+
# ansible task execution to a single compute node
153+
- name: Create openstackdataplanedeployment for ansible limit test
154+
environment:
155+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
156+
PATH: "{{ cifmw_path }}"
157+
cifmw.general.ci_script:
158+
output_dir: "{{ cifmw_validations_basedir }}/artifacts"
159+
script: |
160+
oc apply -f - <<EOF
161+
apiVersion: dataplane.openstack.org/v1beta1
162+
kind: OpenStackDataPlaneDeployment
163+
metadata:
164+
name: hello-world-ansible-limit
165+
namespace: {{ cifmw_validations_namespace }}
166+
spec:
167+
nodeSets:
168+
- "{{ deployed_nodeset_name.stdout | trim }}"
169+
ansibleLimit:
170+
"{{ cifmw_validations_edpm_check_node }}"
171+
servicesOverride:
172+
- hello-world
173+
EOF
174+
175+
- name: Wait for ansible limit deployment to be complete
176+
environment:
177+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
178+
PATH: "{{ cifmw_path }}"
179+
cifmw.general.ci_script:
180+
output_dir: "{{ cifmw_validations_basedir }}/artifacts"
181+
script: >-
182+
oc wait openstackdataplanedeployment hello-world-ansible-limit
183+
--namespace={{ cifmw_validations_namespace }}
184+
--for=condition=ready
185+
--timeout={{ cifmw_validations_timeout }}m
186+
187+
- name: Get the ansible limit test log
188+
environment:
189+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
190+
PATH: "{{ cifmw_path }}"
191+
cifmw.general.ci_script:
192+
output_dir: "{{ cifmw_validations_basedir }}/artifacts"
193+
script: >-
194+
oc logs --namespace={{ cifmw_validations_namespace }} job.batch/hello-world-hello-world-ansible-limit-openstack-edpm
195+
register: ansible_limit_test_log
196+
197+
# Need failure msg for xml results file
198+
- name: Verify the ansible limit test log
199+
ansible.builtin.fail:
200+
msg: "{{ cifmw_validations_edpm_second_check_node }} in ansible limit test log or {{ cifmw_validations_edpm_check_node }} not in ansible skip tag test log"
201+
when: 'cifmw_validations_edpm_second_check_node in ansible_limit_test_log.stdout or cifmw_validations_edpm_check_node not in ansible_limit_test_log.stdout'
202+
203+
# Create a deployment that uses custom service hello-world and uses
204+
# ansibleExtraVars when the service executes
205+
- name: Create openstackdataplanedeployment for ansible extra vars test
206+
environment:
207+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
208+
PATH: "{{ cifmw_path }}"
209+
cifmw.general.ci_script:
210+
output_dir: "{{ cifmw_validations_basedir }}/artifacts"
211+
script: |
212+
oc apply -f - <<EOF
213+
apiVersion: dataplane.openstack.org/v1beta1
214+
kind: OpenStackDataPlaneDeployment
215+
metadata:
216+
name: hello-world-extra-vars
217+
namespace: {{ cifmw_validations_namespace }}
218+
spec:
219+
nodeSets:
220+
- "{{ deployed_nodeset_name.stdout | trim }}"
221+
ansibleExtraVars:
222+
target: Mars
223+
servicesOverride:
224+
- hello-world
225+
EOF
226+
227+
- name: Wait for ansibleExtraVar deployment to be complete
228+
environment:
229+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
230+
PATH: "{{ cifmw_path }}"
231+
cifmw.general.ci_script:
232+
output_dir: "{{ cifmw_validations_basedir }}/artifacts"
233+
script: >-
234+
oc wait openstackdataplanedeployment hello-world-extra-vars
235+
--namespace={{ cifmw_validations_namespace }}
236+
--for=condition=ready
237+
--timeout={{ cifmw_validations_timeout }}m
238+
239+
- name: Get the ansibleExtraVars test log
240+
environment:
241+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
242+
PATH: "{{ cifmw_path }}"
243+
cifmw.general.ci_script:
244+
output_dir: "{{ cifmw_validations_basedir }}/artifacts"
245+
script: >-
246+
oc logs --namespace={{ cifmw_validations_namespace }} job.batch/hello-world-hello-world-extra-vars-openstack-edpm
247+
register: ansible_extra_vars_test_log
248+
249+
# Need failure msg for xml results file
250+
- name: Verify the ansibleExtraVars test log
251+
ansible.builtin.fail:
252+
msg: "World in ansibleExtraVars test log or Mars not in ansibleExtraVars test log"
253+
when: "'World' in ansible_extra_vars_test_log.stdout or 'Mars' not in ansible_extra_vars_test_log.stdout"

0 commit comments

Comments
 (0)