mirror of
https://github.com/YunoHost/package_check.git
synced 2024-09-03 20:06:20 +02:00
Test backup sans installation
This commit is contained in:
parent
6b8f3a075d
commit
794161a190
3 changed files with 62 additions and 36 deletions
|
@ -15,7 +15,9 @@ Le script est capable d'effectuer les tests suivant:
|
|||
- Installation en privé
|
||||
- Installation en public
|
||||
- Upgrade sur la même version du package
|
||||
- Backup puis restore
|
||||
- Backup
|
||||
- Restore après suppression de l'application
|
||||
- Restore sans installation préalable
|
||||
- Installation multi-instance
|
||||
- Test d'utilisateur incorrect
|
||||
- Test de domaine incorrect
|
||||
|
@ -155,7 +157,9 @@ The script is able to perform following tests:
|
|||
- Private installation.
|
||||
- Public installation
|
||||
- Upgrade on same package version
|
||||
- Backup then restore
|
||||
- Backup
|
||||
- Restore after application uninstall
|
||||
- Restore without installation before
|
||||
- Multi-instances installation
|
||||
- Test with wrong user
|
||||
- Test with wrong domain
|
||||
|
|
|
@ -112,6 +112,7 @@ LXC_NETWORK_CONFIG () {
|
|||
lxc_network=0
|
||||
if ! sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q "^lxc.network.type = veth"; then
|
||||
lxc_network=1 # Si la ligne de la config réseau est absente, c'est une erreur.
|
||||
check_repair=1
|
||||
if sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q ".*lxc.network.type"; then # Si la ligne est incorrecte, elle est corrigée.
|
||||
sudo sed -i "s/.*lxc.network.type.*/lxc.network.type = veth/g" /var/lib/lxc/$LXC_NAME/config
|
||||
else # Sinon elle est ajoutée.
|
||||
|
@ -120,6 +121,7 @@ LXC_NETWORK_CONFIG () {
|
|||
fi
|
||||
if ! sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q "^lxc.network.flags = up"; then
|
||||
lxc_network=1
|
||||
check_repair=1
|
||||
if sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q ".*lxc.network.flags"; then
|
||||
sudo sed -i "s/.*lxc.network.flags.*/lxc.network.flags = up/g" /var/lib/lxc/$LXC_NAME/config
|
||||
else
|
||||
|
@ -128,6 +130,7 @@ LXC_NETWORK_CONFIG () {
|
|||
fi
|
||||
if ! sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q "^lxc.network.link = lxc-pchecker"; then
|
||||
lxc_network=1
|
||||
check_repair=1
|
||||
if sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q ".*lxc.network.link"; then
|
||||
sudo sed -i "s/.*lxc.network.link.*/lxc.network.link = lxc-pchecker/g" /var/lib/lxc/$LXC_NAME/config
|
||||
else
|
||||
|
@ -136,6 +139,7 @@ LXC_NETWORK_CONFIG () {
|
|||
fi
|
||||
if ! sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q "^lxc.network.name = eth0"; then
|
||||
lxc_network=1
|
||||
check_repair=1
|
||||
if sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q ".*lxc.network.name"; then
|
||||
sudo sed -i "s/.*lxc.network.name.*/lxc.network.name = eth0/g" /var/lib/lxc/$LXC_NAME/config
|
||||
else
|
||||
|
@ -144,6 +148,7 @@ LXC_NETWORK_CONFIG () {
|
|||
fi
|
||||
if ! sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q "^lxc.network.veth.pair = $LXC_NAME"; then
|
||||
lxc_network=1
|
||||
check_repair=1
|
||||
if sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q ".*lxc.network.veth.pair"; then
|
||||
sudo sed -i "s/.*lxc.network.veth.pair.*/lxc.network.veth.pair = $LXC_NAME/g" /var/lib/lxc/$LXC_NAME/config
|
||||
else
|
||||
|
@ -152,13 +157,14 @@ LXC_NETWORK_CONFIG () {
|
|||
fi
|
||||
if ! sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q "^lxc.network.hwaddr = 00:FF:AA:00:00:01"; then
|
||||
lxc_network=1
|
||||
check_repair=1
|
||||
if sudo cat /var/lib/lxc/$LXC_NAME/config | grep -q ".*lxc.network.hwaddr"; then
|
||||
sudo sed -i "s/.*lxc.network.hwaddr.*/lxc.network.hwaddr = 00:FF:AA:00:00:01/g" /var/lib/lxc/$LXC_NAME/config
|
||||
else
|
||||
echo "lxc.network.hwaddr = 00:FF:AA:00:00:01" | sudo tee -a /var/lib/lxc/$LXC_NAME/config
|
||||
fi
|
||||
fi
|
||||
if [ "$lxc_network" -eq 1 ]; then
|
||||
if [ $lxc_network -eq 1 ]; then
|
||||
echo -e "\e[91mLa configuration réseau LXC du conteneur est incorrecte et a été corrigée.\e[0m"
|
||||
else
|
||||
echo -e "\e[92mLa configuration réseau LXC du conteneur est correcte.\e[0m"
|
||||
|
|
|
@ -421,41 +421,57 @@ CHECK_BACKUP_RESTORE () {
|
|||
ECHO_FORMAT "--- FAIL ---\n" "lred" "bold"
|
||||
GLOBAL_CHECK_BACKUP=-1 # Backup échoué
|
||||
fi
|
||||
# Suppression de l'app
|
||||
REMOVE_APP
|
||||
ECHO_FORMAT "\nRestauration de l'application...\n" "white" "bold"
|
||||
# Restore de l'app
|
||||
COPY_LOG 1
|
||||
LXC_START "sudo yunohost --debug backup restore Backup_test --force --apps $APPID"
|
||||
YUNOHOST_RESULT=$?
|
||||
COPY_LOG 2
|
||||
LOG_EXTRACTOR
|
||||
# Test l'accès à l'app
|
||||
CHECK_URL
|
||||
tnote=$((tnote+1))
|
||||
if [ "$YUNOHOST_RESULT" -eq 0 ] && [ "$curl_error" -eq 0 ]; then
|
||||
ECHO_FORMAT "--- SUCCESS ---\n" "lgreen" "bold"
|
||||
note=$((note+1))
|
||||
if [ $GLOBAL_CHECK_RESTORE -ne -1 ]; then # La restauration ne peux pas être réussie si elle a échouée précédemment...
|
||||
GLOBAL_CHECK_RESTORE=1 # Restore réussi
|
||||
sudo cp -a /var/lib/lxc/$LXC_NAME/rootfs/home/yunohost.backup/archives ./ # Récupère le backup sur le conteneur
|
||||
for j in 0 1
|
||||
do # 2 passes, pour tester la restauration après suppression de l'app ET après restauration du conteneur.
|
||||
if [ "$j" -eq 0 ]
|
||||
then # Commence par tester la restauration après suppression de l'application
|
||||
REMOVE_APP # Suppression de l'app
|
||||
ECHO_FORMAT "\nRestauration de l'application après suppression de l'application...\n" "white" "bold"
|
||||
if [ "$no_lxc" -ne 0 ]; then # Si lxc n'est pas utilisé, impossible d'effectuer le 2e test
|
||||
j=1 # Ignore le 2e test
|
||||
echo "LXC n'est pas utilisé, impossible de tester la restauration sur un système vierge...\n"
|
||||
fi
|
||||
elif [ "$j" -eq 1 ]
|
||||
then # Puis la restauration après restauration du conteneur (si LXC est utilisé)
|
||||
sudo cp -a /var/lib/lxc/$LXC_NAME/rootfs/home/yunohost.backup/archives ./ # Récupère le backup sur le conteneur
|
||||
LXC_STOP # Restaure le conteneur.
|
||||
sudo mv -f ./archives /var/lib/lxc/$LXC_NAME/rootfs/home/yunohost.backup/ # Replace le backup sur le conteneur
|
||||
ECHO_FORMAT "\nRestauration de l'application sur un système vierge...\n" "white" "bold"
|
||||
fi
|
||||
else
|
||||
ECHO_FORMAT "--- FAIL ---\n" "lred" "bold"
|
||||
GLOBAL_CHECK_RESTORE=-1 # Restore échoué
|
||||
fi
|
||||
if [ "$no_lxc" -ne 0 ]; then
|
||||
# Suppression de l'app si lxc n'est pas utilisé.
|
||||
REMOVE_APP
|
||||
# Suppression de l'archive
|
||||
sudo yunohost backup delete Backup_test > /dev/null
|
||||
elif [ "$auto_remove" -eq 0 ] && [ "$bash_mode" -ne 1 ]; then # Si l'auto_remove est désactivée. Marque une pause avant de continuer.
|
||||
if [ "$no_lxc" -eq 0 ]; then
|
||||
echo "Utilisez ssh pour vous connecter au conteneur LXC. 'ssh $ARG_SSH $LXC_NAME'"
|
||||
# Restore de l'app
|
||||
COPY_LOG 1
|
||||
LXC_START "sudo yunohost --debug backup restore Backup_test --force --apps $APPID"
|
||||
YUNOHOST_RESULT=$?
|
||||
COPY_LOG 2
|
||||
LOG_EXTRACTOR
|
||||
# Test l'accès à l'app
|
||||
CHECK_URL
|
||||
tnote=$((tnote+1))
|
||||
if [ "$YUNOHOST_RESULT" -eq 0 ] && [ "$curl_error" -eq 0 ]; then
|
||||
ECHO_FORMAT "--- SUCCESS ---\n" "lgreen" "bold"
|
||||
note=$((note+1))
|
||||
if [ $GLOBAL_CHECK_RESTORE -ne -1 ]; then # La restauration ne peux pas être réussie si elle a échouée précédemment...
|
||||
GLOBAL_CHECK_RESTORE=1 # Restore réussi
|
||||
fi
|
||||
else
|
||||
ECHO_FORMAT "--- FAIL ---\n" "lred" "bold"
|
||||
GLOBAL_CHECK_RESTORE=-1 # Restore échoué
|
||||
fi
|
||||
read -p "Appuyer sur une touche pour continuer les tests..." < /dev/tty
|
||||
fi
|
||||
YUNOHOST_RESULT=-1
|
||||
LXC_STOP # Restaure le snapshot du conteneur avant de recommencer le processus de backup
|
||||
if [ "$no_lxc" -ne 0 ]; then
|
||||
# Suppression de l'app si lxc n'est pas utilisé.
|
||||
REMOVE_APP
|
||||
# Suppression de l'archive
|
||||
sudo yunohost backup delete Backup_test > /dev/null
|
||||
elif [ "$auto_remove" -eq 0 ] && [ "$bash_mode" -ne 1 ]; then # Si l'auto_remove est désactivée. Marque une pause avant de continuer.
|
||||
if [ "$no_lxc" -eq 0 ]; then
|
||||
echo "Utilisez ssh pour vous connecter au conteneur LXC. 'ssh $ARG_SSH $LXC_NAME'"
|
||||
fi
|
||||
read -p "Appuyer sur une touche pour continuer les tests..." < /dev/tty
|
||||
fi
|
||||
YUNOHOST_RESULT=-1
|
||||
LXC_STOP # Restaure le snapshot du conteneur avant de recommencer le processus de backup
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue