mirror of
https://github.com/YunoHost/package_check.git
synced 2024-09-03 20:06:20 +02:00
Zblerg
This commit is contained in:
parent
6f432740cb
commit
925f6cdbe8
4 changed files with 297 additions and 388 deletions
120
package_check.sh
120
package_check.sh
|
@ -289,20 +289,17 @@ COMPUTE_RESULTS_SUMMARY () {
|
||||||
# Print the result for each test
|
# Print the result for each test
|
||||||
echo -e "\n\n"
|
echo -e "\n\n"
|
||||||
print_result "Package linter" $RESULT_linter
|
print_result "Package linter" $RESULT_linter
|
||||||
print_result "Install" $RESULT_global_setup
|
|
||||||
print_result "Remove" $RESULT_global_remove
|
|
||||||
print_result "Install (subpath)" $RESULT_check_sub_dir
|
|
||||||
print_result "Remove (subpath)" $RESULT_check_remove_sub_dir
|
|
||||||
print_result "Install (root)" $RESULT_check_root
|
print_result "Install (root)" $RESULT_check_root
|
||||||
print_result "Remove (root)" $RESULT_check_remove_root
|
print_result "Install (subpath)" $RESULT_check_sub_dir
|
||||||
print_result "Upgrade" $RESULT_check_upgrade
|
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
|
||||||
print_result "Install (multi-instance)" $RESULT_check_multi_instance
|
print_result "Install (multi-instance)" $RESULT_check_multi_instance
|
||||||
print_result "Port already used" $RESULT_check_port
|
print_result "Upgrade" $RESULT_check_upgrade
|
||||||
print_result "Backup" $RESULT_check_backup
|
print_result "Backup" $RESULT_check_backup
|
||||||
print_result "Restore" $RESULT_check_restore
|
print_result "Restore" $RESULT_check_restore
|
||||||
print_result "Change URL" $RESULT_change_url
|
print_result "Change URL" $RESULT_change_url
|
||||||
|
print_result "Port already used" $RESULT_check_port
|
||||||
print_result "Actions and config-panel" $RESULT_action_config_panel
|
print_result "Actions and config-panel" $RESULT_action_config_panel
|
||||||
|
|
||||||
# Determine the level for this app
|
# Determine the level for this app
|
||||||
|
@ -330,16 +327,13 @@ COMPUTE_RESULTS_SUMMARY () {
|
||||||
pass_level_1() {
|
pass_level_1() {
|
||||||
# -> The package can be install and remove.
|
# -> The package can be install and remove.
|
||||||
[ $RESULT_global_setup -eq 1 ] && \
|
[ $RESULT_global_setup -eq 1 ] && \
|
||||||
[ $RESULT_global_remove -eq 1 ]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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_sub_dir -ne -1 ] && \
|
||||||
[ $RESULT_check_remove_sub_dir -ne -1 ] && \
|
|
||||||
[ $RESULT_check_root -ne -1 ] && \
|
[ $RESULT_check_root -ne -1 ] && \
|
||||||
[ $RESULT_check_remove_root -ne -1 ] && \
|
|
||||||
[ $RESULT_check_private -ne -1 ] && \
|
[ $RESULT_check_private -ne -1 ] && \
|
||||||
[ $RESULT_check_public -ne -1 ] && \
|
[ $RESULT_check_public -ne -1 ] && \
|
||||||
[ $RESULT_check_multi_instance -ne -1 ]
|
[ $RESULT_check_multi_instance -ne -1 ]
|
||||||
|
@ -450,12 +444,7 @@ COMPUTE_RESULTS_SUMMARY () {
|
||||||
# So this level will set at 0.
|
# So this level will set at 0.
|
||||||
level[i]=0
|
level[i]=0
|
||||||
|
|
||||||
# If the level is at 'na', it will be ignored
|
# If the level is at 1 or 2. The global level will be set at this level
|
||||||
elif [ "${level[i]}" == "na" ]
|
|
||||||
then
|
|
||||||
continue
|
|
||||||
|
|
||||||
# If the level is at 1 or 2. The global level will be set at this level
|
|
||||||
elif [ "${level[i]}" -ge 1 ]
|
elif [ "${level[i]}" -ge 1 ]
|
||||||
then
|
then
|
||||||
global_level=$i
|
global_level=$i
|
||||||
|
@ -496,9 +485,7 @@ COMPUTE_RESULTS_SUMMARY () {
|
||||||
for i in `seq 1 10`
|
for i in `seq 1 10`
|
||||||
do
|
do
|
||||||
display="0"
|
display="0"
|
||||||
if [ "${level[$i]}" == "na" ]; then
|
if [ "${level[$i]}" -ge 1 ]; then
|
||||||
display="N/A"
|
|
||||||
elif [ "${level[$i]}" -ge 1 ]; then
|
|
||||||
display="1"
|
display="1"
|
||||||
fi
|
fi
|
||||||
echo -e "\t Level $i: $display"
|
echo -e "\t Level $i: $display"
|
||||||
|
@ -521,12 +508,9 @@ 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_global_setup=0
|
|
||||||
RESULT_global_remove=0
|
|
||||||
RESULT_check_sub_dir=0
|
RESULT_check_sub_dir=0
|
||||||
RESULT_check_root=0
|
RESULT_check_root=0
|
||||||
RESULT_check_remove_sub_dir=0
|
RESULT_check_nourl=0
|
||||||
RESULT_check_remove_root=0
|
|
||||||
RESULT_check_upgrade=0
|
RESULT_check_upgrade=0
|
||||||
RESULT_check_backup=0
|
RESULT_check_backup=0
|
||||||
RESULT_check_restore=0
|
RESULT_check_restore=0
|
||||||
|
@ -612,19 +596,14 @@ parse_check_process() {
|
||||||
extract_check_process_section "^$tests_serie" "^;;" > $test_serie_rawconf
|
extract_check_process_section "^$tests_serie" "^;;" > $test_serie_rawconf
|
||||||
extract_check_process_section "^; pre-install" "^; " $test_serie_rawconf > $test_serie_dir/preinstall.sh.template
|
extract_check_process_section "^; pre-install" "^; " $test_serie_rawconf > $test_serie_dir/preinstall.sh.template
|
||||||
# This is the arg list to be later fed to "yunohost app install"
|
# This is the arg list to be later fed to "yunohost app install"
|
||||||
|
# Looking like domain=foo.com&path=/bar&password=stuff
|
||||||
|
# "Standard" arguments like domain/path will later be overwritten
|
||||||
|
# during tests
|
||||||
extract_check_process_section "^; Manifest" "^; " $test_serie_rawconf | awk '{print $1}' | tr -d '"' | tr '\n' '&' > $test_serie_dir/install_args
|
extract_check_process_section "^; Manifest" "^; " $test_serie_rawconf | awk '{print $1}' | tr -d '"' | tr '\n' '&' > $test_serie_dir/install_args
|
||||||
extract_check_process_section "^; Actions" "^; " $test_serie_rawconf > $test_serie_dir/check_process.actions_infos
|
extract_check_process_section "^; Actions" "^; " $test_serie_rawconf > $test_serie_dir/check_process.actions_infos
|
||||||
extract_check_process_section "^; Config_panel" "^; " $test_serie_rawconf > $test_serie_dir/check_process.configpanel_infos
|
extract_check_process_section "^; Config_panel" "^; " $test_serie_rawconf > $test_serie_dir/check_process.configpanel_infos
|
||||||
extract_check_process_section "^; Checks" "^; " $test_serie_rawconf > $test_serie_dir/check_process.tests_infos
|
extract_check_process_section "^; Checks" "^; " $test_serie_rawconf > $test_serie_dir/check_process.tests_infos
|
||||||
|
|
||||||
# This is the test of commits to test upgrade from
|
|
||||||
for LINE in $(grep "^upgrade=1" "$test_serie_dir/check_process.tests_infos")
|
|
||||||
do
|
|
||||||
commit=$(echo $LINE | grep -o "from_commit=.*" | awk -F= '{print $2}')
|
|
||||||
[ -n "$commit" ] || commit="current"
|
|
||||||
echo $commit >> $test_serie_dir/upgrades_to_test
|
|
||||||
done
|
|
||||||
|
|
||||||
is_test_enabled () {
|
is_test_enabled () {
|
||||||
# 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}')
|
||||||
|
@ -640,21 +619,40 @@ parse_check_process() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
cat << EOF > $test_serie_dir/tests_to_perform
|
is_test_enabled pkg_linter && echo "PACKAGE_LINTER" >> $test_serie_dir/tests_to_perform
|
||||||
pkg_linter=$(is_test_enabled pkg_linter)
|
is_test_enabled setup_sub_dir && echo "TEST_INSTALL subdir " >> $test_serie_dir/tests_to_perform
|
||||||
setup_sub_dir=$(is_test_enabled setup_sub_dir)
|
is_test_enabled setup_root && echo "TEST_INSTALL root" >> $test_serie_dir/tests_to_perform
|
||||||
setup_root=$(is_test_enabled setup_root)
|
is_test_enabled setup_nourl && echo "TEST_INSTALL nourl" >> $test_serie_dir/tests_to_perform
|
||||||
setup_nourl=$(is_test_enabled setup_nourl)
|
is_test_enabled setup_private && echo "TEST_PUBLIC_PRIVATE private" >> $test_serie_dir/tests_to_perform
|
||||||
setup_private=$(is_test_enabled setup_private)
|
is_test_enabled setup_public && echo "TEST_PUBLIC_PRIVATE public" >> $test_serie_dir/tests_to_perform
|
||||||
setup_public=$(is_test_enabled setup_public)
|
is_test_enabled multi_instance && echo "TEST_MULTI_INSTANCE" >> $test_serie_dir/tests_to_perform
|
||||||
upgrade=$(is_test_enabled upgrade)
|
is_test_enabled backup_restore && echo "TEST_BACKUP_RESTORE" >> $test_serie_dir/tests_to_perform
|
||||||
backup_restore=$(is_test_enabled backup_restore)
|
|
||||||
multi_instance=$(is_test_enabled multi_instance)
|
# Upgrades
|
||||||
port_already_use=$(is_test_enabled port_already_use)
|
|
||||||
change_url=$(is_test_enabled change_url)
|
for LINE in $(grep "^upgrade=1" "$test_serie_dir/check_process.tests_infos")
|
||||||
actions=$(is_test_enabled actions)
|
do
|
||||||
config_panel=$(is_test_enabled config_panel)
|
commit=$(echo $LINE | grep -o "from_commit=.*" | awk -F= '{print $2}')
|
||||||
EOF
|
[ -n "$commit" ] || commit="current"
|
||||||
|
echo "TEST_UPGRADE $commit" >> $test_serie_dir/tests_to_perform
|
||||||
|
done
|
||||||
|
|
||||||
|
# "Advanced" features
|
||||||
|
|
||||||
|
is_test_enabled change_url && echo "TEST_CHANGE_URL" >> $test_serie_dir/tests_to_perform
|
||||||
|
is_test_enabled actions && echo "ACTIONS_CONFIG_PANEL actions" >> $test_serie_dir/tests_to_perform
|
||||||
|
is_test_enabled config_panel && echo "ACTIONS_CONFIG_PANEL config_panel" >> $test_serie_dir/tests_to_perform
|
||||||
|
|
||||||
|
# Port already used ... do we really need this ...
|
||||||
|
|
||||||
|
if grep -q -m1 "port_already_use=1" "$test_serie_dir/check_process.tests_infos"
|
||||||
|
then
|
||||||
|
local check_port=$(grep -m1 "port_already_use=1" "$test_serie_dir/check_process.tests_infos" | grep -o -E "\([0-9]+\)" | tr -d '()')
|
||||||
|
else
|
||||||
|
local check_port=6660
|
||||||
|
fi
|
||||||
|
|
||||||
|
is_test_enabled port_already_use && echo "TEST_PORT_ALREADY_USED $check_port" >> $test_serie_dir/tests_to_perform
|
||||||
|
|
||||||
done 3<<< "$(grep "^;; " "$check_process")"
|
done 3<<< "$(grep "^;; " "$check_process")"
|
||||||
|
|
||||||
|
@ -677,19 +675,20 @@ guess_test_configuration() {
|
||||||
python "./sub_scripts/manifest_parsing.py" "$package_path/manifest.json" \
|
python "./sub_scripts/manifest_parsing.py" "$package_path/manifest.json" \
|
||||||
| cut -d ':' -f1,2 | tr ':' '=' | tr '\n' '&' > $test_serie_dir/install_args
|
| cut -d ':' -f1,2 | tr ':' '=' | tr '\n' '&' > $test_serie_dir/install_args
|
||||||
|
|
||||||
cat << EOF > $test_serie_dir/tests_to_perform
|
echo "PACKAGE_LINTER" >> $test_serie_dir/tests_to_perform
|
||||||
pkg_linter=1
|
echo "TEST_INSTALL subdir" >> $test_serie_dir/tests_to_perform
|
||||||
setup_sub_dir=1
|
echo "TEST_INSTALL root" >> $test_serie_dir/tests_to_perform
|
||||||
setup_root=1
|
if grep -q "is_public=" $test_serie_dir/install_args
|
||||||
setup_nourl=0
|
then
|
||||||
setup_private=$(grep -q "is_public=" $test_serie_dir/install_args && echo 1 || echo 0)
|
echo "TEST_PUBLIC_PRIVATE private" >> $test_serie_dir/tests_to_perform
|
||||||
setup_public=$(grep -q "is_public=" $test_serie_dir/install_args && echo 1 || echo 0)0
|
echo "TEST_PUBLIC_PRIVATE public" >> $test_serie_dir/tests_to_perform
|
||||||
upgrade=1
|
fi
|
||||||
backup_restore=1
|
if grep multi_instance "$package_path/manifest.json" | grep -q true
|
||||||
multi_instance=$(grep multi_instance "$package_path/manifest.json" | grep -q true && echo 1 || echo 0)
|
then
|
||||||
port_already_use=0
|
echo "TEST_MULTI_INSTANCE" >> $test_serie_dir/tests_to_perform
|
||||||
change_url=0
|
fi
|
||||||
EOF
|
echo "TEST_BACKUP_RESTORE" >> $test_serie_dir/tests_to_perform
|
||||||
|
echo "TEST_UPGRADE current" >> $test_serie_dir/tests_to_perform
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -701,7 +700,6 @@ run_all_tests() {
|
||||||
# And keep this value separately
|
# And keep this value separately
|
||||||
complete_start_timer=$starttime
|
complete_start_timer=$starttime
|
||||||
|
|
||||||
|
|
||||||
LXC_INIT
|
LXC_INIT
|
||||||
|
|
||||||
for test_serie_id in $test_series
|
for test_serie_id in $test_series
|
||||||
|
@ -719,7 +717,7 @@ run_all_tests() {
|
||||||
# Print the final results of the tests
|
# Print the final results of the tests
|
||||||
COMPUTE_RESULTS_SUMMARY $test_serie_id
|
COMPUTE_RESULTS_SUMMARY $test_serie_id
|
||||||
|
|
||||||
# FIXME FIXME FIXME gotta reset the snapshot
|
LXC_PURGE_SNAPSHOTS
|
||||||
done
|
done
|
||||||
|
|
||||||
# Restore the started time for the timer
|
# Restore the started time for the timer
|
||||||
|
|
|
@ -88,10 +88,10 @@ LXC_INIT () {
|
||||||
sudo rm --force $LXC_ROOTFS/swap_*
|
sudo rm --force $LXC_ROOTFS/swap_*
|
||||||
sudo swapoff $LXC_SNAPSHOTS/snap0/rootfs/swap_* 2>/dev/null
|
sudo swapoff $LXC_SNAPSHOTS/snap0/rootfs/swap_* 2>/dev/null
|
||||||
sudo rm --force $LXC_SNAPSHOTS/snap0/rootfs/swap_*
|
sudo rm --force $LXC_SNAPSHOTS/snap0/rootfs/swap_*
|
||||||
sudo swapoff $LXC_SNAPSHOTS/snap_rootinstall/rootfs/swap_* 2>/dev/null
|
sudo swapoff $LXC_SNAPSHOTS/snap_afterinstall/rootfs/swap_* 2>/dev/null
|
||||||
sudo rm --force $LXC_SNAPSHOTS/snap_rooinstall/rootfs/swap_*
|
sudo rm --force $LXC_SNAPSHOTS/snap_afterinstall/rootfs/swap_*
|
||||||
sudo swapoff $LXC_SNAPSHOTS/snap_subdirintsall/rootfs/swap_* 2>/dev/null
|
|
||||||
sudo rm --force $LXC_SNAPSHOTS/snap_subdirinstall/rootfs/swap_*
|
LXC_PURGE_SNAPSHOTS
|
||||||
|
|
||||||
# Initialize LXC network
|
# Initialize LXC network
|
||||||
|
|
||||||
|
@ -106,6 +106,15 @@ LXC_INIT () {
|
||||||
sudo iptables --table nat --append POSTROUTING --source $LXC_NETWORK.0/24 --jump MASQUERADE | tee --append "$complete_log" 2>&1
|
sudo iptables --table nat --append POSTROUTING --source $LXC_NETWORK.0/24 --jump MASQUERADE | tee --append "$complete_log" 2>&1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LXC_PURGE_SNAPSHOTS() {
|
||||||
|
LXC_STOP
|
||||||
|
|
||||||
|
for SNAP in $(sudo ls $LXC_SNAPSHOTS/snap_*install)
|
||||||
|
do
|
||||||
|
sudo lxc-snapshot -n $LXC_NAME -d $(basename $SNAP)
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
LXC_START () {
|
LXC_START () {
|
||||||
# Start the lxc container and execute the given command in it
|
# Start the lxc container and execute the given command in it
|
||||||
local cmd=$1
|
local cmd=$1
|
||||||
|
|
|
@ -8,23 +8,34 @@ assert_we_are_the_setup_user
|
||||||
|
|
||||||
touch "$lock_file"
|
touch "$lock_file"
|
||||||
|
|
||||||
|
|
||||||
log_title "Retire l'ip forwarding."
|
log_title "Retire l'ip forwarding."
|
||||||
|
|
||||||
sudo rm -f /etc/sysctl.d/lxc_pchecker.conf
|
sudo rm -f /etc/sysctl.d/lxc_pchecker.conf
|
||||||
sudo sysctl -p
|
sudo sysctl -p
|
||||||
|
|
||||||
|
|
||||||
log_title "Désactive le bridge réseau"
|
log_title "Désactive le bridge réseau"
|
||||||
|
|
||||||
sudo ifdown --force $LXC_BRIDGE
|
sudo ifdown --force $LXC_BRIDGE
|
||||||
|
|
||||||
|
|
||||||
log_title "Supprime le brige réseau"
|
log_title "Supprime le brige réseau"
|
||||||
|
|
||||||
sudo rm -f /etc/network/interfaces.d/$LXC_BRIDGE
|
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
|
||||||
sudo lxc-snapshot -n $LXC_NAME -d snap_rootinstall
|
for SNAP in $(sudo ls $LXC_SNAPSHOTS/snap_*install)
|
||||||
sudo lxc-snapshot -n $LXC_NAME -d snap_subdirinstall
|
do
|
||||||
|
sudo lxc-snapshot -n $LXC_NAME -d $(basename $SNAP)
|
||||||
|
done
|
||||||
sudo rm -f /var/lib/lxcsnaps/$LXC_NAME/snap0.tar.gz
|
sudo rm -f /var/lib/lxcsnaps/$LXC_NAME/snap0.tar.gz
|
||||||
sudo lxc-destroy -n $LXC_NAME -f
|
sudo lxc-destroy -n $LXC_NAME -f
|
||||||
|
|
||||||
log_title "Suppression des lignes de pchecker_lxc dans $HOME/.ssh/config"
|
log_title "Suppression des lignes de pchecker_lxc dans $HOME/.ssh/config"
|
||||||
|
|
||||||
BEGIN_LINE=$(cat $HOME/.ssh/config | grep -n "^# ssh pchecker_lxc$" | cut -d':' -f 1 | tail -n1)
|
BEGIN_LINE=$(cat $HOME/.ssh/config | grep -n "^# ssh pchecker_lxc$" | cut -d':' -f 1 | tail -n1)
|
||||||
sed -i "$BEGIN_LINE,/^IdentityFile/d" $HOME/.ssh/config
|
sed -i "$BEGIN_LINE,/^IdentityFile/d" $HOME/.ssh/config
|
||||||
|
|
|
@ -55,6 +55,27 @@ GET_RESULT() {
|
||||||
grep "RESULT_$1=" $test_serie_dir/results | awk -F= '{print $2}'
|
grep "RESULT_$1=" $test_serie_dir/results | awk -F= '{print $2}'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
at_least_one_install_succeeded () {
|
||||||
|
|
||||||
|
[ "$(GET_RESULT check_sub_dir)" -eq 1 ] \
|
||||||
|
|| [ "$(GET_RESULT check_root)" -eq 1 ] \
|
||||||
|
|| [ "$(GET_RESULT check_nourl)" -eq 1 ] \
|
||||||
|
|| { log_error "All installs failed, therefore the following tests cannot be performed...";
|
||||||
|
return 1; }
|
||||||
|
}
|
||||||
|
|
||||||
|
this_is_a_web_app () {
|
||||||
|
# Usually the fact that we test "nourl"
|
||||||
|
# installs should be a good indicator for this
|
||||||
|
grep "TEST_INSTALL nourl" $test_serie_dir/tests_to_perform && return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
default_install_path() {
|
||||||
|
this_is_a_web_app && echo ""
|
||||||
|
|| [ "$(GET_RESULT check_sub_dir)" -eq 1 ] && echo "/path "
|
||||||
|
|| echo "/"
|
||||||
|
}
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# Install and remove an app
|
# Install and remove an app
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -102,10 +123,19 @@ INSTALL_APP () {
|
||||||
return $ret
|
return $ret
|
||||||
}
|
}
|
||||||
|
|
||||||
|
path_to_install_type() {
|
||||||
|
local check_path="$1"
|
||||||
|
|
||||||
|
[ -z "$check_path" ] && echo "nourl" \
|
||||||
|
|| [ "$check_path" == "/" ] && echo "root" \
|
||||||
|
|| echo "subdir"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
LOAD_SNAPSHOT_OR_INSTALL_APP () {
|
LOAD_SNAPSHOT_OR_INSTALL_APP () {
|
||||||
|
|
||||||
local check_path="$1"
|
local check_path="$1"
|
||||||
local _install_type=$([ "$check_path" = "/" ] && echo "root" || echo "subdir")
|
local _install_type=$(path_to_install_type $check_path)
|
||||||
local snapname="snap_${_install_type}install"
|
local snapname="snap_${_install_type}install"
|
||||||
|
|
||||||
if [ ! -e "$LXC_SNAPSHOTS/$snapname" ]
|
if [ ! -e "$LXC_SNAPSHOTS/$snapname" ]
|
||||||
|
@ -121,6 +151,7 @@ LOAD_SNAPSHOT_OR_INSTALL_APP () {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
REMOVE_APP () {
|
REMOVE_APP () {
|
||||||
# Remove an application
|
# Remove an application
|
||||||
|
|
||||||
|
@ -151,8 +182,8 @@ VALIDATE_THAT_APP_CAN_BE_ACCESSED () {
|
||||||
local fell_on_sso_portal=0
|
local fell_on_sso_portal=0
|
||||||
local curl_output=$test_serie_dir/curl_output
|
local curl_output=$test_serie_dir/curl_output
|
||||||
|
|
||||||
# Not checking this if this ain't relevant for the current test / app
|
# Not checking this if this ain't relevant for the current app
|
||||||
[ $enable_validate_that_app_can_be_accessed == "true" ] || return 0
|
this_is_a_web_app || return 0
|
||||||
|
|
||||||
log_small_title "Validating that the app can (or cannot) be accessed with its url..."
|
log_small_title "Validating that the app can (or cannot) be accessed with its url..."
|
||||||
|
|
||||||
|
@ -253,7 +284,7 @@ VALIDATE_THAT_APP_CAN_BE_ACCESSED () {
|
||||||
log_debug "HTTP code: $http_code"
|
log_debug "HTTP code: $http_code"
|
||||||
log_debug "$test_url_details"
|
log_debug "$test_url_details"
|
||||||
log_debug "Page title: $page_title"
|
log_debug "Page title: $page_title"
|
||||||
log_debug "Page extract: $page_extract"
|
log_debug "Page extract:\n$page_extract"
|
||||||
|
|
||||||
if [[ $curl_error -ne 0 ]]
|
if [[ $curl_error -ne 0 ]]
|
||||||
then
|
then
|
||||||
|
@ -262,7 +293,7 @@ VALIDATE_THAT_APP_CAN_BE_ACCESSED () {
|
||||||
log_warning "HTTP code: $http_code"
|
log_warning "HTTP code: $http_code"
|
||||||
log_warning "$test_url_details"
|
log_warning "$test_url_details"
|
||||||
log_warning "Page title: $page_title"
|
log_warning "Page title: $page_title"
|
||||||
log_warning "Page extract: $page_extract"
|
log_warning "Page extract:\n$page_extract"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -285,21 +316,6 @@ VALIDATE_THAT_APP_CAN_BE_ACCESSED () {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# Generic functions for unit tests
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
|
|
||||||
validate_that_at_least_one_install_succeeded () {
|
|
||||||
|
|
||||||
if [ $(GET_RESULT check_sub_dir) -eq 0 ] && [ $(GET_RESULT check_root) -eq 0 ]
|
|
||||||
then
|
|
||||||
log_error "All installs failed, therefore this test cannot be performed..."
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# Unit tests
|
# Unit tests
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -311,7 +327,8 @@ TEST_INSTALL () {
|
||||||
local install_type=$1
|
local install_type=$1
|
||||||
[ "$install_type" = "subdir" ] && { start_test "Installation in a sub path"; local check_path=/path; }
|
[ "$install_type" = "subdir" ] && { start_test "Installation in a sub path"; local check_path=/path; }
|
||||||
[ "$install_type" = "root" ] && { start_test "Installation on the root"; local check_path=/; }
|
[ "$install_type" = "root" ] && { start_test "Installation on the root"; local check_path=/; }
|
||||||
[ "$install_type" = "no_url" ] && { start_test "Installation without url access"; local check_path=""; }
|
[ "$install_type" = "nourl" ] && { start_test "Installation without url access"; local check_path=""; }
|
||||||
|
local snapname=snap_${install_type}install
|
||||||
|
|
||||||
LOAD_LXC_SNAPSHOT snap0
|
LOAD_LXC_SNAPSHOT snap0
|
||||||
|
|
||||||
|
@ -319,151 +336,108 @@ TEST_INSTALL () {
|
||||||
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
|
||||||
|
|
||||||
# Check the result and print SUCCESS or FAIL
|
local install=$?
|
||||||
if [ $? -eq 0 ]
|
|
||||||
then
|
|
||||||
SET_RESULT global_setup 1
|
|
||||||
local check_result_setup=1
|
|
||||||
|
|
||||||
if [ "$install_type" = "root" ]
|
# Create the snapshot that'll be used by other tests later
|
||||||
then
|
[ $install -eq 0 ] \
|
||||||
[ -e "$LXC_SNAPSHOTS/snap_rootinstall" ] \
|
&& [ ! -e "$LXC_SNAPSHOTS/$snapname" ] \
|
||||||
&& log_debug "Create a snapshot for root installation." \
|
&& log_debug "Create a snapshot after app install" \
|
||||||
&& CREATE_LXC_SNAPSHOT snap_rootinstall
|
&& CREATE_LXC_SNAPSHOT $snapname
|
||||||
else
|
|
||||||
# Check if a snapshot already exist for a subpath (or no_url) install
|
|
||||||
[ ! -e "$LXC_SNAPSHOTS/snap_subdirinstall" ] \
|
|
||||||
&& log_debug "Create a snapshot for sub path installation." \
|
|
||||||
&& CREATE_LXC_SNAPSHOT snap_subdirinstall
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
SET_RESULT_IF_NONE_YET global_setup -1
|
|
||||||
local check_result_setup=-1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Remove the application
|
# Remove and reinstall the application
|
||||||
REMOVE_APP
|
[ $install -eq 0 ] \
|
||||||
|
&& log_small_title "Remove and reinstall the application after a removal." \
|
||||||
if [ $? -eq 0 ]
|
&& REMOVE_APP \
|
||||||
then
|
&& INSTALL_APP "path=$check_path" \
|
||||||
local check_result_remove=1
|
&& VALIDATE_THAT_APP_CAN_BE_ACCESSED $SUBDOMAIN $check_path
|
||||||
SET_RESULT global_remove 1
|
|
||||||
else
|
|
||||||
# The global success for a deletion can't be failed if another remove succeed
|
|
||||||
SET_RESULT_IF_NONE_YET global_remove -1
|
|
||||||
local check_result_remove=-1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Reinstall the application after the removing
|
# Reinstall the application after the removing
|
||||||
# Try to resintall only if the first install is a success.
|
# Try to resintall only if the first install is a success.
|
||||||
if [ $check_result_setup -eq 1 ]
|
[ $? -eq 0 ] \
|
||||||
then
|
&& SET_RESULT check_$install_type 1 \
|
||||||
log_small_title "Reinstall the application after a removing."
|
|| SET_RESULT check_$install_type -1
|
||||||
|
|
||||||
INSTALL_APP "path=$check_path" \
|
|
||||||
&& VALIDATE_THAT_APP_CAN_BE_ACCESSED $SUBDOMAIN $check_path
|
|
||||||
|
|
||||||
# Check the result and print SUCCESS or FAIL
|
|
||||||
[ $? -eq 0 ] && local check_result_setup=1 || local check_result_setup=-1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Fill the correct variable depend on the type of test
|
|
||||||
if [ "$install_type" = "subdir" ]
|
|
||||||
then
|
|
||||||
SET_RESULT check_sub_dir $check_result_setup
|
|
||||||
SET_RESULT check_remove_sub_dir $check_result_remove
|
|
||||||
else # root and no_url
|
|
||||||
SET_RESULT check_root $check_result_setup
|
|
||||||
SET_RESULT check_remove_root $check_result_remove
|
|
||||||
fi
|
|
||||||
|
|
||||||
break_before_continue
|
break_before_continue
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_UPGRADE () {
|
TEST_UPGRADE () {
|
||||||
|
|
||||||
[ $(GET_RESULT check_sub_dir) -eq 1 ] && local check_path=/path || local check_path=/
|
if [ "$commit" == "current" ]
|
||||||
|
then
|
||||||
|
start_test "Upgrade from the same version"
|
||||||
|
else
|
||||||
|
specific_upgrade_args="$(grep "^manifest_arg=" "$test_serie_dir/upgrades/$commit" | cut -d'=' -f2-)"
|
||||||
|
upgrade_name=$(grep "^name=" "$test_serie_dir/upgrades/$commit" | cut -d'=' -f2)
|
||||||
|
|
||||||
# Do an upgrade test for each commit in the upgrade list
|
[ -n "$upgrade_name" ] || upgrade_name="commit $commit"
|
||||||
for commit in $(cat $test_serie_dir/upgrades_to_test)
|
start_test "Upgrade from $upgrade_name"
|
||||||
do
|
fi
|
||||||
if [ "$commit" == "current" ]
|
|
||||||
then
|
|
||||||
start_test "Upgrade from the same version"
|
|
||||||
else
|
|
||||||
specific_upgrade_args="$(grep "^manifest_arg=" "$test_serie_dir/upgrades/$commit" | cut -d'=' -f2-)"
|
|
||||||
upgrade_name=$(grep "^name=" "$test_serie_dir/upgrades/$commit" | cut -d'=' -f2)
|
|
||||||
|
|
||||||
[ -n "$upgrade_name" ] || upgrade_name="commit $commit"
|
at_least_one_install_succeeded || return
|
||||||
start_test "Upgrade from $upgrade_name"
|
|
||||||
|
local check_path=$(default_install_path)
|
||||||
|
|
||||||
|
# Install the application in a LXC container
|
||||||
|
log_small_title "Preliminary install..."
|
||||||
|
if [ "$commit" == "current" ]
|
||||||
|
then
|
||||||
|
# If no commit is specified, use the current version.
|
||||||
|
LOAD_SNAPSHOT_OR_INSTALL_APP "$check_path"
|
||||||
|
local ret=$?
|
||||||
|
else
|
||||||
|
# Get the arguments of the manifest for this upgrade.
|
||||||
|
if [ -n "$specific_upgrade_args" ]; then
|
||||||
|
cp "$test_serie_dir/install_args" "$test_serie_dir/install_args.bkp"
|
||||||
|
echo "$specific_upgrade_args" > "$test_serie_dir/install_args"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
validate_that_at_least_one_install_succeeded || return
|
# Make a backup of the directory
|
||||||
|
# and Change to the specified commit
|
||||||
|
sudo cp -a "$package_path" "${package_path}_back"
|
||||||
|
(cd "$package_path"; git checkout --force --quiet "$commit")
|
||||||
|
|
||||||
# Install the application in a LXC container
|
LOAD_LXC_SNAPSHOT snap0
|
||||||
log_small_title "Preliminary install..."
|
|
||||||
if [ "$commit" == "current" ]
|
|
||||||
then
|
|
||||||
# If no commit is specified, use the current version.
|
|
||||||
LOAD_SNAPSHOT_OR_INSTALL_APP "$check_path"
|
|
||||||
local ret=$?
|
|
||||||
else
|
|
||||||
# Get the arguments of the manifest for this upgrade.
|
|
||||||
if [ -n "$specific_upgrade_args" ]; then
|
|
||||||
cp "$test_serie_dir/install_args" "$test_serie_dir/install_args.bkp"
|
|
||||||
echo "$specific_upgrade_args" > "$test_serie_dir/install_args"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Make a backup of the directory
|
# Install the application
|
||||||
# and Change to the specified commit
|
INSTALL_APP "path=$check_path"
|
||||||
sudo cp -a "$package_path" "${package_path}_back"
|
local ret=$?
|
||||||
(cd "$package_path"; git checkout --force --quiet "$commit")
|
|
||||||
|
|
||||||
LOAD_LXC_SNAPSHOT snap0
|
if [ -n "$specific_upgrade_args" ]; then
|
||||||
|
mv "$test_serie_dir/install_args.bkp" "$test_serie_dir/install_args"
|
||||||
# Install the application
|
|
||||||
INSTALL_APP "path=$check_path"
|
|
||||||
local ret=$?
|
|
||||||
|
|
||||||
if [ -n "$specific_upgrade_args" ]; then
|
|
||||||
mv "$test_serie_dir/install_args.bkp" "$test_serie_dir/install_args"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Then replace the backup
|
|
||||||
sudo rm -r "$package_path"
|
|
||||||
sudo mv "${package_path}_back" "$package_path"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if the install had work
|
# Then replace the backup
|
||||||
[ $ret -eq 0 ] || { log_error "Initial install failed... upgrade test ignore"; LXC_STOP; continue; }
|
sudo rm -r "$package_path"
|
||||||
|
sudo mv "${package_path}_back" "$package_path"
|
||||||
|
fi
|
||||||
|
|
||||||
log_small_title "Upgrade..."
|
# Check if the install had work
|
||||||
|
[ $ret -eq 0 ] || { log_error "Initial install failed... upgrade test ignore"; LXC_STOP; continue; }
|
||||||
|
|
||||||
# Upgrade the application in a LXC container
|
log_small_title "Upgrade..."
|
||||||
RUN_YUNOHOST_CMD "app upgrade $app_id -f ./app_folder/" \
|
|
||||||
&& VALIDATE_THAT_APP_CAN_BE_ACCESSED $SUBDOMAIN $check_path
|
|
||||||
|
|
||||||
if [ $? -eq 0 ]
|
# Upgrade the application in a LXC container
|
||||||
then
|
RUN_YUNOHOST_CMD "app upgrade $app_id -f ./app_folder/" \
|
||||||
SET_RESULT_IF_NONE_YET check_upgrade 1
|
&& VALIDATE_THAT_APP_CAN_BE_ACCESSED $SUBDOMAIN $check_path
|
||||||
else
|
|
||||||
SET_RESULT check_upgrade -1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Remove the application
|
if [ $? -eq 0 ]
|
||||||
REMOVE_APP
|
then
|
||||||
done
|
SET_RESULT_IF_NONE_YET check_upgrade 1
|
||||||
|
else
|
||||||
|
SET_RESULT check_upgrade -1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove the application
|
||||||
|
REMOVE_APP
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_PUBLIC_PRIVATE () {
|
TEST_PUBLIC_PRIVATE () {
|
||||||
# Try to install in public or private mode
|
|
||||||
# $1 = install type
|
|
||||||
|
|
||||||
local install_type=$1
|
local install_type=$1
|
||||||
[ "$install_type" = "private" ] && start_test "Installation in private mode"
|
[ "$install_type" = "private" ] && start_test "Installation in private mode"
|
||||||
[ "$install_type" = "public" ] && start_test "Installation in public mode"
|
[ "$install_type" = "public" ] && start_test "Installation in public mode"
|
||||||
|
|
||||||
validate_that_at_least_one_install_succeeded || return
|
at_least_one_install_succeeded || return
|
||||||
|
|
||||||
# Set public or private according to type of test requested
|
# Set public or private according to type of test requested
|
||||||
if [ "$install_type" = "private" ]; then
|
if [ "$install_type" = "private" ]; then
|
||||||
|
@ -526,18 +500,13 @@ TEST_PUBLIC_PRIVATE () {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_MULTI_INSTANCE () {
|
TEST_MULTI_INSTANCE () {
|
||||||
# Try multi-instance installations
|
|
||||||
|
|
||||||
start_test "Multi-instance installations"
|
start_test "Multi-instance installations"
|
||||||
|
|
||||||
# Check if an install have previously work
|
# Check if an install have previously work
|
||||||
validate_that_at_least_one_install_succeeded || return
|
at_least_one_install_succeeded || return
|
||||||
|
|
||||||
[ $(GET_RESULT check_sub_dir) -eq 1 ] && local check_path=/path || local check_path=/
|
|
||||||
|
|
||||||
local multi_yunohost_result_1=0
|
|
||||||
local multi_yunohost_result_2=0
|
|
||||||
|
|
||||||
|
local check_path=$(default_install_path)
|
||||||
|
|
||||||
LOAD_LXC_SNAPSHOT snap0
|
LOAD_LXC_SNAPSHOT snap0
|
||||||
|
|
||||||
|
@ -559,22 +528,14 @@ TEST_MULTI_INSTANCE () {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_PORT_ALREADY_USED () {
|
TEST_PORT_ALREADY_USED () {
|
||||||
# Try to install with specific complications
|
|
||||||
# $1 = install type
|
|
||||||
|
|
||||||
start_test "Port already used"
|
start_test "Port already used"
|
||||||
|
|
||||||
# Check if an install have previously work
|
# Check if an install have previously work
|
||||||
validate_that_at_least_one_install_succeeded || return
|
at_least_one_install_succeeded || return
|
||||||
|
|
||||||
# Use a path according to previous succeeded installs
|
local check_port=$1
|
||||||
|
local check_path=$(default_install_path)
|
||||||
if grep -q -m1 "port_already_use=1" "$test_serie_dir/check_process.tests_infos"
|
|
||||||
then
|
|
||||||
local check_port=$(grep -m1 "port_already_use=1" "$test_serie_dir/check_process.tests_infos" | grep -o -E "\([0-9]+\)" | tr -d '()')
|
|
||||||
else
|
|
||||||
local check_port=6660
|
|
||||||
fi
|
|
||||||
|
|
||||||
LOAD_LXC_SNAPSHOT snap0
|
LOAD_LXC_SNAPSHOT snap0
|
||||||
|
|
||||||
|
@ -587,8 +548,6 @@ TEST_PORT_ALREADY_USED () {
|
||||||
# Then start this service to block this port.
|
# Then start this service to block this port.
|
||||||
LXC_START "sudo systemctl enable netcat & sudo systemctl start netcat"
|
LXC_START "sudo systemctl enable netcat & sudo systemctl start netcat"
|
||||||
|
|
||||||
[ $(GET_RESULT check_sub_dir) -eq 1 ] && local check_path=/path || local check_path=/
|
|
||||||
|
|
||||||
# Install the application in a LXC container
|
# Install the application in a LXC container
|
||||||
INSTALL_APP "path=$check_path" "port=$check_port" \
|
INSTALL_APP "path=$check_path" "port=$check_port" \
|
||||||
&& VALIDATE_THAT_APP_CAN_BE_ACCESSED $SUBDOMAIN $check_path
|
&& VALIDATE_THAT_APP_CAN_BE_ACCESSED $SUBDOMAIN $check_path
|
||||||
|
@ -599,131 +558,103 @@ TEST_PORT_ALREADY_USED () {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_BACKUP_RESTORE () {
|
TEST_BACKUP_RESTORE () {
|
||||||
|
|
||||||
# Try to backup then restore the app
|
# Try to backup then restore the app
|
||||||
|
|
||||||
start_test "Backup/Restore"
|
start_test "Backup/Restore"
|
||||||
|
|
||||||
# Check if an install have previously work
|
# Check if an install have previously work
|
||||||
validate_that_at_least_one_install_succeeded || return
|
at_least_one_install_succeeded || return
|
||||||
|
|
||||||
# Try in 2 times, first in root and second in sub path.
|
local check_path=$(default_install_path)
|
||||||
local i=0
|
|
||||||
for i in 0 1
|
# Install the application in a LXC container
|
||||||
|
LOAD_SNAPSHOT_OR_INSTALL_APP "$check_path"
|
||||||
|
|
||||||
|
local ret=$?
|
||||||
|
|
||||||
|
# Remove the previous residual backups
|
||||||
|
sudo rm -rf $LXC_ROOTFS/home/yunohost.backup/archives
|
||||||
|
|
||||||
|
# BACKUP
|
||||||
|
# Made a backup if the installation succeed
|
||||||
|
if [ $ret -ne 0 ]
|
||||||
|
then
|
||||||
|
log_error "Installation failed..."
|
||||||
|
else
|
||||||
|
log_small_title "Backup of the application..."
|
||||||
|
|
||||||
|
# Made a backup of the application
|
||||||
|
RUN_YUNOHOST_CMD "backup create -n Backup_test --apps $app_id"
|
||||||
|
|
||||||
|
ret=$?
|
||||||
|
|
||||||
|
if [ $ret -eq 0 ]; then
|
||||||
|
log_debug "Backup successful"
|
||||||
|
else
|
||||||
|
log_error "Backup failed."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check the result and print SUCCESS or FAIL
|
||||||
|
if [ $ret -eq 0 ]
|
||||||
|
then
|
||||||
|
SET_RESULT_IF_NONE_YET check_backup 1
|
||||||
|
else
|
||||||
|
SET_RESULT check_backup -1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Grab the backup archive into the LXC container, and keep a copy
|
||||||
|
sudo cp -a $LXC_ROOTFS/home/yunohost.backup/archives ./
|
||||||
|
|
||||||
|
# RESTORE
|
||||||
|
# Try the restore process in 2 times, first after removing the app, second after a restore of the container.
|
||||||
|
local j=0
|
||||||
|
for j in 0 1
|
||||||
do
|
do
|
||||||
# First, try with a root install
|
# First, simply remove the application
|
||||||
if [ $i -eq 0 ]
|
if [ $j -eq 0 ]
|
||||||
then
|
then
|
||||||
# Check if root installation worked, or if force_install_ok is setted.
|
# Remove the application
|
||||||
if [ $(GET_RESULT check_root) -eq 0 ]
|
REMOVE_APP
|
||||||
then
|
|
||||||
log_warning "Root install failed, therefore this test cannot be performed..."
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
local check_path=/
|
log_small_title "Restore after removing the application..."
|
||||||
log_small_title "Preliminary installation on the root..."
|
|
||||||
|
|
||||||
# Second, try with a sub path install
|
# Second, restore the whole container to remove completely the application
|
||||||
elif [ $i -eq 1 ]
|
elif [ $j -eq 1 ]
|
||||||
then
|
then
|
||||||
# Check if sub path installation worked, or if force_install_ok is setted.
|
|
||||||
if [ $(GET_RESULT check_sub_dir) -eq 1 ]
|
# Remove the previous residual backups
|
||||||
then
|
sudo rm -rf $LXC_SNAPSHOTS/snap0/rootfs/home/yunohost.backup/archives
|
||||||
log_warning "Sub path install failed, therefore this test cannot be performed..."
|
|
||||||
continue
|
# Place the copy of the backup archive in the container.
|
||||||
fi
|
sudo mv -f ./archives $LXC_SNAPSHOTS/snap0/rootfs/home/yunohost.backup/
|
||||||
local check_path=/path
|
|
||||||
log_small_title "Preliminary installation in a sub path..." "white" "bold" clog
|
LXC_STOP
|
||||||
|
LOAD_LXC_SNAPSHOT snap0
|
||||||
|
|
||||||
|
log_small_title "Restore on a clean YunoHost system..."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install the application in a LXC container
|
# Restore the application from the previous backup
|
||||||
LOAD_SNAPSHOT_OR_INSTALL_APP "$check_path"
|
RUN_YUNOHOST_CMD "backup restore Backup_test --force --apps $app_id" \
|
||||||
|
&& VALIDATE_THAT_APP_CAN_BE_ACCESSED $SUBDOMAIN $check_path
|
||||||
|
|
||||||
local ret=$?
|
local ret=$?
|
||||||
|
|
||||||
# Remove the previous residual backups
|
# Print the result of the backup command
|
||||||
sudo rm -rf $LXC_ROOTFS/home/yunohost.backup/archives
|
if [ $ret -eq 0 ]; then
|
||||||
|
log_debug "Restore successful."
|
||||||
# BACKUP
|
SET_RESULT_IF_NONE_YET check_restore 1
|
||||||
# Made a backup if the installation succeed
|
|
||||||
if [ $ret -ne 0 ]
|
|
||||||
then
|
|
||||||
log_error "Installation failed..."
|
|
||||||
else
|
else
|
||||||
log_small_title "Backup of the application..."
|
log_error "Restore failed."
|
||||||
|
SET_RESULT check_restore -1
|
||||||
# Made a backup of the application
|
|
||||||
RUN_YUNOHOST_CMD "backup create -n Backup_test --apps $app_id"
|
|
||||||
|
|
||||||
ret=$?
|
|
||||||
|
|
||||||
if [ $ret -eq 0 ]; then
|
|
||||||
log_debug "Backup successful"
|
|
||||||
else
|
|
||||||
log_error "Backup failed."
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check the result and print SUCCESS or FAIL
|
break_before_continue
|
||||||
if [ $ret -eq 0 ]
|
|
||||||
then
|
|
||||||
SET_RESULT_IF_NONE_YET check_backup 1
|
|
||||||
else
|
|
||||||
SET_RESULT check_backup -1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Grab the backup archive into the LXC container, and keep a copy
|
# Stop and restore the LXC container
|
||||||
sudo cp -a $LXC_ROOTFS/home/yunohost.backup/archives ./
|
LXC_STOP
|
||||||
|
|
||||||
# RESTORE
|
|
||||||
# Try the restore process in 2 times, first after removing the app, second after a restore of the container.
|
|
||||||
local j=0
|
|
||||||
for j in 0 1
|
|
||||||
do
|
|
||||||
# First, simply remove the application
|
|
||||||
if [ $j -eq 0 ]
|
|
||||||
then
|
|
||||||
# Remove the application
|
|
||||||
REMOVE_APP
|
|
||||||
|
|
||||||
log_small_title "Restore after removing the application..."
|
|
||||||
|
|
||||||
# Second, restore the whole container to remove completely the application
|
|
||||||
elif [ $j -eq 1 ]
|
|
||||||
then
|
|
||||||
|
|
||||||
# Remove the previous residual backups
|
|
||||||
sudo rm -rf $LXC_SNAPSHOTS/snap0/rootfs/home/yunohost.backup/archives
|
|
||||||
|
|
||||||
# Place the copy of the backup archive in the container.
|
|
||||||
sudo mv -f ./archives $LXC_SNAPSHOTS/snap0/rootfs/home/yunohost.backup/
|
|
||||||
|
|
||||||
LXC_STOP
|
|
||||||
LOAD_LXC_SNAPSHOT snap0
|
|
||||||
|
|
||||||
log_small_title "Restore on a clean YunoHost system..."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Restore the application from the previous backup
|
|
||||||
RUN_YUNOHOST_CMD "backup restore Backup_test --force --apps $app_id" \
|
|
||||||
&& VALIDATE_THAT_APP_CAN_BE_ACCESSED $SUBDOMAIN $check_path
|
|
||||||
|
|
||||||
local ret=$?
|
|
||||||
|
|
||||||
# Print the result of the backup command
|
|
||||||
if [ $ret -eq 0 ]; then
|
|
||||||
log_debug "Restore successful."
|
|
||||||
SET_RESULT_IF_NONE_YET check_restore 1
|
|
||||||
else
|
|
||||||
log_error "Restore failed."
|
|
||||||
SET_RESULT check_restore -1
|
|
||||||
fi
|
|
||||||
|
|
||||||
break_before_continue
|
|
||||||
|
|
||||||
# Stop and restore the LXC container
|
|
||||||
LXC_STOP
|
|
||||||
done
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -733,13 +664,14 @@ TEST_CHANGE_URL () {
|
||||||
start_test "Change URL"
|
start_test "Change URL"
|
||||||
|
|
||||||
# Check if an install have previously work
|
# Check if an install have previously work
|
||||||
validate_that_at_least_one_install_succeeded || return
|
at_least_one_install_succeeded || return
|
||||||
|
this_is_a_web_app || return
|
||||||
|
|
||||||
# Try in 6 times !
|
# Try in 6 times !
|
||||||
# Without modify the domain, root to path, path to path and path to root.
|
# Without modify the domain, root to path, path to path and path to root.
|
||||||
# And then, same with a domain change
|
# And then, same with a domain change
|
||||||
local i=0
|
local i=0
|
||||||
for i in `seq 1 7`
|
for i in $(seq 1 7)
|
||||||
do
|
do
|
||||||
# Same domain, root to path
|
# Same domain, root to path
|
||||||
if [ $i -eq 1 ]; then
|
if [ $i -eq 1 ]; then
|
||||||
|
@ -747,37 +679,37 @@ TEST_CHANGE_URL () {
|
||||||
local new_path=/path
|
local new_path=/path
|
||||||
local new_domain=$SUBDOMAIN
|
local new_domain=$SUBDOMAIN
|
||||||
|
|
||||||
# Same domain, path to path
|
# Same domain, path to path
|
||||||
elif [ $i -eq 2 ]; then
|
elif [ $i -eq 2 ]; then
|
||||||
check_path=/path
|
check_path=/path
|
||||||
local new_path=/path_2
|
local new_path=/path_2
|
||||||
local new_domain=$SUBDOMAIN
|
local new_domain=$SUBDOMAIN
|
||||||
|
|
||||||
# Same domain, path to root
|
# Same domain, path to root
|
||||||
elif [ $i -eq 3 ]; then
|
elif [ $i -eq 3 ]; then
|
||||||
check_path=/path
|
check_path=/path
|
||||||
local new_path=/
|
local new_path=/
|
||||||
local new_domain=$SUBDOMAIN
|
local new_domain=$SUBDOMAIN
|
||||||
|
|
||||||
# Other domain, root to path
|
# Other domain, root to path
|
||||||
elif [ $i -eq 4 ]; then
|
elif [ $i -eq 4 ]; then
|
||||||
check_path=/
|
check_path=/
|
||||||
local new_path=/path
|
local new_path=/path
|
||||||
local new_domain=$DOMAIN
|
local new_domain=$DOMAIN
|
||||||
|
|
||||||
# Other domain, path to path
|
# Other domain, path to path
|
||||||
elif [ $i -eq 5 ]; then
|
elif [ $i -eq 5 ]; then
|
||||||
check_path=/path
|
check_path=/path
|
||||||
local new_path=/path_2
|
local new_path=/path_2
|
||||||
local new_domain=$DOMAIN
|
local new_domain=$DOMAIN
|
||||||
|
|
||||||
# Other domain, path to root
|
# Other domain, path to root
|
||||||
elif [ $i -eq 6 ]; then
|
elif [ $i -eq 6 ]; then
|
||||||
check_path=/path
|
check_path=/path
|
||||||
local new_path=/
|
local new_path=/
|
||||||
local new_domain=$DOMAIN
|
local new_domain=$DOMAIN
|
||||||
|
|
||||||
# Other domain, root to root
|
# Other domain, root to root
|
||||||
elif [ $i -eq 7 ]; then
|
elif [ $i -eq 7 ]; then
|
||||||
check_path=/
|
check_path=/
|
||||||
local new_path=/
|
local new_path=/
|
||||||
|
@ -878,13 +810,11 @@ ACTIONS_CONFIG_PANEL () {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if an install have previously work
|
# Check if an install have previously work
|
||||||
validate_that_at_least_one_install_succeeded || return
|
at_least_one_install_succeeded || return
|
||||||
|
|
||||||
# Use a path according to previous succeeded installs
|
|
||||||
[ $(GET_RESULT check_sub_dir) -eq 1 ] && local check_path=/path || local check_path=/
|
|
||||||
|
|
||||||
# Install the application in a LXC container
|
# Install the application in a LXC container
|
||||||
log_small_title "Preliminary install..."
|
log_small_title "Preliminary install..."
|
||||||
|
local check_path=$(default_install_path)
|
||||||
LOAD_SNAPSHOT_OR_INSTALL_APP "$check_path"
|
LOAD_SNAPSHOT_OR_INSTALL_APP "$check_path"
|
||||||
|
|
||||||
validate_action_config_panel()
|
validate_action_config_panel()
|
||||||
|
@ -1277,6 +1207,7 @@ check_witness_files () {
|
||||||
[ $(GET_RESULT witness) -eq 1 ] && return 1 || return 0
|
[ $(GET_RESULT witness) -eq 1 ] && return 1 || return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
RUN_TEST_SERIE() {
|
RUN_TEST_SERIE() {
|
||||||
# Launch all tests successively
|
# Launch all tests successively
|
||||||
test_serie_dir=$1
|
test_serie_dir=$1
|
||||||
|
@ -1293,54 +1224,16 @@ RUN_TEST_SERIE() {
|
||||||
# Print the version of YunoHost from the LXC container
|
# Print the version of YunoHost from the LXC container
|
||||||
LXC_START "sudo yunohost --version"
|
LXC_START "sudo yunohost --version"
|
||||||
|
|
||||||
source $test_serie_dir/tests_to_perform
|
|
||||||
# Init the value for the current test
|
# Init the value for the current test
|
||||||
current_test_number=1
|
current_test_number=1
|
||||||
|
|
||||||
# We will chech that the app can be accessed
|
# The list of test contains for example "TEST_UPGRADE some_commit_id"
|
||||||
# (except if it's a no-url app)
|
for test in $test_serie_dir/tests_to_perform
|
||||||
[ $setup_nourl -eq 0 ] \
|
do
|
||||||
&& enable_validate_that_app_can_be_accessed="true" \
|
TEST_LAUNCHER $test
|
||||||
||enable_validate_that_app_can_be_accessed="false"
|
done
|
||||||
|
|
||||||
# Check the package with package linter
|
|
||||||
[ $pkg_linter -eq 1 ] && PACKAGE_LINTER
|
|
||||||
|
|
||||||
# Try to install in a sub path
|
|
||||||
[ $setup_sub_dir -eq 1 ] && TEST_LAUNCHER TEST_INSTALL subdir
|
|
||||||
|
|
||||||
# Try to install on root
|
|
||||||
[ $setup_root -eq 1 ] && TEST_LAUNCHER TEST_INSTALL root
|
|
||||||
|
|
||||||
# Try to install without url access
|
|
||||||
[ $setup_nourl -eq 1 ] && TEST_LAUNCHER TEST_INSTALL no_url
|
|
||||||
|
|
||||||
# Try the upgrade script
|
|
||||||
[ $upgrade -eq 1 ] && TEST_LAUNCHER TEST_UPGRADE
|
|
||||||
|
|
||||||
# Try to install in private mode
|
|
||||||
[ $setup_private -eq 1 ] && TEST_LAUNCHER TEST_PUBLIC_PRIVATE private
|
|
||||||
|
|
||||||
# Try to install in public mode
|
|
||||||
[ $setup_public -eq 1 ] && TEST_LAUNCHER TEST_PUBLIC_PRIVATE public
|
|
||||||
|
|
||||||
# Try multi-instance installations
|
|
||||||
[ $multi_instance -eq 1 ] && TEST_LAUNCHER TEST_MULTI_INSTANCE
|
|
||||||
|
|
||||||
# Try to install with a port already used
|
|
||||||
[ $port_already_use -eq 1 ] && TEST_LAUNCHER TEST_PORT_ALREADY_USED
|
|
||||||
|
|
||||||
# Try to backup then restore the app
|
|
||||||
[ $backup_restore -eq 1 ] && TEST_LAUNCHER TEST_BACKUP_RESTORE
|
|
||||||
|
|
||||||
# Try the change_url script
|
|
||||||
[ $change_url -eq 1 ] && TEST_LAUNCHER TEST_CHANGE_URL
|
|
||||||
|
|
||||||
# Try the actions
|
|
||||||
[ $actions -eq 1 ] && TEST_LAUNCHER ACTIONS_CONFIG_PANEL actions
|
|
||||||
|
|
||||||
# Try the config-panel
|
|
||||||
[ $config_panel -eq 1 ] && TEST_LAUNCHER ACTIONS_CONFIG_PANEL config_panel
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_LAUNCHER () {
|
TEST_LAUNCHER () {
|
||||||
|
@ -1356,18 +1249,16 @@ TEST_LAUNCHER () {
|
||||||
# Execute the test
|
# Execute the test
|
||||||
$1 $2
|
$1 $2
|
||||||
|
|
||||||
# Stop and restore the LXC container
|
|
||||||
LXC_STOP
|
|
||||||
|
|
||||||
# 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 2
|
||||||
|
|
||||||
|
LXC_STOP
|
||||||
|
|
||||||
# Update the lock file with the date of the last finished test.
|
# Update the lock file with the date of the last finished test.
|
||||||
# $$ is the PID of package_check itself.
|
# $$ is the PID of package_check itself.
|
||||||
echo "$1 $2:$(date +%s):$$" > "$lock_file"
|
echo "$1 $2:$(date +%s):$$" > "$lock_file"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue