Browse Source

Issue #510: Updated ethernet test automation script

Signed-off-by: Bhagyashree-shetty <Bhagyashree_Shetty@dellteam.com>
Bhagyashree-shetty 3 years ago
parent
commit
53c6084f08

+ 12 - 1
.all-contributorsrc

@@ -18,7 +18,8 @@
         "ideas",
         "maintenance",
         "mentoring",
-        "design"
+        "design",
+        "review"
       ]
     },
     {
@@ -274,6 +275,16 @@
         "test",
         "code"
       ]
+    },
+    {
+      "login": "nihalranjan-hpc",
+      "name": "Nihal Ranjan",
+      "avatar_url": "https://avatars.githubusercontent.com/u/84398828?v=4",
+      "profile": "https://github.com/nihalranjan-hpc",
+      "contributions": [
+        "test",
+        "code"
+      ]
     }
   ],
   "contributorsPerLine": 7,

File diff suppressed because it is too large
+ 2 - 1
README.md


+ 2 - 2
control_plane/test/test_eth_mtu.yml

@@ -29,7 +29,7 @@
 
    - name: View running configurations
      dellos10_command:
-       commands: show interface ethernet 1/1/4
+       commands: show interface ethernet {{ validation_port }}
      register: var1
      tags: mtu
 
@@ -44,4 +44,4 @@
           - command: 'reload'
             prompt: '\[confirm yes/no\]:?$'
             answer: 'yes'
-     tags: reload
+     tags: reload

+ 27 - 34
control_plane/test/test_ethernet_config.yml

@@ -18,7 +18,7 @@
 - name: OMNIA_1.1_EF_TC_007
   hosts: ethernet
   gather_facts: false
-  tags: VERIFY_OMNIA_01
+  tags: TC_007
   connection: local
   vars_files:
     - test_vars/test_ethernet_vars.yml
@@ -29,7 +29,7 @@
       copy:
         src: "{{ ethernet_config_dir }}"
         dest: "{{ ethernet_config_backup_dir }}"
-        mode: '0644'
+        mode: "{{ file_perm }}"
       tags: TC_007
 
     - name: Executing ethernet role with default ethernet_config
@@ -46,16 +46,16 @@
        - name: Validate default flow
          assert:
            that:
-             - "'successful' in job_status.status"
+             - ethernet_success_msg in job_status.status
            success_msg: "{{ success_message }}"
            fail_msg: "{{ fail_case }}"
          changed_when: false
 
-    - name: Set MTU of port 4
+    - name: Set MTU of port {{ port_num }}
       lineinfile:
        dest: "{{ ethernet_config_dir }}"
-       insertbefore: '    ethernet 1/1/5:'
-       line: '      mtu: 2345'
+       insertbefore: "{{ search_line }}"
+       line: "{{ add_mtu_line }}"
     
     - name: Executing ethernet role with default ethernet_config
       vars:
@@ -67,16 +67,16 @@
        delete_status: true
       include_tasks: "{{ awx_script_path }}"
       
-    - name: Getting MTU of ethernet 1/1/4
+    - name: Getting MTU of ethernet {{ validation_port }}
       command: ansible-playbook -i "{{ inventory_dir }}" "{{ get_mtu_dir }}" --tags 'mtu'
       changed_when: false
-      register: port4
+      register: mtu_out
       tags: TC_007,TC_002
        
     - name: Validate role exec output pre and post MTU addition
       assert:
         that:          
-          - "'MTU 2345 bytes' in port4.stdout"
+          - validate_mtu_line in mtu_out.stdout
         success_msg: "{{ success_message }}"
         fail_msg: "{{ fail_case }}"
       changed_when: false
@@ -101,18 +101,18 @@
     
     - name: Pausing for switch to come up
       pause:
-        minutes: 4
+        minutes: "{{ time_to_pause }}"
         
-    - name: Getting MTU of ethernet 1/1/4
+    - name: Getting MTU of ethernet {{ validation_port }}
       command: ansible-playbook -i "{{ inventory_dir }}" "{{ get_mtu_dir }}" --tags 'mtu'
       changed_when: false
-      register: port4
+      register: mtu_out
       
     - block:
        - name: Validate that MTU is changed
          assert:
            that:
-             - "'MTU 2345 bytes' not in port4.stdout"
+             - validate_mtu_line not in mtu_out.stdout
            success_msg: "{{ success_message }}"
            fail_msg: "{{ fail_case }}"
          changed_when: false
@@ -152,18 +152,18 @@
     
     - name: Pausing for switch to come up
       pause:
-        minutes: 4
+        minutes: "{{ time_to_pause }}"
         
-    - name: Getting MTU of ethernet 1/1/4
+    - name: Getting MTU of ethernet {{ validation_port }}
       command: ansible-playbook -i "{{ inventory_dir }}" "{{ get_mtu_dir }}" --tags 'mtu'
       changed_when: false
-      register: port4
+      register: mtu_out
     
     - block:
        - name: Validate that MTU is changed
          assert:
            that:
