Skip to content

Commit

Permalink
Fixed test
Browse files Browse the repository at this point in the history
  • Loading branch information
indraniBh committed Aug 23, 2024
1 parent ec438b2 commit 5be7c59
Show file tree
Hide file tree
Showing 31 changed files with 598 additions and 480 deletions.
37 changes: 25 additions & 12 deletions tests/arp/test_arp_packet.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,8 @@ def test_arp_packet(api, b2b_raw_config_vports, utils, tx_vport, rx_vport):
target_hardware_addr_list = utils.mac_or_ip_addr_from_counter_pattern(
"00:0c:29:e3:53:f4", flow3_step, flow3_count, True
)
sender_protocol_addr_list = [
"10.10.0.1", "10.10.0.2", "10.10.0.3"
]
target_protocol_addr_list = [
"20.20.0.1", "20.20.0.2", "20.20.0.3"
]
sender_protocol_addr_list = ["10.10.0.1", "10.10.0.2", "10.10.0.3"]
target_protocol_addr_list = ["20.20.0.1", "20.20.0.2", "20.20.0.3"]
flow3.tx_rx.port.tx_name = tx_vport.name
flow3.tx_rx.port.rx_name = rx_vport.name
flow3.packet.ethernet().arp()
Expand All @@ -82,12 +78,28 @@ def test_arp_packet(api, b2b_raw_config_vports, utils, tx_vport, rx_vport):
f2_attrs = {
"ethernetARP.header.hardwareType": "{:x}".format(int(hardware_type)),
"ethernetARP.header.protocolType": "{:x}".format(int(protocol_type)),
"ethernetARP.header.hardwareAddressLength": "{:x}".format(int(hardware_length)),
"ethernetARP.header.protocolAddressLength": "{:x}".format(int(protocol_length)),
"ethernetARP.header.hardwareAddressLength": "{:x}".format(
int(hardware_length)
),
"ethernetARP.header.protocolAddressLength": "{:x}".format(
int(protocol_length)
),
"ethernetARP.header.opCode": str(operation),
"ethernetARP.header.srcHardwareAddress": (sender_hardware_addr.lower(), mac_step, str(count)),
"ethernetARP.header.dstHardwareAddress": (target_hardware_addr.lower(), mac_step, str(count)),
"ethernetARP.header.srcIP": (sender_protocol_addr, ip_step, str(count)),
"ethernetARP.header.srcHardwareAddress": (
sender_hardware_addr.lower(),
mac_step,
str(count)
),
"ethernetARP.header.dstHardwareAddress": (
target_hardware_addr.lower(),
mac_step,
str(count)
),
"ethernetARP.header.srcIP": (
sender_protocol_addr,
ip_step,
str(count)
),
"ethernetARP.header.dstIP": (target_protocol_addr, ip_step, str(count)),
}
utils.validate_config(api, "f2", "ethernetARP", **f2_attrs)
Expand All @@ -100,5 +112,6 @@ def test_arp_packet(api, b2b_raw_config_vports, utils, tx_vport, rx_vport):
}
utils.validate_config(api, "f3", "ethernetARP", **f3_attrs)


