test_web_ui.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. # Copyright 2020 Dell Inc. or its subsidiaries. All Rights Reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. ---
  15. # Testcase OMNIA_CRM_US_AWXD_TC_001
  16. # Test case to verify the prerequisites are installed and execute the AWX deployment
  17. - name: OMNIA_CRM_US_AWXD_TC_001
  18. hosts: localhost
  19. connection: local
  20. gather_subset:
  21. - 'min'
  22. vars_files:
  23. - ../roles/web_ui/vars/main.yml
  24. - test_vars/test_web_ui_vars.yml
  25. tasks:
  26. - name: Get the docker package facts
  27. package_facts:
  28. manager: auto
  29. tags: TC_001
  30. - name: Check if docker-ce is already installed
  31. debug:
  32. var: ansible_facts.packages['{{ package }}']
  33. tags: TC_001
  34. - block:
  35. - name: Call common role
  36. include_role:
  37. name: ../roles/common
  38. vars:
  39. input_config_filename: "{{ test_input_config_filename }}"
  40. - name: Calling the web_ui role to be tested
  41. include_role:
  42. name: ../roles/web_ui
  43. tags: TC_001
  44. - name: Check that you can connect to github repo and it returns a status 200
  45. uri:
  46. url: "{{ awx_git_repo }}"
  47. status_code: "{{ return_status }}"
  48. return_content: true
  49. tags: TC_001
  50. - name: Check that you can can connect to AWX UI and it returns a status 200
  51. uri:
  52. url: "{{ awx_ip }}"
  53. status_code: "{{ return_status }}"
  54. return_content: true
  55. tags: TC_001
  56. - name: verify awx-server is listening on 8081
  57. wait_for:
  58. port: "{{ awx_listening_port }}"
  59. timeout: "{{ time }}"
  60. tags: TC_001
  61. - name: Get the containers count
  62. shell: |
  63. set -o pipefail
  64. docker ps -a | grep awx | wc -l
  65. register: containers_count
  66. changed_when: False
  67. tags: TC_001
  68. - name: Validate the containers count
  69. assert:
  70. that: containers_count.stdout | int >= actual_containers
  71. success_msg: "{{ awx_exists_msg }}"
  72. fail_msg: "{{ awx_not_exists_msg }}"
  73. tags: TC_001
  74. # Testcase OMNIA_CRM_US_AWXD_TC_002
  75. # Test case to verify regression testing
  76. - name: OMNIA_CRM_US_AWXD_TC_002
  77. hosts: localhost
  78. connection: local
  79. gather_subset:
  80. - 'min'
  81. vars_files:
  82. - ../roles/web_ui/vars/main.yml
  83. - test_vars/test_web_ui_vars.yml
  84. tasks:
  85. - block:
  86. - name: Call common role
  87. include_role:
  88. name: ../roles/common
  89. vars:
  90. input_config_filename: "{{ test_input_config_filename }}"
  91. - name: Calling the web_ui role to be tested
  92. include_role:
  93. name: ../roles/web_ui
  94. tags: TC_002
  95. - name: Check that you can connect to github repo and it returns a status 200
  96. uri:
  97. url: "{{ awx_git_repo }}"
  98. status_code: "{{ return_status }}"
  99. return_content: true
  100. tags: TC_002
  101. - name: Check that you can can connect to AWX UI and it returns a status 200
  102. uri:
  103. url: "{{ awx_ip }}"
  104. status_code: "{{ return_status }}"
  105. return_content: true
  106. tags: TC_002
  107. - name: verify awx-server is listening on 80
  108. wait_for:
  109. port: "{{ awx_listening_port }}"
  110. timeout: "{{ time }}"
  111. tags: TC_002
  112. - name: Get the containers count
  113. shell: |
  114. set -o pipefail
  115. docker ps -a | grep awx | wc -l
  116. register: containers_count
  117. changed_when: False
  118. tags: TC_002
  119. - name: Validate the containers count
  120. assert:
  121. that: containers_count.stdout | int >= actual_containers
  122. success_msg: "{{ awx_exists_msg }}"
  123. fail_msg: "{{ awx_not_exists_msg }}"
  124. tags: TC_002
  125. # Testcase OMNIA_CRM_US_AWXD_TC_003
  126. # Test case to validate the AWX configuration
  127. - name: OMNIA_CRM_US_AWXD_TC_003
  128. hosts: localhost
  129. connection: local
  130. gather_subset:
  131. - 'min'
  132. vars_files:
  133. - ../roles/web_ui/vars/main.yml
  134. - ../roles/common/vars/main.yml
  135. - test_vars/test_web_ui_vars.yml
  136. tasks:
  137. - block:
  138. - name: Call common role
  139. include_role:
  140. name: ../roles/common
  141. vars:
  142. input_config_filename: "{{ test_input_config_filename }}"
  143. - name: Calling the web_ui role to be tested
  144. include_role:
  145. name: ../roles/web_ui
  146. tags: TC_003
  147. - name: Get the package facts
  148. package_facts:
  149. manager: auto
  150. tags: TC_003
  151. - name: Check if ansible-tower-cli is already installed
  152. assert:
  153. that: "'{{ tower_cli_package_name }}' in ansible_facts.packages"
  154. success_msg: "{{ resource_exists_success_msg }}"
  155. fail_msg: "{{ resource_exists_fail_msg }}"
  156. tags: TC_003
  157. - name: Get the existing organizations
  158. command: >-
  159. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ admin_password }}"
  160. organizations list -f human
  161. register: organizations_array
  162. changed_when: False
  163. tags: TC_003
  164. - name: Check for organization
  165. assert:
  166. that: organization_name in organizations_array.stdout
  167. success_msg: "{{ resource_exists_success_msg }}"
  168. fail_msg: "{{ resource_exists_fail_msg }}"
  169. tags: TC_003
  170. - name: Get the existing projects
  171. command: >-
  172. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ admin_password }}"
  173. projects list -f human
  174. changed_when: False
  175. register: projects_array
  176. tags: TC_003
  177. - name: Check for project
  178. assert:
  179. that: project_name in projects_array.stdout
  180. success_msg: "{{ resource_exists_success_msg }}"
  181. fail_msg: "{{ resource_exists_fail_msg }}"
  182. tags: TC_003
  183. - name: Get the existing inventories
  184. command: >-
  185. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ admin_password }}"
  186. inventory list -f human
  187. changed_when: False
  188. register: inventory_array
  189. tags: TC_003
  190. - name: Check for inventories
  191. assert:
  192. that: omnia_inventory_name in inventory_array.stdout
  193. success_msg: "{{ resource_exists_success_msg }}"
  194. fail_msg: "{{ resource_exists_fail_msg }}"
  195. tags: TC_003
  196. - name: Get the existing groups if omnia-inventory exists
  197. command: >-
  198. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ admin_password }}"
  199. groups list --inventory "{{ omnia_inventory_name }}" -f human
  200. changed_when: False
  201. register: groups_array
  202. when: omnia_inventory_name in inventory_array.stdout
  203. tags: TC_003
  204. - name: Check for manager and compute groups
  205. assert:
  206. that: manager_group_name and compute_group_name in groups_array.stdout
  207. success_msg: "{{ resource_exists_success_msg }}"
  208. fail_msg: "{{ resource_exists_fail_msg }}"
  209. tags: TC_003
  210. - name: Get the existing credentials
  211. command: >-
  212. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ admin_password }}"
  213. credentials list -f human
  214. changed_when: False
  215. register: credentials_array
  216. tags: TC_003
  217. - name: Check for "{{ credential_name }}"
  218. assert:
  219. that: credential_name in credentials_array.stdout
  220. success_msg: "{{ resource_exists_success_msg }}"
  221. fail_msg: "{{ resource_exists_fail_msg }}"
  222. tags: TC_003
  223. - name: Get the existing job templates
  224. command: >-
  225. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ admin_password }}"
  226. job_templates list -f human
  227. changed_when: False
  228. register: templates_array
  229. tags: TC_003
  230. - name: Check for templates
  231. assert:
  232. that: omnia_template_name and inventory_template_name in templates_array.stdout
  233. success_msg: "{{ resource_exists_success_msg }}"
  234. fail_msg: "{{ resource_exists_fail_msg }}"
  235. tags: TC_003
  236. - name: Get the existing schedules for job templates
  237. command: >-
  238. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ admin_password }}"
  239. schedules list -f human
  240. changed_when: False
  241. register: schedules_array
  242. tags: TC_003
  243. - name: Check for schedules to job template
  244. assert:
  245. that: schedule_name in schedules_array.stdout
  246. success_msg: "{{ resource_exists_success_msg }}"
  247. fail_msg: "{{ resource_exists_fail_msg }}"
  248. tags: TC_003
  249. # Testcase OMNIA_CRM_US_AWXD_TC_004
  250. # Execute common role in management station without internet connectivity
  251. - name: OMNIA_CRM_US_AWXD_TC_004
  252. hosts: localhost
  253. connection: local
  254. gather_subset:
  255. - 'min'
  256. vars_files:
  257. - test_vars/test_common_vars.yml
  258. - ../roles/common/vars/main.yml
  259. tasks:
  260. - name: Down internet connectivity
  261. lineinfile:
  262. path: /etc/hosts
  263. line: "172.16.0.5 github.com"
  264. state: present
  265. backup: yes
  266. tags: TC_004
  267. - block:
  268. - name: Call common role
  269. include_role:
  270. name: ../roles/common
  271. vars:
  272. input_config_filename: "{{ test_input_config_filename }}"
  273. - name: Calling the web_ui role to be tested
  274. include_role:
  275. name: ../roles/web_ui
  276. rescue:
  277. - name: Validate internet connectivity failure message
  278. assert:
  279. that: internet_status in internet_value.msg
  280. success_msg: "{{ internet_check_success_msg }}"
  281. fail_msg: "{{ internet_check_fail_msg }}"
  282. tags: TC_004
  283. - name: Up internet connectivity
  284. lineinfile:
  285. path: /etc/hosts
  286. line: "172.16.0.5 github.com"
  287. state: absent
  288. tags: TC_004
  289. # Testcase OMNIA_CRM_US_AWXD_TC_005
  290. # Execute web_ui role in management station and reboot the server
  291. - name: OMNIA_CRM_US_AWXD_TC_005
  292. hosts: localhost
  293. connection: local
  294. vars_files:
  295. - test_vars/test_web_ui_vars.yml
  296. tasks:
  297. - name: Get last uptime of the server
  298. command: uptime -s
  299. register: uptime_status
  300. changed_when: false
  301. ignore_errors: yes
  302. tags: TC_005
  303. - name: Get current date
  304. command: date +"%Y-%m-%d %H"
  305. register: current_time
  306. changed_when: false
  307. ignore_errors: yes
  308. tags: TC_005
  309. - block:
  310. - name: Call common role
  311. include_role:
  312. name: ../roles/common
  313. vars:
  314. input_config_filename: "{{ test_input_config_filename }}"
  315. - name: Calling the web_ui role to be tested
  316. include_role:
  317. name: ../roles/web_ui
  318. tags: TC_005
  319. - name: Reboot localhost
  320. command: reboot
  321. when: current_time.stdout not in uptime_status.stdout
  322. tags: TC_005
  323. - name: Inspect AWX web container
  324. docker_container_info:
  325. name: "{{ docker_container_name }}"
  326. register: awx_container_status
  327. tags: TC_005
  328. - name: Verify AWX container is running after reboot
  329. assert:
  330. that:
  331. - "'running' in awx_container_status.container.State.Status"