Skip to content

Commit 5f86536

Browse files
Compress pcap file before copying it from pft to sonic-mgmt (sonic-net#11391)
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.
1 parent 04d9d58 commit 5f86536

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tests/ptf_runner.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@ def ptf_collect(host, log_file):
2121
pcap_file = filename_prefix + '.pcap'
2222
output = host.shell("[ -f {} ] && echo exist || echo null".format(pcap_file))['stdout']
2323
if output == 'exist':
24-
filename_pcap = './logs/ptf_collect/' + rename_prefix + '.' + suffix + '.pcap'
25-
host.fetch(src=pcap_file, dest=filename_pcap, flat=True, fail_on_missing=False)
24+
# Compress the file
25+
compressed_pcap_file = pcap_file + '.tar.gz'
26+
host.archive(path=pcap_file, dest=compressed_pcap_file, format='gz')
27+
# Copy compressed file from ptf to sonic-mgmt
28+
filename_pcap = './logs/ptf_collect/' + rename_prefix + '.' + suffix + '.pcap.tar.gz'
29+
host.fetch(src=compressed_pcap_file, dest=filename_pcap, flat=True, fail_on_missing=False)
2630
allure.attach.file(filename_pcap, 'ptf_pcap: ' + filename_pcap, allure.attachment_type.PCAP)
2731

2832

0 commit comments

Comments
 (0)