if __name__ == "__main__":
pytest.main(["-s", __file__])
pytest.main(["-s", __file__])
15 changes: 8 additions & 7 deletions tests/arp/test_arp_packet_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ def test_arp_packet_e2e(api, utils, b2b_raw_config):
- 10% line rate
Validate,
- tx/rx frame count and bytes are as expected
- all captured frames have expected sender_hardware_addr and target_hardware_addr
- all captured frames have expected sender_hardware_addr and
target_hardware_addr
"""
api.set_config(api.config())
flow1 = b2b_raw_config.flows[0]
Expand Down Expand Up @@ -81,11 +82,11 @@ def captures_ok(api, cfg, size, utils):
[0x00, 0x0C, 0x30, 0xE3, 0x50, 0xEA],
]
sender_protocol_addr = [
[0x0a, 0x01, 0x01, 0x02],
[0x0a, 0x01, 0x01, 0x03],
[0x0a, 0x01, 0x01, 0x04],
[0x0a, 0x01, 0x01, 0x05],
[0x0a, 0x01, 0x01, 0x06],
[0x0A, 0x01, 0x01, 0x02],
[0x0A, 0x01, 0x01, 0x03],
[0x0A, 0x01, 0x01, 0x04],
[0x0A, 0x01, 0x01, 0x05],
[0x0A, 0x01, 0x01, 0x06],
]
target_protocol_addr = [
[0x14, 0x01, 0x01, 0x05],
Expand All @@ -109,4 +110,4 @@ def captures_ok(api, cfg, size, utils):


if __name__ == "__main__":
pytest.main(["-s", __file__])
pytest.main(["-s", __file__])
10 changes: 5 additions & 5 deletions tests/bgp/test_bgp_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def test_bgp_attributes(api, utils):
ipv6.gateway = "2000::2"
bgpv6 = device.bgp
bgpv6.router_id = "192.0.0.1"
bgpv6_int = bgpv6.ipv6_interfaces.add()
bgpv6_int = bgpv6.ipv6_interfaces.add()
bgpv6_int.ipv6_name = ipv6.name
bgp6_peer = bgpv6_int.peers.add()
bgp6_peer.name = "rx_bgpv6"
Expand Down Expand Up @@ -183,8 +183,8 @@ def validate_community_config(api, community, aspaths, med, origin):
assert last_two_octets == community.split(":")[1]

as_paths = bgpv4.AsPathASString
as_paths = as_paths[0].replace('}', '').replace('{', '')
as_paths = as_paths.split(',')
as_paths = as_paths[0].replace("}", "").replace("{", "")
as_paths = as_paths.split(",")
as_paths = [int(ele) for ele in as_paths]
assert as_paths == aspaths

Expand All @@ -198,8 +198,8 @@ def validate_community_config(api, community, aspaths, med, origin):
assert last_two_octets == community.split(":")[1]

as_paths = bgpv6.AsPathASString
as_paths = as_paths[0].replace('}', '').replace('{', '')
as_paths = as_paths.split(',')
as_paths = as_paths[0].replace("}", "").replace("{", "")
as_paths = as_paths.split(",")
as_paths = [int(ele) for ele in as_paths]
assert as_paths == aspaths

Expand Down
1 change: 1 addition & 0 deletions tests/bgp/test_bgp_sr_te_1000_policies.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest
from functools import reduce


@pytest.mark.skip("New SR TE model is not available")
def test_bgp_sr_te_1000_policies(api):
"""
Expand Down
1 change: 1 addition & 0 deletions tests/bgp/test_bgp_sr_te_policy_v4v6.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest


@pytest.mark.skip("New SR TE model is not available")
def test_bgp_sr_te_policy_v4v6(api):
"""
Expand Down
1 change: 1 addition & 0 deletions tests/bgp/test_bgp_sr_te_weighted.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest


@pytest.mark.skip("New SR TE model is not available")
def test_bgp_sr_te_weighted(api):
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/bgp/test_bgpv4_stats.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest


@pytest.mark.skip(reason="Revisit CI/CD fail")
# @pytest.mark.skip(reason="Revisit CI/CD fail")
def test_bgpv4_stats(api, b2b_raw_config, utils):
"""
Test for the bgpv4 metrics
Expand Down
114 changes: 59 additions & 55 deletions tests/bgp_evpn/test_bgp_evpn.py
Original file line number Diff line number Diff line change
@@ -1,47 +1,49 @@
def test_bgp_evpn(api, utils):
# Creating Ports
config = api.config()
p1 = config.ports.port(name='p1', location=utils.settings.ports[0])[-1]
p2 = config.ports.port(name='p2', location=utils.settings.ports[1])[-1]
p1 = config.ports.port(name="p1", location=utils.settings.ports[0])[-1]
p2 = config.ports.port(name="p2", location=utils.settings.ports[1])[-1]

# Create BGP devices on tx & rx
tx_d = config.devices.device(name='tx_d')[-1]
rx_d = config.devices.device(name='rx_d')[-1]
tx_d = config.devices.device(name="tx_d")[-1]
rx_d = config.devices.device(name="rx_d")[-1]

tx_eth = tx_d.ethernets.ethernet(port_name=p1.name)[-1]
rx_eth = rx_d.ethernets.ethernet(port_name=p2.name)[-1]

tx_eth.name = 'tx_eth'
tx_eth.mac = '00:11:00:00:00:01'
tx_ip = tx_eth.ipv4_addresses.ipv4(name='tx_ip',
address='20.20.20.2',
gateway='20.20.20.1')[-1]
tx_eth.name = "tx_eth"
tx_eth.mac = "00:11:00:00:00:01"
tx_ip = tx_eth.ipv4_addresses.ipv4(
name="tx_ip", address="20.20.20.2", gateway="20.20.20.1"
)[-1]

