test_common.yml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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_DIO_US_DVC_TC_001
  16. # Execute common role in management station with os installed centos 8.2
  17. - name: OMNIA_DIO_US_DVC_TC_001
  18. hosts: localhost
  19. connection: local
  20. gather_subset:
  21. - 'min'
  22. vars_files:
  23. - test_vars/test_common_vars.yml
  24. - ../roles/common/vars/main.yml
  25. tasks:
  26. - name: Check OS support
  27. fail:
  28. msg: "{{ os_status }}"
  29. when: not(ansible_distribution == os_name and ansible_distribution_version >= os_version)
  30. tags: TC_001
  31. - block:
  32. - name: Call common role
  33. include_role:
  34. name: ../roles/common
  35. tags: TC_001
  36. - name: Fetching docker volume info
  37. docker_volume_info:
  38. name: "{{ docker_volume_name }}"
  39. register: docker_volume_status
  40. tags: TC_001
  41. - name: Validate docker volume
  42. assert:
  43. that:
  44. - docker_volume_status.exists
  45. fail_msg: "{{ docker_volume_fail_msg }}"
  46. success_msg: "{{ docker_volume_success_msg }}"
  47. tags: TC_001
  48. # Testcase OMNIA_DIO_US_DVC_TC_002
  49. # Execute common role in management station with docker volume omnia-storage already present
  50. - name: OMNIA_DIO_US_DVC_TC_002
  51. hosts: localhost
  52. connection: local
  53. gather_subset:
  54. - 'min'
  55. vars_files:
  56. - test_vars/test_common_vars.yml
  57. - ../roles/common/vars/main.yml
  58. tasks:
  59. - block:
  60. - name: Call common role
  61. include_role:
  62. name: ../roles/common
  63. tags: TC_002
  64. - name: Fetching docker volume info
  65. docker_volume_info:
  66. name: "{{ docker_volume_name }}"
  67. register: docker_volume_status
  68. tags: TC_002
  69. - name: Validate docker volume
  70. assert:
  71. that:
  72. - docker_volume_status.exists
  73. fail_msg: "{{ docker_volume_fail_msg }}"
  74. success_msg: "{{ docker_volume_success_msg }}"
  75. tags: TC_002
  76. # Testcase OMNIA_DIO_US_DVC_TC_003
  77. # Execute common role in management station with os installed different than centos 8.2
  78. - name: OMNIA_DIO_US_DVC_TC_003
  79. hosts: localhost
  80. connection: local
  81. gather_subset:
  82. - 'min'
  83. vars_files:
  84. - test_vars/test_common_vars.yml
  85. - ../roles/common/vars/main.yml
  86. tasks:
  87. - block:
  88. - name: Call common role
  89. include_role:
  90. name: ../roles/common
  91. vars:
  92. ansible_distribution_version: "{{ centos_version }}"
  93. rescue:
  94. - name: Validate OS check failure message
  95. assert:
  96. that: os_status in os_value.msg
  97. success_msg: "{{ os_check_success_msg }}"
  98. fail_msg: "{{ os_check_fail_msg }}"
  99. tags: TC_003
  100. # Testcase OMNIA_DIO_US_DVC_TC_004
  101. # Execute common role in management station without internet connectivity
  102. - name: OMNIA_DIO_US_DVC_TC_004
  103. hosts: localhost
  104. connection: local
  105. gather_subset:
  106. - 'min'
  107. vars_files:
  108. - test_vars/test_common_vars.yml
  109. - ../roles/common/vars/main.yml
  110. tasks:
  111. - name: Down internet connectivity
  112. lineinfile:
  113. path: /etc/hosts
  114. line: "172.16.0.5 github.com"
  115. state: present
  116. backup: yes
  117. tags: TC_004
  118. - block:
  119. - name: Call common role
  120. include_role:
  121. name: ../roles/common
  122. rescue:
  123. - name: Validate internet connectivity failure message
  124. assert:
  125. that: internet_status in internet_value.msg
  126. success_msg: "{{ internet_check_success_msg }}"
  127. fail_msg: "{{ internet_check_fail_msg }}"
  128. tags: TC_004
  129. - name: Up internet connectivity
  130. lineinfile:
  131. path: /etc/hosts
  132. line: "172.16.0.5 github.com"
  133. state: absent
  134. tags: TC_004
  135. # Testcase OMNIA_DIO_US_DVC_TC_005
  136. # Execute common role in management station with different user than root
  137. - name: OMNIA_DIO_US_DVC_TC_005
  138. hosts: localhost
  139. connection: local
  140. gather_subset:
  141. - 'min'
  142. vars_files:
  143. - test_vars/test_common_vars.yml
  144. tasks:
  145. - name: Create temp user
  146. user:
  147. name: temp
  148. tags: TC_005
  149. - block:
  150. - name: Execute playbook with different user
  151. command: ansible-playbook ../appliance.yml --become-user=temp
  152. register: temp_user_output
  153. rescue:
  154. - name: Validate the different user execution failure message
  155. assert:
  156. that:
  157. - '"FAILED" in temp_user_output.stdout'
  158. - '"This command has to be run under the root user" in temp_user_output.stdout'
  159. success_msg: "{{ different_user_check_success_msg }}"
  160. fail_msg: "{{ different_user_check_fail_msg }}"
  161. tags: TC_005
  162. - name: Remove temp user
  163. user:
  164. name: temp
  165. state: absent
  166. remove: yes
  167. tags: TC_005
  168. # Testcase OMNIA_DIO_US_DVC_TC_006
  169. # Execute common role in management station with selinux enabled.
  170. - name: OMNIA_DIO_US_DVC_TC_006
  171. hosts: localhost
  172. connection: local
  173. gather_subset:
  174. - 'min'
  175. vars_files:
  176. - test_vars/test_common_vars.yml
  177. - ../roles/common/vars/main.yml
  178. tasks:
  179. - name: Enable selinux
  180. selinux:
  181. policy: targeted
  182. state: enforcing
  183. when: ansible_selinux.status == "disabled"
  184. tags: TC_006
  185. - name: Reboot localhost
  186. command: reboot
  187. when: ansible_selinux.status == "disabled"
  188. tags: TC_006
  189. - block:
  190. - name: Call common role
  191. include_role:
  192. name: ../roles/common
  193. rescue:
  194. - name: Validate selinux failure message
  195. assert:
  196. that: selinux_status in selinux_value.msg
  197. success_msg: "{{ selinux_check_success_msg }}"
  198. fail_msg: "{{ selinux_check_fail_msg }}"
  199. tags: TC_006
  200. - name: Disable selinux
  201. selinux:
  202. state: disabled
  203. tags: TC_006