Skip to content

Commit b68bf7c

Browse files
authored
Add support for tags to molecule tests (#62)
1 parent 28223db commit b68bf7c

File tree

5 files changed

+254
-142
lines changed

5 files changed

+254
-142
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
minor_changes:
3+
- add support for using tags when running molecule test suite (https://github.com/ansible-collections/kubernetes.core/pull/62).

molecule/default/converge.yml

+115-12
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,123 @@
2020
assert:
2121
that: (pod_list.resources | count) > 5
2222

23-
- include_tasks: tasks/delete.yml
24-
- include_tasks: tasks/scale.yml
25-
- include_tasks: tasks/apply.yml
26-
- include_tasks: tasks/waiter.yml
27-
- include_tasks: tasks/full.yml
28-
- include_tasks: tasks/exec.yml
29-
- include_tasks: tasks/log.yml
30-
- include_tasks: tasks/cluster_info.yml
31-
- include_tasks: tasks/access_review.yml
32-
- include_tasks: tasks/rollback.yml
33-
- include_tasks: tasks/gc.yml
23+
- name: Include access_review.yml
24+
include_tasks:
25+
file: tasks/access_review.yml
26+
apply:
27+
tags: [ access_review, k8s ]
28+
tags:
29+
- always
30+
- name: Include append_hash.yml
31+
include_tasks:
32+
file: tasks/append_hash.yml
33+
apply:
34+
tags: [ append_hash, k8s ]
35+
tags:
36+
- always
37+
- name: Include apply.yml
38+
include_tasks:
39+
file: tasks/apply.yml
40+
apply:
41+
tags: [ apply, k8s ]
42+
tags:
43+
- always
44+
- name: Include cluster_info.yml
45+
include_tasks:
46+
file: tasks/cluster_info.yml
47+
apply:
48+
tags: [ cluster_info, k8s ]
49+
tags:
50+
- always
51+
- name: Include crd.yml
52+
include_tasks:
53+
file: tasks/crd.yml
54+
apply:
55+
tags: [ crd, k8s ]
56+
tags:
57+
- always
58+
- name: Include delete.yml
59+
include_tasks:
60+
file: tasks/delete.yml
61+
apply:
62+
tags: [ delete, k8s ]
63+
tags:
64+
- always
65+
- name: Include exec.yml
66+
include_tasks:
67+
file: tasks/exec.yml
68+
apply:
69+
tags: [ exec, k8s ]
70+
tags:
71+
- always
72+
- name: Include full.yml
73+
include_tasks:
74+
file: tasks/full.yml
75+
apply:
76+
tags: [ full, k8s ]
77+
tags:
78+
- always
79+
- name: Include gc.yml
80+
include_tasks:
81+
file: tasks/gc.yml
82+
apply:
83+
tags: [ gc, k8s ]
84+
tags:
85+
- always
86+
- name: Include info.yml
87+
include_tasks:
88+
file: tasks/info.yml
89+
apply:
90+
tags: [ info, k8s ]
91+
tags:
92+
- always
93+
- name: Include lists.yml
94+
include_tasks:
95+
file: tasks/lists.yml
96+
apply:
97+
tags: [ lists, k8s ]
98+
tags:
99+
- always
100+
- name: Include log.yml
101+
include_tasks:
102+
file: tasks/log.yml
103+
apply:
104+
tags: [ log, k8s ]
105+
tags:
106+
- always
107+
- name: Include rollback.yml
108+
include_tasks:
109+
file: tasks/rollback.yml
110+
apply:
111+
tags: [ rollback, k8s ]
112+
tags:
113+
- always
114+
- name: Include scale.yml
115+
include_tasks:
116+
file: tasks/scale.yml
117+
apply:
118+
tags: [ scale, k8s ]
119+
tags:
120+
- always
121+
- name: Include template.yml
122+
include_tasks:
123+
file: tasks/template.yml
124+
apply:
125+
tags: [ template, k8s ]
126+
tags:
127+
- always
128+
- name: Include waiter.yml
129+
include_tasks:
130+
file: tasks/waiter.yml
131+
apply:
132+
tags: [ waiter, k8s ]
133+
tags:
134+
- always
34135

35136
roles:
36-
- helm
137+
- role: helm
138+
tags:
139+
- helm
37140

38141
post_tasks:
39142
- name: Ensure namespace exists

molecule/default/tasks/full.yml

-4
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,6 @@
333333
register: k8s_info_testing6
334334
failed_when: not k8s_info_testing6.resources or k8s_info_testing6.resources[0].status.phase != "Active"
335335

336-
- include_tasks: crd.yml
337-
- include_tasks: lists.yml
338-
- include_tasks: append_hash.yml
339-
340336
always:
341337
- name: Delete all namespaces
342338
k8s:

molecule/default/tasks/info.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
- block:
33
- set_fact:
44
wait_namespace: wait
5-
k8s_pod_name: pod-info-1
65
multi_pod_one: multi-pod-1
76
multi_pod_two: multi-pod-2
87

@@ -200,6 +199,9 @@
200199
that:
201200
- "{{ lookup('pipe', 'date +%s') }} - {{ start }} > 30"
202201

202+
vars:
203+
k8s_pod_name: pod-info-1
204+
203205
always:
204206
- name: Remove namespace
205207
k8s:

0 commit comments

Comments
 (0)