tests: use parentdir config in sys handler

This commit is contained in:
Jerome Charaoui 2021-01-06 22:23:45 -05:00
parent 4287819043
commit 142274d950

View File

@ -5,6 +5,7 @@ begin_sys() {
cat << EOF > "${BATS_TMPDIR}/backup.d/test.sys"
when = manual
parentdir = $BN_BACKUPDIR
packages = yes
partitions = yes
hardware = yes
@ -27,14 +28,11 @@ EOF
cryptsetup -q --type luks1 luksFormat /dev/sdd1 <<< 123test
cryptsetup -q --type luks2 luksFormat /dev/sdd2 <<< 123test
cryptsetup -q --type luks2 luksFormat /dev/sde <<< 123test
# Do backup
run backupninja -f "${BATS_TMPDIR}/backupninja.conf" --now --run "${BATS_TMPDIR}/backup.d/test.sys"
}
finish_sys() {
# remove test artifacts
rm -rf /var/backups/*
rm -rf ${BN_BACKUPDIR}/*
# cleanup lvm
lvremove -f vgtest/lvtest
vgremove vgtest
@ -48,46 +46,47 @@ finish_sys() {
}
@test "action runs without errors" {
grep -q "Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning." "${BATS_TMPDIR}/log/backupninja.log"
runaction
greplog "Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning."
}
@test "system report is created" {
[ -s /var/backups/sysreport.txt ]
[ -s "${BN_BACKUPDIR}/sysreport.txt" ]
}
@test "packages backup is made" {
[ -s /var/backups/dpkg-selections.txt ]
[ -s /var/backups/debconfsel.txt ]
[ -s "${BN_BACKUPDIR}/dpkg-selections.txt" ]
[ -s "${BN_BACKUPDIR}/debconfsel.txt" ]
}
@test "partitions backup is made" {
[ -s /var/backups/partitions.sda.txt ]
[ -s /var/backups/partitions.sdd.txt ]
[ -s "${BN_BACKUPDIR}/partitions.sda.txt" ]
[ -s "${BN_BACKUPDIR}/partitions.sdd.txt" ]
}
@test "mbr backup is made" {
[ -s /var/backups/mbr.sda.bin ]
file /var/backups/mbr.sda.bin | grep -q "DOS/MBR boot sector"
[ -s "${BN_BACKUPDIR}/mbr.sda.bin" ]
file "${BN_BACKUPDIR}/mbr.sda.bin" | grep -q "DOS/MBR boot sector"
}
@test "hardware info backup is made" {
[ -s /var/backups/hardware.txt ]
[ -s "${BN_BACKUPDIR}/hardware.txt" ]
}
@test "lvm backup is made" {
[ -d /var/backups/lvm ]
[ -s /var/backups/lvm/vgtest ]
grep -q 'contents = "Text Format Volume Group"' "/var/backups/lvm/vgtest"
[ -d "${BN_BACKUPDIR}/lvm" ]
[ -s "${BN_BACKUPDIR}/lvm/vgtest" ]
grep -q 'contents = "Text Format Volume Group"' "${BN_BACKUPDIR}/lvm/vgtest"
}
@test "luksheaders v1 partition backup is made" {
file /var/backups/luksheader.sdd1.bin | grep -q "LUKS encrypted file"
file "${BN_BACKUPDIR}/luksheader.sdd1.bin" | grep -q "LUKS encrypted file"
}
@test "luksheaders v2 partition backup is made" {
file /var/backups/luksheader.sdd2.bin | grep -q "LUKS encrypted file"
file "${BN_BACKUPDIR}/luksheader.sdd2.bin" | grep -q "LUKS encrypted file"
}
@test "luksheaders v2 device backup is made" {
file /var/backups/luksheader.sde.bin | grep -q "LUKS encrypted file"
file "${BN_BACKUPDIR}/luksheader.sde.bin" | grep -q "LUKS encrypted file"
}