File: 02_logfile.t

package info (click to toggle)
check-postgres 2.26.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 2,032 kB
  • sloc: perl: 12,710; sh: 19; makefile: 13
file content (69 lines) | stat: -rw-r--r-- 1,739 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!perl

## Test the "logfile" action
## this does not test $S for syslog or stderr output

use 5.008;
use strict;
use warnings;
use Data::Dumper;
use Test::More tests => 11;
use lib 't','.';
use CP_Testing;

use vars qw/$dbh $result $t $host $dbname/;

my $cp = CP_Testing->new( {default_action => 'logfile'} );

$dbh = $cp->test_database_handle();

## Remove any old fake schema
$cp->drop_schema_if_exists();

$host = $cp->get_host();
$dbname = $cp->get_dbname();

my $S = q{Action 'logfile'};
my $label = 'POSTGRES_LOGFILE';

my $logfile = 'test_database_check_postgres/pg.log';

my $cmd = $cp->get_command("--logfile=$logfile");

$result = $cp->run("--logfile=$logfile");

$t = qq{$S self-identifies correctly};
like ($result, qr{^$label}, $t);

$t = qq{$S identifies host};
like ($result, qr{host:$host}, $t);

$t = qq{$S correctly identifies logfile};
like ($result, qr{logs to: $logfile}, $t);

$t = qq{$S correctly identifies host};
like ($result, qr{host:$host}, $t);

$t = qq{$S returned expected text};
like ($result, qr{\bOK\b}, $t);

$t = qq{$S flagged missing logfile param};
like ($cp->run(''), qr{^ERROR:.*redirected.*stderr}, $t);

$t = qq{$S flagged erroneous logfile param};
like ($result = $cp->run("--logfile $logfile" . 'x'), qr{^$label\b}, $t);

$t = qq{$S covers unknown};
like ($result, qr{\bUNKNOWN\b}, $t);

$t = qq{$S covers warning};
like ($cp->run("--warning=1 --logfile $logfile" . 'x'), qr{\bWARNING\b}, $t);

$t = qq{$S returns correct MRTG (OK)};
is ($cp->run("--output=mrtg --warning=1 --logfile $logfile"), qq{1\n0\n\n\n}, $t);

$t = qq{$S returns correct MRTG (fail)};
is ($cp->run("--output=mrtg --warning=1 --logfile $logfile" . 'x'),
    qq{ERROR: logfile ${logfile}x does not exist!\n}, $t);

exit;