Skip to content

Commit

Permalink
test: detect error log (#1882)
Browse files Browse the repository at this point in the history
  • Loading branch information
nexustar authored May 17, 2022
1 parent f062b88 commit bdac542
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/integrate-cluster-cmd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,24 @@ jobs:
- name: Collect component log
working-directory: ${{ env.working-directory }}
if: ${{ failure() }}
# if: always()
run: |
docker exec tiup-cluster-control bash /tiup-cluster/tests/tiup-cluster/script/pull_log.sh /tiup-cluster/logs
ls ${{ env.working-directory }}
tar czvf ${{ env.working-directory }}/logs.tar.gz ${{ env.working-directory }}/logs/
- name: Detect error log
working-directory: ${{ env.working-directory }}
# if: always()
run: |
bash ./tests/tiup-cluster/script/detect_error.sh ./logs/
- name: Upload component log
if: ${{ failure() }}
# if: always()
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v3
with:
name: component_logs
path: ${{ env.working-directory }}/logs.tar.gz
path: ${{ env.working-directory }}/logs/

- name: Output cluster debug log
working-directory: ${{ env.working-directory }}
Expand Down
12 changes: 8 additions & 4 deletions .github/workflows/integrate-cluster-scale.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,24 @@ jobs:
- name: Collect component log
working-directory: ${{ env.working-directory }}
if: ${{ failure() }}
# if: always()
run: |
docker exec tiup-cluster-control bash /tiup-cluster/tests/tiup-cluster/script/pull_log.sh /tiup-cluster/logs
ls ${{ env.working-directory }}
tar czvf ${{ env.working-directory }}/logs.tar.gz ${{ env.working-directory }}/logs/
- name: Detect error log
working-directory: ${{ env.working-directory }}
# if: always()
run: |
bash ./tests/tiup-cluster/script/detect_error.sh ./logs/
- name: Upload component log
if: ${{ failure() }}
# if: always()
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v3
with:
name: cluster_logs
path: ${{ env.working-directory }}/logs.tar.gz
path: ${{ env.working-directory }}/logs/

- name: Output cluster debug log
working-directory: ${{ env.working-directory }}
Expand Down
16 changes: 16 additions & 0 deletions tests/tiup-cluster/script/detect_error.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
set -eu

err_num=$(find $1 -name "*.log" -exec grep "\[ERROR\]" {} \; | wc -l)
if [ ${err_num} != "0" ]; then
echo "detect ${err_num} [ERROR] log"
exit 1
fi

err_num=$(find $1 -name "*stderr.log" -exec cat {} \; | wc -l)
if [ ${err_num} != "0" ]; then
echo "detect ${err_num} stderr log"
exit 1
fi

echo "no error log found"

0 comments on commit bdac542

Please sign in to comment.