From c920e3d5f38efd571efd84ea0f2ed80ba5fb60a8 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Mon, 23 Oct 2017 19:29:15 +0530 Subject: [PATCH 01/13] launcher: fix creation of snap2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When snap1 doesn't exist, `lxc-snapshot` will create a snapshot named `snap1` (instead of `snap2`). In this case we need to rename snap1 into snap2. However the condition check is wrong: after creating the snapshot, `snap1` will *always* exist – even if it didn't before. Thus the renaming never happens. Fix the issue by detecting the absence of snap2 (rather than snap1). --- sub_scripts/launcher.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sub_scripts/launcher.sh b/sub_scripts/launcher.sh index 1b14842..25a001f 100755 --- a/sub_scripts/launcher.sh +++ b/sub_scripts/launcher.sh @@ -84,7 +84,7 @@ create_temp_backup () { # lxc always creates the first snapshot it can creates. # So if snap1 doesn't exist and you try to create snap2, it will be named snap1. - if [ "$snap_number" == "2" ] && [ ! -e "$snapshot_path/snap1" ] + if [ "$snap_number" == "2" ] && [ ! -e "$snapshot_path/snap2" ] then # Rename snap1 to snap2 sudo mv "$snapshot_path/snap1" "$snapshot_path/snap2" From b7c56494511858871280771471c30da34293097a Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sat, 11 Nov 2017 16:53:11 +0100 Subject: [PATCH 02/13] Allow multi-instance without subpath --- README-fr.md | 2 +- README.md | 2 +- package_check.sh | 2 +- sub_scripts/testing_process.sh | 69 ++++++++++++---------------------- 4 files changed, 27 insertions(+), 48 deletions(-) diff --git a/README-fr.md b/README-fr.md index 0c38b71..38dc3ea 100644 --- a/README-fr.md +++ b/README-fr.md @@ -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. diff --git a/README.md b/README.md index 9ed3ce3..b14080e 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/package_check.sh b/package_check.sh index a69ccba..bf5b674 100755 --- a/package_check.sh +++ b/package_check.sh @@ -813,7 +813,7 @@ initialize_values() { all_test=0 # Default path - test_path=/check + test_path=/ } #================================================= diff --git a/sub_scripts/testing_process.sh b/sub_scripts/testing_process.sh index 98a79ea..5654505 100644 --- a/sub_scripts/testing_process.sh +++ b/sub_scripts/testing_process.sh @@ -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 @@ -783,36 +773,28 @@ CHECK_MULTI_INSTANCE () { if [ $i -eq 1 ] then local multi_yunohost_result_1=$yunohost_result - local ynh_app_id_1=$ynh_app_id + local ynh_app_id_1=$ynh_app_id # Second installation elif [ $i -eq 2 ] 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 + local ynh_app_id_2=$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 - ynh_app_id=$ynh_app_id_1 + check_domain=$main_domain + ynh_app_id=$ynh_app_id_1 # Second app elif [ $i -eq 2 ] then - check_path=$path_2 - ynh_app_id=$ynh_app_id_2 - # Third app - else - check_path=$path_3 - ynh_app_id=$ynh_app_id_3 + check_domain=$sub_domain + ynh_app_id=$ynh_app_id_2 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 From abb6d1e7cf97a9ca0e758b4ab0bbbf0776ff2303 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sat, 11 Nov 2017 17:27:44 +0100 Subject: [PATCH 03/13] Print html with lynx instead of curl --- package_check.sh | 7 +++++++ sub_scripts/lxc_build.sh | 4 ++-- sub_scripts/testing_process.sh | 8 ++++---- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/package_check.sh b/package_check.sh index bf5b674..fcb9e32 100755 --- a/package_check.sh +++ b/package_check.sh @@ -254,6 +254,13 @@ EOF # Give the execution right chmod +x "$script_dir/upgrade_script.sh" + # Temporary upgrade fix + # Check if lynx is already installed. + if [ ! -e "$(which lynx)" ] + then + sudo apt-get install -y lynx + fi + # Start the upgrade script by replacement of this process exec "$script_dir/upgrade_script.sh" fi diff --git a/sub_scripts/lxc_build.sh b/sub_scripts/lxc_build.sh index c41c08b..1cb09b7 100755 --- a/sub_scripts/lxc_build.sh +++ b/sub_scripts/lxc_build.sh @@ -71,8 +71,8 @@ echo -e "\e[1m> Update et install lxc lxctl\e[0m" | tee "$LOG_BUILD_LXC" sudo apt-get update >> "$LOG_BUILD_LXC" 2>&1 sudo apt-get install -y lxc lxctl >> "$LOG_BUILD_LXC" 2>&1 -echo -e "\e[1m> Install git curl\e[0m" | tee "$LOG_BUILD_LXC" -sudo apt-get install -y git curl >> "$LOG_BUILD_LXC" 2>&1 +echo -e "\e[1m> Install git, curl and lynx\e[0m" | tee "$LOG_BUILD_LXC" +sudo apt-get install -y git curl lynx >> "$LOG_BUILD_LXC" 2>&1 sudo mkdir -p /var/lib/lxcsnaps # Créer le dossier lxcsnaps, pour s'assurer que lxc utilisera ce dossier, même avec lxc 2. diff --git a/sub_scripts/testing_process.sh b/sub_scripts/testing_process.sh index 5654505..b2fd174 100644 --- a/sub_scripts/testing_process.sh +++ b/sub_scripts/testing_process.sh @@ -288,10 +288,10 @@ CHECK_URL () { ECHO_FORMAT "The connection attempt fall on nginx default page.\n" "white" "bold" clog fi - # Print the first 20 lines of the body - ECHO_FORMAT "Extract of the body:\n" "white" - echo -e "\e[37m" # Write in 'light grey' - grep " Date: Sat, 11 Nov 2017 18:06:53 +0100 Subject: [PATCH 04/13] Allow private test without is_public arg --- sub_scripts/testing_process.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sub_scripts/testing_process.sh b/sub_scripts/testing_process.sh index b2fd174..34dc50b 100644 --- a/sub_scripts/testing_process.sh +++ b/sub_scripts/testing_process.sh @@ -145,7 +145,7 @@ CHECK_URL () { ECHO_FORMAT "\nTry to access by url...\n" "white" "bold" # Force a skipped_uris if public mode is not set - if [ -z "$public_arg" ] + if [ "$install_type" != "private" ] && [ "$install_type" != "public" ] && [ -z "$public_arg" ] then # Add a skipped_uris on / for the app LXC_START "sudo yunohost app setting \"$ynh_app_id\" skipped_uris -v \"/\"" From 0c841b6bbc15efc8667fbcaa9e7857f1b78aa06b Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sun, 12 Nov 2017 19:00:23 +0100 Subject: [PATCH 05/13] Add new feature upgrade from commit --- README-fr.md | 13 +++ README.md | 13 +++ check_process | 5 + package_check.sh | 35 +++++-- sub_scripts/testing_process.sh | 176 ++++++++++++++++++++++----------- 5 files changed, 176 insertions(+), 66 deletions(-) diff --git a/README-fr.md b/README-fr.md index 38dc3ea..3577415 100644 --- a/README-fr.md +++ b/README-fr.md @@ -69,6 +69,7 @@ package_check/package_check.sh APP_ynh setup_private=1 setup_public=1 upgrade=1 + upgrade=1 from_commit=65c382d138596fcb32b4c97c39398815a1dcd4e8 backup_restore=1 multi_instance=1 incorrect_path=1 @@ -88,6 +89,10 @@ package_check/package_check.sh APP_ynh ;;; Options Email= Notification=none +;;; Upgrade options + ; commit=65c382d138596fcb32b4c97c39398815a1dcd4e8 + name=Name of this previous version + manifest_arg=domain=DOMAIN&path=PATH&admin=USER&password=pass&is_public=1& ``` ### `;; Nom du test` Nom du scénario de test qui sera effectué. @@ -118,6 +123,7 @@ Si un test est absent de la liste, il sera ignoré. Cela revient à le noter à - `setup_private`: Installation en privé. - `setup_public`: Installation en public. - `upgrade`: Upgrade du package sur la même version. Test uniquement le script upgrade. +- `upgrade from_commit`: Upgrade du package à partir du commit spécifié vers la dernière version. - `backup_restore`: Backup et restauration. - `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/. @@ -159,6 +165,13 @@ Ces options sont facultatives. - `change` : Envoi un mail seulement si le niveau de l'application a changé. - `all` : Envoi un mail pour chaque test de l'application, quel que ce soit le résultat. +### `;;; Upgrade options` +*Instruction optionnelle* +Pour chaque commit indiqué pour un upgrade, permet d'indiquer un nom pour cette version et les paramètres du manifest à utiliser lors de l'installation préliminaire. +En cas d'absence de nom, le commit sera utilisé. +De même en cas d'absence d'arguments pour le manifest, les arguments du check_process seront utilisés. +> 3 variables doivent être utilisées pour les arguments du manifest, DOMAIN, PATH et USER. + --- Le script `package_check.sh` accepte 6 arguments en plus du package à tester. - `--bash-mode`: Rend le script autonome. Aucune intervention de l'utilisateur ne sera nécessaire. diff --git a/README.md b/README.md index b14080e..212e901 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,7 @@ package_check/package_check.sh APP_ynh setup_private=1 setup_public=1 upgrade=1 + upgrade=1 from_commit=65c382d138596fcb32b4c97c39398815a1dcd4e8 backup_restore=1 multi_instance=1 incorrect_path=1 @@ -88,6 +89,10 @@ package_check/package_check.sh APP_ynh ;;; Options Email= Notification=none +;;; Upgrade options + ; commit=65c382d138596fcb32b4c97c39398815a1dcd4e8 + name=Name of this previous version + manifest_arg=domain=DOMAIN&path=PATH&admin=USER&password=pass&is_public=1& ``` ### `;; Test name` Name of tests series that will be perform. @@ -118,6 +123,7 @@ If a test is not in the list, it will be ignored. It's similar to marked at 0. - `setup_private`: Private installation. - `setup_public`: Public installation. - `upgrade`: Upgrade package on same version. Only test the upgrade script. +- `upgrade from_commit`: Upgrade package from the specified commit to the latest version. - `backup_restore`: Backup then restore. - `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/. @@ -159,6 +165,13 @@ These options are facultative. - `change` : Send an email if the level of this application has changed. - `all` : Send an email for each test on this application, which ever the result. +### `;;; Upgrade options` +*Optionnal instruction* +For each specified commit for an upgrade, allow to give a name for this version and manifest parameters which will be used for the preliminary installation. +In case of lack of name, the commit will be used. +And so on in case of lack of manifest arguments, the default arguments of the check process will be used. +> 3 variables shall be used for the arguments of the manifest, DOMAIN, PATH et USER. + --- The `package_check.sh` script accept 6 arguments in addition of package to be checked. - `--bash-mode`: The script will work without user intervention. diff --git a/check_process b/check_process index a92e6da..bd0968b 100644 --- a/check_process +++ b/check_process @@ -20,6 +20,7 @@ setup_private=1 setup_public=1 upgrade=1 + upgrade=1 from_commit=65c382d138596fcb32b4c97c39398815a1dcd4e8 backup_restore=1 multi_instance=1 incorrect_path=1 @@ -39,3 +40,7 @@ ;;; Options Email= Notification=none +;;; Upgrade options + ; commit=65c382d138596fcb32b4c97c39398815a1dcd4e8 + name=Name of this previous version + manifest_arg=domain=DOMAIN&path=PATH&admin=USER&password=pass&is_public=1& diff --git a/package_check.sh b/package_check.sh index fcb9e32..3dd622c 100755 --- a/package_check.sh +++ b/package_check.sh @@ -498,9 +498,6 @@ if [ ! -d "$package_path" ]; then clean_exit 1 fi -# Remove the .git directory. -rm -rf "$package_path/.git" - @@ -844,7 +841,7 @@ then # Search a string in the partial check_process find_string () { - echo $(grep "$1" "$partial_check_process") + echo $(grep -m1 "$1" "$partial_check_process") } # Extract a section found between $1 and $2 from the file $3 @@ -1016,6 +1013,7 @@ then test "$1" -eq 1 && all_test=$((all_test+1)) } + # Get standard options pkg_linter=$(read_check_option pkg_linter) count_test $pkg_linter setup_sub_dir=$(read_check_option setup_sub_dir) @@ -1028,8 +1026,6 @@ then count_test $setup_private setup_public=$(read_check_option setup_public) count_test $setup_public - upgrade=$(read_check_option upgrade) - count_test $upgrade backup_restore=$(read_check_option backup_restore) count_test $backup_restore multi_instance=$(read_check_option multi_instance) @@ -1053,6 +1049,33 @@ then fi fi + # Clean the upgrade list + > "$script_dir/upgrade_list" + # Get multiples lines for upgrade option. + while $(grep --quiet "^upgrade=" "$partial_check_process") + do + # Get the value for the first upgrade test. + temp_upgrade=$(read_check_option upgrade) + count_test $temp_upgrade + # Set upgrade to 1, but never to 0. + if [ "$upgrade" != "1" ]; then + upgrade=$temp_upgrade + fi + # Get this line to find if there an option. + line=$(find_string "^upgrade=") + if echo "$line" | grep --quiet "from_commit=" + then + # Add the commit to the upgrade list + line="${line##*from_commit=}" + echo "$line" >> "$script_dir/upgrade_list" + else + # Or simply 'current' for a standard upgrade. + echo "current" >> "$script_dir/upgrade_list" + fi + # Remove this line from the check_process + sed --in-place "\|${line}$|d" "$partial_check_process" + done + # Launch all tests successively TESTING_PROCESS # Print the final results of the tests diff --git a/sub_scripts/testing_process.sh b/sub_scripts/testing_process.sh index 34dc50b..d4d393c 100644 --- a/sub_scripts/testing_process.sh +++ b/sub_scripts/testing_process.sh @@ -533,73 +533,129 @@ CHECK_SETUP () { CHECK_UPGRADE () { # Try the upgrade script - unit_test_title "Upgrade..." - - # 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" - # Use a path according to previous succeeded installs - if [ "$previous_install" = "subdir" ]; then - local check_path=$test_path - elif [ "$previous_install" = "root" ]; then - local check_path=/ - fi - replace_manifest_key "path" "$check_path" - replace_manifest_key "user" "$test_user" - replace_manifest_key "public" "$public_public_arg" - - # Install the application in a LXC container - ECHO_FORMAT "\nPreliminary install...\n" "white" "bold" clog - STANDARD_SETUP_APP - - # Check if the install had work - if [ $yunohost_result -ne 0 ] - then - ECHO_FORMAT "\nInstallation failed...\n" "red" "bold" - else - ECHO_FORMAT "\nUpgrade on the same version...\n" "white" "bold" clog - - # Upgrade the application in a LXC container - LXC_START "sudo yunohost --debug app upgrade $ynh_app_id -f \"$package_dir\"" - - # yunohost_result gets the return code of the upgrade - yunohost_result=$? - - # Print the result of the upgrade command - if [ $yunohost_result -eq 0 ]; then - ECHO_FORMAT "Upgrade successful. ($yunohost_result)\n" "white" clog + # Do an upgrade test for each commit in the upgrade list + while read <&4 commit + do + if [ "$commit" == "current" ] + then + unit_test_title "Upgrade from the same version..." else - ECHO_FORMAT "Upgrade failed. ($yunohost_result)\n" "white" clog + # Get the specific section for this upgrade from the check_process + extract_section "^; commit=$commit" "^;" "$check_process" + # Get the name for this upgrade. + upgrade_name=$(grep "^name=" "$partial_check_process" | cut -d'=' -f2) + # Or use the commit if there's no name. + if [ -z "$upgrade_name" ]; then + unit_test_title "Upgrade from the commit $commit..." + else + unit_test_title "Upgrade from $upgrade_name..." + fi fi - # Check all the witness files, to verify if them still here - check_witness_files + # Check if an install have previously work + local previous_install=$(is_install_failed) + # Abort if none install worked + [ "$previous_install" = "1" ] && return - # Analyse the log to extract "warning" and "error" lines - LOG_EXTRACTOR + # Copy original arguments + local manifest_args_mod="$manifest_arguments" - # Try to access the app by its url - CHECK_URL - fi + # Replace manifest key for the test + check_domain=$sub_domain + replace_manifest_key "domain" "$check_domain" + # Use a path according to previous succeeded installs + if [ "$previous_install" = "subdir" ]; then + local check_path=$test_path + elif [ "$previous_install" = "root" ]; then + local check_path=/ + fi + replace_manifest_key "path" "$check_path" + replace_manifest_key "user" "$test_user" + replace_manifest_key "public" "$public_public_arg" - # Check the result and print SUCCESS or FAIL - if check_test_result - then # Success - RESULT_check_upgrade=1 # Upgrade succeed - else # Fail - RESULT_check_upgrade=-1 # Upgrade failed - fi + # Install the application in a LXC container + ECHO_FORMAT "\nPreliminary install...\n" "white" "bold" clog + if [ "$commit" == "current" ] + then + # If no commit is specified, use the current version. + STANDARD_SETUP_APP + else + # Otherwise, use a specific commit + # Backup the modified arguments + update_manifest_args="$manifest_args_mod" + # Get the arguments of the manifest for this upgrade. + manifest_args_mod=$(grep "^manifest_arg=" "$partial_check_process" | cut -d'=' -f2-) + if [ -z "$manifest_args_mod" ]; then + # If there's no specific arguments, use the previous one. + manifest_args_mod="$update_manifest_args" + else + # Otherwise, keep the new arguments, and replace the variables. + manifest_args_mod="${manifest_args_mod//DOMAIN/$check_domain}" + manifest_args_mod="${manifest_args_mod//PATH/$check_path}" + manifest_args_mod="${manifest_args_mod//USER/$test_user}" + fi + # Make a backup of the directory + sudo cp -a "$package_path" "${package_path}_back" + # Change to the specified commit + (cd "$package_path"; git checkout --force --quiet "$commit") + # Install the application + SETUP_APP + # Then replace the backup + sudo rm -r "$package_path" + sudo mv "${package_path}_back" "$package_path" + # And restore the arguments for the manifest + manifest_args_mod="$update_manifest_args" + fi - # Remove the application - REMOVE_APP + # Check if the install had work + if [ $yunohost_result -ne 0 ] + then + ECHO_FORMAT "\nInstallation failed...\n" "red" "bold" + else + ECHO_FORMAT "\nUpgrade...\n" "white" "bold" clog + + # Upgrade the application in a LXC container + LXC_START "sudo yunohost --debug app upgrade $ynh_app_id -f \"$package_dir\"" + + # yunohost_result gets the return code of the upgrade + yunohost_result=$? + + # Print the result of the upgrade command + if [ $yunohost_result -eq 0 ]; then + ECHO_FORMAT "Upgrade successful. ($yunohost_result)\n" "white" clog + else + ECHO_FORMAT "Upgrade failed. ($yunohost_result)\n" "white" clog + fi + + # Check all the witness files, to verify if them still here + check_witness_files + + # Analyse the log to extract "warning" and "error" lines + LOG_EXTRACTOR + + # Try to access the app by its url + CHECK_URL + fi + + # Check the result and print SUCCESS or FAIL + if check_test_result + then # Success + # The global success for an upgrade can't be a success if another upgrade failed + if [ $RESULT_check_upgrade -ne -1 ]; then + RESULT_check_upgrade=1 # Upgrade succeed + fi + else # Fail + RESULT_check_upgrade=-1 # Upgrade failed + fi + + # Remove the application + REMOVE_APP + + # Uses the default snapshot + current_snapshot=snap0 + # Stop and restore the LXC container + LXC_STOP + done 4< "$script_dir/upgrade_list" } CHECK_PUBLIC_PRIVATE () { From 2006e866358885f9bc58b8ee07a4a3d34f6cd993 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Sun, 12 Nov 2017 22:50:03 +0100 Subject: [PATCH 06/13] Typo fix --- sub_scripts/launcher.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sub_scripts/launcher.sh b/sub_scripts/launcher.sh index 25a001f..1341375 100755 --- a/sub_scripts/launcher.sh +++ b/sub_scripts/launcher.sh @@ -78,7 +78,7 @@ create_temp_backup () { # Check if the snapshot already exist if [ ! -e "$snapshot_path/snap$snap_number" ] then - echo "snap$snap_number doesn't exist, its first creation can be take a little while." >&2 + echo "snap$snap_number doesn't exist, its first creation can takes a little while." >&2 # Create the snapshot. sudo lxc-snapshot --name $lxc_name >> "$test_result" 2>&1 From 258dff95ceabbfad8002a59dcadc5c5d1679e27e Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Wed, 15 Nov 2017 19:11:36 +0100 Subject: [PATCH 07/13] Check resources of main page --- sub_scripts/testing_process.sh | 46 ++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/sub_scripts/testing_process.sh b/sub_scripts/testing_process.sh index d4d393c..28b7b98 100644 --- a/sub_scripts/testing_process.sh +++ b/sub_scripts/testing_process.sh @@ -293,6 +293,52 @@ CHECK_URL () { echo -en "\e[37m" # Write in 'light grey' lynx -dump -force_html "$script_dir/url_output" | head --lines 20 | tee --append "$test_result" echo -e "\e[0m" + + # Get all the resources for the main page of the app. + local HTTP_return + local moved=0 + while read HTTP_return + do + # If it's the line with the resource to get + if echo "$HTTP_return" | grep --quiet "^--.*-- http" + then + # Get only the resource itself. + local resource=${HTTP_return##*http*://} + + # Else, if would be the HTTP return code. + else + # If the return code is different than 200. + if ! echo "$HTTP_return" | grep --quiet "200 OK$" + then + # Isolate the http return code. + http_code="${HTTP_return##*awaiting response... }" + http_code="${http_code:0:3}" + # If the return code is 301 or 302, let's check the redirection. + if echo "$HTTP_return" | grep --quiet "30[12] Moved" + then + ECHO_FORMAT "Ressource moved:" "white" + ECHO_FORMAT " $resource\n" + moved=1 + else + ECHO_FORMAT "Resource unreachable (Code $http_code)" "red" "bold" + ECHO_FORMAT " $resource\n" +# curl_error=1 + moved=0 + fi + else + if [ $moved -eq 1 ] + then + if echo "$resource" | grep --quiet "/yunohost/sso/" + then + ECHO_FORMAT "The previous resource is redirected to the YunoHost portal\n" "red" +# curl_error=1 + fi + fi + moved=0 + fi + fi + done <<< "$(LC_ALL=C wget --adjust-extension --page-requisites --no-check-certificate $check_domain$curl_check_path 2>&1 | grep "^--.*-- http\|^HTTP request sent")" + echo "" fi fi done From 582ea0e713cd277d31c3875b4973e82603d61b41 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Wed, 15 Nov 2017 19:28:34 +0100 Subject: [PATCH 08/13] Remove temporary wget dump --- sub_scripts/testing_process.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sub_scripts/testing_process.sh b/sub_scripts/testing_process.sh index 28b7b98..a144985 100644 --- a/sub_scripts/testing_process.sh +++ b/sub_scripts/testing_process.sh @@ -337,7 +337,7 @@ CHECK_URL () { moved=0 fi fi - done <<< "$(LC_ALL=C wget --adjust-extension --page-requisites --no-check-certificate $check_domain$curl_check_path 2>&1 | grep "^--.*-- http\|^HTTP request sent")" + done <<< "$(cd "$package_path"; LC_ALL=C wget --adjust-extension --page-requisites --no-check-certificate $check_domain$curl_check_path 2>&1 | grep "^--.*-- http\|^HTTP request sent")" echo "" fi fi From 0cabde172b3b39d0ae5f6101f7622a3260412229 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Thu, 23 Nov 2017 16:24:17 +0100 Subject: [PATCH 09/13] Fix infinite 503 --- sub_scripts/testing_process.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sub_scripts/testing_process.sh b/sub_scripts/testing_process.sh index d4d393c..c117445 100644 --- a/sub_scripts/testing_process.sh +++ b/sub_scripts/testing_process.sh @@ -248,7 +248,7 @@ CHECK_URL () { ECHO_FORMAT "Service temporarily unavailable\n" "lyellow" "bold" # 3 successive error are allowed http503=$(( http503 + 1 )) - if [ $http503 -eq 3 ]; then + if [ $http503 -ge 3 ]; then # Over 3, it's definitively an error curl_error=1 else From 8d29c0f507f966a583735217d7359c9c20819640 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Thu, 14 Dec 2017 01:01:39 +0100 Subject: [PATCH 10/13] Ignore robots.txt and ynhpanel.js --- sub_scripts/testing_process.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/sub_scripts/testing_process.sh b/sub_scripts/testing_process.sh index 36832e7..1a96d1e 100644 --- a/sub_scripts/testing_process.sh +++ b/sub_scripts/testing_process.sh @@ -139,7 +139,7 @@ REMOVE_APP () { CHECK_URL () { # Try to access the app by its url - + if [ $use_curl -eq 1 ] then ECHO_FORMAT "\nTry to access by url...\n" "white" "bold" @@ -297,8 +297,16 @@ CHECK_URL () { # Get all the resources for the main page of the app. local HTTP_return local moved=0 + local ignored=0 while read HTTP_return do + # Ignore robots.txt and ynhpanel.js. They always redirect to the portal. + if echo "$HTTP_return" | grep --quiet "$check_domain/robots.txt\|$check_domain/ynhpanel.js"; then + ECHO_FORMAT "Ressource ignored:" "white" + ECHO_FORMAT " ${HTTP_return##*http*://}\n" + ignored=1 + fi + # If it's the line with the resource to get if echo "$HTTP_return" | grep --quiet "^--.*-- http" then @@ -310,6 +318,12 @@ CHECK_URL () { # If the return code is different than 200. if ! echo "$HTTP_return" | grep --quiet "200 OK$" then + # Skipped the check of ignored ressources. + if [ $ignored -eq 1 ] + then + ignored=0 + continue + fi # Isolate the http return code. http_code="${HTTP_return##*awaiting response... }" http_code="${http_code:0:3}" From eba357cc626d4672a01001bdbaa4d4e0c4a88cc5 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Fri, 15 Dec 2017 17:02:01 +0100 Subject: [PATCH 11/13] from_yuno not needed anymore ? --- package_check.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/package_check.sh b/package_check.sh index 3dd622c..af6701d 100755 --- a/package_check.sh +++ b/package_check.sh @@ -1354,9 +1354,10 @@ if [ $type_exec_env -ge 1 ] && [ $send_mail -eq 1 ] then # Add a 'from' header for the official CI only. - if [ $type_exec_env -eq 2 ]; then - from_yuno="-a \"From: yunohost@yunohost.org\"" - fi +# Apparently, this trick is not needed anymore !? +# if [ $type_exec_env -eq 2 ]; then +# from_yuno="-a \"From: yunohost@yunohost.org\"" +# fi # Get the maintainer email from the manifest. If it doesn't found if the check_process if [ -z "$dest" ]; then From eafcc5b1772b7889e08af4fcd56c75da0ac53b8e Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Fri, 15 Dec 2017 19:28:58 +0100 Subject: [PATCH 12/13] Set the variable PACKAGE_CHECK_EXEC --- sub_scripts/testing_process.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sub_scripts/testing_process.sh b/sub_scripts/testing_process.sh index 1a96d1e..01ade8c 100644 --- a/sub_scripts/testing_process.sh +++ b/sub_scripts/testing_process.sh @@ -54,7 +54,7 @@ SETUP_APP () { fi # Install the application in a LXC container - LXC_START "sudo yunohost --debug app install \"$package_dir\" -a \"$manifest_args_mod\"" + LXC_START "sudo PACKAGE_CHECK_EXEC=1 yunohost --debug app install \"$package_dir\" -a \"$manifest_args_mod\"" # yunohost_result gets the return code of the installation yunohost_result=$? @@ -117,7 +117,7 @@ REMOVE_APP () { ECHO_FORMAT "\nDeleting...\n" "white" "bold" clog # Remove the application from the LXC container - LXC_START "sudo yunohost --debug app remove \"$ynh_app_id\"" + LXC_START "sudo PACKAGE_CHECK_EXEC=1 yunohost --debug app remove \"$ynh_app_id\"" # yunohost_remove gets the return code of the deletion yunohost_remove=$? @@ -675,7 +675,7 @@ CHECK_UPGRADE () { ECHO_FORMAT "\nUpgrade...\n" "white" "bold" clog # Upgrade the application in a LXC container - LXC_START "sudo yunohost --debug app upgrade $ynh_app_id -f \"$package_dir\"" + LXC_START "sudo PACKAGE_CHECK_EXEC=1 yunohost --debug app upgrade $ynh_app_id -f \"$package_dir\"" # yunohost_result gets the return code of the upgrade yunohost_result=$? @@ -1118,7 +1118,7 @@ CHECK_BACKUP_RESTORE () { ECHO_FORMAT "\nBackup of the application...\n" "white" "bold" clog # Made a backup of the application - LXC_START "sudo yunohost --debug backup create -n Backup_test --apps $ynh_app_id --system $backup_hooks" + LXC_START "sudo PACKAGE_CHECK_EXEC=1 yunohost --debug backup create -n Backup_test --apps $ynh_app_id --system $backup_hooks" # yunohost_result gets the return code of the backup yunohost_result=$? @@ -1185,7 +1185,7 @@ CHECK_BACKUP_RESTORE () { fi # Restore the application from the previous backup - LXC_START "sudo yunohost --debug backup restore Backup_test --force --apps $ynh_app_id" + LXC_START "sudo PACKAGE_CHECK_EXEC=1 yunohost --debug backup restore Backup_test --force --apps $ynh_app_id" # yunohost_result gets the return code of the restore yunohost_result=$? @@ -1323,7 +1323,7 @@ CHECK_CHANGE_URL () { ECHO_FORMAT "Change the url from $sub_domain$check_path to $new_domain$new_path...\n" "white" "bold" clog # Change the url - LXC_START "sudo yunohost --debug app change-url $ynh_app_id -d \"$new_domain\" -p \"$new_path\"" + LXC_START "sudo PACKAGE_CHECK_EXEC=1 yunohost --debug app change-url $ynh_app_id -d \"$new_domain\" -p \"$new_path\"" # yunohost_result gets the return code of the change-url script yunohost_result=$? From 9dfa0a53df061f32c7494b9d23168138cf201947 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Mon, 18 Dec 2017 22:25:19 +0100 Subject: [PATCH 13/13] Fix issue with apparmor --- sub_scripts/lxc_build.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sub_scripts/lxc_build.sh b/sub_scripts/lxc_build.sh index 1cb09b7..2a56c57 100755 --- a/sub_scripts/lxc_build.sh +++ b/sub_scripts/lxc_build.sh @@ -80,6 +80,8 @@ if sudo lxc-info -n $LXC_NAME > /dev/null 2>&1 then # Si le conteneur existe déjà echo -e "\e[1m> Suppression du conteneur existant.\e[0m" | tee -a "$LOG_BUILD_LXC" sudo lxc-snapshot -n $LXC_NAME -d snap0 | tee -a "$LOG_BUILD_LXC" + sudo lxc-snapshot -n $LXC_NAME -d snap1 | tee -a "$LOG_BUILD_LXC" + sudo lxc-snapshot -n $LXC_NAME -d snap2 | tee -a "$LOG_BUILD_LXC" sudo rm -f /var/lib/lxcsnaps/$LXC_NAME/snap0.tar.gz | tee -a "$LOG_BUILD_LXC" sudo lxc-destroy -n $LXC_NAME -f | tee -a "$LOG_BUILD_LXC" fi @@ -124,6 +126,9 @@ if [ $dnsforce -eq 1 ]; then # Force la réécriture du resolv.conf echo "nameserver $dns" | sudo tee /var/lib/lxc/$LXC_NAME/rootfs/etc/resolv.conf fi +# Fix an issue with apparmor when the container start. +echo -e "\n# Fix apparmor issues\nlxc.aa_profile = unconfined" | sudo tee -a /var/lib/lxc/$LXC_NAME/config >> "$LOG_BUILD_LXC" 2>&1 + echo -e "\e[1m> Démarrage de la machine\e[0m" | tee -a "$LOG_BUILD_LXC" sudo lxc-start -n $LXC_NAME -d --logfile "$script_dir/lxc_boot.log" >> "$LOG_BUILD_LXC" 2>&1 sleep 3