def reload_dut_config(request, duthost, define_sub_ports_configuration): """ DUT's configuration reload on teardown Args: request: pytest request object duthost: DUT host object define_sub_ports_configuration: Dictonary of parameters for configuration DUT """ yield sub_ports = define_sub_ports_configuration['sub_ports'] dut_ports = define_sub_ports_configuration['dut_ports'] cfg_facts = duthost.config_facts(host=duthost.hostname, source="running")['ansible_facts'] existing_sub_ports = cfg_facts.get("VLAN_SUB_INTERFACE", {}) for sub_port in sub_ports: if sub_port in existing_sub_ports: remove_sub_port(duthost, sub_port, sub_ports[sub_port]['ip']) py_assert(check_sub_port(duthost, sub_ports.keys(), True), "Some sub-port were not deleted") if 'port_in_lag' in request.node.name: for lag_port in dut_ports.values(): remove_lag_port(duthost, cfg_facts, lag_port) duthost.shell('sudo config load -y /etc/sonic/config_db.json')
def test_vlan_config_impact(self, duthost, ptfadapter, apply_config_on_the_dut, apply_config_on_the_ptf): """ Validates that removal of VLAN doesn't impact sub-port RIF with same VLAN ID. Test steps: 1.) Setup correct configuration of sub-ports on the DUT. 3.) Create a VLAN RIF with the same VLAN ID of sub-port. 4.) Added PortChannel interface to VLAN members. 5.) Delete a VLAN RIF. 6.) Make sure sub-port is available in redis-db. 7.) Verify that DUT sends ICMP reply packet to PTF. 8.) Clear configuration of sub-ports on the DUT. 9.) Clear configuration of sub-ports on the PTF. Pass Criteria: 1.) Sub-port is available in redis-db. 2.) PTF gets ICMP reply packet from DUT. """ sub_ports = apply_config_on_the_dut['sub_ports'] for sub_port, value in sub_ports.items(): # Get VLAN ID from name of sub-port vlan_vid = int(sub_port.split('.')[1]) # Create a VLAN RIF setup_vlan(duthost, vlan_vid) # Delete a VLAN RIF remove_vlan(duthost, vlan_vid) pytest_assert(check_sub_port(duthost, sub_port), "Sub-port {} was deleted".format(sub_port)) generate_and_verify_traffic(duthost=duthost, ptfadapter=ptfadapter, src_port=value['neighbor_port'], ip_src=value['neighbor_ip'], dst_port=sub_port, ip_dst=value['ip'], pkt_action='fwd')