Allow multi-instance without subpath

This commit is contained in:
Maniack Crudelis 2017-11-11 16:53:11 +01:00
parent eee83b8500
commit b7c5649451
4 changed files with 27 additions and 48 deletions

View file

@ -119,7 +119,7 @@ Si un test est absent de la liste, il sera ignoré. Cela revient à le noter à
- `setup_public`: Installation en public.
- `upgrade`: Upgrade du package sur la même version. Test uniquement le script upgrade.
- `backup_restore`: Backup et restauration.
- `multi_instance`: Installation de l'application 3 fois de suite, pour vérifier sa capacité à être multi-instance. Les 2e et 3e installations se font respectivement en ajoutant un suffixe et un préfixe au path.
- `multi_instance`: Installation de l'application 2 fois de suite, pour vérifier sa capacité à être multi-instance.
- `incorrect_path`: Provoque une erreur avec un path malformé, path/.
- `port_already_use`: Provoque une erreur sur le port en l'ouvrant avant le script d'install.
Le test` port_already_use` peut éventuellement prendre en argument un numéro de port. Si celui-ci n'est pas dans le manifest.

View file

@ -119,7 +119,7 @@ If a test is not in the list, it will be ignored. It's similar to marked at 0.
- `setup_public`: Public installation.
- `upgrade`: Upgrade package on same version. Only test the upgrade script.
- `backup_restore`: Backup then restore.
- `multi_instance`: Installing the application 3 times to verify its ability to be multi-instance. The 2nd and 3rd respectively installs are adding a suffix then prefix path.
- `multi_instance`: Installing the application 2 times to verify its ability to be multi-instance.
- `incorrect_path`: Causes an arror with a malformed path, path/.
- `port_already_use`: Causes an error on the port by opening before.
The `port_already_use` test may eventually take in argument the port number.

View file

@ -813,7 +813,7 @@ initialize_values() {
all_test=0
# Default path
test_path=/check
test_path=/
}
#=================================================

View file

@ -732,48 +732,38 @@ CHECK_MULTI_INSTANCE () {
unit_test_title "Multi-instance installations..."
# Check if the sub path install have previously work
if [ $RESULT_check_sub_dir -ne 1 ] && [ $force_install_ok -ne 1 ]
then
# If subdir installation doesn't worked and force_install_ok not setted, aborted this test.
ECHO_FORMAT "Sub path install failed, impossible to perform this test...\n" "red" clog
return
fi
# Check if an install have previously work
local previous_install=$(is_install_failed)
# Abort if none install worked
[ "$previous_install" = "1" ] && return
# Copy original arguments
local manifest_args_mod="$manifest_arguments"
# Replace manifest key for the test
check_domain=$sub_domain
replace_manifest_key "domain" "$check_domain"
replace_manifest_key "path" "$test_path"
check_path=$test_path
replace_manifest_key "user" "$test_user"
replace_manifest_key "public" "$public_public_arg"
# Install 3 times the same app
# Install 2 times the same app
local i=0
for i in 1 2 3
for i in 1 2
do
# First installation
if [ $i -eq 1 ]
then
local path_1=$test_path
ECHO_FORMAT "First installation: path=$path_1\n" clog
check_path=$path_1
check_domain=$main_domain
ECHO_FORMAT "First installation: path=$check_domain$check_path\n" clog
# Second installation
elif [ $i -eq 2 ]
then
local path_2="/2${test_path#/}"
ECHO_FORMAT "Second installation: path=$path_2\n" clog
check_path=$path_2
# Third installation
else
local path_3="/3-${test_path#/}"
ECHO_FORMAT "Third installation: path=$path_3\n" clog
check_path=$path_3
check_domain=$sub_domain
ECHO_FORMAT "Second installation: path=$check_domain$check_path\n" clog
fi
# Replace path manifest key for the test
replace_manifest_key "path" "$check_path"
# Replace path and domain manifest keys for the test
replace_manifest_key "domain" "$check_domain"
# Install the application in a LXC container
SETUP_APP
@ -789,30 +779,22 @@ CHECK_MULTI_INSTANCE () {
then
local multi_yunohost_result_2=$yunohost_result
local ynh_app_id_2=$ynh_app_id
# Third installation
else
local multi_yunohost_result_3=$yunohost_result
local ynh_app_id_3=$ynh_app_id
fi
done
# Try to access to the 3 apps by theirs url
for i in 1 2 3
# Try to access to the 2 apps by theirs url
for i in 1 2
do
# First app
if [ $i -eq 1 ]
then
check_path=$path_1
check_domain=$main_domain
ynh_app_id=$ynh_app_id_1
# Second app
elif [ $i -eq 2 ]
then
check_path=$path_2
check_domain=$sub_domain
ynh_app_id=$ynh_app_id_2
# Third app
else
check_path=$path_3
ynh_app_id=$ynh_app_id_3
fi
# Try to access the app by its url
@ -830,16 +812,13 @@ CHECK_MULTI_INSTANCE () {
elif [ $i -eq 2 ]
then
multi_yunohost_result_2=1
# Third app
else
multi_yunohost_result_3=1
fi
fi
done
# Check the result and print SUCCESS or FAIL
# Succeed if first installation works, and either the second or the third works also
if [ $multi_yunohost_result_1 -eq 0 ] && ( [ $multi_yunohost_result_2 -eq 0 ] || [ $multi_yunohost_result_3 -eq 0 ] )
# Succeed if the 2 installations work;
if [ $multi_yunohost_result_1 -eq 0 ] && [ $multi_yunohost_result_2 -eq 0 ]
then # Success
check_success
RESULT_check_multi_instance=1