test_ethernet_fact.yml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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_EF_TC_002
  16. # Execute ethernetfacts.yml with valid IP with valid credentials in ethernet inventory group
  17. - name: OMNIA_1.1_EF_TC_002
  18. hosts: ethernet
  19. gather_facts: false
  20. tags: TC_002
  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: Execute ethernet_facts with valid creds and valid IP
  28. vars:
  29. inventory_name: "{{ eth_inventory_name }}"
  30. host_name: "{{ eth_host_name }}"
  31. template_name: "{{ fact_template_value }}"
  32. job_template_name: "{{ fact_job_name }}"
  33. playbook_path: "{{ eth_facts_playbook_path }}"
  34. delete_status: true
  35. include_tasks: "{{ awx_script_path }}"
  36. tags: TC_002
  37. - block:
  38. - name: Validate default flow with valid IP and valid credentials
  39. assert:
  40. that:
  41. - "'successful' in job_status.status"
  42. success_msg: "{{ success_message }}"
  43. fail_msg: "{{ fail_case }}"
  44. changed_when: false
  45. # Testcase OMNIA_1.1_EF_TC_003
  46. # Execute ethernetfacts.yml with Invalid IP in ethernet inventory group
  47. - name: OMNIA_1.1_EF_TC_003
  48. hosts: ethernet
  49. gather_facts: false
  50. tags: TC_003
  51. connection: local
  52. vars_files:
  53. - test_vars/test_ethernet_vars.yml
  54. - ../roles/webui_awx/vars/main.yml
  55. - ../input_params/base_vars.yml
  56. tasks:
  57. - name: setting ip
  58. set_fact:
  59. eth_host_name: "{{ random_ip }}"
  60. - name: Execute ethernet_facts with random IP
  61. vars:
  62. inventory_name: "{{ eth_inventory_name }}"
  63. host_name: "{{ eth_host_name }}"
  64. template_name: "{{ fact_template_value }}"
  65. job_template_name: "{{ fact_job_name }}"
  66. playbook_path: "{{ eth_facts_playbook_path }}"
  67. delete_status: true
  68. include_tasks: "{{ awx_script_path }}"
  69. - block:
  70. - name: Validate invalid IP and valid credentials
  71. assert:
  72. that:
  73. - "'failed' in job_status.status"
  74. success_msg: "{{ success_message }}"
  75. fail_msg: "{{ fail_case }}"
  76. changed_when: false
  77. # Testcase OMNIA_1.1_EF_TC_001
  78. # Execute ethernetfacts.yml with no hosts in ethernet inventory group
  79. - name: OMNIA_1.1_EF_TC_001
  80. hosts: ethernet
  81. gather_facts: false
  82. tags: TC_001
  83. connection: local
  84. vars_files:
  85. - test_vars/test_ethernet_vars.yml
  86. - ../roles/webui_awx/vars/main.yml
  87. - ../input_params/base_vars.yml
  88. tasks:
  89. - name: Execute ethernet_facts with no host details
  90. vars:
  91. inventory_name: "{{ eth_inventory_name }}"
  92. template_name: "{{ fact_template_value }}"
  93. job_template_name: "{{ fact_job_name }}"
  94. playbook_path: "{{ eth_facts_playbook_path }}"
  95. delete_status: true
  96. include_tasks: "{{ awx_script_path }}"
  97. - block:
  98. - name: Validate no hosts and valid credentials
  99. assert:
  100. that:
  101. - "'successful' in job_status.status"
  102. success_msg: "{{ success_message }}"
  103. fail_msg: "{{ fail_case }}"
  104. changed_when: false
  105. # Testcase OMNIA_1.1_EF_TC_004
  106. # Execute ethernetfacts.yml with valid IP in ethernet inventory group with incorrect credentials
  107. - name: OMNIA_1.1_EF_TC_004
  108. hosts: ethernet
  109. gather_facts: false
  110. tags: TC_004
  111. connection: local
  112. vars_files:
  113. - test_vars/test_ethernet_vars.yml
  114. - ../roles/webui_awx/vars/main.yml
  115. - ../input_params/base_vars.yml
  116. tasks:
  117. - name: Making ethernet_credentials invalid
  118. tower_credential:
  119. name: "ethernet_credential"
  120. credential_type: "Machine"
  121. inputs:
  122. username: "{{ invalid_username }}"
  123. - name: Execute ethernet_facts with invalid credentials
  124. vars:
  125. inventory_name: "{{ eth_inventory_name }}"
  126. host_name: "{{ eth_host_name }}"
  127. template_name: "{{ fact_template_value }}"
  128. job_template_name: "{{ fact_job_name }}"
  129. playbook_path: "{{ eth_facts_playbook_path }}"
  130. delete_status: true
  131. include_tasks: "{{ awx_script_path }}"
  132. - block:
  133. - name: Validate valid IP and invalid credentials
  134. assert:
  135. that:
  136. - "'failed' in job_status.status"
  137. success_msg: "{{ success_message }}"
  138. fail_msg: "{{ fail_case }}"
  139. changed_when: false
  140. - name: Set credentials back to default
  141. tower_credential:
  142. name: "ethernet_credential"
  143. credential_type: "Machine"
  144. inputs:
  145. username: "{{ username }}"
  146. password: "{{ password }}"