Skip to content

Commit

Permalink
Merge pull request #35 from open-traffic-generator/capture_changes
Browse files Browse the repository at this point in the history
Issue522: Capture is failing in tests in 9.20
  • Loading branch information
ASHNA-AGGARWAL-KEYSIGHT authored Apr 25, 2022
2 parents d51ed2d + d5b30e6 commit 2a4d6c6
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion do.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def get_version():
version_info = re.findall(r"version: (.+)", out)
if version_info:
version_info = version_info[0]
with open("version.txt", "w+") as f:
f.close()
if version_info:
new_data = []
with open("requirements.txt") as f:
Expand All @@ -54,7 +56,6 @@ def get_version():
f.writelines(new_data)
elif workflow_id:
print(workflow_id)
open("version.txt", "w+")


def lint():
Expand Down
2 changes: 1 addition & 1 deletion scripts/hello_snappi.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def captures_ok(api, cfg):
req = api.capture_request()
req.port_name = p.name
# fetch captured pcap bytes and feed it to pcap parser dpkt
pcap = dpkt.pcap.Reader(api.get_capture(req))
pcap = dpkt.pcapng.Reader(api.get_capture(req))
for _, buf in pcap:
# check if current packet is a valid UDP packet
eth = dpkt.ethernet.Ethernet(buf)
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def b2b_raw_config(api):

cap = config.captures.capture(name="c1")[-1]
cap.port_names = [rx.name]
cap.format = cap.PCAP
cap.format = cap.PCAPNG

return config

Expand Down
2 changes: 1 addition & 1 deletion tests/ip/test_ip_v4v6_device_raw_capture.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_ip_v4v6_device_and_raw_capture(api, utils):

cap = config.captures.capture(name="c1")[-1]
cap.port_names = [rx.name]
cap.format = cap.PCAP
cap.format = cap.PCAPNG

# Device configuration
tx_dev, rx_dev = config.devices.device().device()
Expand Down
4 changes: 2 additions & 2 deletions tests/raw/test_basic_flow_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_basic_flow_stats(settings):
# configure capture
cap = config.captures.capture(name="cap")[-1]
cap.port_names = [rx.name]
cap.format = cap.PCAP
cap.format = cap.PCAPNG
# configure flow properties
flw = config.flows.flow(name="flw")[-1]
# flow endpoints
Expand Down Expand Up @@ -67,5 +67,5 @@ def test_basic_flow_stats(settings):
cr.port_name = rx.name
pcap_bytes = api.get_capture(cr)
# generate pcap in pwd
with open("out.pcap", "wb") as out:
with open("out.pcapng", "wb") as out:
out.write(pcap_bytes.read())
2 changes: 1 addition & 1 deletion tests/utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def get_all_captures(api, cfg):
pcap_bytes = api.get_capture(request)

cap_dict[name] = []
for ts, pkt in dpkt.pcap.Reader(pcap_bytes):
for ts, pkt in dpkt.pcapng.Reader(pcap_bytes):
if sys.version_info[0] == 2:
cap_dict[name].append([ord(b) for b in pkt])
else:
Expand Down

0 comments on commit 2a4d6c6

Please sign in to comment.