Private GIT

Skip to content
Snippets Groups Projects
Commit e0ea03a3 authored by Stephane Chapron's avatar Stephane Chapron Committed by sc979
Browse files

fix(downtime): fix recurrent downtimes on hostGroups when no serviceGroup exist

parent 40a9a129
No related branches found
No related tags found
No related merge requests found
......@@ -105,6 +105,10 @@ default:
paths: [ %paths.base%/features/DowntimeDST.feature ]
contexts: [ DowntimeDSTContext ]
downtime_recurrent:
paths: [ %paths.base%/features/DowntimeRecurrent.feature ]
contexts: [ DowntimeRecurrentContext ]
command_arguments:
paths: [ %paths.base%/features/CommandArguments.feature ]
contexts: [ CommandArgumentsContext ]
......
Feature: Testing a recurrent Downtime
As a Centreon user
I want to be certain that the recurrent downtimes work correctly
To release quality products
Background:
Given I am logged in a Centreon server
@critical
Scenario: Testing a recurrent Downtime on a HostGroup without any ServiceGroup created (Bugfix)
Given a hostGroup is configured
And a recurrent downtime on a hostGroup
When this one gives a downtime
Then the recurrent downtime started
<?php
use Centreon\Test\Behat\CentreonContext;
use Centreon\Test\Behat\Configuration\ServiceConfigurationPage;
use Centreon\Test\Behat\Configuration\DowntimeConfigurationListingPage;
use Centreon\Test\Behat\Configuration\HostConfigurationPage;
use Centreon\Test\Behat\Configuration\HostGroupConfigurationPage;
use Centreon\Test\Behat\Configuration\RecurrentDowntimeConfigurationPage;
/**
* Defines application features from the specific context.
*/
class DowntimeRecurrentContext extends CentreonContext
{
protected $currentPage;
protected $startDate;
protected $endDate;
protected $host = array(
'name' => 'host',
'alias' => 'host',
'address' => 'host2@localhost',
'check_command' => 'check_centreon_dummy'
);
protected $hostGroup = array(
'name' => 'hostGroupName',
'alias' => 'hostGroupAlias',
'hosts' => 'host',
'enabled' => 1
);
protected $service = array(
'hosts' => 'host',
'description' => 'service',
'templates' => 'generic-service',
'check_command' => 'check_centreon_dummy',
'check_period' => '24x7',
'max_check_attempts' => 1,
'normal_check_interval' => 1,
'retry_check_interval' => 1,
'active_checks_enabled' => 1,
'passive_checks_enabled' => 0,
'notifications_enabled' => 1,
'notify_on_recovery' => 1,
'notify_on_critical' => 1,
'recovery_notification_delay' => 1,
'cs' => 'admin_admin'
);
/**
* @Given a hostGroup is configured
*/
public function aHostGroupIsConfigured()
{
$this->currentPage = new HostConfigurationPage($this);
$this->currentPage->setproperties($this->host);
$this->currentPage->save();
$this->currentPage = new HostGroupConfigurationPage($this);
$this->currentPage->setProperties($this->hostGroup);
$this->currentPage->save();
$this->currentPage = new ServiceConfigurationPage($this);
$this->currentPage->setProperties($this->service);
$this->currentPage->save();
$this->reloadAllPollers();
}
/**
* @Given a recurrent downtime on a hostGroup
*/
public function aRecurrentDowntime()
{
$this->startDate = new DateTime('now');
$this->endDate = new DateTime('now');
$this->endDate->add(new DateInterval('PT360M'));
$this->currentPage = new RecurrentDowntimeConfigurationPage($this);
$this->currentPage->setProperties(array(
'name' => 'test_DT',
'alias' => 'recurrent_DT',
'days' => array(7, 1, 2, 3, 4, 5, 6),
'start' => $this->startDate->format('H:i'),
'end' => $this->endDate->format('H:i'),
'hostgroup_relation' => $this->hostGroup['name']
));
$this->currentPage->save();
}
/**
* @When this one gives a downtime
*/
public function thisOneGivesADowntime()
{
/* faking cron's launchtime. 2 min sooner */
$this->container->execute(
"faketime -f '-120s' php /usr/share/centreon/cron/downtimeManager.php",
'web'
);
}
/**
* @Then the recurrent downtime started
*/
public function aRecurrentDowntimeIsStarted()
{
/* checking for results */
$this->spin(
function ($context) {
$found = false;
$this->currentPage = new DowntimeConfigurationListingPage($context);
$this->currentPage->displayDowntimeCycle();
foreach ($this->currentPage->getEntries() as $entry) {
if ($entry['host'] == $context->host['name'] &&
$entry['service'] == $context->service['description'] &&
$entry['started'] == true
) {
$found = true;
}
}
return $found;
}
);
}
}
\ No newline at end of file
......@@ -360,7 +360,7 @@ class CentreonDowntime
. 'dtp.dtp_month_cycle, dtp.dtp_day_of_month, dtp.dtp_fixed, dtp.dtp_duration, '
. 'h.host_id, h.host_name, NULL as service_id, NULL as service_description '
. 'FROM downtime_period dtp, downtime dt, '
. 'downtime_hostgroup_relation dhr, servicegroup sg, '
. 'downtime_hostgroup_relation dhr, '
. 'host h, hostgroup_relation hgr '
. 'WHERE dtp.dt_id = dhr.dt_id '
. 'AND dtp.dt_id = dt.dt_id '
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment