diff options
| author | Sven Nierlein <sven@nierlein.org> | 2018-12-07 10:34:45 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-12-07 10:34:45 +0100 |
| commit | c7c4be2ad1fa97d5b8db0cff5f7204c605992047 (patch) | |
| tree | 56c6268f2a2481ff7b866ccd09c2005d7ec24a67 /plugins-scripts/t | |
| parent | c285edd2f34582c954a720317c3feba37aa1a33a (diff) | |
| parent | d7dcca22ae2f7bdf0ee2282e00c1999de0b58e26 (diff) | |
| download | monitoring-plugins-c7c4be2ad1fa97d5b8db0cff5f7204c605992047.tar.gz | |
Merge pull request #1565 from sni/travis_run_plugin_root_tests
Travis run plugin root tests
Diffstat (limited to 'plugins-scripts/t')
| -rw-r--r-- | plugins-scripts/t/check_file_age.t | 103 |
1 files changed, 36 insertions, 67 deletions
diff --git a/plugins-scripts/t/check_file_age.t b/plugins-scripts/t/check_file_age.t index ebf673f5..8b876708 100644 --- a/plugins-scripts/t/check_file_age.t +++ b/plugins-scripts/t/check_file_age.t | |||
| @@ -20,105 +20,74 @@ my $temp_link = "/tmp/check_file_age.link.tmp"; | |||
| 20 | 20 | ||
| 21 | unlink $temp_file, $temp_link; | 21 | unlink $temp_file, $temp_link; |
| 22 | 22 | ||
| 23 | $result = NPTest->testCmd( | 23 | $result = NPTest->testCmd("./check_file_age"); |
| 24 | "./check_file_age" | ||
| 25 | ); | ||
| 26 | cmp_ok( $result->return_code, '==', 3, "Missing parameters" ); | 24 | cmp_ok( $result->return_code, '==', 3, "Missing parameters" ); |
| 27 | like ( $result->output, $unknownOutput, "Output for unknown correct" ); | 25 | like ( $result->output, $unknownOutput, "Output for unknown correct" ); |
| 28 | 26 | ||
| 29 | $result = NPTest->testCmd( | 27 | $result = NPTest->testCmd("./check_file_age -f $temp_file"); |
| 30 | "./check_file_age -f $temp_file" | ||
| 31 | ); | ||
| 32 | cmp_ok( $result->return_code, '==', 2, "File not exists" ); | 28 | cmp_ok( $result->return_code, '==', 2, "File not exists" ); |
| 33 | like ( $result->output, $criticalOutput, "Output for file missing correct" ); | 29 | like ( $result->output, $criticalOutput, "Output for file missing correct" ); |
| 34 | 30 | ||
| 35 | write_chars(100); | 31 | write_chars(100); |
| 36 | $result = NPTest->testCmd( | 32 | $result = NPTest->testCmd("./check_file_age -f $temp_file"); |
| 37 | "./check_file_age -f $temp_file" | ||
| 38 | ); | ||
| 39 | cmp_ok( $result->return_code, '==', 0, "File is new enough" ); | 33 | cmp_ok( $result->return_code, '==', 0, "File is new enough" ); |
| 40 | like ( $result->output, $successOutput, "Output for success correct" ); | 34 | like ( $result->output, $successOutput, "Output for success correct" ); |
| 41 | 35 | ||
| 42 | sleep 2; | 36 | sleep 2; |
| 43 | 37 | ||
| 44 | $result = NPTest->testCmd( | 38 | $result = NPTest->testCmd("./check_file_age -f $temp_file -w 1"); |
| 45 | "./check_file_age -f $temp_file -w 1" | ||
| 46 | ); | ||
| 47 | cmp_ok( $result->return_code, '==', 1, "Warning for file over 1 second old" ); | 39 | cmp_ok( $result->return_code, '==', 1, "Warning for file over 1 second old" ); |
| 48 | like ( $result->output, $warningOutput, "Output for warning correct" ); | 40 | like ( $result->output, $warningOutput, "Output for warning correct" ); |
| 49 | 41 | ||
| 50 | $result = NPTest->testCmd( | 42 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1"); |
| 51 | "./check_file_age -f $temp_file -w 0:1" | ||
| 52 | ); | ||
| 53 | cmp_ok( $result->return_code, '==', 1, "Warning for file over 1 second old by range" ); | ||
| 54 | like ( $result->output, $warningOutput, "Output for warning by range correct" ); | ||
| 55 | |||
| 56 | $result = NPTest->testCmd( | ||
| 57 | "./check_file_age -f $temp_file -c 1" | ||
| 58 | ); | ||
| 59 | cmp_ok( $result->return_code, '==', 2, "Critical for file over 1 second old" ); | 43 | cmp_ok( $result->return_code, '==', 2, "Critical for file over 1 second old" ); |
| 60 | like ( $result->output, $criticalOutput, "Output for critical correct" ); | 44 | like ( $result->output, $criticalOutput, "Output for critical correct" ); |
| 61 | 45 | ||
| 62 | $result = NPTest->testCmd( | 46 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 100"); |
| 63 | "./check_file_age -f $temp_file -c 0:1" | ||
| 64 | ); | ||
| 65 | cmp_ok( $result->return_code, '==', 2, "Critical for file over 1 second old by range" ); | ||
| 66 | like ( $result->output, $criticalOutput, "Output for critical by range correct" ); | ||
| 67 | |||
| 68 | $result = NPTest->testCmd( | ||
| 69 | "./check_file_age -f $temp_file -c 1000 -W 100" | ||
| 70 | ); | ||
| 71 | cmp_ok( $result->return_code, '==', 0, "Checking file size" ); | 47 | cmp_ok( $result->return_code, '==', 0, "Checking file size" ); |
| 72 | 48 | ||
| 73 | $result = NPTest->testCmd( | 49 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 100"); |
| 74 | "./check_file_age -f $temp_file -c 0:1000 -W 0:100" | ||
| 75 | ); | ||
| 76 | cmp_ok( $result->return_code, '==', 0, "Checking file size by range" ); | ||
| 77 | |||
| 78 | $result = NPTest->testCmd( | ||
| 79 | "./check_file_age -f $temp_file -c 1000 -W 100" | ||
| 80 | ); | ||
| 81 | like( $result->output, $performanceOutput, "Checking for performance Output" ); | 50 | like( $result->output, $performanceOutput, "Checking for performance Output" ); |
| 82 | 51 | ||
| 83 | $result = NPTest->testCmd( | 52 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 100"); |
| 84 | "./check_file_age -f $temp_file -c 1000 -W 100" | ||
| 85 | ); | ||
| 86 | like( $result->output, $performanceOutput, "Checking for performance Output from range" ); | 53 | like( $result->output, $performanceOutput, "Checking for performance Output from range" ); |
| 87 | 54 | ||
| 88 | $result = NPTest->testCmd( | 55 | $result = NPTest->testCmd("./check_file_age -f /non/existent --ignore-missing"); |
| 89 | "./check_file_age -f /non/existent --ignore-missing" | ||
| 90 | ); | ||
| 91 | cmp_ok( $result->return_code, '==', 0, "Honours --ignore-missing" ); | 56 | cmp_ok( $result->return_code, '==', 0, "Honours --ignore-missing" ); |
| 92 | 57 | ||
| 93 | $result = NPTest->testCmd( | 58 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 101"); |
| 94 | "./check_file_age -f $temp_file -c 1000 -W 101" | ||
| 95 | ); | ||
| 96 | cmp_ok( $result->return_code, '==', 1, "One byte too short" ); | 59 | cmp_ok( $result->return_code, '==', 1, "One byte too short" ); |
| 97 | 60 | ||
| 98 | $result = NPTest->testCmd( | 61 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -C 101"); |
| 99 | "./check_file_age -f $temp_file -c 1000 -W 101:" | ||
| 100 | ); | ||
| 101 | cmp_ok( $result->return_code, '==', 1, "One byte too short by range" ); | ||
| 102 | |||
| 103 | $result = NPTest->testCmd( | ||
| 104 | "./check_file_age -f $temp_file -c 1000 -C 101" | ||
| 105 | ); | ||
| 106 | cmp_ok( $result->return_code, '==', 2, "One byte too short - critical" ); | 62 | cmp_ok( $result->return_code, '==', 2, "One byte too short - critical" ); |
| 107 | 63 | ||
| 108 | $result = NPTest->testCmd( | 64 | SKIP: { |
| 109 | "./check_file_age -f $temp_file -c 1000 -C 101:" | 65 | eval 'use Monitoring::Plugin::Range'; |
| 110 | ); | 66 | skip "Monitoring::Plugin::Range module require", 9 if $@; |
| 111 | cmp_ok( $result->return_code, '==', 2, "One byte too short by range - critical" ); | 67 | |
| 68 | $result = NPTest->testCmd("./check_file_age -f $temp_file -w 0:1"); | ||
| 69 | cmp_ok( $result->return_code, '==', 1, "Warning for file over 1 second old by range" ); | ||
| 70 | like ( $result->output, $warningOutput, "Output for warning by range correct" ); | ||
| 71 | |||
| 72 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 0:1"); | ||
| 73 | cmp_ok( $result->return_code, '==', 2, "Critical for file over 1 second old by range" ); | ||
| 74 | like ( $result->output, $criticalOutput, "Output for critical by range correct" ); | ||
| 75 | |||
| 76 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 0:1000 -W 0:100"); | ||
| 77 | cmp_ok( $result->return_code, '==', 0, "Checking file size by range" ); | ||
| 78 | |||
| 79 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 101:"); | ||
| 80 | cmp_ok( $result->return_code, '==', 1, "One byte too short by range" ); | ||
| 81 | |||
| 82 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 0:99"); | ||
| 83 | cmp_ok( $result->return_code, '==', 1, "One byte too long by range" ); | ||
| 112 | 84 | ||
| 113 | $result = NPTest->testCmd( | 85 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -C 101:"); |
| 114 | "./check_file_age -f $temp_file -c 1000 -W 0:99" | 86 | cmp_ok( $result->return_code, '==', 2, "One byte too short by range - critical" ); |
| 115 | ); | ||
| 116 | cmp_ok( $result->return_code, '==', 1, "One byte too long by range" ); | ||
| 117 | 87 | ||
| 118 | $result = NPTest->testCmd( | 88 | $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -C 0:99"); |
| 119 | "./check_file_age -f $temp_file -c 1000 -C 0:99" | 89 | cmp_ok( $result->return_code, '==', 2, "One byte too long by range - critical" ); |
| 120 | ); | 90 | }; |
| 121 | cmp_ok( $result->return_code, '==', 2, "One byte too long by range - critical" ); | ||
| 122 | 91 | ||
| 123 | symlink $temp_file, $temp_link or die "Cannot create symlink"; | 92 | symlink $temp_file, $temp_link or die "Cannot create symlink"; |
| 124 | $result = NPTest->testCmd("./check_file_age -f $temp_link -c 10"); | 93 | $result = NPTest->testCmd("./check_file_age -f $temp_link -c 10"); |
