Skip to content

Commit

Permalink
check p4 flow table for test case verification
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyzhai committed Nov 14, 2024
1 parent 36b6424 commit da6f216
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
25 changes: 25 additions & 0 deletions test/test-cases/functional/ptf/p4_dash_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,28 @@ def tearDown(self, *args, **kwargs):
setattr(cls, "tearDown", tearDown)
return cls


class P4Table():
def __init__(self):
channel = grpc.insecure_channel('localhost:9559')
self.stub = p4runtime_pb2_grpc.P4RuntimeStub(channel)

def read(self, table_id):
entry = p4runtime_pb2.TableEntry()
entry.table_id = table_id

req = p4runtime_pb2.ReadRequest()
req.device_id = 0
entity = req.entities.add()
entity.table_entry.CopyFrom(entry)
for response in self.stub.Read(req):
for entity in response.entities:
yield entity.table_entry

def print_flow_table(self):
p4info = P4info(self.stub)
p4info_flow_entry = p4info.get_table("dash_ingress.conntrack_lookup_stage.flow_entry")

for entry in self.read(p4info_flow_entry.preamble.id):
print(entry)

4 changes: 3 additions & 1 deletion test/test-cases/functional/ptf/saidashdpapp_sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ def trafficUdpTest(self):
send_packet(self, 0, vxlan_pkt)
print("\tVerifying packet in dpapp port...")
verify_packet(self, self.pkt_exp, 0)
P4Table().print_flow_table()
print ("SaiThriftDpappUdpPktTest OK")

def trafficTcpTest(self):
Expand Down Expand Up @@ -238,10 +239,11 @@ def trafficTcpTest(self):
inner_frame=inner_exp_pkt)

self.pkt_exp = vxlan_exp_pkt
print("\tSending outbound packet...")
print("\tSending outbound packet TCP SYN ...")
send_packet(self, 0, vxlan_pkt)
print("\tVerifying packet in dpapp port...")
verify_packet(self, self.pkt_exp, 0)
P4Table().print_flow_table()

# customer packet: tcp FIN
inner_pkt = simple_tcp_packet(eth_dst="02:02:02:02:02:02",
Expand Down

0 comments on commit da6f216

Please sign in to comment.