Coder Social home page Coder Social logo

mickael-martin / package_check Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yunohost/package_check

0.0 1.0 0.0 445 KB

Shell script which check package actions: install, remove, upgrade, backup, restore…

License: GNU General Public License v3.0

Shell 98.70% Python 1.30%

package_check's Introduction

Package checker for YunoHost

Yunohost project

Lire ce readme en francais

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

The script is able to perform following tests:

  • Check the package with package linter
  • Installation in a subdir
  • Installation at root of domain
  • Installation without url access (For apps without web UI)
  • Private installation.
  • Public installation
  • Upgrade on same package version
  • Backup
  • Restore after application uninstall
  • Restore without installation before
  • Multi-instances installation
  • Test malformed path (path/ instead od /path)
  • Test port already use
  • Test of change_url script

Package_check script use an LXC container to manipulate the package in a non parasited environnement by previous installs.

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

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 try to retrieve domain, path and admin user arguments in the manifest for execute some tests, based on arguments found.


Deploying test script

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.

;; Test name
# Comment ignored
	; pre-install
		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"
		is_public=1	(PUBLIC|public=1|private=0)
		password="password"
		port="666"	(PORT)
	; Checks
		pkg_linter=1
		setup_sub_dir=1
		setup_root=1
		setup_nourl=0
		setup_private=1
		setup_public=1
		upgrade=1
		upgrade=1	from_commit=65c382d138596fcb32b4c97c39398815a1dcd4e8
		backup_restore=1
		multi_instance=1
		incorrect_path=1
		port_already_use=1 (XXXX)
		change_url=1
;;; Levels
	Level 5=auto
;;; 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.
It's possible to create multiples tests series, all with the same syntax.
All different tests series will be perform sequentialy.

; pre-install

Optionnal instruction
If you have to execute a command or a group of commands before the installation. You can use this instruction.
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.

; 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.

  • pkg_linter: Check the package with 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_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/.
  • 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.

;;; Levels

From levels 1 to 7, levels are determined automatically.
Except for the level 5, you can't force a value for a level anymore.
The level 5 is determined by the results of 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.

;;; Options

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.

;;; 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.
    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.
  • --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.

There must also be enough space on the host, at least 4GB for the container, its snapshot and backup.

Using LXC is simplified by 4 scripts, allowing to manage the creation, updating, deleting and repairing of 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.
    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_check.sh: Check the LXC container and try to fix it if necessary.

package_check's People

Contributors

maniackcrudelis avatar yalh76 avatar scith avatar kay0u avatar mickael-martin avatar kemenaran avatar jimbojoe avatar jibec avatar julienmalik avatar opi avatar jocelyndelalande avatar m5oul avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.