test_ethernet_config.yml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  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. # Testacase OMNIA_1.1_EF_TC_007
  16. # Execute ethernet.yml with both valid Global and interface configs in ethernet_config.yml
  17. - name: OMNIA_1.1_EF_TC_007
  18. hosts: ethernet
  19. gather_facts: false
  20. tags: TC_007
  21. connection: local
  22. vars_files:
  23. - test_vars/test_ethernet_vars.yml
  24. - ../roles/webui_awx/vars/main.yml
  25. - ../input_params/base_vars.yml
  26. tasks:
  27. - name: Back up of ethernet_config.yml
  28. copy:
  29. src: "{{ ethernet_config_dir }}"
  30. dest: "{{ ethernet_config_backup_dir }}"
  31. mode: "{{ file_perm }}"
  32. tags: TC_007
  33. - name: Executing ethernet role with default ethernet_config
  34. vars:
  35. inventory_name: "{{ eth_inventory_name }}"
  36. host_name: "{{ eth_host_name }}"
  37. template_name: "{{ eth_template_value }}"
  38. job_template_name: "{{ eth_job_name }}"
  39. playbook_path: "{{ eth_playbook_path }}"
  40. delete_status: true
  41. include_tasks: "{{ awx_script_path }}"
  42. - block:
  43. - name: Validate default flow
  44. assert:
  45. that:
  46. - ethernet_success_msg in job_status.status
  47. success_msg: "{{ success_message }}"
  48. fail_msg: "{{ fail_case }}"
  49. changed_when: false
  50. - name: Set MTU of port {{ port_num }}
  51. lineinfile:
  52. dest: "{{ ethernet_config_dir }}"
  53. insertbefore: "{{ search_line }}"
  54. line: "{{ add_mtu_line }}"
  55. - name: Executing ethernet role with default ethernet_config
  56. vars:
  57. inventory_name: "{{ eth_inventory_name }}"
  58. host_name: "{{ eth_host_name }}"
  59. template_name: "{{ eth_template_value }}"
  60. job_template_name: "{{ eth_job_name }}"
  61. playbook_path: "{{ eth_playbook_path }}"
  62. delete_status: true
  63. include_tasks: "{{ awx_script_path }}"
  64. - name: Getting MTU of ethernet {{ validation_port }}
  65. command: ansible-playbook -i "{{ inventory_dir }}" "{{ get_mtu_dir }}" --tags 'mtu'
  66. changed_when: false
  67. register: mtu_out
  68. tags: TC_007,TC_002
  69. - name: Validate role exec output pre and post MTU addition
  70. assert:
  71. that:
  72. - validate_mtu_line in mtu_out.stdout
  73. success_msg: "{{ success_message }}"
  74. fail_msg: "{{ fail_case }}"
  75. changed_when: false
  76. failed_when: false
  77. tags: TC_007
  78. # Testacase OMNIA_1.1_EF_TC_005
  79. # Execute ethernet.yml with save_config set to False
  80. - name: OMNIA_1.1_EF_TC_005
  81. hosts: ethernet
  82. gather_facts: false
  83. tags: TC_005
  84. connection: local
  85. vars_files:
  86. - test_vars/test_ethernet_vars.yml
  87. - ../roles/webui_awx/vars/main.yml
  88. - ../input_params/base_vars.yml
  89. tasks:
  90. - name: Reload switch
  91. command: ansible-playbook -i "{{ inventory_dir }}" "{{ get_mtu_dir }}" --tags 'reload'
  92. changed_when: false
  93. - name: Pausing for switch to come up
  94. pause:
  95. minutes: "{{ time_to_pause }}"
  96. - name: Getting MTU of ethernet {{ validation_port }}
  97. command: ansible-playbook -i "{{ inventory_dir }}" "{{ get_mtu_dir }}" --tags 'mtu'
  98. changed_when: false
  99. register: mtu_out
  100. - block:
  101. - name: Validate that MTU is changed
  102. assert:
  103. that:
  104. - validate_mtu_line not in mtu_out.stdout
  105. success_msg: "{{ success_message }}"
  106. fail_msg: "{{ fail_case }}"
  107. changed_when: false
  108. failed_when: false
  109. # Testacase OMNIA_1.1_EF_TC_006
  110. # Execute ethernet.yml with save_config set to True
  111. - name: OMNIA_1.1_EF_TC_006
  112. hosts: ethernet
  113. gather_facts: false
  114. tags: TC_006
  115. connection: local
  116. vars_files:
  117. - test_vars/test_ethernet_vars.yml
  118. - ../roles/webui_awx/vars/main.yml
  119. - ../input_params/base_vars.yml
  120. tasks:
  121. - name: Set save_changes_to_startup to True in ethernet_vars
  122. ansible.builtin.replace:
  123. dest: "{{ ethernet_config_dir }}"
  124. regexp: 'save_changes_to_startup: false'
  125. replace: 'save_changes_to_startup: True'
  126. - name: Execute network_ethernet role as port 4 has mtu set in ethernet_vars
  127. vars:
  128. inventory_name: "{{ eth_inventory_name }}"
  129. host_name: "{{ eth_host_name }}"
  130. template_name: "{{ eth_template_value }}"
  131. job_template_name: "{{ eth_job_name }}"
  132. playbook_path: "{{ eth_playbook_path }}"
  133. delete_status: true
  134. include_tasks: "{{ awx_script_path }}"
  135. - name: Reload switch
  136. command: ansible-playbook -i "{{ inventory_dir }}" "{{ get_mtu_dir }}" --tags 'reload'
  137. changed_when: false
  138. - name: Pausing for switch to come up
  139. pause:
  140. minutes: "{{ time_to_pause }}"
  141. - name: Getting MTU of ethernet {{ validation_port }}
  142. command: ansible-playbook -i "{{ inventory_dir }}" "{{ get_mtu_dir }}" --tags 'mtu'
  143. changed_when: false
  144. register: mtu_out
  145. - block:
  146. - name: Validate that MTU is changed
  147. assert:
  148. that:
  149. - validate_mtu_line in mtu_out.stdout
  150. success_msg: "{{ success_message }}"
  151. fail_msg: "{{ fail_case }}"
  152. changed_when: false
  153. # Testcase OMNIA_1.1_EF_TC_010
  154. # Execute ethernet.yml with invalid Global and correct interface configs in ethernet_config.yml
  155. - name: OMNIA_1.1_EF_TC_010
  156. hosts: ethernet
  157. gather_facts: false
  158. tags: TC_010
  159. connection: local
  160. vars_files:
  161. - test_vars/test_ethernet_vars.yml
  162. - ../roles/webui_awx/vars/main.yml
  163. - ../input_params/base_vars.yml
  164. tasks:
  165. - name: Making interface config invalid
  166. lineinfile:
  167. path: "{{ ethernet_config_dir }}"
  168. insertafter: 'os10_config:'
  169. line: 'gibberish inserted'
  170. tags: TC_007
  171. - name: Executing ethernet role with invalid global config
  172. vars:
  173. inventory_name: "{{ eth_inventory_name }}"
  174. host_name: "{{ eth_host_name }}"
  175. template_name: "{{ eth_template_value }}"
  176. job_template_name: "{{ eth_job_name }}"
  177. playbook_path: "{{ eth_playbook_path }}"
  178. delete_status: true
  179. include_tasks: "{{ awx_script_path }}"
  180. - block:
  181. - name: Validate role exec output
  182. assert:
  183. that:
  184. - ethernet_fail_msg in job_status.status
  185. success_msg: "{{ success_message }}"
  186. fail_msg: "{{ fail_case }}"
  187. # Testcase OMNIA_1.1_EF_TC_009
  188. # Validation of ethernet default configuration
  189. - name: OMNIA_1.1_EF_TC_009
  190. hosts: ethernet
  191. gather_facts: false
  192. tags: VERIFY_OMNIA_01
  193. connection: local
  194. vars_files:
  195. - test_vars/test_ethernet_vars.yml
  196. - ../roles/webui_awx/vars/main.yml
  197. - ../input_params/base_vars.yml
  198. tasks:
  199. - name: Executing ethernet role
  200. vars:
  201. inventory_name: "{{ eth_inventory_name }}"
  202. host_name: "{{ eth_host_name }}"
  203. template_name: "{{ eth_template_value }}"
  204. job_template_name: "{{ eth_job_name }}"
  205. playbook_path: "{{ eth_playbook_path }}"
  206. delete_status: true
  207. include_tasks: "{{ awx_script_path }}"
  208. - block:
  209. - name: Validate default flow
  210. assert:
  211. that:
  212. - ethernet_success_msg in job_status.status
  213. success_msg: "{{ success_message }}"
  214. fail_msg: "{{ fail_case }}"
  215. changed_when: false
  216. # Testcase OMNIA_1.1_EF_TC_011
  217. # Execute ethernet.yml with valid Global and incorrect interface configs in ethernet_config.yml
  218. - name: OMNIA_1.1_EF_TC_011
  219. hosts: ethernet
  220. gather_facts: false
  221. connection: local
  222. vars_files:
  223. - test_vars/test_ethernet_vars.yml
  224. - ../roles/webui_awx/vars/main.yml
  225. - ../input_params/base_vars.yml
  226. tasks:
  227. - name: Making interface config invalid
  228. lineinfile:
  229. path: "{{ ethernet_config_dir }}"
  230. insertafter: 'os10_interface:'
  231. line: 'gibberish inserted'
  232. - name: Executing ethernet role with invalid interface config
  233. vars:
  234. inventory_name: "{{ eth_inventory_name }}"
  235. host_name: "{{ eth_host_name }}"
  236. template_name: "{{ eth_template_value }}"
  237. job_template_name: "{{ eth_job_name }}"
  238. playbook_path: "{{ eth_playbook_path }}"
  239. delete_status: true
  240. include_tasks: "{{ awx_script_path }}"
  241. - block:
  242. - name: Validate role exec output
  243. assert:
  244. that:
  245. - ethernet_fail_msg in job_status.status
  246. success_msg: "{{ success_message }}"
  247. fail_msg: "{{ fail_case }}"
  248. # Testcase OMNIA_1.1_EF_TC_008
  249. # Execute ethernet.yml with only Global and no interface configs in ethernet_config.yml
  250. - name: OMNIA_1.1_EF_TC_008
  251. hosts: ethernet
  252. gather_facts: false
  253. connection: local
  254. vars_files:
  255. - test_vars/test_ethernet_vars.yml
  256. - ../roles/webui_awx/vars/main.yml
  257. - ../input_params/base_vars.yml
  258. tasks:
  259. - name: Retrieving ethernet_config backup
  260. copy:
  261. src: "{{ ethernet_config_backup_dir }}"
  262. dest: "{{ ethernet_config_dir }}"
  263. mode: "{{ file_perm }}"
  264. tags: TC_008
  265. - name: Removing interface config from ethernet_config
  266. ansible.builtin.command: sed -i '22,117d' "{{ ethernet_config_dir }}"
  267. args:
  268. warn: no
  269. changed_when: false
  270. tags: TC_008
  271. - name: Executing ethernet role with no interface config
  272. vars:
  273. inventory_name: "{{ eth_inventory_name }}"
  274. host_name: "{{ eth_host_name }}"
  275. template_name: "{{ eth_template_value }}"
  276. job_template_name: "{{ eth_job_name }}"
  277. playbook_path: "{{ eth_playbook_path }}"
  278. delete_status: true
  279. include_tasks: "{{ awx_script_path }}"
  280. - block:
  281. - name: Validate default flow
  282. assert:
  283. that:
  284. - ethernet_success_msg in job_status.status
  285. success_msg: "{{ success_message }}"
  286. fail_msg: "{{ fail_case }}"
  287. changed_when: false
  288. - name: Restoring original ethernt_config
  289. copy:
  290. src: "{{ ethernet_config_backup_dir }}"
  291. dest: "{{ ethernet_config_dir }}"
  292. mode: "{{ file_perm }}"
  293. tags: TC_008
  294. - name: Set save_changes_to_startup to True in ethernet_vars
  295. ansible.builtin.replace:
  296. dest: "{{ ethernet_config_dir }}"
  297. regexp: 'save_changes_to_startup: false'
  298. replace: 'save_changes_to_startup: True'
  299. - name: Execute network_ethernet role as port 4 has mtu set in ethernet_vars
  300. vars:
  301. inventory_name: "{{ eth_inventory_name }}"
  302. host_name: "{{ eth_host_name }}"
  303. template_name: "{{ eth_template_value }}"
  304. job_template_name: "{{ eth_job_name }}"
  305. playbook_path: "{{ eth_playbook_path }}"
  306. delete_status: true
  307. include_tasks: "{{ awx_script_path }}"
  308. - name: Set save_changes_to_startup to False in ethernet_vars
  309. ansible.builtin.replace:
  310. dest: "{{ ethernet_config_dir }}"
  311. regexp: 'save_changes_to_startup: True'
  312. replace: 'save_changes_to_startup: False'