Moar fiksize

This commit is contained in:
Alexandre Aubin 2020-12-12 01:38:05 +01:00
parent 925f6cdbe8
commit aac6226d4f
5 changed files with 42 additions and 44 deletions

View file

@ -290,7 +290,7 @@ COMPUTE_RESULTS_SUMMARY () {
echo -e "\n\n" echo -e "\n\n"
print_result "Package linter" $RESULT_linter print_result "Package linter" $RESULT_linter
print_result "Install (root)" $RESULT_check_root print_result "Install (root)" $RESULT_check_root
print_result "Install (subpath)" $RESULT_check_sub_dir print_result "Install (subpath)" $RESULT_check_subdir
print_result "Install (no url)" $RESULT_check_nourl print_result "Install (no url)" $RESULT_check_nourl
print_result "Install (private mode)" $RESULT_check_private print_result "Install (private mode)" $RESULT_check_private
print_result "Install (public mode)" $RESULT_check_public print_result "Install (public mode)" $RESULT_check_public
@ -325,14 +325,14 @@ COMPUTE_RESULTS_SUMMARY () {
test -n "${level[10]}" || level[10]=0 test -n "${level[10]}" || level[10]=0
pass_level_1() { pass_level_1() {
# -> The package can be install and remove. # FIXME FIXME #FIXME
[ $RESULT_global_setup -eq 1 ] && \ return 0
} }
pass_level_2() { pass_level_2() {
# -> The package can be install and remove in all tested configurations. # -> The package can be install and remove in all tested configurations.
# Validated if none install failed # Validated if none install failed
[ $RESULT_check_sub_dir -ne -1 ] && \ [ $RESULT_check_subdir -ne -1 ] && \
[ $RESULT_check_root -ne -1 ] && \ [ $RESULT_check_root -ne -1 ] && \
[ $RESULT_check_private -ne -1 ] && \ [ $RESULT_check_private -ne -1 ] && \
[ $RESULT_check_public -ne -1 ] && \ [ $RESULT_check_public -ne -1 ] && \
@ -378,11 +378,7 @@ COMPUTE_RESULTS_SUMMARY () {
pass_level_7() { pass_level_7() {
# -> None errors in all tests performed # -> None errors in all tests performed
# Validated if none errors is happened. # Validated if none errors is happened.
[ $RESULT_global_setup -ne -1 ] && \ [ $RESULT_check_subdir -ne -1 ] && \
[ $RESULT_global_remove -ne -1 ] && \
[ $RESULT_check_sub_dir -ne -1 ] && \
[ $RESULT_check_remove_sub_dir -ne -1 ] && \
[ $RESULT_check_remove_root -ne -1 ] && \
[ $RESULT_check_upgrade -ne -1 ] && \ [ $RESULT_check_upgrade -ne -1 ] && \
[ $RESULT_check_private -ne -1 ] && \ [ $RESULT_check_private -ne -1 ] && \
[ $RESULT_check_public -ne -1 ] && \ [ $RESULT_check_public -ne -1 ] && \
@ -508,7 +504,7 @@ RESULT_linter_level_6=0
RESULT_linter_level_7=0 RESULT_linter_level_7=0
RESULT_linter_level_8=0 RESULT_linter_level_8=0
RESULT_linter_broken=0 RESULT_linter_broken=0
RESULT_check_sub_dir=0 RESULT_check_subdir=0
RESULT_check_root=0 RESULT_check_root=0
RESULT_check_nourl=0 RESULT_check_nourl=0
RESULT_check_upgrade=0 RESULT_check_upgrade=0
@ -572,10 +568,11 @@ parse_check_process() {
# Extract the Upgrade infos # Extract the Upgrade infos
extract_check_process_section "^;;; Upgrade options" ";; " > $TEST_CONTEXT/check_process.upgrade_options extract_check_process_section "^;;; Upgrade options" ";; " > $TEST_CONTEXT/check_process.upgrade_options
mkdir -p $TEST_CONTEXT/upgrades.d mkdir -p $TEST_CONTEXT/upgrades
local commit
for commit in $(cat $TEST_CONTEXT/check_process.upgrade_options | grep "^; commit=.*" | awk -F= '{print $2}') for commit in $(cat $TEST_CONTEXT/check_process.upgrade_options | grep "^; commit=.*" | awk -F= '{print $2}')
do do
cat $TEST_CONTEXT/check_process.upgrade_options | sed -n -e "/^;; $commit/,/^;;/ p" | grep -v "^;;" > $TEST_CONTEXT/upgrades cat $TEST_CONTEXT/check_process.upgrade_options | sed -n -e "/^;; $commit/,/^;;/ p" | grep -v "^;;" > $TEST_CONTEXT/upgrades/$commit
done done
rm $TEST_CONTEXT/check_process.upgrade_options rm $TEST_CONTEXT/check_process.upgrade_options
@ -608,15 +605,7 @@ parse_check_process() {
# Find the line for the given check option # Find the line for the given check option
local value=$(grep -m1 -o "^$1=." "$test_serie_dir/check_process.tests_infos" | awk -F= '{print $2}') local value=$(grep -m1 -o "^$1=." "$test_serie_dir/check_process.tests_infos" | awk -F= '{print $2}')
# And return this value # And return this value
if [ "${value:0:1}" = "1" ] [ "${value:0:1}" = "1" ]
then
echo 1
elif [ "${value:0:1}" = "0" ]
then
echo 0
else
echo -1
fi
} }
is_test_enabled pkg_linter && echo "PACKAGE_LINTER" >> $test_serie_dir/tests_to_perform is_test_enabled pkg_linter && echo "PACKAGE_LINTER" >> $test_serie_dir/tests_to_perform
@ -629,8 +618,8 @@ parse_check_process() {
is_test_enabled backup_restore && echo "TEST_BACKUP_RESTORE" >> $test_serie_dir/tests_to_perform is_test_enabled backup_restore && echo "TEST_BACKUP_RESTORE" >> $test_serie_dir/tests_to_perform
# Upgrades # Upgrades
grep "^upgrade=1" "$test_serie_dir/check_process.tests_infos" |
for LINE in $(grep "^upgrade=1" "$test_serie_dir/check_process.tests_infos") while IFS= read -r LINE;
do do
commit=$(echo $LINE | grep -o "from_commit=.*" | awk -F= '{print $2}') commit=$(echo $LINE | grep -o "from_commit=.*" | awk -F= '{print $2}')
[ -n "$commit" ] || commit="current" [ -n "$commit" ] || commit="current"
@ -654,8 +643,11 @@ parse_check_process() {
is_test_enabled port_already_use && echo "TEST_PORT_ALREADY_USED $check_port" >> $test_serie_dir/tests_to_perform is_test_enabled port_already_use && echo "TEST_PORT_ALREADY_USED $check_port" >> $test_serie_dir/tests_to_perform
cat $test_serie_dir/tests_to_perform
done 3<<< "$(grep "^;; " "$check_process")" done 3<<< "$(grep "^;; " "$check_process")"
return 0
} }
guess_test_configuration() { guess_test_configuration() {
@ -669,6 +661,8 @@ guess_test_configuration() {
mkdir -p $test_serie_dir mkdir -p $test_serie_dir
init_results $test_serie_id init_results $test_serie_id
echo "Auto generated test serie" > $test_serie_dir/test_serie_name
test_series+="$test_serie_id " test_series+="$test_serie_id "

View file

@ -109,7 +109,7 @@ LXC_INIT () {
LXC_PURGE_SNAPSHOTS() { LXC_PURGE_SNAPSHOTS() {
LXC_STOP LXC_STOP
for SNAP in $(sudo ls $LXC_SNAPSHOTS/snap_*install) for SNAP in $(sudo ls $LXC_SNAPSHOTS/snap_*install 2>/dev/null)
do do
sudo lxc-snapshot -n $LXC_NAME -d $(basename $SNAP) sudo lxc-snapshot -n $LXC_NAME -d $(basename $SNAP)
done done
@ -247,11 +247,13 @@ LXC_START () {
rsync -rq --delete "$package_path" "$LXC_NAME": >> "$complete_log" 2>&1 rsync -rq --delete "$package_path" "$LXC_NAME": >> "$complete_log" 2>&1
# Execute the command given in argument in the container and log its results. # Execute the command given in argument in the container and log its results.
ssh $arg_ssh $LXC_NAME "$cmd; exit $?" | tee -a "$complete_log" ssh $arg_ssh $LXC_NAME "$cmd" | tee -a "$complete_log"
# Store the return code of the command # Store the return code of the command
local returncode=${PIPESTATUS[0]} local returncode=${PIPESTATUS[0]}
log_debug "Return code: $return_code"
stop_timer 1 stop_timer 1
# Return the exit code of the ssh command # Return the exit code of the ssh command
return $returncode return $returncode

View file

@ -20,7 +20,7 @@ LXC_BUILD()
touch "$lock_file" touch "$lock_file"
echo $(whoami) > "./.setup_user" echo $(whoami) > "./.setup_user"
log_title "Installing dependencies..." log_title "Installing host dependencies..."
DEPENDENCIES="lxc lxctl git curl lynx jq python3-pip debootstrap rsync bridge-utils" DEPENDENCIES="lxc lxctl git curl lynx jq python3-pip debootstrap rsync bridge-utils"
sudo apt-get update sudo apt-get update
@ -128,7 +128,7 @@ EOF
fi fi
done done
log_title "Update et install aptitude sudo git" log_title "Installing container dependencies"
RUN_INSIDE_LXC apt-get update RUN_INSIDE_LXC apt-get update
RUN_INSIDE_LXC apt-get install -y sudo git ssh openssh-server RUN_INSIDE_LXC apt-get install -y sudo git ssh openssh-server

View file

@ -28,7 +28,7 @@ sudo rm -f /etc/network/interfaces.d/$LXC_BRIDGE
log_title "Suppression de la machine et de son snapshots" log_title "Suppression de la machine et de son snapshots"
sudo lxc-snapshot -n $LXC_NAME -d snap0 sudo lxc-snapshot -n $LXC_NAME -d snap0
for SNAP in $(sudo ls $LXC_SNAPSHOTS/snap_*install) for SNAP in $(sudo ls $LXC_SNAPSHOTS/snap_*install 2>/dev/null)
do do
sudo lxc-snapshot -n $LXC_NAME -d $(basename $SNAP) sudo lxc-snapshot -n $LXC_NAME -d $(basename $SNAP)
done done

View file

@ -17,7 +17,7 @@ break_before_continue () {
start_test () { start_test () {
total_number_of_test=$(grep -c "=1$" $test_serie_dir/tests_to_perform) total_number_of_test=$(cat $test_serie_dir/tests_to_perform | wc -l)
log_title "$1 [Test $current_test_number/$total_number_of_test]" log_title "$1 [Test $current_test_number/$total_number_of_test]"
@ -57,7 +57,7 @@ GET_RESULT() {
at_least_one_install_succeeded () { at_least_one_install_succeeded () {
[ "$(GET_RESULT check_sub_dir)" -eq 1 ] \ [ "$(GET_RESULT check_subdir)" -eq 1 ] \
|| [ "$(GET_RESULT check_root)" -eq 1 ] \ || [ "$(GET_RESULT check_root)" -eq 1 ] \
|| [ "$(GET_RESULT check_nourl)" -eq 1 ] \ || [ "$(GET_RESULT check_nourl)" -eq 1 ] \
|| { log_error "All installs failed, therefore the following tests cannot be performed..."; || { log_error "All installs failed, therefore the following tests cannot be performed...";
@ -67,12 +67,12 @@ at_least_one_install_succeeded () {
this_is_a_web_app () { this_is_a_web_app () {
# Usually the fact that we test "nourl" # Usually the fact that we test "nourl"
# installs should be a good indicator for this # installs should be a good indicator for this
grep "TEST_INSTALL nourl" $test_serie_dir/tests_to_perform && return 1 grep -q "TEST_INSTALL nourl" $test_serie_dir/tests_to_perform && return 1
} }
default_install_path() { default_install_path() {
this_is_a_web_app && echo "" this_is_a_web_app && echo "" \
|| [ "$(GET_RESULT check_sub_dir)" -eq 1 ] && echo "/path " || [ "$(GET_RESULT check_subdir)" -eq 1 ] && echo "/path " \
|| echo "/" || echo "/"
} }
@ -86,7 +86,7 @@ INSTALL_APP () {
# We have default values for domain, user and is_public, but these # We have default values for domain, user and is_public, but these
# may still be overwritten by the args ($@) # may still be overwritten by the args ($@)
for arg_override in "domain=$SUBDOMAIN" "user=$TEST_USER" "is_public=1" "$@" for arg_override in "domain=$SUBDOMAIN" "admin=$TEST_USER" "user=$TEST_USER" "is_public=1" "$@"
do do
key="$(echo $arg_override | cut -d '=' -f 1)" key="$(echo $arg_override | cut -d '=' -f 1)"
value="$(echo $arg_override | cut -d '=' -f 2-)" value="$(echo $arg_override | cut -d '=' -f 2-)"
@ -95,7 +95,7 @@ INSTALL_APP () {
# Exec the pre-install instruction, if there one # Exec the pre-install instruction, if there one
preinstall_script_template="$test_serie_dir/preinstall.sh.template" preinstall_script_template="$test_serie_dir/preinstall.sh.template"
if [ -n "$(cat $preinstall_script_template)" ] if [ -e "$preinstall_script_template" ] && [ -n "$(cat $preinstall_script_template)" ]
then then
log_small_title "Pre installation request" log_small_title "Pre installation request"
# Start the lxc container # Start the lxc container
@ -346,8 +346,8 @@ TEST_INSTALL () {
# Remove and reinstall the application # Remove and reinstall the application
[ $install -eq 0 ] \ [ $install -eq 0 ] \
&& log_small_title "Remove and reinstall the application after a removal." \
&& REMOVE_APP \ && REMOVE_APP \
&& log_small_title "Reinstalling after removal." \
&& INSTALL_APP "path=$check_path" \ && INSTALL_APP "path=$check_path" \
&& VALIDATE_THAT_APP_CAN_BE_ACCESSED $SUBDOMAIN $check_path && VALIDATE_THAT_APP_CAN_BE_ACCESSED $SUBDOMAIN $check_path
@ -362,6 +362,8 @@ TEST_INSTALL () {
TEST_UPGRADE () { TEST_UPGRADE () {
local commit=$1
if [ "$commit" == "current" ] if [ "$commit" == "current" ]
then then
start_test "Upgrade from the same version" start_test "Upgrade from the same version"
@ -464,7 +466,7 @@ TEST_PUBLIC_PRIVATE () {
elif [ $i -eq 1 ] elif [ $i -eq 1 ]
then then
# Check if sub path installation worked, or if force_install_ok is setted. # Check if sub path installation worked, or if force_install_ok is setted.
[ $(GET_RESULT check_sub_dir) -eq 1 ] || { log_warning "Sub path install failed, therefore this test cannot be performed..."; continue; } [ $(GET_RESULT check_subdir) -eq 1 ] || { log_warning "Sub path install failed, therefore this test cannot be performed..."; continue; }
local check_path=/path local check_path=/path
fi fi
@ -723,7 +725,7 @@ TEST_CHANGE_URL () {
|| { log_warning "Root install failed, therefore this test cannot be performed..."; continue; } || { log_warning "Root install failed, therefore this test cannot be performed..."; continue; }
# If any of the being/end path is not /, we need to have sub_dir install working # If any of the being/end path is not /, we need to have sub_dir install working
( [ "$new_path" == "/" ] && [ "$new_path" == "/" ] ) || [ $(GET_RESULT check_sub_dir) -eq 1 ] \ ( [ "$new_path" == "/" ] && [ "$new_path" == "/" ] ) || [ $(GET_RESULT check_subdir) -eq 1 ] \
|| { log_warning "Subpath install failed, therefore this test cannot be performed..."; continue; } || { log_warning "Subpath install failed, therefore this test cannot be performed..."; continue; }
# Install the application in a LXC container # Install the application in a LXC container
@ -1227,13 +1229,13 @@ RUN_TEST_SERIE() {
# Init the value for the current test # Init the value for the current test
current_test_number=1 current_test_number=1
# The list of test contains for example "TEST_UPGRADE some_commit_id" # The list of test contains for example "TEST_UPGRADE some_commit_id
for test in $test_serie_dir/tests_to_perform readarray -t tests < $test_serie_dir/tests_to_perform
for test in "${tests[@]}";
do do
TEST_LAUNCHER $test TEST_LAUNCHER $test
done done
} }
TEST_LAUNCHER () { TEST_LAUNCHER () {