mirror of
https://github.com/YunoHost/package_check.git
synced 2024-09-03 20:06:20 +02:00
Add new tests for actions and config_pane
This commit is contained in:
parent
176c9de776
commit
a5768bd046
6 changed files with 529 additions and 86 deletions
53
README-fr.md
53
README-fr.md
|
@ -1,7 +1,7 @@
|
|||
Package checker for YunoHost
|
||||
Package checker pour YunoHost
|
||||
==================
|
||||
|
||||
[Yunohost project](https://yunohost.org/#/)
|
||||
[Projet YunoHost](https://yunohost.org/#/)
|
||||
|
||||
> [Read this readme in english](README.md)
|
||||
|
||||
|
@ -14,16 +14,19 @@ Le script est capable d'effectuer les tests suivant:
|
|||
- Installation en sous-dossier
|
||||
- Installation à la racine du domaine
|
||||
- Installation sans accès par url (Pour les applications n'ayant pas d'interface web)
|
||||
- Désinstallation
|
||||
- Réinstallation après désinstallation
|
||||
- Installation en privé
|
||||
- Installation en public
|
||||
- Upgrade sur la même version du package
|
||||
- Upgrade depuis la même version du package
|
||||
- Upgrade depuis une précédente version du package
|
||||
- Backup
|
||||
- Restore après suppression de l'application
|
||||
- Restore sans installation préalable
|
||||
- Installation multi-instance
|
||||
- Test de path mal formé (path/ au lieu de /path)
|
||||
- Test de port déjà utilisé
|
||||
- Test du script change_url
|
||||
- Test des actions et configurations disponible dans le config-panel
|
||||
|
||||
Package check utilise un conteneur LXC pour créer un environnement de test propre sans résidus d'installations précédentes.
|
||||
|
||||
|
@ -35,11 +38,12 @@ Il est nécessaire de fournir, à la racine du package de l'app à tester, un fi
|
|||
Si ce fichier n'est pas présent, package_check sera utilisé en mode dégradé. Il va tenter de repérer les arguments domain, path et admin dans le manifest pour exécuter un nombre restreint de test, en fonction des arguments trouvés.
|
||||
|
||||
---
|
||||
## Déploiement du script de test
|
||||
## Déploiement de package_check
|
||||
|
||||
```
|
||||
git clone https://github.com/YunoHost/package_check
|
||||
package_check/sub_scripts/lxc_build.sh
|
||||
|
||||
package_check/package_check.sh APP_ynh
|
||||
```
|
||||
|
||||
|
@ -61,6 +65,15 @@ package_check/package_check.sh APP_ynh
|
|||
is_public=1 (PUBLIC|public=1|private=0)
|
||||
password="password"
|
||||
port="666" (PORT)
|
||||
; Actions
|
||||
action_argument=arg1|arg2
|
||||
is_public=1|0
|
||||
; Config_panel
|
||||
main.categorie.config_example=arg1|arg2
|
||||
main.overwrite_files.overwrite_phpfpm=1|0
|
||||
main.php_fpm_config.footprint=low|medium|high|specific
|
||||
main.php_fpm_config.free_footprint=20
|
||||
main.php_fpm_config.usage=low|medium|high
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_sub_dir=1
|
||||
|
@ -72,9 +85,10 @@ package_check/package_check.sh APP_ynh
|
|||
upgrade=1 from_commit=65c382d138596fcb32b4c97c39398815a1dcd4e8
|
||||
backup_restore=1
|
||||
multi_instance=1
|
||||
incorrect_path=1
|
||||
port_already_use=1 (XXXX)
|
||||
change_url=1
|
||||
actions=1
|
||||
config_panel=1
|
||||
;;; Levels
|
||||
Level 5=auto
|
||||
;;; Options
|
||||
|
@ -99,16 +113,31 @@ Toutes les commandes ajoutées après l'instruction `; pre-install` seront exéc
|
|||
Ensemble des clés du manifest.
|
||||
Toutes les clés du manifest doivent être renseignée afin de procéder à l'installation.
|
||||
> Les clés de manifest données ici ne le sont qu'à titre d'exemple. Voir le manifest de l'application.
|
||||
|
||||
Certaines clés de manifest sont indispensables au script pour effectuer certains test. Ces clés doivent être mises en évidence afin que le script soit capable de les retrouver et de changer leur valeur.
|
||||
`(DOMAIN)`, `(PATH)`, `(USER)` et `(PORT)` doivent être mis en bout de ligne des clés correspondantes. Ces clés seront modifiées par le script.
|
||||
`(PUBLIC|public=1|private=0)` doit, en plus de correspondre à la clé de visibilité public, indiquer les valeurs du manifest pour public et privé.
|
||||
|
||||
### `; Actions`
|
||||
List des arguments pour chaque action nécessitant un argument.
|
||||
`action_argument` est le nom de l'argument, ainsi que vous pouvez le trouver à la fin de [action.arguments.**action_argument**].
|
||||
`arg1|arg2` sont les différents arguments à utiliser pour les test. Vous pouvez mettre autant d'arguments que désiré, séparé par `|`.
|
||||
|
||||
*Seul `actions.toml` peut être testé par package_check, pas `actions.json`.*
|
||||
|
||||
### `; Config_panel`
|
||||
List des arguments pour chaque configuration de config_panel.
|
||||
`main.categorie.config_example` est l'entrée toml complète pour l'argument de cette configuration.
|
||||
`arg1|arg2` sont les différents arguments à utiliser pour les test. Vous pouvez mettre autant d'arguments que désiré, séparé par `|`.
|
||||
|
||||
*Seul `config_panel.toml` peut être testé par package_check, pas `config_panel.json`.*
|
||||
|
||||
### `; Checks`
|
||||
Ensemble des tests à effectuer.
|
||||
Chaque test marqué à 1 sera effectué par le script.
|
||||
Si un test est absent de la liste, il sera ignoré. Cela revient à le noter à 0.
|
||||
- `pkg_linter`: Vérification du package avec [package linter](https://github.com/YunoHost/package_linter)
|
||||
- `setup_sub_dir`: Installation dans le path /check.
|
||||
- `setup_sub_dir`: Installation dans un path.
|
||||
- `setup_root`: Installation à la racine du domaine.
|
||||
- `setup_nourl`: Installation sans accès http. Ce test ne devrait être choisi que pour les applications ne disposant pas d'une interface web.
|
||||
- `setup_private`: Installation en privé.
|
||||
|
@ -117,15 +146,15 @@ Si un test est absent de la liste, il sera ignoré. Cela revient à le noter à
|
|||
- `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/.
|
||||
- `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.
|
||||
Le numéro de port doit alors être noté entre parenthèse, il servira au test de port.
|
||||
- `change_url`: Test le script change_url de 6 manières différentes, Root vers un path, path vers un autre path et path vers root. Et la même chose avec un autre domaine.
|
||||
- `actions`: Toutes les actions disponible dans actions.toml
|
||||
- `config_panel`: Toutes les configurations disponible dans config_panel.toml
|
||||
|
||||
### `;;; Levels`
|
||||
|
||||
Les [niveaux](https://yunohost.org/#/packaging_apps_levels_fr) 1 à 7 sont déterminés automatiquement.
|
||||
Les [niveaux](https://yunohost.org/#/packaging_apps_levels_fr) 1 à 8 sont déterminés automatiquement.
|
||||
A l'exception du niveau 5, vous ne pouvez plus forcer une valeur pour un niveau.
|
||||
Le niveau 5 est déterminé par les résultats de [package linter](https://github.com/YunoHost/package_linter).
|
||||
La valeur par défaut pour ce niveau est `auto`, cependant, si nécessaire, vous pouvez forcer la valeur pour ce niveau en la fixant à `1`, pour un résultat positif, ou à `0`, pour un résultat négatif.
|
||||
|
@ -164,11 +193,11 @@ Le script `package_check.sh` accepte 6 arguments en plus du package à tester.
|
|||
Package check utilise la virtualisation en conteneur pour assurer l'intégrité de l'environnement de test.
|
||||
L'usage de LXC apporte une meilleure stabilité au processus de test, un test de suppression échoué n'entraine pas l'échec des tests suivant, et permet de garder un environnement de test sans résidus de test précédents. En revanche, l'usage de LXC augmente la durée des tests, en raison des manipulations du conteneur et de la réinstallation systématique des dépendances de l'application.
|
||||
|
||||
Il faut prévoir également un espace suffisant sur l'hôte, au minimum 4Go pour le conteneur, son snapshot et sa copie de sauvegarde.
|
||||
Il faut prévoir également un espace suffisant sur l'hôte, au minimum 6Go pour le conteneur, ses snapshots et sa copie de sauvegarde.
|
||||
|
||||
L'usage de LXC est facilité par 4 scripts, permettant de gérer la création, la mise à jour, la suppression et la réparation du conteneur.
|
||||
- `lxc_build.sh`: lxc_build installe LXC et ses dépendances, puis créer le conteneur debian.
|
||||
Il ajoute ensuite le support réseau, installe Yunohost et le configure. Et enfin configure un accès ssh.
|
||||
Il ajoute ensuite le support réseau, installe YunoHost et le configure. Et enfin configure un accès ssh.
|
||||
L'accès ssh par défaut est `ssh -t pchecker_lxc`
|
||||
- `lxc_upgrade.sh`: Effectue la mise à jour du conteneur à l'aide d'apt-get et recréer le snapshot.
|
||||
- `lxc_remove.sh`: Supprime le conteneur LXC, son snapshot et sa sauvegarde. Désinstalle LXC et déconfigure le réseau associé.
|
||||
|
|
166
README.md
166
README.md
|
@ -1,66 +1,79 @@
|
|||
Package checker for YunoHost
|
||||
==================
|
||||
|
||||
[Yunohost project](https://yunohost.org/#/)
|
||||
[YunoHost project](https://yunohost.org/#/)
|
||||
|
||||
> [Lire ce readme en francais](README-fr.md)
|
||||
|
||||
Set of unit tests for check Yunohost packages.
|
||||
The `package_check.sh` script perform a series of tests on a package for check its capability to install and remove in différents cases.
|
||||
The tests results are print directly in the terminal and stored in the log file Test_results.log
|
||||
Set of unit tests to check YunoHost packages.
|
||||
The `package_check.sh` script perform a series of tests on a package for verify its capability to be installed and removed in different situation.
|
||||
The test results are printed directly in the terminal and stored in the log file Test_results.log
|
||||
|
||||
The script is able to perform following tests:
|
||||
The script is able to perform the following tests:
|
||||
- Check the package with [package linter](https://github.com/YunoHost/package_linter)
|
||||
- Installation in a subdir
|
||||
- Installation at root of domain
|
||||
- Installation at the root of a domain
|
||||
- Installation without url access (For apps without web UI)
|
||||
- Private installation.
|
||||
- Uninstallation
|
||||
- Reinstallation after uninstallation
|
||||
- Private installation
|
||||
- Public installation
|
||||
- Upgrade on same package version
|
||||
- Upgrade from same version of the package
|
||||
- Upgrade from a previous version of the package
|
||||
- Backup
|
||||
- Restore after application uninstall
|
||||
- Restore without installation before
|
||||
- Restore the application after uninstallation
|
||||
- Restoration without an previous installation
|
||||
- Multi-instances installation
|
||||
- Test malformed path (path/ instead od /path)
|
||||
- Test port already use
|
||||
- Test with the port already used
|
||||
- Test of change_url script
|
||||
- Test of all actions and configurations available in config-panel
|
||||
|
||||
Package_check script use an LXC container to manipulate the package in a non parasited environment by previous installs.
|
||||
Package_check script uses a LXC container to manipulate the package in a clean environment without any previous installations.
|
||||
|
||||
Usage:
|
||||
For an app in a dir: `./package_check.sh APP_ynh`
|
||||
For an app on github: `./package_check.sh https://github.com/USER/APP_ynh`
|
||||
For a package in a directory: `./package_check.sh APP_ynh`
|
||||
For a package on GitHub: `./package_check.sh https://github.com/YunoHost-Apps/APP_ynh`
|
||||
|
||||
It's necessary to provide, at the root of package to be tested, a `check_process` file for inform the script of needed arguments and tests to perform.
|
||||
If this file is not present, package_check will be used in downgraded mode. It will try to retrieve domain, path and admin user arguments in the manifest and execute some tests, based on the arguments found.
|
||||
You need to provide, at the root of the package, a `check_process` file to help the script to test the package with the correct arguments.
|
||||
If this file is not present, package_check will be used in downgraded mode. It will try to retrieve domain, path and admin user arguments in the manifest and execute some tests, based on the arguments it can find.
|
||||
|
||||
---
|
||||
## Deploying test script
|
||||
## Deploying package_check
|
||||
|
||||
```
|
||||
git clone https://github.com/YunoHost/package_check
|
||||
package_check/sub_scripts/lxc_build.sh
|
||||
|
||||
package_check/package_check.sh APP_ynh
|
||||
```
|
||||
|
||||
---
|
||||
## Syntax `check_process` file
|
||||
> Except space, this file syntax must be respected.
|
||||
## Syntax of `check_process`
|
||||
> Except spaces, the syntax of this file must be respected.
|
||||
|
||||
```
|
||||
;; Test name
|
||||
# Comment ignored
|
||||
; pre-install
|
||||
echo -n "Here your commands to execute in the container, "
|
||||
echo "before each installation of the app."
|
||||
echo -n "Here your commands to execute in the container"
|
||||
echo ", before each installation of the app."
|
||||
; Manifest
|
||||
domain="domain.tld" (DOMAIN)
|
||||
path="/path" (PATH)
|
||||
admin="john" (USER)
|
||||
language="en"
|
||||
language="fr"
|
||||
is_public=1 (PUBLIC|public=1|private=0)
|
||||
password="password"
|
||||
port="666" (PORT)
|
||||
; Actions
|
||||
action_argument=arg1|arg2
|
||||
is_public=1|0
|
||||
; Config_panel
|
||||
main.categorie.config_example=arg1|arg2
|
||||
main.overwrite_files.overwrite_phpfpm=1|0
|
||||
main.php_fpm_config.footprint=low|medium|high|specific
|
||||
main.php_fpm_config.free_footprint=20
|
||||
main.php_fpm_config.usage=low|medium|high
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_sub_dir=1
|
||||
|
@ -72,9 +85,10 @@ package_check/package_check.sh APP_ynh
|
|||
upgrade=1 from_commit=65c382d138596fcb32b4c97c39398815a1dcd4e8
|
||||
backup_restore=1
|
||||
multi_instance=1
|
||||
incorrect_path=1
|
||||
port_already_use=1 (XXXX)
|
||||
change_url=1
|
||||
actions=1
|
||||
config_panel=1
|
||||
;;; Levels
|
||||
Level 5=auto
|
||||
;;; Options
|
||||
|
@ -86,9 +100,9 @@ Notification=none
|
|||
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&password=pass&is_public=1&
|
||||
```
|
||||
### `;; Test name`
|
||||
Name of tests series that will be perform.
|
||||
A name for the series of tests to perform.
|
||||
It's possible to create multiple tests series, all with the same syntax.
|
||||
All different tests series will be perform sequentialy.
|
||||
All different series will be performed sequentially.
|
||||
|
||||
### `; pre-install`
|
||||
*Optional instruction*
|
||||
|
@ -96,36 +110,52 @@ If you have to execute a command or a group of commands before the installation.
|
|||
All the commands added after the instruction `; pre-install` will be executed in the container before each installation of the app.
|
||||
|
||||
### `; Manifest`
|
||||
Set of manifest keys.
|
||||
All manifest keys need to be filled to perform installation.
|
||||
> The manifest keys filled here are simply an exemple. Check the app's manifest.
|
||||
Some manifest keys are necessary for the script to performs some tests. This keys must be highlighted for the script is able to find them and modify their values.
|
||||
`(DOMAIN)`, `(PATH)`, `(USER)` and `(PORT)` must be placed at the end of corresponding key. This key will be changed by the script.
|
||||
`(PUBLIC|public=1|private=0)` must, in addition to match the public key, indicate the values for public and private.
|
||||
List of manifest keys.
|
||||
All manifest keys need to be filled to perform the installation.
|
||||
> The manifest keys already in the file here are simply examples. Check the package manifest.
|
||||
|
||||
Some manifest keys are mandatory for the script to performs some tests. This keys must be highlighted, so the script is able to find them and modify their values.
|
||||
`(DOMAIN)`, `(PATH)`, `(USER)` and `(PORT)` must be placed at the end of corresponding key. These keys will be changed by the script.
|
||||
`(PUBLIC|public=1|private=0)` must, aside of marking the public key, indicate the values for public and private.
|
||||
|
||||
### `; Actions`
|
||||
List of arguments for each action that needs an argument.
|
||||
`action_argument` is the name of the argument, as you can find at the end of [action.arguments.**action_argument**].
|
||||
`arg1|arg2` are the different arguments to use for the tests. You can have as many arguments as you want, each separated by `|`.
|
||||
|
||||
*Only `actions.toml` can be tested by package_check, not `actions.json`.*
|
||||
|
||||
### `; Config_panel`
|
||||
List of arguments for each config_panel configuration.
|
||||
`main.categorie.config_example` is the complete toml entry for the argument of a configuration.
|
||||
`arg1|arg2` are the different arguments to use for the tests. You can as many arguments as you want, each separated by `|`.
|
||||
|
||||
*Only `config_panel.toml` can be tested by package_check, not `config_panel.json`.*
|
||||
|
||||
### `; Checks`
|
||||
Set of tests to perform.
|
||||
Each test marked à 1 will be perform by the script.
|
||||
If a test is not in the list, it will be ignored. It's similar to marked at 0.
|
||||
List of tests to perform.
|
||||
Each test set to 1 will be performed by the script.
|
||||
If a test is not in the list, it will be ignored. It's similar to set the test at 0.
|
||||
- `pkg_linter`: Check the package with [package linter](https://github.com/YunoHost/package_linter)
|
||||
- `setup_sub_dir`: Installation in the path /check.
|
||||
- `setup_root`: Installation at the root of domain.
|
||||
- `setup_nourl`: Installation without http access. This test should be perform only for apps that not have web interface.
|
||||
- `setup_sub_dir`: Installation in a path.
|
||||
- `setup_root`: Installation at the root of a domain.
|
||||
- `setup_nourl`: Installation without http access. This test should be perform only for apps that does not have a web interface.
|
||||
- `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.
|
||||
- `upgrade`: Upgrade the package to the same version. Only to test the upgrade script.
|
||||
- `upgrade from_commit`: Upgrade the 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/.
|
||||
- `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.
|
||||
The port number must be written into parentheses, it will serve to test port.
|
||||
- `change_url`: Try to change the url by 6 different way. Root to path, path to another path and path to root. And the same thing, with another domain.
|
||||
- `multi_instance`: Install the application 2 times, to verify its ability to be multi-instanced.
|
||||
- `port_already_use`: Provoke an error by opening the port before.
|
||||
The `port_already_use` test may eventually take as argument the port number.
|
||||
The port number must be written into parentheses.
|
||||
- `change_url`: Try to change the url by 6 different ways. Root to path, path to another path and path to root. And the same thing, to another domain.
|
||||
- `actions`: All actions available in actions.toml
|
||||
- `config_panel`: All configurations available in config_panel.toml
|
||||
|
||||
### `;;; Levels`
|
||||
From [levels](https://yunohost.org/#/packaging_apps_levels_fr) 1 to 7, levels are determined automatically.
|
||||
Except for the level 5, you can't force a value for a level anymore.
|
||||
From [levels](https://yunohost.org/#/packaging_apps_levels_fr) 1 to 8, levels are determined automatically.
|
||||
Except the level 5, you can't force a value for a level anymore.
|
||||
The level 5 is determined by the results of [package linter](https://github.com/YunoHost/package_linter).
|
||||
The default value for this level is `auto`, however, if needed, you can force the value for this level by setting it at `1`, for a positive result, or at `0`, for a negative one.
|
||||
If you do so, please add a comment to justify why you force this level.
|
||||
|
@ -134,41 +164,41 @@ If you do so, please add a comment to justify why you force this level.
|
|||
Supplementary options available in the check_process.
|
||||
These options are facultative.
|
||||
|
||||
- `Email` : Allow to specify an alternative email than this is in the manifest for notification by package check, when it's in a context of continuous integration.
|
||||
- `Notification` : Grade of notification for this application. There are 3 available levels.
|
||||
- `down` : Send an email only if the level of this application has decreased.
|
||||
- `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.
|
||||
- `Email` : Allow to specify an alternative email than the one in the manifest for notification by package check, when in a context of a continuous integration server.
|
||||
- `Notification` : Level of notification for this package. There are 3 available levels.
|
||||
- `down` : Send an email only if the level of the package has decreased.
|
||||
- `change` : Send an email if the level of the package has changed.
|
||||
- `all` : Send an email for each test on this package, whatever 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.
|
||||
*Optional instruction*
|
||||
For each specified commit for an upgrade, allow to give a name for this version and the manifest parameters which will be used for the preliminary installation.
|
||||
If there's no name specified, the commit will be used.
|
||||
And if there's no manifest arguments, the default arguments of the check process will be used.
|
||||
> 3 variables have to be used for the arguments of the manifest, DOMAIN, PATH and USER.
|
||||
|
||||
---
|
||||
The `package_check.sh` script accept 6 arguments in addition of package to be checked.
|
||||
The `package_check.sh` script accept 6 arguments in addition of the package to be checked.
|
||||
- `--bash-mode`: The script will work without user intervention.
|
||||
auto_remove value is ignored
|
||||
- `--branch=branch-name`: Check a branch of the repository instead of master. Allow to check a pull request.
|
||||
- `--build-lxc`: Install LXC and create the Debian Yunohost container if necessary.
|
||||
- `--force-install-ok`: Force success of installation, even if they fail. Allow to perform following tests even if installation fail.
|
||||
- `--build-lxc`: Install LXC and create the Debian YunoHost container if necessary.
|
||||
- `--force-install-ok`: Force success of installations, even if they fail. Allow to perform following tests even if an installation fails.
|
||||
- `--interrupt`: Force auto_remove value, break before each remove.
|
||||
- `--help`: Display help.
|
||||
|
||||
---
|
||||
## LXC
|
||||
|
||||
Package check use virtualization in container for ensure integrity of test environnement.
|
||||
Using LXC provides better stability to test process, a failed remove test doesn't failed the following tests and provides a test environnement without residues of previous tests. However, using LXC increases the durations of tests, because of the manipulations of container and installed app dépendancies.
|
||||
Package check uses the virtualization in containers to ensure the integrity of the testing environment.
|
||||
Using LXC provides a better stability to the test process, a failed test doesn't impact the following tests and provides a testing environment without residues of previous tests. However, using LXC increases the length of tests, because of the manipulations of the container and reinstallations of dependencies.
|
||||
|
||||
There must also be enough space on the host, at least 4GB for the container, its snapshot and backup.
|
||||
It uses also some space on the host, at least 6GB for the container, its snapshots and backup have to available.
|
||||
|
||||
Using LXC is simplified by 4 scripts, allowing to manage the creation, updating, deleting and repairing of container.
|
||||
Using LXC is eased by 4 scripts, allowing to manage the creation, update, deletion and repair of the container.
|
||||
- `lxc_build.sh`: lxc_build install LXC and its dependencies, then create a Debian container.
|
||||
It add network support, install Yunohost and configure it. And then configure ssh.
|
||||
It add network support, install YunoHost and configure it. And then configure ssh.
|
||||
The default ssh access is `ssh -t pchecker_lxc`
|
||||
- `lxc_upgrade.sh`: Perform a upgrade of the container with apt-get and recreate the snapshot.
|
||||
- `lxc_remove.sh`: Delete the LXC container, its snapshot and backup. Uninstall LXC and deconfigures the associated network.
|
||||
- `lxc_upgrade.sh`: Perform an upgrade of the container with apt-get and recreate the snapshot.
|
||||
- `lxc_remove.sh`: Delete the LXC container, its snapshots and backup. Uninstall LXC and deconfigure the associated network.
|
||||
- `lxc_check.sh`: Check the LXC container and try to fix it if necessary.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
;; Nom du test
|
||||
# Commentaire ignoré
|
||||
;; Test name
|
||||
# Comment ignored
|
||||
; pre-install
|
||||
echo -n "Here your commands to execute in the container"
|
||||
echo ", before each installation of the app."
|
||||
|
@ -8,10 +8,18 @@
|
|||
path="/path" (PATH)
|
||||
admin="john" (USER)
|
||||
language="fr"
|
||||
# is_public="Yes" (PUBLIC|public=Yes|private=No)
|
||||
is_public=1 (PUBLIC|public=1|private=0)
|
||||
password="password"
|
||||
port="666" (PORT)
|
||||
; Actions
|
||||
action_argument=arg1|arg2
|
||||
is_public=1|0
|
||||
; Config_panel
|
||||
main.categorie.config_example=arg1|arg2
|
||||
main.overwrite_files.overwrite_phpfpm=1|0
|
||||
main.php_fpm_config.footprint=low|medium|high|specific
|
||||
main.php_fpm_config.free_footprint=20
|
||||
main.php_fpm_config.usage=low|medium|high
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_sub_dir=1
|
||||
|
@ -23,10 +31,10 @@
|
|||
upgrade=1 from_commit=65c382d138596fcb32b4c97c39398815a1dcd4e8
|
||||
backup_restore=1
|
||||
multi_instance=1
|
||||
# This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version.
|
||||
# incorrect_path=1
|
||||
port_already_use=1 (66)
|
||||
change_url=0
|
||||
actions=0
|
||||
config_panel=0
|
||||
;;; Levels
|
||||
# If the level 5 (Package linter) is forced to 1. Please add justifications here.
|
||||
Level 5=auto
|
||||
|
|
|
@ -559,6 +559,7 @@ TEST_RESULTS () {
|
|||
print_result "Backup" $RESULT_check_backup
|
||||
print_result "Restore" $RESULT_check_restore
|
||||
print_result "Change URL" $RESULT_change_url
|
||||
print_result "Actions and config-panel" $RESULT_action_config_panel
|
||||
|
||||
|
||||
|
||||
|
@ -718,7 +719,8 @@ TEST_RESULTS () {
|
|||
[ $RESULT_check_port -ne -1 ] && \
|
||||
[ $RESULT_check_backup -ne -1 ] && \
|
||||
[ $RESULT_check_restore -ne -1 ] && \
|
||||
[ $RESULT_change_url -ne -1 ]
|
||||
[ $RESULT_change_url -ne -1 ] && \
|
||||
[ $RESULT_action_config_panel -ne -1 ]
|
||||
then level[7]=2
|
||||
else level[7]=0
|
||||
fi
|
||||
|
@ -899,6 +901,7 @@ initialize_values() {
|
|||
RESULT_check_path=0
|
||||
RESULT_check_port=0
|
||||
RESULT_change_url=0
|
||||
RESULT_action_config_panel=0
|
||||
|
||||
# auto_remove parameter
|
||||
if [ $interrupt -eq 1 ]; then
|
||||
|
@ -912,6 +915,10 @@ initialize_values() {
|
|||
|
||||
# Default path
|
||||
test_path=/
|
||||
|
||||
# CHECK_URL default values
|
||||
curl_error=0
|
||||
yuno_portal=0
|
||||
}
|
||||
|
||||
#=================================================
|
||||
|
@ -1086,6 +1093,38 @@ then
|
|||
LIGNE=$(echo "$LIGNE" | cut -d '(' -f1) # Retire l'indicateur de clé de manifest à la fin de la ligne
|
||||
fi
|
||||
|
||||
# Parse all infos about arguments of actions.toml
|
||||
# Extract the actions arguments section from the second partial file
|
||||
extract_section "^; Actions" "^; " "$partial2"
|
||||
|
||||
# Initialize the arguments list
|
||||
actions_arguments=""
|
||||
|
||||
# Read each arguments and store them
|
||||
while read line
|
||||
do
|
||||
# Remove all double quotes
|
||||
add_arg="${line//\"/}"
|
||||
# Then add this argument and follow it by :
|
||||
actions_arguments="${actions_arguments}${add_arg}:"
|
||||
done < "$partial_check_process"
|
||||
|
||||
# Parse all infos about arguments of config-panel.toml
|
||||
# Extract the config_panel arguments section from the second partial file
|
||||
extract_section "^; Config_panel" "^; " "$partial2"
|
||||
|
||||
# Initialize the arguments list
|
||||
config_panel_arguments=""
|
||||
|
||||
# Read each arguments and store them
|
||||
while read line
|
||||
do
|
||||
# Remove all double quotes
|
||||
add_arg="${line//\"/}"
|
||||
# Then add this argument and follow it by :
|
||||
config_panel_arguments="${config_panel_arguments}${add_arg}:"
|
||||
done < "$partial_check_process"
|
||||
|
||||
# Parse all tests to perform
|
||||
# Extract the checks options section from the second partial file
|
||||
extract_section "^; Checks" "^; " "$partial2"
|
||||
|
@ -1135,6 +1174,10 @@ then
|
|||
count_test $port_already_use
|
||||
change_url=$(read_check_option change_url)
|
||||
count_test $change_url
|
||||
actions=$(read_check_option actions)
|
||||
count_test $actions
|
||||
config_panel=$(read_check_option config_panel)
|
||||
count_test $config_panel
|
||||
|
||||
# For port_already_use, check if there is also a port number
|
||||
if [ $port_already_use -eq 1 ]
|
||||
|
|
|
@ -134,6 +134,12 @@ CLEAR_LOG () {
|
|||
# Clean INFO lines
|
||||
sed --in-place 's/^\(>INFO: \)yunohost\.hook <lambda> - \[[[:digit:].]*\]/\1/g' "$temp_result"
|
||||
|
||||
# "This feature is experimental"
|
||||
sed --in-place '/^>WARNING: .* This feature is experimental and not considered stable/d' "$temp_result"
|
||||
|
||||
# "moulinette.core translate"
|
||||
sed --in-place '/^>ERROR: moulinette.core translate/d' "$temp_result"
|
||||
|
||||
# Empty lines
|
||||
sed --in-place '/^$/d' "$temp_result"
|
||||
}
|
||||
|
|
|
@ -1469,6 +1469,323 @@ CHECK_CHANGE_URL () {
|
|||
done
|
||||
}
|
||||
|
||||
# Define a function to split a file in multiple parts. Used for actions and config-panel toml
|
||||
splitterAA()
|
||||
{
|
||||
local bound="$1"
|
||||
local file="$2"
|
||||
|
||||
# If $2 is a real file
|
||||
if [ -e "$file" ]
|
||||
then
|
||||
# Replace name of the file by its content
|
||||
file="$(cat "$file")"
|
||||
fi
|
||||
|
||||
local file_lenght=$(echo "$file" | wc --lines | awk '{print $1}')
|
||||
|
||||
bounds=($(echo "$file" | grep --line-number --extended-regexp "$bound" | cut -d':' -f1))
|
||||
|
||||
# Go for each line number (boundary) into the array
|
||||
for line_number in $(seq 0 $(( ${#bounds[@]} -1 )))
|
||||
do
|
||||
# The first bound is the next line number in the array
|
||||
# That the low bound on which we cut
|
||||
first_bound=$(( ${bounds[$line_number+1]} - 1 ))
|
||||
# If there's no next cell in the array, we got -1, in such case, use the lenght of the file.
|
||||
# We cut at the end of the file
|
||||
test $first_bound -lt 0 && first_bound=$file_lenght
|
||||
# The second bound is the current line number in the array minus the next one.
|
||||
# The the upper bound in the file.
|
||||
second_bound=$(( ${bounds[$line_number]} - $first_bound - 1 ))
|
||||
# Cut the file a first time from the beginning to the first bound
|
||||
# And a second time from the end, back to the second bound.
|
||||
parts[line_number]="$(echo "$file" | head --lines=$first_bound \
|
||||
| tail --lines=$second_bound)"
|
||||
done
|
||||
}
|
||||
|
||||
ACTIONS_CONFIG_PANEL () {
|
||||
# Try the actions and config-panel features
|
||||
|
||||
test_type=$1
|
||||
if [ "$test_type" == "actions" ]
|
||||
then
|
||||
unit_test_title "Actions..."
|
||||
|
||||
toml_file="$package_path/actions.toml"
|
||||
if [ ! -e "$toml_file" ]
|
||||
then
|
||||
ECHO_FORMAT "\nNo actions.toml found !\n" "red" "bold"
|
||||
return 1
|
||||
fi
|
||||
|
||||
elif [ "$test_type" == "config_panel" ]
|
||||
then
|
||||
unit_test_title "Config-panel..."
|
||||
|
||||
toml_file="$package_path/config_panel.toml"
|
||||
if [ ! -e "$toml_file" ]
|
||||
then
|
||||
ECHO_FORMAT "\nNo config_panel.toml found !\n" "red" "bold"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check if the needed manifest key are set or abort the test
|
||||
check_manifest_key "domain" || return
|
||||
|
||||
# Check if an install have previously work
|
||||
is_install_failed || 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 "user" "$test_user"
|
||||
replace_manifest_key "public" "$public_public_arg"
|
||||
# Use a path according to previous succeeded installs
|
||||
if [ $sub_dir_install -eq 1 ]; then
|
||||
local check_path=$test_path
|
||||
else
|
||||
local check_path=/
|
||||
fi
|
||||
replace_manifest_key "path" "$check_path"
|
||||
|
||||
# Install the application in a LXC container
|
||||
ECHO_FORMAT "\nPreliminary install...\n" "white" "bold" clog
|
||||
STANDARD_SETUP_APP
|
||||
check_false_positive_error || return $?
|
||||
|
||||
validate_action_config_panel()
|
||||
{
|
||||
# yunohost_result gets the return code of the command
|
||||
yunohost_result=$?
|
||||
|
||||
local message="$1"
|
||||
|
||||
# Print the result of the command
|
||||
if [ $yunohost_result -eq 0 ]; then
|
||||
ECHO_FORMAT "$message succeed. ($yunohost_result)\n" "white" clog
|
||||
else
|
||||
ECHO_FORMAT "$message failed. ($yunohost_result)\n" "white" clog
|
||||
fi
|
||||
|
||||
# Check all the witness files, to verify if they're still there
|
||||
check_witness_files
|
||||
|
||||
# Analyse the log to extract "warning" and "error" lines
|
||||
LOG_EXTRACTOR
|
||||
check_false_positive_error || return $?
|
||||
|
||||
# Check the result and print SUCCESS or FAIL
|
||||
if check_test_result
|
||||
then # Success
|
||||
# The global success for a actions can't be a success if another iteration failed
|
||||
if [ $RESULT_action_config_panel -ne -1 ]; then
|
||||
RESULT_action_config_panel=1 # Actions succeed
|
||||
fi
|
||||
else # Fail
|
||||
RESULT_action_config_panel=-1 # Actions failed
|
||||
fi
|
||||
|
||||
# Make a break if auto_remove is set
|
||||
break_before_continue
|
||||
}
|
||||
|
||||
# List first, then execute
|
||||
local i=0
|
||||
for i in `seq 1 2`
|
||||
do
|
||||
# Do a test if the installation succeed
|
||||
if [ $yunohost_result -ne 0 ]
|
||||
then
|
||||
ECHO_FORMAT "\nThe previous test has failed...\n" "red" "bold"
|
||||
else
|
||||
if [ $i -eq 1 ]
|
||||
then
|
||||
if [ "$test_type" == "actions" ]
|
||||
then
|
||||
ECHO_FORMAT "\n> List the available actions...\n" "white" "bold" clog
|
||||
|
||||
# List the actions
|
||||
LXC_START "sudo PACKAGE_CHECK_EXEC=1 yunohost --debug app action list $ynh_app_id"
|
||||
|
||||
validate_action_config_panel "yunohost app action list"
|
||||
elif [ "$test_type" == "config_panel" ]
|
||||
then
|
||||
ECHO_FORMAT "\n> Show the config panel...\n" "white" "bold" clog
|
||||
|
||||
# Show the config-panel
|
||||
LXC_START "sudo PACKAGE_CHECK_EXEC=1 yunohost --debug app config show-panel $ynh_app_id"
|
||||
validate_action_config_panel "yunohost app config show-panel"
|
||||
fi
|
||||
elif [ $i -eq 2 ]
|
||||
then
|
||||
local parts
|
||||
if [ "$test_type" == "actions" ]
|
||||
then
|
||||
ECHO_FORMAT "\n> Execute the actions...\n" "white" "bold" clog
|
||||
|
||||
# Split the actions.toml file to separate each actions
|
||||
splitterAA "^[[:blank:]]*\[[^.]*\]" "$toml_file"
|
||||
elif [ "$test_type" == "config_panel" ]
|
||||
then
|
||||
ECHO_FORMAT "\n> Apply configurations...\n" "white" "bold" clog
|
||||
|
||||
# Split the config_panel.toml file to separate each configurations
|
||||
splitterAA "^[[:blank:]]*\[.*\]" "$toml_file"
|
||||
fi
|
||||
|
||||
# Read each part, each action, one by one
|
||||
for part in $(seq 0 $(( ${#parts[@]} -1 )))
|
||||
do
|
||||
local action_config_argument_name=""
|
||||
local action_config_argument_type=""
|
||||
local action_config_argument_default=""
|
||||
local actions_config_arguments_specifics=""
|
||||
local nb_actions_config_arguments_specifics=1
|
||||
|
||||
# Ignore part of the config_panel which are only titles
|
||||
if [ "$test_type" == "config_panel" ]
|
||||
then
|
||||
# A real config_panel part should have a `ask = ` line. Ignore the part if not.
|
||||
if ! echo "${parts[$part]}" | grep --quiet --extended-regexp "^[[:blank:]]*ask ="
|
||||
then
|
||||
continue
|
||||
fi
|
||||
# Get the name of the config. ask = "Config ?"
|
||||
local action_config_name="$(echo "${parts[$part]}" | grep "ask" | sed 's/^.* = \"\(.*\)\"/\1/')"
|
||||
|
||||
# Get the config argument name "YNH_CONFIG_part1_part2.part3.partx"
|
||||
local action_config_argument_name="$(echo "${parts[$part]}" | grep "^[[:blank:]]*\[.*\]$")"
|
||||
# Remove []
|
||||
action_config_argument_name="${action_config_argument_name//[\[\]]/}"
|
||||
# And remove spaces
|
||||
action_config_argument_name="${action_config_argument_name// /}"
|
||||
|
||||
elif [ "$test_type" == "actions" ]
|
||||
then
|
||||
# Get the name of the action. name = "Name of the action"
|
||||
local action_config_name="$(echo "${parts[$part]}" | grep "name" | sed 's/^.* = \"\(.*\)\"/\1/')"
|
||||
|
||||
# Get the action. [action]
|
||||
local action_config_action="$(echo "${parts[$part]}" | grep "^\[.*\]$" | sed 's/\[\(.*\)\]/\1/')"
|
||||
fi
|
||||
|
||||
# Check if there's any [action.arguments]
|
||||
# config_panel always have arguments.
|
||||
if echo "${parts[$part]}" | grep --quiet "$action_config_action\.arguments" || [ "$test_type" == "config_panel" ]
|
||||
then local action_config_has_arguments=1
|
||||
else local action_config_has_arguments=0
|
||||
fi
|
||||
# If there's arguments for this action.
|
||||
if [ $action_config_has_arguments -eq 1 ]
|
||||
then
|
||||
if [ "$test_type" == "actions" ]
|
||||
then
|
||||
# Get the argument [action.arguments.name_of_the_argument]
|
||||
action_config_argument_name="$(echo "${parts[$part]}" | grep "$action_config_action\.arguments\." | sed 's/.*\.\(.*\)]/\1/')"
|
||||
fi
|
||||
|
||||
# Get the type of the argument. type = "type"
|
||||
action_config_argument_type="$(echo "${parts[$part]}" | grep "type" | sed 's/^.* = \"\(.*\)\"/\1/')"
|
||||
# Get the default value of this argument. default = true
|
||||
action_config_argument_default="$(echo "${parts[$part]}" | grep "default" | sed 's/^.* = \(.*\)/\1/')"
|
||||
# Do not use true or false, use 1/0 instead
|
||||
if [ "$action_config_argument_default" == "true" ] && [ "$action_config_argument_type" == "boolean" ]; then
|
||||
action_config_argument_default=1
|
||||
elif [ "$action_config_argument_default" == "false" ] && [ "$action_config_argument_type" == "boolean" ]; then
|
||||
action_config_argument_default=0
|
||||
fi
|
||||
|
||||
if [ "$test_type" == "config_panel" ]
|
||||
then
|
||||
local check_process_arguments="$config_panel_arguments"
|
||||
elif [ "$test_type" == "actions" ]
|
||||
then
|
||||
local check_process_arguments="$actions_arguments"
|
||||
fi
|
||||
# Look for arguments into the check_process
|
||||
if echo "$check_process_arguments" | grep --quiet "$action_config_argument_name"
|
||||
then
|
||||
# If there's arguments for this actions into the check_process
|
||||
# Isolate the values
|
||||
actions_config_arguments_specifics="$(echo "$check_process_arguments" | sed "s/.*$action_config_argument_name=\(.*\)/\1/")"
|
||||
# And remove values of the following action
|
||||
actions_config_arguments_specifics="${actions_config_arguments_specifics%%\:*}"
|
||||
nb_actions_config_arguments_specifics=$(( $(echo "$actions_config_arguments_specifics" | tr --complement --delete "|" | wc --chars) + 1 ))
|
||||
fi
|
||||
|
||||
if [ "$test_type" == "config_panel" ]
|
||||
then
|
||||
# Finish to format the name
|
||||
# Remove . by _
|
||||
action_config_argument_name="${action_config_argument_name//./_}"
|
||||
# Move all characters to uppercase
|
||||
action_config_argument_name="${action_config_argument_name^^}"
|
||||
# Add YNH_CONFIG_
|
||||
action_config_argument_name="YNH_CONFIG_$action_config_argument_name"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Loop on the number of values into the check_process.
|
||||
# Or loop once for the default value
|
||||
for j in `seq 1 $nb_actions_config_arguments_specifics`
|
||||
do
|
||||
local action_config_argument_built=""
|
||||
if [ $action_config_has_arguments -eq 1 ]
|
||||
then
|
||||
# If there's values into the check_process
|
||||
if [ -n "$actions_config_arguments_specifics" ]
|
||||
then
|
||||
# Build the argument from a value from the check_process
|
||||
local action_config_actual_argument="$(echo "$actions_config_arguments_specifics" | cut -d'|' -f $j)"
|
||||
action_config_argument_built="--args $action_config_argument_name=$action_config_actual_argument"
|
||||
elif [ -n "$action_config_argument_default" ]
|
||||
then
|
||||
# Build the argument from the default value
|
||||
local action_config_actual_argument="$action_config_argument_default"
|
||||
action_config_argument_built="--args $action_config_argument_name=$action_config_actual_argument"
|
||||
else
|
||||
ECHO_FORMAT "\n> No argument into the check_process to use or default argument for \"$action_config_name\"..." "lyellow" "bold" clog
|
||||
action_config_actual_argument=""
|
||||
fi
|
||||
if [ "$test_type" == "config_panel" ]
|
||||
then
|
||||
ECHO_FORMAT "\n> Apply the configuration for \"$action_config_name\" with the argument \"$action_config_actual_argument\"...\n" "white" "bold" clog
|
||||
elif [ "$test_type" == "actions" ]
|
||||
then
|
||||
ECHO_FORMAT "\n> Execute the action \"$action_config_name\" with the argument \"$action_config_actual_argument\"...\n" "white" "bold" clog
|
||||
fi
|
||||
else
|
||||
ECHO_FORMAT "\n> Execute the action \"$action_config_name\"...\n" "white" "bold" clog
|
||||
fi
|
||||
|
||||
if [ "$test_type" == "config_panel" ]
|
||||
then
|
||||
# Aply a configuration
|
||||
LXC_START "sudo PACKAGE_CHECK_EXEC=1 yunohost --debug app config apply $ynh_app_id $action_config_action $action_config_argument_built"
|
||||
elif [ "$test_type" == "actions" ]
|
||||
then
|
||||
# Execute an action
|
||||
LXC_START "sudo PACKAGE_CHECK_EXEC=1 yunohost --debug app action run $ynh_app_id $action_config_action $action_config_argument_built"
|
||||
fi
|
||||
validate_action_config_panel "yunohost action $action_config_action"
|
||||
done
|
||||
done
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Uses the default snapshot
|
||||
current_snapshot=snap0
|
||||
# Stop and restore the LXC container
|
||||
LXC_STOP
|
||||
}
|
||||
|
||||
PACKAGE_LINTER () {
|
||||
# Package linter
|
||||
|
||||
|
@ -1734,4 +2051,14 @@ TESTING_PROCESS () {
|
|||
if [ $change_url -eq 1 ]; then
|
||||
TEST_LAUNCHER CHECK_CHANGE_URL
|
||||
fi
|
||||
|
||||
# Try the actions
|
||||
if [ $actions -eq 1 ]; then
|
||||
TEST_LAUNCHER ACTIONS_CONFIG_PANEL actions
|
||||
fi
|
||||
|
||||
# Try the config-panel
|
||||
if [ $config_panel -eq 1 ]; then
|
||||
TEST_LAUNCHER ACTIONS_CONFIG_PANEL config_panel
|
||||
fi
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue