Skip to content

Commit 617b210

Browse files
committed
Add a new validation to verify creation and usage of
edpm custom services.
1 parent 61c908b commit 617b210

File tree

2 files changed

+254
-1
lines changed

2 files changed

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

0 commit comments

Comments
 (0)