Skip to content

Commit

Permalink
Compress pcap file before copying it from pft to sonic-mgmt (#11391)
Browse files Browse the repository at this point in the history
Before change, it took about 15 minutes to copy a 400M pcap file from ptf to sonic-mgmt.
After change, the 400M pcap file can be compressed to 4M, and the copy takes 2 seconds.
  • Loading branch information
weiguo-nvidia authored and mssonicbld committed Feb 15, 2024
1 parent a4c83a8 commit 61c3eef
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tests/ptf_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ def ptf_collect(host, log_file):
pcap_file = filename_prefix + '.pcap'
output = host.shell("[ -f {} ] && echo exist || echo null".format(pcap_file))['stdout']
if output == 'exist':
filename_pcap = './logs/ptf_collect/' + rename_prefix + '.' + suffix + '.pcap'
host.fetch(src=pcap_file, dest=filename_pcap, flat=True, fail_on_missing=False)
# Compress the file
compressed_pcap_file = pcap_file + '.tar.gz'
host.archive(path=pcap_file, dest=compressed_pcap_file, format='gz')
# Copy compressed file from ptf to sonic-mgmt
filename_pcap = './logs/ptf_collect/' + rename_prefix + '.' + suffix + '.pcap.tar.gz'
host.fetch(src=compressed_pcap_file, dest=filename_pcap, flat=True, fail_on_missing=False)
allure.attach.file(filename_pcap, 'ptf_pcap: ' + filename_pcap, allure.attachment_type.PCAP)


Expand Down

0 comments on commit 61c3eef

Please sign in to comment.