def test_slow_routing_direct_connected(topology, step): """ Verify slow path routing for directly connected hosts. """ ops1 = topology.get('ops1') hs1 = topology.get('hs1') hs2 = topology.get('hs2') assert ops1 is not None assert hs1 is not None assert hs2 is not None # ----------Configure Switches and Hosts---------- step('Configure switch and host ports') lib.switch_cfg_iface(ops1, 'if01', '192.168.1.1/24', '2000::1/120') lib.switch_cfg_iface(ops1, 'if02', '192.168.2.1/24', '2002::1/120') sleep(10) lib.host_cfg_iface(hs1, 'eth0', '192.168.1.2/24', '2000::2/120') lib.host_cfg_iface(hs2, 'eth0', '192.168.2.2/24', '2002::2/120') lib.host_add_route(hs1, '192.168.2.0/24', '192.168.1.1') lib.host_add_route(hs2, '192.168.1.0/24', '192.168.2.1') lib.host_add_route(hs1, '2002::0/120', '2000::1') lib.host_add_route(hs2, '2000::0/120', '2002::1') # ----------Test IPv4 Ping---------- step('Test IPv4 Ping') lib.host_ping_expect_success(10, hs1, ops1, '192.168.1.1') lib.host_ping_expect_success(10, hs2, ops1, '192.168.2.1') lib.host_ping_expect_success(10, hs1, hs2, '192.168.2.2') # ----------Test IPv6 Ping---------- step('Test IPv6 Ping') lib.host_ping_expect_success(10, hs1, ops1, '2000::1') lib.host_ping_expect_success(10, hs2, ops1, '2002::1') lib.host_ping_expect_success(10, hs1, hs2, '2002::2')
def test_intervlan_routing(topology, step): """ Verify intervlan routing. """ ops1 = topology.get('ops1') hs1 = topology.get('hs1') hs2 = topology.get('hs2') hs3 = topology.get('hs3') hs4 = topology.get('hs4') assert ops1 is not None assert hs1 is not None assert hs2 is not None assert hs3 is not None assert hs4 is not None # ----------Configure Switches and Hosts---------- step('Configure Switches and Hosts') lib.switch_add_vlan(ops1, 10) lib.switch_add_vlan(ops1, 20) lib.switch_add_vlan_port(ops1, 10, 'if01') lib.switch_add_vlan_port(ops1, 10, 'if02') lib.switch_add_vlan_port(ops1, 20, 'if03') lib.switch_cfg_vlan(ops1, 10, '10.0.0.1/24', '1000::1/120') lib.switch_cfg_vlan(ops1, 20, '20.0.0.1/24', '2000::1/120') lib.switch_cfg_iface(ops1, 'if04', '30.0.0.1/24', '3000::1/120') sleep(10) lib.host_cfg_iface(hs1, 'eth0', '10.0.0.9/24', '1000::9/120') lib.host_cfg_iface(hs2, 'eth0', '10.0.0.10/24', '1000::10/120') lib.host_cfg_iface(hs3, 'eth0', '20.0.0.10/24', '2000::10/120') lib.host_cfg_iface(hs4, 'eth0', '30.0.0.10/24', '3000::10/120') lib.host_add_route(hs1, '0.0.0.0/0', '10.0.0.1') lib.host_add_route(hs2, '0.0.0.0/0', '10.0.0.1') lib.host_add_route(hs3, '0.0.0.0/0', '20.0.0.1') lib.host_add_route(hs4, '0.0.0.0/0', '30.0.0.1') lib.host_add_route(hs1, '::/0', '1000::1') lib.host_add_route(hs2, '::/0', '1000::1') lib.host_add_route(hs3, '::/0', '2000::1') lib.host_add_route(hs4, '::/0', '3000::1') # ----------Ping after configuring vlan---------- step('Ping after configuring vlan') lib.host_ping_expect_success(10, hs1, hs2, '10.0.0.10') lib.host_ping_expect_success(10, hs1, hs3, '20.0.0.10') lib.host_ping_expect_success(10, hs1, hs4, '30.0.0.10') lib.host_ping_expect_success(10, hs1, hs2, '1000::10') lib.host_ping_expect_success(10, hs1, hs3, '2000::10') lib.host_ping_expect_success(10, hs1, hs4, '3000::10') # ----------Baselining stats on L3 interfaces---------- step('Baselining L3 stats') base_vlan10 = ops1.libs.vtysh.show_interface("vlan10") base_vlan20 = ops1.libs.vtysh.show_interface("vlan20") base_ip_intf4 = ops1.libs.vtysh.show_ip_interface("if04") base_ipv6_intf4 = ops1.libs.vtysh.show_ipv6_interface("if04") # ----------Ping host 3 host 4 from host 1---------- step("Ping host 3 host 4 from host 1") hs1.libs.ping.ping(5, '20.0.0.10') hs1.libs.ping.ping(5, '2000::10') hs1.libs.ping.ping(5, '30.0.0.10') hs1.libs.ping.ping(5, '3000::10') # ----------Verify L3 statistics on L3 interfaces---------- step("Verify L3 statistics on L3 interfaces") print("Verify interface vlan10 stats") verify_l3_stats(ops1, "vlan10", base_vlan10, 20) print("Verify interface vlan20 stats") verify_l3_stats(ops1, "vlan20", base_vlan20, 10) print("Verify ip phy interface stats") verify_l3_stats(ops1, "if04", base_ip_intf4, 5) print("Verify ipv6 phy interface stats") verify_l3_stats(ops1, "if04", base_ipv6_intf4, 5) # ----------Remove vlans---------- step('Remove vlan interfaces') lib.switch_remove_interface_vlan(ops1, "10") lib.switch_remove_interface_vlan(ops1, "20") # ----------Ping after removing vlan---------- step('Ping after removing vlan') lib.host_ping_expect_success(10, hs1, hs2, '10.0.0.10') lib.host_ping_expect_failure(10, hs1, hs3, '20.0.0.10') lib.host_ping_expect_success(10, hs1, hs2, '1000::10') lib.host_ping_expect_failure(10, hs1, hs3, '2000::10')
def test_fastpath_routed(topology, step): """ Directly Connected Hosts Fast Path Ping Test """ hs1 = topology.get('hs1') hs2 = topology.get('hs2') ops1 = topology.get('ops1') assert hs1 is not None assert hs2 is not None assert ops1 is not None # ----------Configure Switches and Hosts---------- step('Configure Switches and Hosts') with ops1.libs.vtysh.Configure(): ops1("vlan internal range 400 500 ascending", shell=None) lib.switch_cfg_iface(ops1, 'if01', '10.0.0.1/24', '2000::1/120') lib.switch_cfg_iface(ops1, 'if02', '11.0.0.1/24', '2002::1/120') sleep(10) lib.host_cfg_iface(hs1, 'eth0', '10.0.0.10/24', '2000::2/120') lib.host_cfg_iface(hs2, 'eth0', '11.0.0.10/24', '2002::2/120') lib.host_add_route(hs1, '0.0.0.0/0', '10.0.0.1') lib.host_add_route(hs2, '0.0.0.0/0', '11.0.0.1') lib.host_add_route(hs1, '::/0', '2000::1') lib.host_add_route(hs2, '::/0', '2002::1') # ---------- IPv4 ping between workstations ---------- step("IPv4 ping between workstations") lib.host_ping_expect_success(10, hs2, hs1, '10.0.0.10') lib.host_ping_expect_success(10, hs1, hs2, '11.0.0.10') # ---------- Verifying HIT Bit in ASIC for IPv4 ping ---------- step("Verifying HIT Bit in ASIC for IPv4 ping") lib.host_ping_expect_success(10, hs1, hs2, '11.0.0.10') verify_ipv4_hit_bit(ops1, '10.0.0.10', '11.0.0.10') # ---------- IPv6 ping between workstations ---------- step("IPv6 ping between workstations") lib.host_ping_expect_success(10, hs2, hs1, '2000::2') lib.host_ping_expect_success(10, hs1, hs2, '2002::2') # ---------- Verifying HIT Bit in ASIC for IPv6 ping ---------- step("Verifying HIT Bit in ASIC for IPv6 ping") lib.host_ping_expect_success(10, hs1, hs2, '2002::2') verify_ipv6_hit_bit(ops1, '2000::2', '2002::2') # ---------- IPv4 and IPv6 ping between switch and workstations ---------- step("IPv4 and IPv6 ping between switch and workstations") lib.host_ping_expect_success(10, hs1, ops1, '10.0.0.1') lib.host_ping_expect_success(10, hs1, ops1, '2000::1') lib.host_ping_expect_success(10, hs2, ops1, '11.0.0.1') lib.host_ping_expect_success(10, hs2, ops1, '2002::1')
def test_fastpath_routed(topology, step): """ OpenSwitch Test for simple static routes between nodes. """ hs1 = topology.get('hs1') hs2 = topology.get('hs2') ops1 = topology.get('ops1') ops2 = topology.get('ops2') assert hs1 is not None assert hs2 is not None assert ops1 is not None assert ops2 is not None # ----------Configure Switches and Hosts---------- step('Configure Switches and Hosts') lib.switch_cfg_iface(ops1, 'if01', '10.0.10.2/24', '2000::2/120') lib.switch_cfg_iface(ops1, 'if02', '10.0.20.1/24', '2001::1/120') lib.switch_cfg_iface(ops2, 'if01', '10.0.30.2/24', '2002::2/120') lib.switch_cfg_iface(ops2, 'if02', '10.0.20.2/24', '2001::2/120') sleep(10) lib.host_cfg_iface(hs1, 'eth0', '10.0.10.1/24', '2000::1/120') lib.host_cfg_iface(hs2, 'eth0', '10.0.30.1/24', '2002::1/120') lib.host_add_route(hs1, '10.0.20.0/24', '10.0.10.2') lib.host_add_route(hs1, '10.0.30.0/24', '10.0.10.2') lib.host_add_route(hs2, '10.0.10.0/24', '10.0.30.2') lib.host_add_route(hs2, '10.0.20.0/24', '10.0.30.2') lib.host_add_route(hs1, '2001::/120', '2000::2') lib.host_add_route(hs1, '2002::/120', '2000::2') lib.host_add_route(hs2, '2000::/120', '2002::2') lib.host_add_route(hs2, '2001::/120', '2002::2') # ----------Add IPv4 and IPv6 static routes to switches---------- step('Add IPv4 and IPv6 static routes to switches') lib.switch_add_ipv4_route(ops1, '10.0.30.0/24', '10.0.20.2') lib.switch_add_ipv4_route(ops2, '10.0.10.0/24', '10.0.20.1') lib.switch_add_ipv6_route(ops1, '2002::/120', '2001::2') lib.switch_add_ipv6_route(ops2, '2000::/120', '2001::1') # --------------Baseline rx tx statistics--------------- base_stats_ops1 = ops1.libs.vtysh.show_interface("if02") base_stats_ops2 = ops2.libs.vtysh.show_interface("if02") # ----------Test Ping after adding static routes---------- step('Test Ping after adding static routes') lib.host_ping_expect_success(1, hs1, hs2, '10.0.30.1') lib.host_ping_expect_success(1, hs1, hs2, '2002::1') lib.host_ping_expect_success(1, hs2, hs1, '10.0.10.1') lib.host_ping_expect_success(1, hs2, hs1, '2000::1') """ # ----------Verifying Hit bit in ASIC for IPv4 ping---------- step('Verifying Hit bit in ASIC for IPv4 ping') verify_hit_bit(ops1, '10.0.30.0') verify_hit_bit(ops2, '10.0.10.0') """ # ----------Verifying rx tx stats after IPv4 ping---------- sleep(10) step('Verifying rx tx stats after IPv4 ping') # Though the above code tries to send 1 ping, 2 pings go out verify_l3_stats(ops1, "if02", base_stats_ops1, 4) verify_l3_stats(ops2, "if02", base_stats_ops2, 4) # ----------Remove IPv4 and IPv6 static routes from switches---------- step('Remove IPv4 and IPv6 static routes from switches') lib.switch_remove_ipv4_route(ops1, '10.0.30.0/24', '10.0.20.2') lib.switch_remove_ipv4_route(ops2, '10.0.10.0/24', '10.0.20.1') lib.switch_remove_ipv6_route(ops1, '2002::/120', '2001::2') lib.switch_remove_ipv6_route(ops2, '2000::/120', '2001::1') # ----------Test Ping after removing static routes---------- step('RTest Ping after removing static routes') lib.host_ping_expect_failure(1, hs1, hs2, '10.0.30.1') lib.host_ping_expect_failure(1, hs1, hs2, '2002::1') lib.host_ping_expect_failure(1, hs2, hs1, '10.0.10.1') lib.host_ping_expect_failure(1, hs2, hs1, '2000::1')
def test_static_routes(topology, step): """ Test for static routes. """ hs1 = topology.get('hs1') hs2 = topology.get('hs2') ops1 = topology.get('ops1') ops2 = topology.get('ops2') assert hs1 is not None assert hs2 is not None assert ops1 is not None assert ops2 is not None # ----------Configure Switches and Hosts---------- step('Configure Switches and Hosts') lib.switch_cfg_iface(ops1, 'if01', '10.0.10.2/24', '2000::2/120') lib.switch_cfg_iface(ops1, 'if02', '10.0.20.1/24', '2001::1/120') lib.switch_cfg_iface(ops2, 'if01', '10.0.30.2/24', '2002::2/120') lib.switch_cfg_iface(ops2, 'if02', '10.0.20.2/24', '2001::2/120') sleep(15) lib.host_cfg_iface(hs1, 'eth0', '10.0.10.1/24', '2000::1/120') lib.host_cfg_iface(hs2, 'eth0', '10.0.30.1/24', '2002::1/120') lib.switch_add_ipv4_route(ops1, '10.0.30.0/24', '10.0.20.2') lib.switch_add_ipv6_route(ops1, '2002::/120', '2001::2') lib.switch_add_ipv4_route(ops2, '10.0.10.0/24', '10.0.20.1') lib.switch_add_ipv6_route(ops2, '2000::/120', '2001::1') lib.host_add_route(hs1, '10.0.20.0/24', '10.0.10.2') lib.host_add_route(hs1, '10.0.30.0/24', '10.0.10.2') lib.host_add_route(hs1, '2001::/120', '2000::2') lib.host_add_route(hs1, '2002::/120', '2000::2') lib.host_add_route(hs2, '10.0.10.0/24', '10.0.30.2') lib.host_add_route(hs2, '10.0.20.0/24', '10.0.30.2') lib.host_add_route(hs2, '2000::/120', '2002::2') lib.host_add_route(hs2, '2001::/120', '2002::2') # ----------Test IPv4 ping---------- step('Test IPv4 ping') lib.host_ping_expect_success(10, hs1, ops1, '10.0.10.2') lib.host_ping_expect_success(10, hs2, ops2, '10.0.30.2') lib.switch_ping_expect_success(10, ops1, ops2, '10.0.20.2') lib.host_ping_expect_success(10, hs1, hs2, '10.0.30.1') lib.host_ping_expect_success(10, hs2, hs1, '10.0.10.1') # ----------Test IPv6 ping---------- step('Test IPv6 ping') lib.host_ping_expect_success(10, hs1, ops1, '2000::2') lib.host_ping_expect_success(10, hs2, ops2, '2002::2') lib.switch_ping_expect_success(10, ops1, ops2, '2001::2') lib.host_ping_expect_success(10, hs1, hs2, '2002::1') lib.host_ping_expect_success(10, hs2, hs1, '2000::1') # ----------Verify deletion of IPv4 static routes---------- step('Verify deletion of IPv4 static routes') lib.host_ping_expect_success(10, hs1, hs2, '10.0.30.1') lib.switch_remove_ipv4_route(ops1, '10.0.30.0/24', '10.0.20.2') lib.host_ping_expect_failure(10, hs1, hs2, '10.0.30.1') # ----------Verify deletion of IPv6 static routes---------- step('Verify deletion of IPv6 static routes') lib.host_ping_expect_success(10, hs1, hs2, '2002::1') lib.switch_remove_ipv6_route(ops1, '2002::/120', '2001::2') lib.host_ping_expect_failure(10, hs1, hs2, '2002::1')
def test_ecmp_routing(topology, step): """ Verify ecmp routing. """ ops1 = topology.get('ops1') ops2 = topology.get('ops2') hs1 = topology.get('hs1') hs2 = topology.get('hs2') hs3 = topology.get('hs3') assert ops1 is not None assert ops2 is not None assert hs1 is not None assert hs2 is not None assert hs3 is not None # ----------Configure Switches and Hosts---------- step('Configure Switches and Hosts') lib.switch_cfg_iface(ops1, 'if01', '10.0.30.1/24', '1030::1/120') lib.switch_cfg_iface(ops1, 'if02', '10.0.10.2/24', '1010::2/120') lib.switch_cfg_iface(ops1, 'if03', '10.0.20.2/24', '1020::2/120') lib.switch_cfg_iface(ops1, 'if04', '10.0.50.1/24', '1050::1/120') lib.switch_cfg_iface(ops2, 'if01', '10.0.30.2/24', '1030::2/120') lib.switch_cfg_iface(ops2, 'if02', '10.0.40.2/24', '1040::2/120') lib.switch_cfg_iface(ops2, 'if03', '10.0.50.2/24', '1050::2/120') sleep(15) lib.switch_add_ipv4_route(ops1, '10.0.40.0/24', '10.0.30.2') lib.switch_add_ipv4_route(ops1, '10.0.40.0/24', '10.0.50.2') lib.switch_add_ipv6_route(ops1, '1040::/120', '1030::2') lib.switch_add_ipv6_route(ops1, '1040::/120', '1050::2') lib.switch_add_ipv4_route(ops2, '10.0.10.0/24', '10.0.30.1') lib.switch_add_ipv4_route(ops2, '10.0.20.0/24', '10.0.30.1') lib.switch_add_ipv4_route(ops2, '10.0.10.0/24', '10.0.50.1') lib.switch_add_ipv4_route(ops2, '10.0.20.0/24', '10.0.50.1') lib.switch_add_ipv6_route(ops2, '1010::/120', '1030::1') lib.switch_add_ipv6_route(ops2, '1020::/120', '1030::1') lib.switch_add_ipv6_route(ops2, '1010::/120', '1050::1') lib.switch_add_ipv6_route(ops2, '1020::/120', '1050::1') lib.host_cfg_iface(hs1, 'eth0', '10.0.10.1/24', '1010::1/120') lib.host_cfg_iface(hs2, 'eth0', '10.0.20.1/24', '1020::1/120') lib.host_cfg_iface(hs3, 'eth0', '10.0.40.1/24', '1040::1/120') lib.host_add_route(hs1, '10.0.30.0/24', '10.0.10.2') lib.host_add_route(hs1, '10.0.40.0/24', '10.0.10.2') lib.host_add_route(hs1, '10.0.50.0/24', '10.0.10.2') lib.host_add_route(hs1, '1030::/120', '1010::2') lib.host_add_route(hs1, '1040::/120', '1010::2') lib.host_add_route(hs1, '1050::/120', '1010::2') lib.host_add_route(hs2, '10.0.30.0/24', '10.0.20.2') lib.host_add_route(hs2, '10.0.40.0/24', '10.0.20.2') lib.host_add_route(hs2, '10.0.50.0/24', '10.0.20.2') lib.host_add_route(hs2, '1030::/120', '1020::2') lib.host_add_route(hs2, '1040::/120', '1020::2') lib.host_add_route(hs2, '1050::/120', '1020::2') lib.host_add_route(hs3, '10.0.10.0/24', '10.0.40.2') lib.host_add_route(hs3, '10.0.20.0/24', '10.0.40.2') lib.host_add_route(hs3, '10.0.30.0/24', '10.0.40.2') lib.host_add_route(hs3, '10.0.50.0/24', '10.0.40.2') lib.host_add_route(hs3, '1010::/120', '1040::2') lib.host_add_route(hs3, '1020::/120', '1040::2') lib.host_add_route(hs3, '1030::/120', '1040::2') lib.host_add_route(hs3, '1050::/120', '1040::2') sleep(15) # ----------Do ping tests before removing routes---------- step('Do ping tests before removing routes') lib.host_ping_expect_success(10, hs1, hs3, '10.0.40.1') lib.host_ping_expect_success(10, hs1, hs3, '1040::1') lib.host_ping_expect_success(10, hs2, hs3, '10.0.40.1') lib.host_ping_expect_success(10, hs2, hs3, '1040::1') # ----------Remove Routes---------- step('Remove Routes') lib.switch_remove_ipv4_route(ops1, '10.0.40.0/24', '10.0.30.2') lib.switch_remove_ipv4_route(ops1, '10.0.40.0/24', '10.0.50.2') lib.switch_remove_ipv6_route(ops1, '1040::/120', '1030::2') lib.switch_remove_ipv6_route(ops1, '1040::/120', '1050::2') lib.switch_remove_ipv4_route(ops2, '10.0.10.0/24', '10.0.30.1') lib.switch_remove_ipv4_route(ops2, '10.0.20.0/24', '10.0.30.1') lib.switch_remove_ipv4_route(ops2, '10.0.10.0/24', '10.0.50.1') lib.switch_remove_ipv4_route(ops2, '10.0.20.0/24', '10.0.50.1') lib.switch_remove_ipv6_route(ops2, '1010::/120', '1030::1') lib.switch_remove_ipv6_route(ops2, '1020::/120', '1030::1') lib.switch_remove_ipv6_route(ops2, '1010::/120', '1050::1') lib.switch_remove_ipv6_route(ops2, '1020::/120', '1050::1') sleep(15) # ----------Do ping tests after removing routes---------- step('Do ping tests before after routes') lib.host_ping_expect_failure(10, hs1, hs3, '10.0.40.1') lib.host_ping_expect_failure(10, hs1, hs3, '1040::1') lib.host_ping_expect_failure(10, hs2, hs3, '10.0.40.1') lib.host_ping_expect_failure(10, hs2, hs3, '1040::1')