test_web_ui_awxc.yml 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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_008
  16. # Test case to validate the AWX configuration
  17. - name: OMNIA_CRM_US_AWXD_TC_008
  18. hosts: localhost
  19. connection: local
  20. gather_subset:
  21. - 'min'
  22. vars_files:
  23. - ../roles/web_ui/vars/main.yml
  24. - ../roles/common/vars/main.yml
  25. - test_vars/test_web_ui_vars.yml
  26. tasks:
  27. - block:
  28. - name: Call the role to be tested
  29. include_role:
  30. name: ../roles/web_ui
  31. tags: TC_008
  32. - name: Get the package facts
  33. package_facts:
  34. manager: auto
  35. tags: TC_008
  36. - name: Check if ansible-tower-cli is already installed
  37. assert:
  38. that: "'{{ tower_cli_package_name }}' in ansible_facts.packages"
  39. success_msg: "{{ resource_exists_success_msg }}"
  40. fail_msg: "{{ resource_exists_fail_msg }}"
  41. tags: TC_008
  42. - name: Get the existing organizations
  43. command: >-
  44. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ admin_password }}" organizations list -f human
  45. register: organizations_array
  46. changed_when: False
  47. tags: TC_008
  48. - name: Check for organization
  49. assert:
  50. that: organization_name in organizations_array.stdout
  51. success_msg: "{{ resource_exists_success_msg }}"
  52. fail_msg: "{{ resource_exists_fail_msg }}"
  53. tags: TC_008
  54. - name: Get the existing projects
  55. command: >-
  56. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ admin_password }}" projects list -f human
  57. changed_when: False
  58. register: projects_array
  59. tags: TC_008
  60. - name: Check for project
  61. assert:
  62. that: project_name in projects_array.stdout
  63. success_msg: "{{ resource_exists_success_msg }}"
  64. fail_msg: "{{ resource_exists_fail_msg }}"
  65. tags: TC_008
  66. - name: Get the existing inventories
  67. command: >-
  68. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ admin_password }}" inventory list -f human
  69. changed_when: False
  70. register: inventory_array
  71. tags: TC_008
  72. - name: Check for inventories
  73. assert:
  74. that: omnia_inventory_name in inventory_array.stdout
  75. success_msg: "{{ resource_exists_success_msg }}"
  76. fail_msg: "{{ resource_exists_fail_msg }}"
  77. tags: TC_008
  78. - name: Get the existing groups if omnia-inventory exists
  79. command: >-
  80. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ admin_password }}"
  81. groups list --inventory "{{ omnia_inventory_name }}" -f human
  82. changed_when: False
  83. register: groups_array
  84. when: omnia_inventory_name in inventory_array.stdout
  85. tags: TC_008
  86. - name: Check for manager and compute groups
  87. assert:
  88. that: manager_group_name and compute_group_name in groups_array.stdout
  89. success_msg: "{{ resource_exists_success_msg }}"
  90. fail_msg: "{{ resource_exists_fail_msg }}"
  91. tags: TC_008
  92. - name: Get the existing job templates
  93. command: >-
  94. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ admin_password }}" job_templates list -f human
  95. changed_when: False
  96. register: templates_array
  97. tags: TC_008
  98. - name: Check for templates
  99. assert:
  100. that: omnia_template_name and inventory_template_name in templates_array.stdout
  101. success_msg: "{{ resource_exists_success_msg }}"
  102. fail_msg: "{{ resource_exists_fail_msg }}"
  103. tags: TC_008
  104. - name: Get the existing schedules for job templates
  105. command: >-
  106. awx --conf.host "{{ awx_ip }}" --conf.username "{{ awx_user }}" --conf.password "{{ admin_password }}" schedules list -f human
  107. changed_when: False
  108. register: schedules_array
  109. tags: TC_008
  110. - name: Check for schedules to job template
  111. assert:
  112. that: schedule_name in schedules_array.stdout
  113. success_msg: "{{ resource_exists_success_msg }}"
  114. fail_msg: "{{ resource_exists_fail_msg }}"
  115. tags: TC_008
  116. # Testcase OMNIA_CRM_US_AWXD_TC_009
  117. # Execute common role in management station without internet connectivity
  118. - name: OMNIA_CRM_US_AWXD_TC_009
  119. hosts: localhost
  120. connection: local
  121. gather_subset:
  122. - 'min'
  123. vars_files:
  124. - test_vars/test_common_vars.yml
  125. - ../roles/common/vars/main.yml
  126. tasks:
  127. - name: Down internet connectivity
  128. lineinfile:
  129. path: /etc/hosts
  130. line: "172.16.0.5 github.com"
  131. state: present
  132. backup: yes
  133. tags: TC_009
  134. - block:
  135. - name: Call common role
  136. include_role:
  137. name: ../roles/web_ui
  138. rescue:
  139. - name: Validate internet connectivity failure message
  140. assert:
  141. that: internet_status in internet_value.msg
  142. success_msg: "{{ internet_check_success_msg }}"
  143. fail_msg: "{{ internet_check_fail_msg }}"
  144. tags: TC_009
  145. - name: Up internet connectivity
  146. lineinfile:
  147. path: /etc/hosts
  148. line: "172.16.0.5 github.com"
  149. state: absent
  150. tags: TC_009
  151. # Testcase OMNIA_CRM_US_AWXD_TC_010
  152. # Execute provision role in management station and reboot management station
  153. - name: OMNIA_CRM_US_AWXD_TC_010
  154. hosts: localhost
  155. connection: local
  156. vars_files:
  157. - test_vars/test_web_ui_vars.yml
  158. tasks:
  159. - name: Check last uptime of the server
  160. shell: |
  161. current_time=$(date +"%Y-%m-%d %H")
  162. uptime -s | grep "$current_time"
  163. register: uptime_status
  164. changed_when: false
  165. ignore_errors: yes
  166. tags: TC_010
  167. - block:
  168. - name: Call web_ui role
  169. include_role:
  170. name: ../roles/web_ui
  171. vars:
  172. no_prompt: true
  173. tags: TC_010
  174. - name: Reboot localhost
  175. command: reboot
  176. when: uptime_status.stdout|length < 1
  177. tags: TC_010
  178. - name: Inspect AWX web container
  179. docker_container_info:
  180. name: "{{ docker_container_name }}"
  181. register: awx_container_status
  182. tags: TC_010
  183. - name: Verify AWX container is running after reboot
  184. assert:
  185. that:
  186. - "'running' in awx_container_status.container.State.Status"
  187. tags: TC_010