-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BK: Make logs less noisy and add timestamps (#2317)
- Add timestamps to acceptance test output to better understand their performance. - Better log collection on CI
- Loading branch information
Showing
7 changed files
with
63 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,21 @@ | ||
#!/bin/bash | ||
|
||
$BASE/scripts/clean_env | ||
echo "Running: ${1:?}" | ||
. $BASE/steps/common.sh | ||
|
||
# Pull CI image and start it | ||
$BASE/scripts/registry_login | ||
docker pull $SCION_IMG &>/dev/null | ||
mkdir -p $SCION_MOUNT | ||
./docker.sh start | ||
log "Prepare environment: Start" | ||
prepare | ||
log "Prepare environment: Done" | ||
|
||
# Start runner container | ||
./docker.sh start &>> "$STEP_LOG" | ||
|
||
# Run test | ||
log "Running: ${1:?}" | ||
./tools/ci/"$@" | ||
res=$? | ||
|
||
# Pack logs and stop everything | ||
$BASE/scripts/pack_logs | ||
res=$((res+$?)) | ||
./docker.sh stop | ||
res=$((res+$?)) | ||
$BASE/scripts/clean_env | ||
log "Cleanup environment: Start" | ||
cleanup | ||
res=$((res+$?)) | ||
rm -r $SCION_MOUNT | ||
log "Cleanup environment: Done" | ||
exit $res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
log() { | ||
echo "$(date -u +"%F %T.%6N%z") $@" | ||
} | ||
|
||
prepare() { | ||
mkdir -p "artifacts.out" | ||
$BASE/scripts/clean_env &>> "$STEP_LOG" | ||
$BASE/scripts/registry_login &>> "$STEP_LOG" | ||
docker pull $SCION_IMG &>/dev/null | ||
mkdir -p $SCION_MOUNT | ||
} | ||
|
||
cleanup() { | ||
$BASE/scripts/pack_logs &>> "$STEP_LOG" | ||
local res=$? | ||
./docker.sh stop &>> "$STEP_LOG" | ||
res=$((res+$?)) | ||
$BASE/scripts/clean_env &>> "$STEP_LOG" | ||
res=$((res+$?)) | ||
rm -r $SCION_MOUNT | ||
return $res | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,43 @@ | ||
#!/bin/bash | ||
|
||
. $BASE/steps/common.sh | ||
|
||
run_wrapper() { | ||
PHASE=${1:?} | ||
shift | ||
if $@; then | ||
echo "$PHASE successful" | ||
log "Start $PHASE" | ||
"$@" &>> "$STEP_LOG" | ||
if [ $? -eq 0 ]; then | ||
log "$PHASE successful" | ||
return 0 | ||
else | ||
echo "$PHASE failed" | ||
log "$PHASE failed" | ||
return 1 | ||
fi | ||
} | ||
|
||
$BASE/scripts/clean_env | ||
echo "Running: ${1:?}" | ||
log "Prepare environment: Start" | ||
prepare | ||
log "Prepare environment: Done" | ||
|
||
# Pull CI image and start it | ||
docker pull $SCION_IMG &>/dev/null | ||
mkdir -p $SCION_MOUNT | ||
# Start runner container | ||
mkdir -p $ACCEPTANCE_ARTIFACTS | ||
./docker.sh start | ||
./docker.sh start &>> "$STEP_LOG" | ||
|
||
# Run test | ||
run_wrapper "SETUP" "$1/test setup &>> $ACCEPTANCE_ARTIFACTS/setup.out" | ||
log "Starting ${1:?}" | ||
run_wrapper SETUP $1/test setup | ||
res=$? | ||
run_wrapper "RUN" "./docker.sh exec $1/test run &>> \$ACCEPTANCE_ARTIFACTS/run.out" | ||
run_wrapper RUN ./docker.sh exec $1/test run '&>>' \$ACCEPTANCE_ARTIFACTS/run.out | ||
res=$((res+$?)) | ||
run_wrapper "TEARDOWN" "$1/test teardown &>> $ACCEPTANCE_ARTIFACTS/teardown.out" | ||
run_wrapper TEARDOWN $1/test teardown | ||
res=$((res+$?)) | ||
log "Finished: $1" | ||
|
||
# Pack logs and stop everything | ||
log "Cleanup environment: Start" | ||
cp -r logs "$SCION_MOUNT" | ||
res=$((res+$?)) | ||
$BASE/scripts/pack_logs | ||
res=$((res+$?)) | ||
./docker.sh stop | ||
res=$((res+$?)) | ||
$BASE/scripts/clean_env | ||
cleanup | ||
res=$((res+$?)) | ||
rm -r $SCION_MOUNT | ||
log "Cleanup environment: Done" | ||
exit $res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters