diff --git a/features/DowntimeStartAndStop.feature b/features/DowntimeStartAndStop.feature index ada73d7142c19c7d7181e64828d7ee2af17d1bc0..ea9b060677102ec0eae4ed8535b92a345c6a764d 100644 --- a/features/DowntimeStartAndStop.feature +++ b/features/DowntimeStartAndStop.feature @@ -37,7 +37,7 @@ Feature: Downtime start and stop Given a flexible downtime on a monitored element And the flexible downtime is started When the downtime duration is finished - Then the downtime is stopped + Then the flexible downtime is stopped Scenario: Configure recurrent downtime Given a recurrent downtime on an other timezone service diff --git a/features/bootstrap/DowntimeStartAndStopContext.php b/features/bootstrap/DowntimeStartAndStopContext.php index 58549f7b222d29ee93807074a389a6b09be6e223..38020b6315d169da8a2a3c48705eafad28d4d13c 100644 --- a/features/bootstrap/DowntimeStartAndStopContext.php +++ b/features/bootstrap/DowntimeStartAndStopContext.php @@ -198,6 +198,36 @@ class DowntimeStartAndStopContext extends CentreonContext ); } + /** + * @Then the flexible downtime is stopped + */ + public function theFlexibleDowntimeIsStopped() + { + $this->spin( + function ($context) { + $finished = false; + + $storageDb = $context->getStorageDatabase(); + $res = $storageDb->query( + 'SELECT d.downtime_id, d.actual_end_time ' . + 'FROM downtimes d, hosts h, services s ' . + 'WHERE h.host_id = d.host_id ' . + 'AND s.service_id = d.service_id ' . + 'AND h.name = "' . $context->host . '" ' . + 'AND s.description = "' . $context->service . '" ' . + 'AND d.actual_end_time IS NOT NULL ' . + 'AND d.actual_end_time < ' . time() + ); + if ($row = $res->fetch()) { + $finished = true; + } + return $finished; + }, + 'FLexible downtime is still running.', + 30 + ); + } + /** * @Given a downtime in configuration of a user in other timezone */