-             - "'MTU 2345 bytes' in port4.stdout"
+             - validate_mtu_line in mtu_out.stdout
            success_msg: "{{ success_message }}"
            fail_msg: "{{ fail_case }}"
          changed_when: false
@@ -201,30 +201,23 @@
        - name: Validate role exec output
          assert:
            that:
-             - "'failed' in job_status.status"
+             - ethernet_fail_msg in job_status.status
            success_msg: "{{ success_message }}"
            fail_msg: "{{ fail_case }}"
 
 # Testcase OMNIA_1.1_EF_TC_009
-# Execute ethernet.yml with only interface and no Global configs in ethernet_config.yml 
+# Validation of ethernet default configuration
 - name: OMNIA_1.1_EF_TC_009
   hosts: ethernet
   gather_facts: false
-  tags: TC_009
+  tags: VERIFY_OMNIA_01
   connection: local
   vars_files:
     - test_vars/test_ethernet_vars.yml
     - ../roles/webui_awx/vars/main.yml    
     - ../input_params/base_vars.yml    
   tasks:
-    - name: Deleting global config completely
-      ansible.builtin.command: sed -i '18,23d' "{{ ethernet_config_dir }}"
-      args:
-       warn: no
-      changed_when: false
-      tags: TC_009
-      
-    - name: Executing ethernet role with no global config
+    - name: Executing ethernet role
       vars:
        inventory_name: "{{ eth_inventory_name }}"
        host_name: "{{ eth_host_name }}"
@@ -238,7 +231,7 @@
        - name: Validate default flow
          assert:
            that:
-             - "'successful' in job_status.status"
+             - ethernet_success_msg in job_status.status
            success_msg: "{{ success_message }}"
            fail_msg: "{{ fail_case }}"
          changed_when: false
@@ -274,7 +267,7 @@
        - name: Validate role exec output
          assert:
            that:
-             - "'failed' in job_status.status"
+             - ethernet_fail_msg in job_status.status
            success_msg: "{{ success_message }}"
            fail_msg: "{{ fail_case }}"      
 
@@ -294,7 +287,7 @@
       copy:
         src: "{{ ethernet_config_backup_dir }}"
         dest: "{{ ethernet_config_dir }}"
-        mode: '0644'
+        mode: "{{ file_perm }}"
       tags: TC_008
     
     - name: Removing interface config from ethernet_config
@@ -318,7 +311,7 @@
        - name: Validate default flow
          assert:
            that:
-             - "'successful' in job_status.status"
+             - ethernet_success_msg in job_status.status
            success_msg: "{{ success_message }}"
            fail_msg: "{{ fail_case }}"
          changed_when: false
@@ -327,7 +320,7 @@
       copy:
         src: "{{ ethernet_config_backup_dir }}"
         dest: "{{ ethernet_config_dir }}"
-        mode: '0644'
+        mode: "{{ file_perm }}"
       tags: TC_008
       
     - name: Set save_changes_to_startup to True in ethernet_vars
@@ -350,4 +343,4 @@
       ansible.builtin.replace:
         dest: "{{ ethernet_config_dir }}"
         regexp: 'save_changes_to_startup: True'
-        replace: 'save_changes_to_startup: False'
+        replace: 'save_changes_to_startup: False'

+ 1 - 1
control_plane/test/test_ethernet_fact.yml

@@ -154,4 +154,4 @@
         credential_type: "Machine"
         inputs:
           username: "{{ username }}"
-          password: "{{ password }}"
+          password: "{{ password }}"

+ 2 - 17
control_plane/test/test_ethernet_inventory

@@ -1,20 +1,5 @@
-#  Copyright 2021 Dell Inc. or its subsidiaries. All Rights Reserved.
-#
-#  Licensed under the Apache License, Version 2.0 (the "License");
-#  you may not use this file except in compliance with the License.
-#  You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-#  Unless required by applicable law or agreed to in writing, software
-#  distributed under the License is distributed on an "AS IS" BASIS,
-#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#  See the License for the specific language governing permissions and
-#  limitations under the License.
----
-
 [ethernet]
-100.96.23.241
+1.2.3.4
 
 [ethernet:vars]
-ansible_network_os= dellemc.os10.os10
+ansible_network_os= dellemc.os10.os10

+ 10 - 0
control_plane/test/test_vars/test_ethernet_vars.yml

@@ -44,3 +44,13 @@ login_vars_vault_path: "../input_params/.login_vault_key"
 tower_config_file_path: "../roles/webui_awx/files/.tower_cli.cfg"
 tower_vault_file_path: "../roles/webui_awx/files/.tower_vault_key"
 file_perm: '0644'
+
+# Usage : test_eth_mtu.yml, test_ethernet_config.yml
+validation_port: 1/1/4:1
+port_num: 4
+search_line: "    ethernet 1/1/5:"
+add_mtu_line: "      mtu: 2345"
+time_to_pause: 4
+validate_mtu_line: "MTU 2345 bytes"
+ethernet_success_msg: "successful"
+ethernet_fail_msg: "failed"