Add bats test for NRPE check

This commit is contained in:
Victor LABORIE 2018-03-15 12:41:54 +01:00
parent bde8072941
commit d430740383
2 changed files with 28 additions and 0 deletions

2
Vagrantfile vendored
View File

@ -19,6 +19,8 @@ ln -fs /vagrant/bkctld /usr/sbin/bkctld
ln -fs /vagrant/tpl /usr/share/bkctld
ln -fs /vagrant/bash_completion /usr/share/bash-completion/completions/bkctld
ln -fs /vagrant/bkctld.conf /etc/default/bkctld
mkdir -p /usr/lib/nagios/plugins/
ln -fs /vagrant/check_nrpe /usr/lib/nagios/plugins/check_bkctld
SCRIPT
$deps = <<SCRIPT

26
test/nrpe.bats Executable file
View File

@ -0,0 +1,26 @@
#!/usr/bin/env bats
setup() {
bkctld init test
}
teardown() {
bkctld remove all
}
@test "ok" {
run /usr/lib/nagios/plugins/check_bkctld
[ "$status" -eq 0 ]
}
@test "warning" {
touch --date="$(date -d -2days)" /backup/jails/*/var/log/lastlog
run /usr/lib/nagios/plugins/check_bkctld
[ "$status" -eq 1 ]
}
@test "critical" {
touch --date="$(date -d -3days)" /backup/jails/*/var/log/lastlog
run /usr/lib/nagios/plugins/check_bkctld
[ "$status" -eq 2 ]
}