Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: Lawrence Lee <[email protected]>
  • Loading branch information
theasianpianist committed Aug 12, 2024
1 parent 4406145 commit 907d9c8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 21 deletions.
2 changes: 1 addition & 1 deletion tests/_test_dash_crm.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def configure(self):
prefix = f"20.2.{i}.0/24"
if self.addr_family == 'ipv6':
prefix = f'2002::{i}:1011/126'
self.route_table.add(f"eni1:{prefix}", {"routing_type":"vnet", "vnet":"vnet1"})
self.route_table.add(f"eni1:{prefix}", {"action_type":"vnet", "vnet":"vnet1"})

def clear(self):
self.route_table.remove_all()
Expand Down
30 changes: 10 additions & 20 deletions tests/test_dash_vnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def test_vnet_map(self, dvs):
self.underlay_ip = "101.1.2.3"
pb = VnetMapping()
pb.mac_address = bytes.fromhex(self.mac_address.replace(":", ""))
pb.routing_type = RoutingType.ROUTING_TYPE_VNET_ENCAP
pb.action_type = RoutingType.ROUTING_TYPE_VNET_ENCAP
pb.underlay_ip.ipv4 = socket.htonl(int(ipaddress.ip_address(self.underlay_ip)))

dashobj.create_vnet_map(self.vnet, self.ip1, {"pb": pb.SerializeToString()})
Expand Down Expand Up @@ -275,34 +275,24 @@ def test_outbound_routing(self, dvs):
self.vnet = "Vnet1"
self.mac_string = "F4939FEFC47E"
self.ip = "10.1.0.0/24"
self.routing_type = "vnet_direct"
self.action_type = "vnet_direct"
self.overlay_ip= "10.0.0.6"
pb = Route()
pb.routing_type = RoutingType.ROUTING_TYPE_VNET_DIRECT
pb.vnet_direct.vnet = self.vnet
pb.vnet_direct.overlay_ip.ipv4 = socket.htonl(int(ipaddress.ip_address(self.overlay_ip)))
dashobj.create_outbound_routing(self.mac_string, self.ip, {"pb": pb.SerializeToString()})

route_prefix = "10.8.0.0/24"
pb = Route()
# action_type is deprecated in favor of routing_type. Test action_type for backward compatibility
pb.action_type = RoutingType.ROUTING_TYPE_VNET_DIRECT
pb.vnet_direct.vnet = self.vnet
pb.vnet_direct.overlay_ip.ipv4 = socket.htonl(int(ipaddress.ip_address(self.overlay_ip)))
dashobj.create_outbound_routing(self.mac_string, route_prefix, {"pb": pb.SerializeToString()})
dashobj.create_outbound_routing(self.mac_string, self.ip, {"pb": pb.SerializeToString()})
time.sleep(3)

outbound_routing_entries = dashobj.asic_outbound_routing_table.get_keys()
assert outbound_routing_entries
for entry in outbound_routing_entries:
fvs = dashobj.asic_outbound_routing_table[entry]
for fv in fvs.items():
if fv[0] == "SAI_OUTBOUND_ROUTING_ENTRY_ATTR_ACTION":
assert fv[1] == "SAI_OUTBOUND_ROUTING_ENTRY_ACTION_ROUTE_VNET_DIRECT"
if fv[0] == "SAI_OUTBOUND_ROUTING_ENTRY_ATTR_OVERLAY_IP":
assert fv[1] == "10.0.0.6"
assert "SAI_OUTBOUND_ROUTING_ENTRY_ATTR_DST_VNET_ID" in fvs

fvs = dashobj.asic_outbound_routing_table[outbound_routing_entries[0]]
for fv in fvs.items():
if fv[0] == "SAI_OUTBOUND_ROUTING_ENTRY_ATTR_ACTION":
assert fv[1] == "SAI_OUTBOUND_ROUTING_ENTRY_ACTION_ROUTE_VNET_DIRECT"
if fv[0] == "SAI_OUTBOUND_ROUTING_ENTRY_ATTR_OVERLAY_IP":
assert fv[1] == "10.0.0.6"
assert "SAI_OUTBOUND_ROUTING_ENTRY_ATTR_DST_VNET_ID" in fvs
return dashobj

def test_inbound_routing(self, dvs):
Expand Down

0 comments on commit 907d9c8

Please sign in to comment.