This repository has been archived by the owner on Feb 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
main.yml
185 lines (169 loc) · 6.8 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
---
# vim: set ft=ansible:
#
# !!!NOTE!!! This playbook was tested using Ansible 2.2; it is recommended
# that the same version is used.
#
# Test Cases
# Core Functionality
# - Verify system containers can be installed through atomic command
# - Verify system containers can be uninstalled through the atomic command
# - Verify user can specify name for system containers
# - Verify system containers can be listed
# - Verify environment variables can be pass to the container
# - Verify update/rollback of system containers
# - Verify commands can be run in the system container
# - Verify specification of rootfs for system containers.
# - Verify setting RUN_DIRECTORY and STATE_DIRECTORY
# - Verify system containers are started on reboot
# - Verify system containers persist through reboot
#
# Flannel & Etcd Tests
# - Verify installation of flannel and etcd containers
#
# Negative Testing
# - Verify uninstalling a system container that does not exist fails
# - Verify installing a system container that does not exist fails
# - Verify DESTDIR, NAME, EXEC_START, EXEC_STOP, HOST_UID, and HOST_GID
# cannot be set
#
# Not Covered
# Upgrade Tests
# - Verify the system container persists through ostree upgrade
# - Verify the system container persists through ostree rollback
#
- name: System Containers - Test Suite
hosts: all
become: true
vars_files:
- vars.yml
vars:
tests: []
tasks:
- name: Set logging
set_fact:
log_results: true
result_file: "{{ playbook_dir }}/system-containers-result.log"
tags:
- setup
- include_tasks: 'setup.yml'
tags:
- setup
# TEST
# Verify that system containers can be installed/uninstalled
- block:
- include_tasks: 'install_uninstall.yml'
- set_fact:
tests: "{{ tests + [ { 'name':'Install/Uninstall System Containers', 'result':'Passed', 'result_details': '' } ] }}"
rescue:
- set_fact:
tests: "{{ tests + [ { 'name':'Install/Uninstall System Containers', 'result':'Failed', 'result_details': ansible_failed_result } ] }}"
tags:
- install_uninstall
# TEST
# Verify that system container is active/running after reboot
- block:
- include_tasks: 'reboot.yml'
- set_fact:
tests: "{{ tests + [ { 'name':'Running After Reboot', 'result':'Passed', 'result_details': '' } ] }}"
rescue:
- set_fact:
tests: "{{ tests + [ { 'name':'Running After Reboot', 'result':'Failed', 'result_details': ansible_failed_result } ] }}"
tags:
- reboot
# TEST
# Verify environment variables can be pass to the container
- block:
- include_tasks: 'pass_variables.yml'
- set_fact:
tests: "{{ tests + [ { 'name':'Pass Variables to System Container', 'result':'Passed', 'result_details': '' } ] }}"
rescue:
- set_fact:
tests: "{{ tests + [ { 'name':'Pass Variables to System Container', 'result':'Failed', 'result_details': ansible_failed_result } ] }}"
tags:
- pass_variables
# TEST
# Verify update/rollback of system containers
- block:
- include_tasks: 'update_rollback.yml'
- set_fact:
tests: "{{ tests + [ { 'name':'Verify Update/Rollback of System Container', 'result':'Passed', 'result_details': '' } ] }}"
rescue:
- set_fact:
tests: "{{ tests + [ { 'name':'Verify Update/Rollback of System Container', 'result':'Failed', 'result_details': ansible_failed_result } ] }}"
tags:
- update_rollback
# TEST
# Verify specification of rootfs for system containers.
- block:
- include_tasks: 'rootfs.yml'
- set_fact:
tests: "{{ tests + [ { 'name':'Verify Specification of rootfs for System Container', 'result':'Passed', 'result_details': '' } ] }}"
rescue:
- set_fact:
tests: "{{ tests + [ { 'name':'Verify Specification of rootfs for System Container', 'result':'Failed', 'result_details': ansible_failed_result } ] }}"
tags:
- rootfs
# TEST
# Verify install of flannel/etcd system container
- block:
- include_tasks: 'flannel_etcd.yml'
- set_fact:
tests: "{{ tests + [ { 'name':'Install flannel/etcd System Containers', 'result':'Passed', 'result_details': '' } ] }}"
rescue:
- set_fact:
tests: "{{ tests + [ { 'name':'Install flannel/etcd System Containers', 'result':'Failed', 'result_details': ansible_failed_result } ] }}"
tags:
- flannel_etcd
# TEST
# Verify setting RUN_DIRECTORY and STATE_DIRECTORY
- block:
- include_tasks: 'flannel_etcd.yml'
- set_fact:
tests: "{{ tests + [ { 'name':'Configure RUN_DIRECTORY and STATE_DIRECTORY', 'result':'Passed', 'result_details': '' } ] }}"
rescue:
- set_fact:
tests: "{{ tests + [ { 'name':'Configure RUN_DIRECTORY and STATE_DIRECTORY', 'result':'Failed', 'result_details': ansible_failed_result } ] }}"
tags:
- run_state_dir
# TEST
# Verify uninstalling a system container that does not exist fails
# Verify installing a system container that does not exist fails
# Verify DESTDIR, NAME, EXEC_START, EXEC_STOP, HOST_UID, and HOST_GID
# cannot be set
- block:
- include_tasks: 'negative.yml'
- set_fact:
tests: "{{ tests + [ { 'name':'Negative Testing', 'result':'Passed', 'result_details': '' } ] }}"
rescue:
- set_fact:
tests: "{{ tests + [ { 'name':'Negative Testing', 'result':'Failed', 'result_details': ansible_failed_result } ] }}"
tags:
- negative
# Cleanup
- block:
- include_tasks: 'cleanup.yml'
- set_fact:
tests: "{{ tests + [ { 'name':'Cleanup', 'result':'Passed', 'result_details': '' } ] }}"
rescue:
- set_fact:
tests: "{{ tests + [ { 'name':'Cleanup', 'result':'Failed', 'result_details': ansible_failed_result } ] }}"
always:
# WRITE RESULTS TO FILE
- name: Remove existing log files
local_action: file path={{ result_file }} state=absent
become: false
- name: Save result to file
when: log_results
local_action: copy content={{ tests | to_nice_yaml(indent=2) }} dest={{ result_file }}
become: false
# Handled exceptions show up as failures in Ansible but the playbook
# itself does not return 0, so explicitly fail the test by checking
# the test results
- name: Explicitly fail based on test results
when: item['result']|lower == "failed"
fail:
msg: "Failure found in test"
with_items: "{{ tests }}"
tags:
- cleanup