rx_eth.name = 'rx_eth'
rx_eth.mac = '00:12:00:00:00:01'
rx_ip = rx_eth.ipv4_addresses.ipv4(name='rx_ip',
address='20.20.20.1',
gateway='20.20.20.2')[-1]
rx_eth.name = "rx_eth"
rx_eth.mac = "00:12:00:00:00:01"
rx_ip = rx_eth.ipv4_addresses.ipv4(
name="rx_ip", address="20.20.20.1", gateway="20.20.20.2"
)[-1]

# tx_bgp
tx_bgp = tx_d.bgp
tx_bgp.router_id = "192.0.0.1"
tx_bgp_iface = (tx_bgp.ipv4_interfaces
.v4interface(ipv4_name=tx_ip.name)[-1])
tx_bgp_peer = tx_bgp_iface.peers.v4peer(name="tx_eBGP",
peer_address='20.20.20.1',
as_type='ebgp',
as_number=100)[-1]
tx_bgp_iface = tx_bgp.ipv4_interfaces.v4interface(ipv4_name=tx_ip.name)[-1]
tx_bgp_peer = tx_bgp_iface.peers.v4peer(
name="tx_eBGP",
peer_address="20.20.20.1",
as_type="ebgp",
as_number=100,
)[-1]

# rx_bgp
rx_bgp = rx_d.bgp
rx_bgp.router_id = "193.0.0.1"
rx_bgp_iface = (rx_bgp.ipv4_interfaces
.v4interface(ipv4_name=rx_ip.name)[-1])
rx_bgp_peer = rx_bgp_iface.peers.v4peer(name="rx_eBGP",
peer_address='20.20.20.2',
as_type='ebgp',
as_number=200)[-1]
rx_bgp_iface = rx_bgp.ipv4_interfaces.v4interface(ipv4_name=rx_ip.name)[-1]
rx_bgp_peer = rx_bgp_iface.peers.v4peer(
name="rx_eBGP",
peer_address="20.20.20.2",
as_type="ebgp",
as_number=200,
)[-1]

# Create & advertise loopback under bgp in tx and rx
tx_l1 = tx_d.ipv4_loopbacks.add()
Expand All @@ -61,15 +63,15 @@ def test_bgp_evpn(api, utils):
rx_l1_r.addresses.add(address="2.2.2.2", prefix=32)

# Create BGP EVPN on tx
tx_vtep = config.devices.device(name='tx_vtep')[-1]
tx_vtep = config.devices.device(name="tx_vtep")[-1]
tx_vtep_bgp = tx_vtep.bgp
tx_vtep_bgp.router_id = "190.0.0.1"
tx_vtep_bgp_iface = (tx_vtep_bgp.ipv4_interfaces
.v4interface(ipv4_name=tx_l1.name)[-1])
tx_vtep_bgp_peer = tx_vtep_bgp_iface.peers.v4peer(name="bgp1",
peer_address='2.2.2.2',
as_type='ibgp',
as_number=101)[-1]
tx_vtep_bgp_iface = tx_vtep_bgp.ipv4_interfaces.v4interface(
ipv4_name=tx_l1.name
)[-1]
tx_vtep_bgp_peer = tx_vtep_bgp_iface.peers.v4peer(
name="bgp1", peer_address="2.2.2.2", as_type="ibgp", as_number=101
)[-1]

# Adding 1 Ethernet Segment per Bgp Peer
tx_vtep_es1 = tx_vtep_bgp_peer.evpn_ethernet_segments.ethernetsegment()[-1]
Expand All @@ -78,7 +80,8 @@ def test_bgp_evpn(api, utils):
tx_es1_evisV4_1 = tx_vtep_es1.evis.evi_vxlan()[-1]
tx_es1_evisV4_1.route_distinguisher.auto_config_rd_ip_addr = True
tx_es1_evisV4_1.route_distinguisher.rd_type = (
tx_es1_evisV4_1.route_distinguisher.AS_2OCTET)
tx_es1_evisV4_1.route_distinguisher.AS_2OCTET
)
tx_es1_evisV4_1.route_distinguisher.rd_value = "100:1"

export_rt = tx_es1_evisV4_1.route_target_export.routetarget()[-1]
Expand All @@ -90,14 +93,14 @@ def test_bgp_evpn(api, utils):
import_rt.rt_value = "100:20"

