SERVER-95930: Collect network diagnostics for failed tests (#28191)

GitOrigin-RevId: fc5c90c756d9cc21dbc4e55281bfa1d8b4a0a09b
This commit is contained in:
Tianyu Wang 2024-10-21 14:16:16 -04:00 committed by MongoDB Bot
parent fd3cf2c68e
commit 72a5a3d8a8
3 changed files with 51 additions and 0 deletions

View File

@ -86,6 +86,7 @@ post:
- func: "attach docker logs"
- func: "upload jstestfuzz minimized output"
- func: "upload clang tidy results"
- func: "generate and upload network diagnostics"
- func: "kill processes"
- func: "save code coverage data"
- func: "save local client logs"
@ -117,6 +118,7 @@ post:
system-resource-info.tgz
${report_file|src/report.json}
${archive_file|src/archive.json}
src/network_diagnostics.txt
- func: "umount shared scons directory"
- func: "umount tmp directory"
- func: "cleanup FUSE watchdog"

View File

@ -660,6 +660,34 @@ functions:
content_type: application/json
display_name: clang_tidy_fixes.json
"generate network diagnostics": &generate_network_diagnostics
command: subprocess.exec
display_name: "get network diagnostics"
params:
binary: bash
args:
- "src/evergreen/run_python_script.sh"
- "evergreen/functions/get_network_diagnostics.py"
"upload network diagnostics": &upload_network_diagnostics
command: s3.put
dipslay_name: "upload network diagnostics"
params:
aws_key: ${aws_key}
aws_secret: ${aws_secret}
local_file: src/network_diagnostics.txt
remote_file: ${project}/${version_id}/${bv_future_git_tag|version}_network_diagnostics.txt
bucket: mciuploads
permissions: public-read
content_type: text/plain
display_name: Network Diagnostics - netstat output
optional: true
"generate and upload network diagnostics":
- *f_expansions_write
- *generate_network_diagnostics
- *upload_network_diagnostics
"send benchmark results": &send_benchmark_results
command: perf.send
display_name: "send benchmark results"

View File

@ -0,0 +1,21 @@
#!/usr/bin/env python3
"""Generate network diagnostics information and generate a .txt file."""
import pathlib
import shutil
import subprocess
def generate_netstat():
if shutil.which("netstat") is None:
print('Command not found: netstat. Skipping "generate and upload network diagnostics".')
return
with open("network_diagnostics.txt", "w") as outfile:
subprocess.run(["netstat"], stdout=outfile, stderr=subprocess.STDOUT, check=True)
if not pathlib.Path("resmoke_error_code").is_file():
print('resmoke_error_code not found. Skipping "generate and upload network diagnostics".')
else:
generate_netstat()