4
0

check_cluster.t 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #! /usr/bin/perl -w -I ..
  2. #
  3. # check_cluster tests
  4. #
  5. #
  6. use strict;
  7. use Test::More tests => 15;
  8. use NPTest;
  9. my $result;
  10. $result = NPTest->testCmd(
  11. "./check_cluster -s -w 0:0 -c 0:0 -d 0,0,0,0"
  12. );
  13. cmp_ok( $result->return_code, '==', 0, "Exit OK if non-ok services are inside critical and warning ranges" );
  14. like( $result->output, qr/service/i, "Output contains the word 'service' (case insensitive)");
  15. $result = NPTest->testCmd(
  16. "./check_cluster -l LABEL -s -w 0:0 -c 0:0 -d 0,0,0,0"
  17. );
  18. like( $result->output, qr/LABEL/, "Output contains the defined label 'LABEL' (case sensitive)");
  19. $result = NPTest->testCmd(
  20. "./check_cluster -s -w 0:0 -c 0:1 -d 0,0,0,1"
  21. );
  22. cmp_ok( $result->return_code, '==', 1, "Exit WARNING if non-ok services are inside critical and outside warning ranges" );
  23. $result = NPTest->testCmd(
  24. "./check_cluster -s -w 0:0 -c 0:1 -d 0,0,1,1"
  25. );
  26. cmp_ok( $result->return_code, '==', 2, "Exit CRITICAL if non-ok services are inside critical and outside warning ranges" );
  27. $result = NPTest->testCmd(
  28. "./check_cluster -s -w 0 -c 0 -d 0,0,0,0"
  29. );
  30. cmp_ok( $result->return_code, '==', 0, "Exit OK if non-ok services are inside critical and warning (no ranges)" );
  31. $result = NPTest->testCmd(
  32. "./check_cluster -s -w 0 -c 1 -d 0,0,1,0"
  33. );
  34. cmp_ok( $result->return_code, '==', 1, "Exit WARNING if number of non-ok services exceed warning (no ranges)" );
  35. $result = NPTest->testCmd(
  36. "./check_cluster -s -w 0 -c 1 -d 0,0,1,1"
  37. );
  38. cmp_ok( $result->return_code, '==', 2, "Exit Critical if non-ok services exceed critical warning (no ranges)" );
  39. #
  40. # And for hosts..
  41. #
  42. $result = NPTest->testCmd(
  43. "./check_cluster -h -w 0:0 -c 0:0 -d 0,0,0,0"
  44. );
  45. cmp_ok( $result->return_code, '==', 0, "Exit OK if non-ok hosts are inside critical and warning ranges" );
  46. like( $result->output, qr/host/i, "Output contains the word 'host' (case insensitive)");
  47. $result = NPTest->testCmd(
  48. "./check_cluster -h -w 0:0 -c 0:1 -d 0,0,0,1"
  49. );
  50. cmp_ok( $result->return_code, '==', 1, "Exit WARNING if non-ok hosts are inside critical and outside warning ranges" );
  51. $result = NPTest->testCmd(
  52. "./check_cluster -h -w 0:0 -c 0:1 -d 0,0,1,1"
  53. );
  54. cmp_ok( $result->return_code, '==', 2, "Exit CRITICAL if non-ok hosts are inside critical and outside warning ranges" );
  55. $result = NPTest->testCmd(
  56. "./check_cluster -h -w 0 -c 0 -d 0,0,0,0"
  57. );
  58. cmp_ok( $result->return_code, '==', 0, "Exit OK if non-ok hosts are inside critical and warning (no ranges)" );
  59. $result = NPTest->testCmd(
  60. "./check_cluster -h -w 0 -c 1 -d 0,0,1,0"
  61. );
  62. cmp_ok( $result->return_code, '==', 1, "Exit WARNING if number of non-ok hosts exceed warning (no ranges)" );
  63. $result = NPTest->testCmd(
  64. "./check_cluster -h -w 0 -c 1 -d 0,0,1,1"
  65. );
  66. cmp_ok( $result->return_code, '==', 2, "Exit Critical if non-ok hosts exceed critical warning (no ranges)" );