Skip to content

Commit

Permalink
chore(ci-regTests): print logs when regTests timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
kostasrim committed Oct 18, 2023
1 parent 2392eae commit fa9670c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
23 changes: 20 additions & 3 deletions .github/actions/regression-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ runs:
# timeout-minutes: 20
steps:
- name: Run PyTests
id: first
shell: bash
run: |
ls -l ${GITHUB_WORKSPACE}/
Expand All @@ -36,9 +37,10 @@ runs:
export DRAGONFLY_PATH="${GITHUB_WORKSPACE}/${{inputs.build-folder-name}}/${{inputs.dfly-executable}}"
export UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 # to crash on errors
pytest -m "${{inputs.filter}}" --json-report --json-report-file=report.json dragonfly --ignore=dragonfly/replication_test.py --log-cli-level=INFO
timeout 20m pytest -m "${{inputs.filter}}" --json-report --json-report-file=report.json dragonfly --ignore=dragonfly/replication_test.py --log-cli-level=INFO || code=$?; if [[ $code -eq 124 ]]; then echo "TIMEDOUT=1">> "$GITHUB_OUTPUT"; exit 1; fi
- name: Run PyTests replication test
id: second
if: ${{ inputs.run-only-on-ubuntu-latest == 'true' || (inputs.run-only-on-ubuntu-latest == 'false' && matrix.runner == 'ubuntu-latest') }}
shell: bash
run: |
Expand All @@ -47,8 +49,23 @@ runs:
# used by PyTests
export DRAGONFLY_PATH="${GITHUB_WORKSPACE}/${{inputs.build-folder-name}}/${{inputs.dfly-executable}}"
pytest -m "${{inputs.filter}}" --json-report --json-report-file=rep1_report.json dragonfly/replication_test.py --df alsologtostderr --df enable_multi_shard_sync=true
pytest -m "${{inputs.filter}}" --json-report --json-report-file=rep2_report.json dragonfly/replication_test.py --df alsologtostderr --df enable_multi_shard_sync=false
timeout 20m pytest -m "${{inputs.filter}}" --json-report --json-report-file=rep1_report.json dragonfly/replication_test.py --df alsologtostderr --df enable_multi_shard_sync=true || code=$?; if [[ $code -eq 124 ]]; then echo "TIMEDOUT=1">> "$GITHUB_OUTPUT"; exit 1; fi
timeout 20m pytest -m "${{inputs.filter}}" --json-report --json-report-file=rep2_report.json dragonfly/replication_test.py --df alsologtostderr --df enable_multi_shard_sync=false || code=$?; if [[ $code -eq 124 ]]; then echo "TIMEDOUT=1">> "$GITHUB_OUTPUT"; exit 1; fi
- name: Print last log on timeout
if: failure()
shell: bash
env:
TIMEDOUT_STEP_1: ${{ steps.first.outputs.TIMEDOUT }}
TIMEDOUT_STEP_2: ${{ steps.second.outputs.TIMEDOUT }}
run: |
if [[ "${{ env.TIMEDOUT_STEP_1 }}" -eq 1 ]] || [[ "${{ env.TIMEDOUT_STEP_2 }}" -eq 1 ]]; then
echo "🪵🪵🪵🪵🪵🪵 Latest log before timeout 🪵🪵🪵🪵🪵🪵\n\n"
${GITHUB_WORKSPACE}/tools/extract_latest_log.py --path /tmp/ | xargs cat
echo "🪵🪵🪵🪵🪵🪵 Latest log before timeout end 🪵🪵🪵🪵🪵🪵\n\n"
fi
- name: Send notification on failure
if: failure() && github.ref == 'refs/heads/main'
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/regression-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ jobs:
ls -l ..
- name: Run regression tests action
timeout-minutes: 45
uses: ./.github/actions/regression-tests
with:
dfly-executable: dragonfly
Expand Down
21 changes: 21 additions & 0 deletions tools/extract_latest_log.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env python3

"""Extract the most recent INFO log from a directory."""

import argparse
import os


def main():
parser = argparse.ArgumentParser(description="Extract the most recent INFO log in a directory.")
parser.add_argument("--path", type=str, required=True, help="Path to the logs")

args = parser.parse_args()
files = [f for f in os.listdir(args.path) if os.path.isfile(os.path.join(args.path, f))]
filtered_files = [name for name in files if ".log.INFO" in name and "dragonfly" in name]
filtered_files.sort()
print(os.path.join(args.path, filtered_files[-1]))


if __name__ == "__main__":
main()

0 comments on commit fa9670c

Please sign in to comment.