Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

Commit

Permalink
test(acceptance): improve logs of dst downtime acceptance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kduret committed Jun 20, 2018
1 parent cb404be commit 273f548
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions features/bootstrap/DowntimeDSTContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,6 @@ public function theDowntimeIsProperlyScheduled()
{
$this->spin(
function ($context) {
$scheduled = false;
$return = $context->container->execute(
"cat /var/log/centreon-engine/centengine.log",
'web'
Expand All @@ -334,16 +333,16 @@ function ($context) {
$output,
$matches
)) {
$startTimestamp = end($matches[1]);
$endTimestamp = end($matches[2]);
$startTimestamp = $matches[1];
$endTimestamp = $matches[2];
$dateStart = new DateTime('now', new \DateTimeZone('Europe/Paris'));
$dateStart->setTimestamp($startTimestamp);
$dateEnd = new DateTime('now', new \DateTimeZone('Europe/Paris'));
$dateEnd->setTimestamp($endTimestamp);
if ($dateStart->format('Y-m-d H:i') == $context->downtimeProperties['expected_start'] &&
$dateEnd->format('Y-m-d H:i') == $context->downtimeProperties['expected_end'] &&
($endTimestamp - $startTimestamp) == $context->downtimeProperties['expected_duration']) {
$scheduled = true;
if ($dateStart->format('Y-m-d H:i') != $context->downtimeProperties['expected_start'] ||
$dateEnd->format('Y-m-d H:i') != $context->downtimeProperties['expected_end'] ||
($endTimestamp - $startTimestamp) != $context->downtimeProperties['expected_duration']) {
throw new \Exception('Downtime external command parameters are wrong (start, end or duration)');
}
$storageDb = $context->getStorageDatabase();
$res = $storageDb->query(
Expand All @@ -352,11 +351,13 @@ function ($context) {
"AND end_time = " . $endTimestamp
);
if (!$res->fetch()) {
$scheduled = false;
throw new \Exception('Downtime does not exist in storage database');
}
} else {
throw new \Exception('Downtime external command does not exist in centengine logs');
}

return $scheduled;
return true;
},
'Downtime is not scheduled',
10
Expand Down

0 comments on commit 273f548

Please sign in to comment.