Do not display the timer for small operations

This commit is contained in:
Alexandre Aubin 2020-11-29 20:28:23 +01:00
parent c1af081c58
commit 2772b2feaf
2 changed files with 15 additions and 13 deletions

View file

@ -123,7 +123,7 @@ use_temp_snapshot () {
# Restore this snapshot.
sudo rsync --acls --archive --delete --executability --itemize-changes --xattrs "$snapshot_path/$current_snapshot/rootfs/" "/var/lib/lxc/$lxc_name/rootfs/" > /dev/null 2>> "$test_result"
stop_timer 1
stop_timer 1 >> "$complete_log"
# Retrieve the app id in the log. To manage the app after
ynh_app_id=$(sudo tac "$yunohost_log" | grep --only-matching --max-count=1 "YNH_APP_INSTANCE_NAME=[^ ]*" | cut --delimiter='=' --fields=2)
@ -176,11 +176,11 @@ LXC_START () {
# Start the container and log the booting process in $script_dir/lxc_boot.log
# Try to start only if the container is not already started
if ! is_lxc_running; then
echo -n "Start the LXC container" | tee --append "$test_result"
echo -n "Start the LXC container" >> "$test_result"
sudo lxc-start --name=$lxc_name --daemon --logfile "$script_dir/lxc_boot.log" | tee --append "$test_result" 2>&1
local avoid_witness=0
else
echo -n "A LXC container is already running" | tee --append "$test_result"
echo -n "A LXC container is already running" >> "$test_result"
local avoid_witness=1
fi
@ -272,7 +272,7 @@ $(cat "$script_dir/sub_scripts/Build_lxc.log")"
local lxc_check_result="An error has happened with the host. Please check the configuration."
ECHO_FORMAT "$lxc_check_result\n" "red" "bold"
send_email
stop_timer 1
stop_timer 1 >> "$complete_log"
return 1
elif [ $lxc_check -eq 2 ]; then
local lxc_check_result="The container is broken, it will be rebuilt."
@ -289,7 +289,7 @@ $(cat "$script_dir/sub_scripts/Build_lxc.log")"
fi
fi
done
stop_timer 1
stop_timer 1 >> "$complete_log"
start_timer
# Count the number of lines of the current yunohost log file.
@ -323,7 +323,7 @@ $(cat "$script_dir/sub_scripts/Build_lxc.log")"
# Retrieve the log of the previous command and copy its content in the temporary log
sudo cat "/var/lib/lxc/$lxc_name/rootfs/home/pchecker/temp_yunohost-cli.log" >> "$temp_log"
stop_timer 1
stop_timer 1 >> "$complete_log"
# Return the exit code of the ssh command
return $returncode
}
@ -356,7 +356,7 @@ LXC_STOP () {
# Restore the snapshot.
echo "Restore the previous snapshot." | tee --append "$test_result"
sudo rsync --acls --archive --delete --executability --itemize-changes --xattrs "$snapshot_path/$current_snapshot/rootfs/" "/var/lib/lxc/$lxc_name/rootfs/" > /dev/null 2>> "$test_result"
stop_timer 1
stop_timer 1 >> "$complete_log"
}
LXC_TURNOFF () {

View file

@ -122,14 +122,14 @@ STANDARD_SETUP_APP () {
# Check if a snapshot already exist for a root install
if [ -z "$root_snapshot" ]
then
ECHO_FORMAT "\nCreate a snapshot for root installation.\n" "white" clog
ECHO_FORMAT "\nCreate a snapshot for root installation.\n" "white" clog >> $complete_log
create_temp_backup 2
root_snapshot=snap2
fi
fi
else
# Or uses an existing snapshot
ECHO_FORMAT "Uses an existing snapshot for root installation.\n" "white" clog
ECHO_FORMAT "Uses an existing snapshot for root installation.\n" "white" clog >> $complete_log
use_temp_snapshot $root_snapshot
fi
@ -148,14 +148,14 @@ STANDARD_SETUP_APP () {
# Check if a snapshot already exist for a subpath (or no_url) install
if [ -z "$subpath_snapshot" ]
then
ECHO_FORMAT "\nCreate a snapshot for sub path installation.\n" "white" clog
ECHO_FORMAT "\nCreate a snapshot for sub path installation.\n" "white" clog >> $complete_log
create_temp_backup 1
root_snapshot=snap1
fi
fi
else
# Or uses an existing snapshot
ECHO_FORMAT "Uses an existing snapshot for sub path installation.\n" "white" clog
ECHO_FORMAT "Uses an existing snapshot for sub path installation.\n" "white" clog >> $complete_log
use_temp_snapshot $subpath_snapshot
fi
fi
@ -444,7 +444,9 @@ unit_test_title () {
# Print a title for the test
# $1 = Name of the test
ECHO_FORMAT "\n\n>> $1 [Test $cur_test/$all_test]\n" "white" "bold" clog
ECHO_FORMAT "\n\n##########################################\n" "white" "bold" clog
ECHO_FORMAT "# >> $1 [Test $cur_test/$all_test]\n" "white" "bold" clog
ECHO_FORMAT "##########################################\n" "white" "bold" clog
# Increment the value of the current test
cur_test=$((cur_test+1))
@ -1894,7 +1896,7 @@ TEST_LAUNCHER () {
set_witness_files () {
# Create files to check if the remove script does not remove them accidentally
echo "Create witness files..." | tee --append "$test_result"
echo "Create witness files..." >> "$test_result"
lxc_dir="/var/lib/lxc/$lxc_name/rootfs"