mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2025-12-29 02:09:33 -05:00
tests: Fix that some test cases work with invalid configurations
This has been no problem previously. But since the parser establishes parent-child relationships these are not parseable anymore. They'll now work with monitored nodes instead of processes.
This commit is contained in:
parent
75a3d1fd5e
commit
af11c3e715
4 changed files with 99 additions and 106 deletions
|
|
@ -12,8 +12,8 @@ class AndOperatorTest extends BaseTestCase
|
|||
{
|
||||
$storage = new LegacyStorage($this->emptyConfigSection());
|
||||
$expressions = array(
|
||||
'a = b',
|
||||
'a = b & c & d',
|
||||
'a = b;c',
|
||||
'a = b;c & c;d & d;e',
|
||||
);
|
||||
|
||||
foreach ($expressions as $expression) {
|
||||
|
|
@ -27,9 +27,9 @@ class AndOperatorTest extends BaseTestCase
|
|||
public function testThreeTimesCriticalIsCritical()
|
||||
{
|
||||
$bp = $this->getBp();
|
||||
$bp->setNodeState('b', 2);
|
||||
$bp->setNodeState('c', 2);
|
||||
$bp->setNodeState('d', 2);
|
||||
$bp->setNodeState('b;c', 2);
|
||||
$bp->setNodeState('c;d', 2);
|
||||
$bp->setNodeState('d;e', 2);
|
||||
|
||||
$this->assertEquals(
|
||||
'CRITICAL',
|
||||
|
|
@ -40,9 +40,9 @@ class AndOperatorTest extends BaseTestCase
|
|||
public function testTwoTimesCriticalAndOkIsCritical()
|
||||
{
|
||||
$bp = $this->getBp();
|
||||
$bp->setNodeState('b', 2);
|
||||
$bp->setNodeState('c', 0);
|
||||
$bp->setNodeState('d', 2);
|
||||
$bp->setNodeState('b;c', 2);
|
||||
$bp->setNodeState('c;d', 0);
|
||||
$bp->setNodeState('d;e', 2);
|
||||
|
||||
$this->assertEquals(
|
||||
'CRITICAL',
|
||||
|
|
@ -53,9 +53,9 @@ class AndOperatorTest extends BaseTestCase
|
|||
public function testCriticalAndWarningAndOkIsCritical()
|
||||
{
|
||||
$bp = $this->getBp();
|
||||
$bp->setNodeState('b', 2);
|
||||
$bp->setNodeState('c', 1);
|
||||
$bp->setNodeState('d', 0);
|
||||
$bp->setNodeState('b;c', 2);
|
||||
$bp->setNodeState('c;d', 1);
|
||||
$bp->setNodeState('d;e', 0);
|
||||
|
||||
$this->assertEquals(
|
||||
'CRITICAL',
|
||||
|
|
@ -66,9 +66,9 @@ class AndOperatorTest extends BaseTestCase
|
|||
public function testUnknownAndWarningAndOkIsUnknown()
|
||||
{
|
||||
$bp = $this->getBp();
|
||||
$bp->setNodeState('b', 0);
|
||||
$bp->setNodeState('c', 1);
|
||||
$bp->setNodeState('d', 3);
|
||||
$bp->setNodeState('b;c', 0);
|
||||
$bp->setNodeState('c;d', 1);
|
||||
$bp->setNodeState('d;e', 3);
|
||||
|
||||
$this->assertEquals(
|
||||
'UNKNOWN',
|
||||
|
|
@ -79,9 +79,9 @@ class AndOperatorTest extends BaseTestCase
|
|||
public function testTwoTimesWarningAndOkIsWarning()
|
||||
{
|
||||
$bp = $this->getBp();
|
||||
$bp->setNodeState('b', 0);
|
||||
$bp->setNodeState('c', 1);
|
||||
$bp->setNodeState('d', 1);
|
||||
$bp->setNodeState('b;c', 0);
|
||||
$bp->setNodeState('c;d', 1);
|
||||
$bp->setNodeState('d;e', 1);
|
||||
|
||||
$this->assertEquals(
|
||||
'WARNING',
|
||||
|
|
@ -92,9 +92,9 @@ class AndOperatorTest extends BaseTestCase
|
|||
public function testThreeTimesOkIsOk()
|
||||
{
|
||||
$bp = $this->getBp();
|
||||
$bp->setNodeState('b', 0);
|
||||
$bp->setNodeState('c', 0);
|
||||
$bp->setNodeState('d', 0);
|
||||
$bp->setNodeState('b;c', 0);
|
||||
$bp->setNodeState('c;d', 0);
|
||||
$bp->setNodeState('d;e', 0);
|
||||
|
||||
$this->assertEquals(
|
||||
'OK',
|
||||
|
|
@ -203,7 +203,7 @@ class AndOperatorTest extends BaseTestCase
|
|||
protected function getBp()
|
||||
{
|
||||
$storage = new LegacyStorage($this->emptyConfigSection());
|
||||
$expression = 'a = b & c & d';
|
||||
$expression = 'a = b;c & c;d & d;e';
|
||||
$bp = $storage->loadFromString('dummy', $expression);
|
||||
$bp->createBp('b');
|
||||
$bp->createBp('c');
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ class MinOperatorTest extends BaseTestCase
|
|||
{
|
||||
$storage = new LegacyStorage($this->emptyConfigSection());
|
||||
$expressions = array(
|
||||
'a = 1 of: b',
|
||||
'a = 2 of: b + c + d',
|
||||
'a = 1 of: b;c',
|
||||
'a = 2 of: b;c + c;d + d;e',
|
||||
);
|
||||
$this->getName();
|
||||
foreach ($expressions as $expression) {
|
||||
|
|
@ -26,9 +26,9 @@ class MinOperatorTest extends BaseTestCase
|
|||
public function testTwoOfThreeTimesCriticalAreAtLeastCritical()
|
||||
{
|
||||
$bp = $this->getBp();
|
||||
$bp->setNodeState('b', 2);
|
||||
$bp->setNodeState('c', 2);
|
||||
$bp->setNodeState('d', 2);
|
||||
$bp->setNodeState('b;c', 2);
|
||||
$bp->setNodeState('c;d', 2);
|
||||
$bp->setNodeState('d;e', 2);
|
||||
|
||||
$this->assertEquals(
|
||||
'CRITICAL',
|
||||
|
|
@ -39,9 +39,9 @@ class MinOperatorTest extends BaseTestCase
|
|||
public function testTwoOfTwoTimesCriticalAndUnknownAreAtLeastCritical()
|
||||
{
|
||||
$bp = $this->getBp();
|
||||
$bp->setNodeState('b', 2);
|
||||
$bp->setNodeState('c', 3);
|
||||
$bp->setNodeState('d', 2);
|
||||
$bp->setNodeState('b;c', 2);
|
||||
$bp->setNodeState('c;d', 3);
|
||||
$bp->setNodeState('d;e', 2);
|
||||
|
||||
$this->assertEquals(
|
||||
'CRITICAL',
|
||||
|
|
@ -52,9 +52,9 @@ class MinOperatorTest extends BaseTestCase
|
|||
public function testTwoOfCriticalAndWarningAndOkAreAtLeastCritical()
|
||||
{
|
||||
$bp = $this->getBp();
|
||||
$bp->setNodeState('b', 2);
|
||||
$bp->setNodeState('c', 1);
|
||||
$bp->setNodeState('d', 0);
|
||||
$bp->setNodeState('b;c', 2);
|
||||
$bp->setNodeState('c;d', 1);
|
||||
$bp->setNodeState('d;e', 0);
|
||||
|
||||
$this->assertEquals(
|
||||
'CRITICAL',
|
||||
|
|
@ -65,9 +65,9 @@ class MinOperatorTest extends BaseTestCase
|
|||
public function testTwoOfUnknownAndWarningAndCriticalAreAtLeastCritical()
|
||||
{
|
||||
$bp = $this->getBp();
|
||||
$bp->setNodeState('b', 2);
|
||||
$bp->setNodeState('c', 1);
|
||||
$bp->setNodeState('d', 3);
|
||||
$bp->setNodeState('b;c', 2);
|
||||
$bp->setNodeState('c;d', 1);
|
||||
$bp->setNodeState('d;e', 3);
|
||||
|
||||
$this->assertEquals(
|
||||
'CRITICAL',
|
||||
|
|
@ -78,9 +78,9 @@ class MinOperatorTest extends BaseTestCase
|
|||
public function testTwoOfTwoTimesWarningAndUnknownAreAtLeastUnknown()
|
||||
{
|
||||
$bp = $this->getBp();
|
||||
$bp->setNodeState('b', 3);
|
||||
$bp->setNodeState('c', 1);
|
||||
$bp->setNodeState('d', 1);
|
||||
$bp->setNodeState('b;c', 3);
|
||||
$bp->setNodeState('c;d', 1);
|
||||
$bp->setNodeState('d;e', 1);
|
||||
|
||||
$this->assertEquals(
|
||||
'UNKNOWN',
|
||||
|
|
@ -91,9 +91,9 @@ class MinOperatorTest extends BaseTestCase
|
|||
public function testTwoOfThreeTimesOkAreAtLeastOk()
|
||||
{
|
||||
$bp = $this->getBp();
|
||||
$bp->setNodeState('b', 0);
|
||||
$bp->setNodeState('c', 0);
|
||||
$bp->setNodeState('d', 0);
|
||||
$bp->setNodeState('b;c', 0);
|
||||
$bp->setNodeState('c;d', 0);
|
||||
$bp->setNodeState('d;e', 0);
|
||||
|
||||
$this->assertEquals(
|
||||
'OK',
|
||||
|
|
@ -114,8 +114,8 @@ class MinOperatorTest extends BaseTestCase
|
|||
public function testTenWithOnlyTwoCritical()
|
||||
{
|
||||
$bp = $this->getBp(10, 8, 0);
|
||||
$bp->setNodeState('b', 2);
|
||||
$bp->setNodeState('c', 2);
|
||||
$bp->setNodeState('b;c', 2);
|
||||
$bp->setNodeState('c;d', 2);
|
||||
|
||||
$this->assertEquals(
|
||||
'OK',
|
||||
|
|
@ -126,9 +126,9 @@ class MinOperatorTest extends BaseTestCase
|
|||
public function testTenWithThreeCritical()
|
||||
{
|
||||
$bp = $this->getBp(10, 8, 0);
|
||||
$bp->setNodeState('b', 2);
|
||||
$bp->setNodeState('c', 2);
|
||||
$bp->setNodeState('d', 2);
|
||||
$bp->setNodeState('b;c', 2);
|
||||
$bp->setNodeState('c;d', 2);
|
||||
$bp->setNodeState('d;e', 2);
|
||||
|
||||
$this->assertEquals(
|
||||
'CRITICAL',
|
||||
|
|
@ -139,9 +139,9 @@ class MinOperatorTest extends BaseTestCase
|
|||
public function testTenWithThreeWarning()
|
||||
{
|
||||
$bp = $this->getBp(10, 8, 0);
|
||||
$bp->setNodeState('b', 1);
|
||||
$bp->setNodeState('c', 1);
|
||||
$bp->setNodeState('d', 1);
|
||||
$bp->setNodeState('b;c', 1);
|
||||
$bp->setNodeState('c;d', 1);
|
||||
$bp->setNodeState('d;e', 1);
|
||||
|
||||
$this->assertEquals(
|
||||
'WARNING',
|
||||
|
|
@ -157,14 +157,13 @@ class MinOperatorTest extends BaseTestCase
|
|||
$names = array();
|
||||
$a = 97;
|
||||
for ($i = 1; $i <= $count; $i++) {
|
||||
$names[] = chr($a + $i);
|
||||
$names[] = chr($a + $i) . ';' . chr($a + $i + 1);
|
||||
}
|
||||
|
||||
$storage = new LegacyStorage($this->emptyConfigSection());
|
||||
$expression = sprintf('a = %d of: %s', $min, join(' + ', $names));
|
||||
$bp = $storage->loadFromString('dummy', $expression);
|
||||
foreach ($names as $n) {
|
||||
$bp->createBp($n);
|
||||
if ($defaultState !== null) {
|
||||
$bp->setNodeState($n, $defaultState);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,10 +12,10 @@ class NotOperatorTest extends BaseTestCase
|
|||
{
|
||||
$storage = new LegacyStorage($this->emptyConfigSection());
|
||||
$expressions = array(
|
||||
'a = !b',
|
||||
'a = ! b',
|
||||
'a = b ! c ! d',
|
||||
'a = ! b ! c ! d !',
|
||||
'a = !b;c',
|
||||
'a = ! b;c',
|
||||
'a = b;c ! c;d ! d;e',
|
||||
'a = ! b;c ! c;d ! d;e !',
|
||||
);
|
||||
|
||||
foreach ($expressions as $expression) {
|
||||
|
|
@ -29,10 +29,10 @@ class NotOperatorTest extends BaseTestCase
|
|||
public function testASimpleNegationGivesTheCorrectResult()
|
||||
{
|
||||
$storage = new LegacyStorage($this->emptyConfigSection());
|
||||
$expression = 'a = !b';
|
||||
$expression = 'a = !b;c';
|
||||
$bp = $storage->loadFromString('dummy', $expression);
|
||||
$a = $bp->getNode('a');
|
||||
$b = $bp->createBp('b')->setState(3);
|
||||
$b = $bp->getNode('b;c')->setState(3);
|
||||
$this->assertEquals(
|
||||
'OK',
|
||||
$a->getStateName()
|
||||
|
|
@ -49,9 +49,9 @@ class NotOperatorTest extends BaseTestCase
|
|||
public function testThreeTimesCriticalIsOk()
|
||||
{
|
||||
$bp = $this->getBp();
|
||||
$bp->setNodeState('b', 2);
|
||||
$bp->setNodeState('c', 2);
|
||||
$bp->setNodeState('d', 2);
|
||||
$bp->setNodeState('b;c', 2);
|
||||
$bp->setNodeState('c;d', 2);
|
||||
$bp->setNodeState('d;e', 2);
|
||||
|
||||
$this->assertEquals(
|
||||
'OK',
|
||||
|
|
@ -62,9 +62,9 @@ class NotOperatorTest extends BaseTestCase
|
|||
public function testThreeTimesUnknownIsOk()
|
||||
{
|
||||
$bp = $this->getBp();
|
||||
$bp->setNodeState('b', 3);
|
||||
$bp->setNodeState('c', 3);
|
||||
$bp->setNodeState('d', 3);
|
||||
$bp->setNodeState('b;c', 3);
|
||||
$bp->setNodeState('c;d', 3);
|
||||
$bp->setNodeState('d;e', 3);
|
||||
|
||||
$this->assertEquals(
|
||||
'OK',
|
||||
|
|
@ -75,9 +75,9 @@ class NotOperatorTest extends BaseTestCase
|
|||
public function testThreeTimesWarningIsWarning()
|
||||
{
|
||||
$bp = $this->getBp();
|
||||
$bp->setNodeState('b', 1);
|
||||
$bp->setNodeState('c', 1);
|
||||
$bp->setNodeState('d', 1);
|
||||
$bp->setNodeState('b;c', 1);
|
||||
$bp->setNodeState('c;d', 1);
|
||||
$bp->setNodeState('d;e', 1);
|
||||
|
||||
$this->assertEquals(
|
||||
'WARNING',
|
||||
|
|
@ -88,9 +88,9 @@ class NotOperatorTest extends BaseTestCase
|
|||
public function testThreeTimesOkIsCritical()
|
||||
{
|
||||
$bp = $this->getBp();
|
||||
$bp->setNodeState('b', 0);
|
||||
$bp->setNodeState('c', 0);
|
||||
$bp->setNodeState('d', 0);
|
||||
$bp->setNodeState('b;c', 0);
|
||||
$bp->setNodeState('c;d', 0);
|
||||
$bp->setNodeState('d;e', 0);
|
||||
|
||||
$this->assertEquals(
|
||||
'CRITICAL',
|
||||
|
|
@ -101,9 +101,9 @@ class NotOperatorTest extends BaseTestCase
|
|||
public function testNotOkAndWarningAndCriticalIsOk()
|
||||
{
|
||||
$bp = $this->getBp();
|
||||
$bp->setNodeState('b', 0);
|
||||
$bp->setNodeState('c', 1);
|
||||
$bp->setNodeState('d', 2);
|
||||
$bp->setNodeState('b;c', 0);
|
||||
$bp->setNodeState('c;d', 1);
|
||||
$bp->setNodeState('d;e', 2);
|
||||
|
||||
$this->assertEquals(
|
||||
'OK',
|
||||
|
|
@ -114,9 +114,9 @@ class NotOperatorTest extends BaseTestCase
|
|||
public function testNotWarningAndUnknownAndCriticalIsOk()
|
||||
{
|
||||
$bp = $this->getBp();
|
||||
$bp->setNodeState('b', 3);
|
||||
$bp->setNodeState('c', 2);
|
||||
$bp->setNodeState('d', 1);
|
||||
$bp->setNodeState('b;c', 3);
|
||||
$bp->setNodeState('c;d', 2);
|
||||
$bp->setNodeState('d;e', 1);
|
||||
|
||||
$this->assertEquals(
|
||||
'OK',
|
||||
|
|
@ -127,9 +127,9 @@ class NotOperatorTest extends BaseTestCase
|
|||
public function testNotTwoTimesWarningAndOkIsWarning()
|
||||
{
|
||||
$bp = $this->getBp();
|
||||
$bp->setNodeState('b', 0);
|
||||
$bp->setNodeState('c', 1);
|
||||
$bp->setNodeState('d', 1);
|
||||
$bp->setNodeState('b;c', 0);
|
||||
$bp->setNodeState('c;d', 1);
|
||||
$bp->setNodeState('d;e', 1);
|
||||
|
||||
$this->assertEquals(
|
||||
'WARNING',
|
||||
|
|
@ -143,11 +143,8 @@ class NotOperatorTest extends BaseTestCase
|
|||
protected function getBp()
|
||||
{
|
||||
$storage = new LegacyStorage($this->emptyConfigSection());
|
||||
$expression = 'a = ! b ! c ! d';
|
||||
$expression = 'a = ! b;c ! c;d ! d;e';
|
||||
$bp = $storage->loadFromString('dummy', $expression);
|
||||
$bp->createBp('b');
|
||||
$bp->createBp('c');
|
||||
$bp->createBp('d');
|
||||
|
||||
return $bp;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ class OrOperatorTest extends BaseTestCase
|
|||
{
|
||||
$storage = new LegacyStorage($this->emptyConfigSection());
|
||||
$expressions = array(
|
||||
'a = b',
|
||||
'a = b | c | d',
|
||||
'a = b;c',
|
||||
'a = b;c | c;d | d;e',
|
||||
);
|
||||
|
||||
foreach ($expressions as $expression) {
|
||||
|
|
@ -27,9 +27,9 @@ class OrOperatorTest extends BaseTestCase
|
|||
public function testThreeTimesCriticalIsCritical()
|
||||
{
|
||||
$bp = $this->getBp();
|
||||
$bp->setNodeState('b', 2);
|
||||
$bp->setNodeState('c', 2);
|
||||
$bp->setNodeState('d', 2);
|
||||
$bp->setNodeState('b;c', 2);
|
||||
$bp->setNodeState('c;d', 2);
|
||||
$bp->setNodeState('d;e', 2);
|
||||
|
||||
$this->assertEquals(
|
||||
'CRITICAL',
|
||||
|
|
@ -40,9 +40,9 @@ class OrOperatorTest extends BaseTestCase
|
|||
public function testTwoTimesCriticalOrUnknownIsUnknown()
|
||||
{
|
||||
$bp = $this->getBp();
|
||||
$bp->setNodeState('b', 2);
|
||||
$bp->setNodeState('c', 3);
|
||||
$bp->setNodeState('d', 2);
|
||||
$bp->setNodeState('b;c', 2);
|
||||
$bp->setNodeState('c;d', 3);
|
||||
$bp->setNodeState('d;e', 2);
|
||||
|
||||
$this->assertEquals(
|
||||
'UNKNOWN',
|
||||
|
|
@ -53,9 +53,9 @@ class OrOperatorTest extends BaseTestCase
|
|||
public function testCriticalOrWarningOrOkIsOk()
|
||||
{
|
||||
$bp = $this->getBp();
|
||||
$bp->setNodeState('b', 2);
|
||||
$bp->setNodeState('c', 1);
|
||||
$bp->setNodeState('d', 0);
|
||||
$bp->setNodeState('b;c', 2);
|
||||
$bp->setNodeState('c;d', 1);
|
||||
$bp->setNodeState('d;e', 0);
|
||||
|
||||
$this->assertEquals(
|
||||
'OK',
|
||||
|
|
@ -66,9 +66,9 @@ class OrOperatorTest extends BaseTestCase
|
|||
public function testUnknownOrWarningOrCriticalIsWarning()
|
||||
{
|
||||
$bp = $this->getBp();
|
||||
$bp->setNodeState('b', 2);
|
||||
$bp->setNodeState('c', 1);
|
||||
$bp->setNodeState('d', 3);
|
||||
$bp->setNodeState('b;c', 2);
|
||||
$bp->setNodeState('c;d', 1);
|
||||
$bp->setNodeState('d;e', 3);
|
||||
|
||||
$this->assertEquals(
|
||||
'WARNING',
|
||||
|
|
@ -79,9 +79,9 @@ class OrOperatorTest extends BaseTestCase
|
|||
public function testTwoTimesWarningAndOkIsOk()
|
||||
{
|
||||
$bp = $this->getBp();
|
||||
$bp->setNodeState('b', 0);
|
||||
$bp->setNodeState('c', 1);
|
||||
$bp->setNodeState('d', 1);
|
||||
$bp->setNodeState('b;c', 0);
|
||||
$bp->setNodeState('c;d', 1);
|
||||
$bp->setNodeState('d;e', 1);
|
||||
|
||||
$this->assertEquals(
|
||||
'OK',
|
||||
|
|
@ -92,9 +92,9 @@ class OrOperatorTest extends BaseTestCase
|
|||
public function testThreeTimesWarningIsWarning()
|
||||
{
|
||||
$bp = $this->getBp();
|
||||
$bp->setNodeState('b', 1);
|
||||
$bp->setNodeState('c', 1);
|
||||
$bp->setNodeState('d', 1);
|
||||
$bp->setNodeState('b;c', 1);
|
||||
$bp->setNodeState('c;d', 1);
|
||||
$bp->setNodeState('d;e', 1);
|
||||
|
||||
$this->assertEquals(
|
||||
'WARNING',
|
||||
|
|
@ -108,11 +108,8 @@ class OrOperatorTest extends BaseTestCase
|
|||
protected function getBp()
|
||||
{
|
||||
$storage = new LegacyStorage($this->emptyConfigSection());
|
||||
$expression = 'a = b | c | d';
|
||||
$expression = 'a = b;c | c;d | d;e';
|
||||
$bp = $storage->loadFromString('dummy', $expression);
|
||||
$bp->createBp('b');
|
||||
$bp->createBp('c');
|
||||
$bp->createBp('d');
|
||||
|
||||
return $bp;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue