Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
backupninja
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
yova
backupninja
Commits
f6870a61
Commit
f6870a61
authored
4 years ago
by
Jérôme Charaoui
Browse files
Options
Downloads
Patches
Plain Diff
tests: add tests for reporthost functionality
parent
4cfc5e33
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/backupninja.bats
+78
-0
78 additions, 0 deletions
test/backupninja.bats
test/common.bash
+0
-4
0 additions, 4 deletions
test/common.bash
with
78 additions
and
4 deletions
test/backupninja.bats
+
78
−
0
View file @
f6870a61
...
...
@@ -2,6 +2,7 @@ load common
teardown_backupninja() {
[ -x /usr/bin/mail.moved ] && mv /usr/bin/mail.moved /usr/bin/mail
[ -x /usr/bin/rsync.moved ] && mv /usr/bin/rsync.moved /usr/bin/rsync
}
create_test_action() {
...
...
@@ -157,6 +158,83 @@ create_test_action() {
grep -q '^=\{100\}$' /var/mail/vagrant
}
@test "reports: reporthost sends report to remote host" {
cleanup_backups remote
create_test_action info test_info
setconfig backupninja.conf reportsuccess yes
setconfig backupninja.conf reportinfo yes
setconfig backupninja.conf reporthost "$BN_REMOTEHOST"
setconfig backupninja.conf reportuser "$BN_REMOTEUSER"
setconfig backupninja.conf reportdirectory "$BN_BACKUPDIR"
run backupninja --now -f "${BATS_TMPDIR}/backupninja.conf" --run "${BATS_TMPDIR}/backup.d/test.sh"
[ "$status" -eq 0 ]
ssh "${BN_REMOTEUSER}@${BN_REMOTEHOST}" test -s "${BN_BACKUPDIR}/backupninja.log"
}
@test "reports: emits error when reportuser is empty" {
create_test_action info test_info
setconfig backupninja.conf reportsuccess yes
setconfig backupninja.conf reportinfo yes
setconfig backupninja.conf reporthost "$BN_REMOTEHOST"
setconfig backupninja.conf reportdirectory "$BN_BACKUPDIR"
run backupninja --now -f "${BATS_TMPDIR}/backupninja.conf" --run "${BATS_TMPDIR}/backup.d/test.sh"
[ "$status" -eq 1 ]
}
@test "reports: emits error when reportdirectory is empty" {
create_test_action info test_info
setconfig backupninja.conf reportsuccess yes
setconfig backupninja.conf reportinfo yes
setconfig backupninja.conf reporthost "$BN_REMOTEHOST"
setconfig backupninja.conf reportuser "$BN_REMOTEUSER"
run backupninja --now -f "${BATS_TMPDIR}/backupninja.conf" --run "${BATS_TMPDIR}/backup.d/test.sh"
[ "$status" -eq 1 ]
}
@test "reports: emits error when rsync is not found" {
create_test_action info test_info
setconfig backupninja.conf reportsuccess yes
setconfig backupninja.conf reportinfo yes
setconfig backupninja.conf reporthost "$BN_REMOTEHOST"
setconfig backupninja.conf reportuser "$BN_REMOTEUSER"
mv /usr/bin/rsync /usr/bin/rsync.moved
run backupninja --now -f "${BATS_TMPDIR}/backupninja.conf" --run "${BATS_TMPDIR}/backup.d/test.sh"
[ "$status" -eq 1 ]
}
@test "reports: emits error when reporthost is invalid" {
create_test_action info test_info
setconfig backupninja.conf reportsuccess yes
setconfig backupninja.conf reportinfo yes
setconfig backupninja.conf reporthost foo
setconfig backupninja.conf reportuser "$BN_REMOTEUSER"
setconfig backupninja.conf reportdirectory "$BN_BACKUPDIR"
run backupninja --now -f "${BATS_TMPDIR}/backupninja.conf" --run "${BATS_TMPDIR}/backup.d/test.sh"
[ "$status" -eq 1 ]
}
@test "reports: emits error when reportuser is invalid" {
create_test_action info test_info
setconfig backupninja.conf reportsuccess yes
setconfig backupninja.conf reportinfo yes
setconfig backupninja.conf reporthost "$BN_REMOTEHOST"
setconfig backupninja.conf reportuser foo
setconfig backupninja.conf reportdirectory "$BN_BACKUPDIR"
run backupninja --now -f "${BATS_TMPDIR}/backupninja.conf" --run "${BATS_TMPDIR}/backup.d/test.sh"
[ "$status" -eq 1 ]
}
@test "reports: emits error when reportdirectory is unwritable" {
create_test_action info test_info
setconfig backupninja.conf reportsuccess yes
setconfig backupninja.conf reportinfo yes
setconfig backupninja.conf reporthost "$BN_REMOTEHOST"
setconfig backupninja.conf reportuser "$BN_REMOTEUSER"
setconfig backupninja.conf reportdirectory "/foo"
run backupninja --now -f "${BATS_TMPDIR}/backupninja.conf" --run "${BATS_TMPDIR}/backup.d/test.sh"
[ "$status" -eq 1 ]
}
@test "scheduling: runs when = 'everyday at 01' and time matches" {
create_test_action info test_info
setconfig backupninja.conf when 'everyday at 01'
...
...
This diff is collapsed.
Click to expand it.
test/common.bash
+
0
−
4
View file @
f6870a61
...
...
@@ -15,10 +15,6 @@ reportsuccess = yes
reportinfo = no
reportwarning = yes
reportspace = no
reporthost =
reportuser = ninja
reportdirectory = /var/lib/backupninja/reports
admingroup = root
logfile =
${
BATS_TMPDIR
}
/log/backupninja.log
configdirectory =
${
BATS_TMPDIR
}
/backup.d
scriptdirectory = /usr/share/backupninja
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment