Merge pull request #135 from Salamandar/int_to_enum

Use text instead of integers for stop_timer argument
This commit is contained in:
Alexandre Aubin 2023-01-20 14:08:49 +01:00 committed by GitHub
commit 6197e36e21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 13 deletions

View file

@ -142,7 +142,8 @@ start_timer () {
stop_timer () { stop_timer () {
# Ending the timer # Ending the timer
# $1 = Type of querying # $1 = Type of message
msg_type="${1:-}"
local finishtime=$(date +%s) local finishtime=$(date +%s)
# Calculate the gap between the starting and the ending of the timer # Calculate the gap between the starting and the ending of the timer
@ -170,9 +171,9 @@ stop_timer () {
[ $seconds -gt 1 ] && pseconds="${pseconds}s" || pseconds="0s" [ $seconds -gt 1 ] && pseconds="${pseconds}s" || pseconds="0s"
local time="${phours}${pminutes}${pseconds} ($(date '+%T'))" local time="${phours}${pminutes}${pseconds} ($(date '+%T'))"
if [ $1 -eq 2 ]; then if [ "$msg_type" = "one_test" ]; then
log_info "Working time for this test: $time" log_info "Working time for this test: $time"
elif [ $1 -eq 3 ]; then elif [ "$msg_type" = "all_tests" ]; then
log_info "Global working time for all tests: $time" log_info "Global working time for all tests: $time"
else else
log_debug "Working time: $time" log_debug "Working time: $time"

View file

@ -25,7 +25,7 @@ LXC_CREATE () {
else else
log_critical "Can't find base image $LXC_BASE, run ./package_check.sh --rebuild" log_critical "Can't find base image $LXC_BASE, run ./package_check.sh --rebuild"
fi fi
pipestatus="${PIPESTATUS[0]}" pipestatus="${PIPESTATUS[0]}"
location=$(lxc list --format json | jq -e --arg LXC_NAME $LXC_NAME '.[] | select(.name==$LXC_NAME) | .location' | tr -d '"') location=$(lxc list --format json | jq -e --arg LXC_NAME $LXC_NAME '.[] | select(.name==$LXC_NAME) | .location' | tr -d '"')
[[ "$location" != "none" ]] && log_info "... on $location" [[ "$location" != "none" ]] && log_info "... on $location"
@ -57,7 +57,7 @@ CREATE_LXC_SNAPSHOT () {
# Remove swap files to avoid killing the CI with huge snapshots. # Remove swap files to avoid killing the CI with huge snapshots.
CLEAN_SWAPFILES CLEAN_SWAPFILES
LXC_STOP $LXC_NAME LXC_STOP $LXC_NAME
# Check if the snapshot already exist # Check if the snapshot already exist
@ -69,7 +69,7 @@ CREATE_LXC_SNAPSHOT () {
_LXC_START_AND_WAIT $LXC_NAME _LXC_START_AND_WAIT $LXC_NAME
stop_timer 1 stop_timer
} }
LOAD_LXC_SNAPSHOT () { LOAD_LXC_SNAPSHOT () {
@ -104,7 +104,7 @@ LXC_EXEC () {
log_debug "Return code: $returncode" log_debug "Return code: $returncode"
stop_timer 1 stop_timer
# Return the exit code of the ssh command # Return the exit code of the ssh command
return $returncode return $returncode
} }
@ -127,14 +127,14 @@ LXC_RESET () {
if lxc info $LXC_NAME >/dev/null 2>/dev/null; then if lxc info $LXC_NAME >/dev/null 2>/dev/null; then
# Remove swap files before deletting the continer # Remove swap files before deletting the continer
CLEAN_SWAPFILES CLEAN_SWAPFILES
fi fi
LXC_STOP $LXC_NAME LXC_STOP $LXC_NAME
if lxc info $LXC_NAME >/dev/null 2>/dev/null; then if lxc info $LXC_NAME >/dev/null 2>/dev/null; then
local current_storage=$(lxc list $LXC_NAME --format json --columns b | jq '.[].expanded_devices.root.pool') local current_storage=$(lxc list $LXC_NAME --format json --columns b | jq '.[].expanded_devices.root.pool')
swapoff "$(lxc storage get $current_storage source)/containers/$LXC_NAME/rootfs/swap" 2>/dev/null swapoff "$(lxc storage get $current_storage source)/containers/$LXC_NAME/rootfs/swap" 2>/dev/null
fi fi
lxc delete $LXC_NAME --force 2>/dev/null lxc delete $LXC_NAME --force 2>/dev/null
} }
@ -220,4 +220,3 @@ CLEAN_SWAPFILES() {
RUN_INSIDE_LXC() { RUN_INSIDE_LXC() {
lxc exec $LXC_NAME -- "$@" lxc exec $LXC_NAME -- "$@"
} }

View file

@ -90,7 +90,7 @@ run_all_tests() {
# Restore the started time for the timer # Restore the started time for the timer
starttime=$complete_start_timer starttime=$complete_start_timer
# End the timer for the test # End the timer for the test
stop_timer 3 stop_timer all_tests
echo "You can find the complete log of these tests in $(realpath $complete_log)" echo "You can find the complete log of these tests in $(realpath $complete_log)"
@ -151,7 +151,7 @@ TEST_LAUNCHER () {
# Restore the started time for the timer # Restore the started time for the timer
starttime=$global_start_timer starttime=$global_start_timer
# End the timer for the test # End the timer for the test
stop_timer 2 stop_timer one_test
LXC_STOP $LXC_NAME LXC_STOP $LXC_NAME
@ -256,4 +256,3 @@ path_to_install_type() {
[ "$check_path" == "/" ] && { echo "root"; return; } [ "$check_path" == "/" ] && { echo "root"; return; }
echo "subdir" echo "subdir"
} }