# Adding 1 Broadcast Domain per EVI
tx_es1_evisV4_1_bd_1 = (tx_es1_evisV4_1
.broadcast_domains
.broadcastdomain()[-1])
tx_es1_evisV4_1_bd_1 = tx_es1_evisV4_1.broadcast_domains.broadcastdomain()[
-1
]

# Adding 1 MAC Range Per Broadcast Domain
tx_es1_evisV4_1_bd_1_mac_Pool1 = (tx_es1_evisV4_1_bd_1
.cmac_ip_range
.cmaciprange(l2vni=20)[-1])
tx_es1_evisV4_1_bd_1_mac_Pool1 = (
tx_es1_evisV4_1_bd_1.cmac_ip_range.cmaciprange(l2vni=20)[-1]
)

tx_es1_evisV4_1_bd_1_mac_Pool1.name = "tx_mac_pool"
tx_es1_evisV4_1_bd_1_mac_Pool1.mac_addresses.address = "10:11:22:33:44:55"
Expand All @@ -106,15 +109,15 @@ def test_bgp_evpn(api, utils):
tx_es1_evisV4_1_bd_1_mac_Pool1.ipv4_addresses.address = "192.168.0.1"

# Create BGP EVPN on rx
rx_vtep = config.devices.device(name='rx_vtep')[-1]
rx_vtep = config.devices.device(name="rx_vtep")[-1]
rx_vtep_bgp = rx_vtep.bgp
rx_vtep_bgp.router_id = "191.0.0.1"
rx_vtep_bgp_iface = (rx_vtep_bgp.ipv4_interfaces
.v4interface(ipv4_name=rx_l1.name)[-1])
rx_vtep_bgp_peer = rx_vtep_bgp_iface.peers.v4peer(name="bgp2",
peer_address='1.1.1.1',
as_type='ibgp',
as_number=101)[-1]
rx_vtep_bgp_iface = rx_vtep_bgp.ipv4_interfaces.v4interface(
ipv4_name=rx_l1.name
)[-1]
rx_vtep_bgp_peer = rx_vtep_bgp_iface.peers.v4peer(
name="bgp2", peer_address="1.1.1.1", as_type="ibgp", as_number=101
)[-1]

# Adding 1 Ethernet Segment per Bgp Peer
rx_vtep_es1 = rx_vtep_bgp_peer.evpn_ethernet_segments.ethernetsegment()[-1]
Expand All @@ -123,7 +126,8 @@ def test_bgp_evpn(api, utils):
rx_es1_evisV4_1 = rx_vtep_es1.evis.evi_vxlan()[-1]

rx_es1_evisV4_1.route_distinguisher.rd_type = (
rx_es1_evisV4_1.route_distinguisher.AS_2OCTET)
rx_es1_evisV4_1.route_distinguisher.AS_2OCTET
)
rx_es1_evisV4_1.route_distinguisher.rd_value = "1000:1"

export_rt = rx_es1_evisV4_1.route_target_export.routetarget()[-1]
Expand All @@ -135,14 +139,14 @@ def test_bgp_evpn(api, utils):
import_rt.rt_value = "100:20"

# Adding 1 Broadcast Domain per EVI
rx_es1_evisV4_1_bd_1 = (rx_es1_evisV4_1
.broadcast_domains
.broadcastdomain()[-1])
rx_es1_evisV4_1_bd_1 = rx_es1_evisV4_1.broadcast_domains.broadcastdomain()[
-1
]

# Adding 1 MAC Range Per Broadcast Domain
rx_es1_evisV4_1_bd_1_mac_Pool1 = (rx_es1_evisV4_1_bd_1
.cmac_ip_range
.cmaciprange(l2vni=20)[-1])
rx_es1_evisV4_1_bd_1_mac_Pool1 = (
rx_es1_evisV4_1_bd_1.cmac_ip_range.cmaciprange(l2vni=20)[-1]
)
rx_es1_evisV4_1_bd_1_mac_Pool1.name = "rx_mac_pool"
rx_es1_evisV4_1_bd_1_mac_Pool1.mac_addresses.address = "10:11:22:33:44:77"

Expand Down Expand Up @@ -177,4 +181,4 @@ def results_ok(api, flow_names, expected):
request.flow.flow_names = flow_names
flow_results = api.get_metrics(request).flow_metrics
flow_rx = sum([f.frames_rx for f in flow_results])
return flow_rx == expected
return flow_rx == expected
Loading

0 comments on commit 5be7c59

Please sign in to comment.