Skip to content

Commit a6b1506

Browse files
committed
adding data capture for tagged traffic
adding data capture for tagged traffic
1 parent 6081480 commit a6b1506

File tree

1 file changed

+33
-6
lines changed

1 file changed

+33
-6
lines changed

tests/snappi/test_vlan_traffic.py

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def skip_all(testbed_instance):
1616
if testbed is not None and len(testbed.npu) != 1:
1717
pytest.skip('invalid for {} testbed'.format(testbed.name))
1818

19-
def test_l2_untagged_vlan_traffic(npu, dataplane):
19+
def test_l2_tagged_vlan_traffic(npu, dataplane):
2020
"""
2121
Creates vlan 10 and adds two ports to the vlan 10 member
2222
and validates the config using l2 traffic
@@ -38,7 +38,7 @@ def test_l2_untagged_vlan_traffic(npu, dataplane):
3838
"SAI_VLAN_MEMBER_ATTR_BRIDGE_PORT_ID",
3939
"$BRIDGE_PORT_2",
4040
"SAI_VLAN_MEMBER_ATTR_VLAN_TAGGING_MODE",
41-
"SAI_VLAN_TAGGING_MODE_UNTAGGED",
41+
"SAI_VLAN_TAGGING_MODE_TAGGED",
4242
],
4343
},
4444
{
@@ -60,7 +60,7 @@ def test_l2_untagged_vlan_traffic(npu, dataplane):
6060
"SAI_VLAN_MEMBER_ATTR_BRIDGE_PORT_ID",
6161
"$BRIDGE_PORT_3",
6262
"SAI_VLAN_MEMBER_ATTR_VLAN_TAGGING_MODE",
63-
"SAI_VLAN_TAGGING_MODE_UNTAGGED",
63+
"SAI_VLAN_TAGGING_MODE_TAGGED",
6464
],
6565
},
6666
{
@@ -96,7 +96,7 @@ def test_l2_untagged_vlan_traffic(npu, dataplane):
9696
flow1.tx_rx.port.tx_name = config.ports[0].name
9797
flow1.tx_rx.port.rx_name = config.ports[1].name
9898
flow1.size.fixed = 1024
99-
flow1.rate.percentage = 100
99+
flow1.rate.pps = 1000
100100
flow1.metrics.enable = True
101101
flow1.metrics.loss = True
102102
source = macs[1]
@@ -114,14 +114,41 @@ def test_l2_untagged_vlan_traffic(npu, dataplane):
114114

115115
ts = dataplane.api.transmit_state()
116116
ts.flow_names = [flow1.name]
117+
print('Starting Data Traffic')
117118
ts.state = ts.START
118119
dataplane.api.set_transmit_state(ts)
119-
time.sleep(10)
120+
time.sleep(5)
120121
ts = dataplane.api.transmit_state()
121122
ts.flow_names = [flow1.name]
123+
124+
ixnet.Vport.find()[1].Capture.HardwareEnabled = True
125+
print('Starting Data Capture')
126+
ixnet.StartCapture()
127+
time.sleep(10)
128+
print('Stopping Data Capture')
129+
ixnet.StopCapture()
130+
print('Stopping Data Traffic')
122131
ts.state = ts.STOP
123132
dataplane.api.set_transmit_state(ts)
124-
time.sleep(10)
133+
time.sleep(5)
134+
135+
counter = 0
136+
while ixnet.Vport.find()[1].Capture.DataCaptureState != 'ready':
137+
time.sleep(1)
138+
if counter > 120:
139+
raise Exception('FAIL: Data Capture state not ready for Port {} after 120 Seconds')
140+
counter+=1
141+
print('Data Capture State for Rx Port : {}'.format(ixnet.Vport.find()[1].Capture.DataCaptureState))
142+
143+
print('Total Data packets captured on Rx Port: {}'.format(ixnet.Vport.find()[1].Capture.DataPacketCounter))
144+
ixnet.Vport.find()[1].Capture.CurrentPacket.GetPacketFromDataCapture(Arg2=1)
145+
packetHeaderStacks = ixnet.Vport.find()[1].Capture.CurrentPacket.Stack.find()
146+
for packetHeader in packetHeaderStacks.find()[2]:
147+
print('\nPacketHeaderName: {}'.format(packetHeader.DisplayName))
148+
for field in packetHeader.Field.find():
149+
print('\t{}: {}'.format(field.DisplayName, field.FieldValue))
150+
assert int(packetHeader.Field.find()[2].FieldValue) == 10, "Vlan ID Field is not as expected in the packet"
151+
125152
request = dataplane.api.metrics_request()
126153
request.flow.flow_names = [flow1.name]
127154
rows = dataplane.api.get_metrics(request).flow_metrics

0 commit comments

Comments
 (0)