Skip to content

Commit 4c15770

Browse files
MDBF-1124 - Extend MTRTest _save_logs()
[1] compress core files generated by mtr [2] save mariadbd binary if core files were generated [3] save plugins .so files if core files were generated Note on [1]: By doing exec false, find will return non-0 on there being matches and then tar can save the plugins, de-referencing the list of symlinks make by mtr.
1 parent 059f607 commit 4c15770

1 file changed

Lines changed: 27 additions & 5 deletions

File tree

  • configuration/steps/commands

configuration/steps/commands/mtr.py

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,33 @@ def _save_logs(self) -> str:
7070
logs = ["*.log", "*.err*", "core*"]
7171
patterns = " -o ".join([f'-iname "{log}"' for log in logs])
7272
return f"""
73-
echo "Saving MTR logs to persistent volume because some tests failed"
74-
cd {self.log_path}
75-
mkdir -p {self.save_logs_path}
76-
find . -type f \( {patterns} \) -print0 | rsync -a --files-from=- --from0 ./ {self.save_logs_path}/
77-
exit 1
73+
#!/bin/bash
74+
75+
script_dir=$(pwd) # Path where the test runner was invoked
76+
mariadbd_path="$script_dir/../sql/mariadbd"
77+
vardir="${self.log_path}"
78+
save_logs_path="{self.save_logs_path}"
79+
save_bin_path=$(dirname "$save_logs_path")
80+
file_patterns_to_save="{patterns}"
81+
82+
echo "Saving MTR logs"
83+
84+
# Staging path before files are moved to CI
85+
mkdir -p $save_logs_path
86+
87+
# Some core files are left uncompressed by MTR
88+
find $vardir -iregex ".*/core\(\.[0-9]+\)" -ls -exec gzip {{}} + -exec false {{}} +
89+
status=$?
90+
91+
# Save plugins .so and mariadbd if core was generated
92+
if [[ $status -ne 0 ]]; then
93+
tar -czvf "$save_bin_path/plugins.tar.gz" --dereference -C $vardir plugins
94+
gzip -c "$mariadbd_path" > "$save_bin_path/mariadbd.gz"
95+
fi
96+
97+
# Copy pattern matching files to staging
98+
cd "$vardir" && find . -type f \( $file_patterns_to_save \) -print0 | rsync -a --from0 --files-from=- ./ "$save_logs_path/"
99+
exit 1 # Script was invoked by an MTR failure so we must mark the step as failed
78100
"""
79101

80102

0 commit comments

Comments
 (0)