test_infiniband_config.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. # Copyright 2021 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_1.1_IB_TC_007
  16. # Execute infiniband.yml with both valid Global and valid interface configs in ib_config.yml
  17. - name: OMNIA_1.1_IB_TC_007
  18. hosts: infiniband
  19. gather_facts: false
  20. tags: VERIFY_OMNIA_01
  21. connection: local
  22. vars_files:
  23. - test_vars/test_infiniband_vars.yml
  24. - ../roles/webui_awx/vars/main.yml
  25. - ../input_params/base_vars.yml
  26. tasks:
  27. - name: Executing network_ib role
  28. vars:
  29. inventory_name: "{{ ib_inventory_name }}"
  30. host_name: "{{ ib_host_name }}"
  31. template_name: "{{ template_value }}"
  32. job_template_name: "{{ job_name }}"
  33. playbook_path: "{{ ib_playbook_path }}"
  34. delete_status: true
  35. include_tasks: "{{ awx_script_path }}"
  36. - block:
  37. - name: Validate default flow
  38. assert:
  39. that:
  40. - ib_success_msg in job_status.status
  41. success_msg: "{{ success_message }}"
  42. fail_msg: "{{ fail_case }}"
  43. changed_when: false
  44. - name: Backup of ib_vars.yml
  45. copy:
  46. src: "{{ ib_vars_dir }}"
  47. dest: "{{ ib_vars_backup_dir }}"
  48. mode: "{{ file_perm }}"
  49. - name: Set MTU of port {{ port_num }}
  50. lineinfile:
  51. dest: "{{ ib_vars_dir }}"
  52. insertbefore: "{{ search_line }}"
  53. line: "{{ line_to_add }}"
  54. - name: Execute network_ib role after setting MTU
  55. vars:
  56. inventory_name: "{{ ib_inventory_name }}"
  57. host_name: "{{ ib_host_name }}"
  58. template_name: "{{ template_value }}"
  59. job_template_name: "{{ job_name }}"
  60. playbook_path: "{{ ib_playbook_path }}"
  61. delete_status: true
  62. include_tasks: "{{ awx_script_path }}"
  63. - name: Get MTU of port {{ port_num }}
  64. command: ansible-playbook -i "{{ inventory_dir }}" "{{ ib_mtu_path }}" --tags 'mtu'
  65. register: mtuvalue
  66. changed_when: false
  67. - block:
  68. - name: Validate MTU
  69. assert:
  70. that:
  71. - 'var_check in mtuvalue.stdout'
  72. success_msg: "{{ success_message }}"
  73. fail_msg: "{{ fail_case }}"
  74. # Testcase OMNIA_1.1_IB_TC_005
  75. # set save_changes_to_startup to false
  76. - name: OMNIA_1.1_IB_TC_005
  77. hosts: infiniband
  78. gather_facts: false
  79. tags: TC_005
  80. connection: local
  81. vars_files:
  82. - test_vars/test_infiniband_vars.yml
  83. - ../roles/webui_awx/vars/main.yml
  84. - ../input_params/base_vars.yml
  85. tasks:
  86. - name: Reload IB switch
  87. command: ansible-playbook -i "{{ inventory_dir }}" "{{ ib_mtu_path }}" --tags 'reboot'
  88. changed_when: false
  89. - name: Pausing for IB switch to come up
  90. pause:
  91. minutes: "{{ time_to_pause }}"
  92. - name: Get MTU of port {{ port_num }}
  93. command: ansible-playbook -i "{{ inventory_dir }}" "{{ ib_mtu_path }}" --tags 'mtu'
  94. register: mtuvalue
  95. changed_when: false
  96. - block:
  97. - name: Validate that MTU is changed
  98. assert:
  99. that:
  100. - 'var_check not in mtuvalue.stdout'
  101. success_msg: "{{ success_message }}"
  102. fail_msg: "{{ fail_case }}"
  103. # Testcase OMNIA_1.1_IB_TC_006
  104. # set save_changes_to_startup to True
  105. - name: OMNIA_1.1_IB_TC_006
  106. hosts: infiniband
  107. gather_facts: false
  108. tags: TC_006
  109. connection: local
  110. vars_files:
  111. - test_vars/test_infiniband_vars.yml
  112. - ../roles/webui_awx/vars/main.yml
  113. - ../input_params/base_vars.yml
  114. tasks:
  115. - name: Set save_changes_to_startup to True
  116. ansible.builtin.replace:
  117. dest: "{{ ib_vars_dir }}"
  118. regexp: 'save_changes_to_startup: false'
  119. replace: 'save_changes_to_startup: True'
  120. - name: Execute network_ib role as port {{ port_num }} has mtu set in ib_Vars
  121. vars:
  122. inventory_name: "{{ ib_inventory_name }}"
  123. host_name: "{{ ib_host_name }}"
  124. template_name: "{{ template_value }}"
  125. job_template_name: "{{ job_name }}"
  126. playbook_path: "{{ ib_playbook_path }}"
  127. delete_status: true
  128. include_tasks: "{{ awx_script_path }}"
  129. - name: Reload IB switch
  130. command: ansible-playbook -i "{{ inventory_dir }}" "{{ ib_mtu_path }}" --tags 'reboot'
  131. changed_when: false
  132. - name: Pausing for IB switch to come up
  133. pause:
  134. minutes: "{{ time_to_pause }}"
  135. - name: Get MTU of port {{ port_num }}
  136. command: ansible-playbook -i "{{ inventory_dir }}" "{{ ib_mtu_path }}" --tags 'mtu'
  137. register: mtuvalue
  138. changed_when: false
  139. - block:
  140. - name: Validate that MTU is not changed
  141. assert:
  142. that:
  143. - 'var_check in mtuvalue.stdout'
  144. success_msg: "{{ success_message }}"
  145. fail_msg: "{{ fail_case }}"
  146. # Testcase OMNIA_1.1_IB_TC_010
  147. # Execute infiniband.yml with valid interface and incorrect Global configs in ib_config.yml
  148. - name: OMNIA_1.1_IB_TC_010
  149. hosts: infiniband
  150. gather_facts: false
  151. tags: TC_010
  152. connection: local
  153. vars_files:
  154. - test_vars/test_infiniband_vars.yml
  155. - ../roles/webui_awx/vars/main.yml
  156. - ../input_params/base_vars.yml
  157. tasks:
  158. - name: Making gobal config incorrect
  159. lineinfile:
  160. dest: "{{ ib_vars_dir }}"
  161. insertafter: 'mellanox_switch_config:'
  162. line: "gibberish inserted"
  163. - name: Executing network_ib role
  164. vars:
  165. inventory_name: "{{ ib_inventory_name }}"
  166. host_name: "{{ ib_host_name }}"
  167. template_name: "{{ template_value }}"
  168. job_template_name: "{{ job_name }}"
  169. playbook_path: "{{ ib_playbook_path }}"
  170. delete_status: true
  171. include_tasks: "{{ awx_script_path }}"
  172. - block:
  173. - name: Validate role exec output
  174. assert:
  175. that:
  176. - ib_fail_msg in job_status.status
  177. success_msg: "{{ success_message }}"
  178. fail_msg: "{{ fail_case }}"
  179. # Testcase OMNIA_1.1_IB_TC_009
  180. # Execute infiniband.yml with only interface and no Global configs in ib_config.yml
  181. - name: OMNIA_1.1_IB_TC_009
  182. hosts: infiniband
  183. gather_facts: false
  184. tags: TC_009
  185. connection: local
  186. vars_files:
  187. - test_vars/test_infiniband_vars.yml
  188. - ../roles/webui_awx/vars/main.yml
  189. - ../input_params/base_vars.yml
  190. tasks:
  191. - name: Removing global config from ib_vars.yml
  192. lineinfile:
  193. dest: "{{ ib_vars_dir }}"
  194. state: absent
  195. regexp: "^gibberish inserted"
  196. - name: Executing network_ib role
  197. vars:
  198. inventory_name: "{{ ib_inventory_name }}"
  199. host_name: "{{ ib_host_name }}"
  200. template_name: "{{ template_value }}"
  201. job_template_name: "{{ job_name }}"
  202. playbook_path: "{{ ib_playbook_path }}"
  203. delete_status: true
  204. include_tasks: "{{ awx_script_path }}"
  205. - name: Validate role exec output
  206. assert:
  207. that:
  208. - ib_success_msg in job_status.status
  209. success_msg: "{{ success_message }}"
  210. fail_msg: "{{ fail_case }}"
  211. changed_when: false
  212. # Testcase OMNIA_1.1_IB_TC_011
  213. # Execute infiniband.yml with valid Global and incorrect interface configs in ib_config.yml
  214. - name: OMNIA_1.1_IB_TC_011
  215. hosts: infiniband
  216. gather_facts: false
  217. tags: TC_011
  218. connection: local
  219. vars_files:
  220. - test_vars/test_infiniband_vars.yml
  221. - ../roles/webui_awx/vars/main.yml
  222. - ../input_params/base_vars.yml
  223. tasks:
  224. - name: Make interface config incorrect
  225. lineinfile:
  226. dest: "{{ ib_vars_dir }}"
  227. insertafter: "{{ line_to_search }}"
  228. line: "gibberish inserted"
  229. - name: Executing network_ib role
  230. vars:
  231. inventory_name: "{{ ib_inventory_name }}"
  232. host_name: "{{ ib_host_name }}"
  233. template_name: "{{ template_value }}"
  234. job_template_name: "{{ job_name }}"
  235. playbook_path: "{{ ib_playbook_path }}"
  236. delete_status: true
  237. include_tasks: "{{ awx_script_path }}"
  238. - name: Validate role exec output
  239. assert:
  240. that:
  241. - ib_fail_msg in job_status.status
  242. success_msg: "{{ success_message }}"
  243. fail_msg: "{{ fail_case }}"
  244. # Testcase OMNIA_1.1_IB_TC_008
  245. # Execute infiniband.yml with only Global and no interface configs in ib_config.yml
  246. - name: OMNIA_1.1_IB_TC_008
  247. hosts: infiniband
  248. gather_facts: false
  249. tags: TC_008
  250. connection: local
  251. vars_files:
  252. - test_vars/test_infiniband_vars.yml
  253. - ../roles/webui_awx/vars/main.yml
  254. - ../input_params/base_vars.yml
  255. tasks:
  256. - name: Removing interface config
  257. ansible.builtin.command: sed -i '49,196d' "{{ ib_vars_dir }}"
  258. args:
  259. warn: no
  260. changed_when: false
  261. - name: Executing network_ib role
  262. vars:
  263. inventory_name: "{{ ib_inventory_name }}"
  264. host_name: "{{ ib_host_name }}"
  265. template_name: "{{ template_value }}"
  266. job_template_name: "{{ job_name }}"
  267. playbook_path: "{{ ib_playbook_path }}"
  268. delete_status: true
  269. include_tasks: "{{ awx_script_path }}"
  270. - name: Validate role exec output
  271. assert:
  272. that:
  273. - ib_success_msg in job_status.status
  274. success_msg: "{{ success_message }}"
  275. fail_msg: "{{ fail_case }}"
  276. changed_when: false
  277. - name: Restore orginal ib_vars file
  278. copy:
  279. src: "{{ ib_vars_backup_dir }}"
  280. dest: "{{ ib_vars_dir }}"
  281. mode: "{{ file_perm }}"
  282. - name: Set save_changes_to_startup to True
  283. ansible.builtin.replace:
  284. dest: "{{ ib_vars_dir }}"
  285. regexp: 'save_changes_to_startup: false'
  286. replace: 'save_changes_to_startup: True'
  287. - name: Execute network_ib role to set default IB config as is
  288. vars:
  289. inventory_name: "{{ ib_inventory_name }}"
  290. host_name: "{{ ib_host_name }}"
  291. template_name: "{{ template_value }}"
  292. job_template_name: "{{ job_name }}"
  293. playbook_path: "{{ ib_playbook_path }}"
  294. delete_status: true
  295. include_tasks: "{{ awx_script_path }}"
  296. - name: Set save_changes_to_startup back to false
  297. ansible.builtin.replace:
  298. dest: "{{ ib_vars_dir }}"
  299. regexp: 'save_changes_to_startup: True'
  300. replace: 'save_changes_to_startup: false'