test_provision_cdip.yml 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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_CDIP_TC_001
  16. # Execute provison role in management station with os installed centos 7
  17. - name: OMNIA_DIO_US_CDIP_TC_001
  18. hosts: localhost
  19. connection: local
  20. vars_files:
  21. - test_vars/test_provision_vars.yml
  22. - ../roles/provision/vars/main.yml
  23. tasks:
  24. - name: Delete the cobbler container if exits
  25. docker_container:
  26. name: "{{ docker_container_name }}"
  27. state: absent
  28. tags: TC_001
  29. - name: Delete docker image if exists
  30. docker_image:
  31. name: "{{ docker_image_name }}"
  32. tag: "{{ docker_image_tag }}"
  33. state: absent
  34. tags: TC_001
  35. - block:
  36. - name: Call common role
  37. include_role:
  38. name: ../roles/common
  39. vars:
  40. input_config_filename: "{{ test_input_config_filename }}"
  41. - name: Call provision role
  42. include_role:
  43. name: ../roles/provision
  44. tasks_from: "{{ item }}"
  45. with_items:
  46. - "{{ cobbler_image_files }}"
  47. tags: TC_001
  48. - name: Inspect cobbler docker image
  49. docker_image_info:
  50. name: "{{ docker_image_name }}"
  51. register: cobbler_image_status
  52. tags: TC_001,VERIFY_001
  53. - name: Validate cobbler docker image
  54. assert:
  55. that:
  56. - cobbler_image_status.images
  57. fail_msg: "{{ cobbler_img_fail_msg }}"
  58. success_msg: "{{ cobbler_img_success_msg }}"
  59. tags: TC_001,VERIFY_001
  60. - name: Inspect cobbler container
  61. docker_container_info:
  62. name: "{{ docker_container_name }}"
  63. register: cobbler_cnt_status
  64. tags: TC_001,VERIFY_001
  65. - name: Validate cobbler docker container
  66. assert:
  67. that:
  68. - cobbler_cnt_status.exists
  69. fail_msg: "{{ cobbler_cnt_fail_msg }}"
  70. success_msg: "{{ cobbler_cnt_success_msg }}"
  71. tags: TC_001,VERIFY_001
  72. - name: Validate first NIC is not assigned to public internet
  73. shell: |
  74. set -o pipefail
  75. ip route get 8.8.8.8 | awk '{print $5}'
  76. register: nic_output
  77. args:
  78. executable: /bin/bash
  79. failed_when: first_nic in nic_output.stdout
  80. changed_when: false
  81. tags: TC_001,VERIFY_001
  82. - name: "Validate NIC-1 is assigned to IP {{ nic1_ip_address }}"
  83. assert:
  84. that: "'{{ nic1_ip_address }}' in ansible_em1.ipv4.address"
  85. fail_msg: "{{ nic_check_fail_msg }}"
  86. success_msg: "{{ nic_check_success_msg }}"
  87. tags: TC_001,VERIFY_001
  88. # Testcase OMNIA_DIO_US_CDIP_TC_002
  89. # Execute provison role in management station where cobbler container and image already created
  90. - name: OMNIA_DIO_US_CDIP_TC_002
  91. hosts: localhost
  92. connection: local
  93. vars_files:
  94. - test_vars/test_provision_vars.yml
  95. - ../roles/provision/vars/main.yml
  96. tasks:
  97. - block:
  98. - name: Call common role
  99. include_role:
  100. name: ../roles/common
  101. vars:
  102. input_config_filename: "{{ test_input_config_filename }}"
  103. - name: Call provision role
  104. include_role:
  105. name: ../roles/provision
  106. tags: TC_002
  107. - name: Inspect cobbler docker image
  108. docker_image_info:
  109. name: "{{ docker_image_name }}"
  110. register: cobbler_image_status
  111. tags: TC_002,VERIFY_002
  112. - name: Validate cobbler docker image
  113. assert:
  114. that:
  115. - cobbler_image_status.images
  116. fail_msg: "{{ cobbler_img_fail_msg }}"
  117. success_msg: "{{ cobbler_img_success_msg }}"
  118. tags: TC_002,VERIFY_002
  119. - name: Inspect cobbler container
  120. docker_container_info:
  121. name: "{{ docker_container_name }}"
  122. register: cobbler_cnt_status
  123. tags: TC_002,VERIFY_002
  124. - name: Validate cobbler docker container
  125. assert:
  126. that:
  127. - cobbler_cnt_status.exists
  128. fail_msg: "{{ cobbler_cnt_fail_msg }}"
  129. success_msg: "{{ cobbler_cnt_success_msg }}"
  130. tags: TC_002,VERIFY_002
  131. - name: Validate first NIC is not assigned to public internet
  132. shell: |
  133. set -o pipefail
  134. ip route get 8.8.8.8 | awk '{print $5}'
  135. register: nic_output
  136. args:
  137. executable: /bin/bash
  138. failed_when: first_nic in nic_output.stdout
  139. changed_when: false
  140. tags: TC_002,VERIFY_002
  141. - name: "Validate NIC-1 is assigned to IP {{ nic1_ip_address }}"
  142. assert:
  143. that: "'{{ nic1_ip_address }}' in ansible_em1.ipv4.address"
  144. fail_msg: "{{ nic_check_fail_msg }}"
  145. success_msg: "{{ nic_check_success_msg }}"
  146. tags: TC_002,VERIFY_002
  147. # Testcase OMNIA_DIO_US_CDIP_TC_003
  148. # Execute provison role in management station where docker service not running
  149. - name: OMNIA_DIO_US_CDIP_TC_003
  150. hosts: localhost
  151. connection: local
  152. vars_files:
  153. - test_vars/test_provision_vars.yml
  154. - ../roles/provision/vars/main.yml
  155. tasks:
  156. - name: Delete the cobbler container if exits
  157. docker_container:
  158. name: "{{ docker_container_name }}"
  159. state: absent
  160. tags: TC_003
  161. - name: Delete docker image if exists
  162. docker_image:
  163. name: "{{ docker_image_name }}"
  164. tag: "{{ docker_image_tag }}"
  165. state: absent
  166. tags: TC_003
  167. - name: Stop docker service
  168. service:
  169. name: docker
  170. state: stopped
  171. tags: TC_003
  172. - block:
  173. - name: Call common role
  174. include_role:
  175. name: ../roles/common
  176. vars:
  177. input_config_filename: "{{ test_input_config_filename }}"
  178. - name: Call provision role
  179. include_role:
  180. name: ../roles/provision
  181. - name: Docker service stopped usecase success message
  182. debug:
  183. msg: "{{ docker_check_success_msg }}"
  184. rescue:
  185. - name: Docker service stopped usecase fail message
  186. fail:
  187. msg: "{{ docker_check_fail_msg }}"
  188. always:
  189. - name: Start docker service
  190. service:
  191. name: docker
  192. state: started
  193. tags: TC_003