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

Commit

Permalink
New Feature MassiveChangeHost (#5452)
Browse files Browse the repository at this point in the history
* Feature created

* * fix style

* Test completed

* * add recovery notification delay in massive change #5451

* Delete vrml_image

* * dont delete empty input

* * fix style
  • Loading branch information
mariegallardo authored and loiclau committed Jul 24, 2017
1 parent ec67d95 commit 44059e8
Show file tree
Hide file tree
Showing 4 changed files with 396 additions and 0 deletions.
5 changes: 5 additions & 0 deletions behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,8 @@ default:
paths: [ %paths.base%/features/TimePeriodConfiguration.feature ]
contexts:
- TimePeriodConfigurationContext

massive_change_hosts:
paths: [ %paths.base%/features/MassiveChangeHosts.feature ]
contexts:
- MassiveChangeHostsContext
12 changes: 12 additions & 0 deletions features/MassiveChangeHosts.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Feature: Massive Change on Hosts
As a Centreon administrator
I want to modify some properties of similar hosts
To configure quickly numerous hosts at the same time

Background:
Given I am logged in a Centreon server
And several hosts have been created with mandatory properties

Scenario: Configure by massive change several hosts with same properties
When I have applied Massive Change operation to several hosts
Then all selected hosts are updated with the same values
346 changes: 346 additions & 0 deletions features/bootstrap/MassiveChangeHostsContext.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,346 @@
<?php
use Centreon\Test\Behat\CentreonContext;
use Centreon\Test\Behat\Configuration\MassiveChangeHostConfigurationPage;
use Centreon\Test\Behat\Configuration\HostConfigurationPage;
use Centreon\Test\Behat\Configuration\HostConfigurationListingPage;
use Centreon\Test\Behat\Configuration\HostGroupConfigurationPage;
use Centreon\Test\Behat\Configuration\HostCategoryConfigurationPage;

class MassiveChangeHostsContext extends CentreonContext
{
protected $currentPage;

protected $host1 = array(
'name' => 'host1Name',
'alias' => 'host1Alias',
'address' => 'host1@localhost'
);

protected $host2 = array(
'name' => 'host2Name',
'alias' => 'host2Alias',
'address' => 'host2@localhost'
);

protected $host3 = array(
'name' => 'host3Name',
'alias' => 'host3Alias',
'address' => 'host3@localhost'
);

protected $hostGroup = array(
'name' => 'hostGroupName',
'alias' => 'hostGroupAlias'
);

protected $hostCategory1 = array(
'name' => 'hostCategoryName1',
'alias' => 'hostCategoryAlias1',
'severity' => 1,
'severity_level' => 2,
'severity_icon' => ' centreon (png)'
);

protected $hostCategory2 = array(
'name' => 'hostCategoryName2',
'alias' => 'hostCategoryAlias2'
);

protected $updatedProperties = array(
'snmp_community' => 'snmp',
'snmp_version' => '2c',
'monitored_from' => 'Central',
'monitored_option' => 1,
'location' => 'Europe/Paris',
'update_mode_tplp' => 0,
'templates' => array(
'generic-host'
),
'service_linked_to_template' => 0,
'command_arguments' => 'hostCommandArgument',
'macros' => array(
'HOSTMACRONAME' => '22'
),
'check_command' => 'check_http',
'check_period' => 'workhours',
'max_check_attempts' => 34,
'normal_check_interval' => 5,
'retry_check_interval' => 10,
'active_checks_enabled' => 2,
'passive_checks_enabled' => 0,
'notifications_enabled' => 1,
'contact_additive_inheritance' => 1,
'contacts' => 'Guest',
'contact_group_additive_inheritance' => 0,
'contact_groups' => 'Supervisors',
'update_mode_notifopts' => 1,
'notify_on_down' => 1,
'notify_on_unreachable' => 1,
'notify_on_recovery' => 1,
'notify_on_flapping' => 1,
'notify_on_downtime_scheduled' => 1,
'notify_on_none' => 0,
'notification_interval' => 17,
'update_mode_hcg' => 1,
'update_mode_notif_interval' => 0,
'update_mode_timeperiod' => 0,
'notification_period' => 'none',
'update_mode_first_notif_delay' => 1,
'first_notification_delay' => 4,
'recovery_notification_delay' => 3,
'update_mode_hhg' => 0,
'parent_host_groups' => 'hostGroupName',
'update_mode_hhc' => 1,
'parent_host_categories' => 'hostCategoryName2',
'update_mode_hpar' => 1,
'parent_hosts' => 'Centreon-Server',
'update_mode_hch' => 0,
'child_hosts' => 'host3Name',
'obsess_over_host' => 2,
'acknowledgement_timeout' => 2,
'check_freshness' => 0,
'freshness_threshold' => 34,
'flap_detection_enabled' => 1,
'low_flap_threshold' => 67,
'high_flap_threshold' => 85,
'retain_status_information' => 2,
'retain_non_status_information' => 0,
'stalking_option_on_up' => 1,
'stalking_option_on_down' => 0,
'stalking_option_on_unreachable' => 1,
'event_handler_enabled' => 2,
'event_handler' => 'check_https',
'event_handler_arguments' => 'event_handler_arguments',
'url' => 'hostMassiveChangeUrl',
'notes' => 'hostMassiveChangeNotes',
'action_url' => 'hostMassiveChangeActionUrl',
'icon' => ' centreon (png)',
'alt_icon' => 'hostMassiveChangeIcon',
'status_map_image' => ' centreon (png)',
'geo_coordinates' => 'Paris',
'2d_coords' => '15,84',
'3d_coords' => '15,84,76',
'severity_level' => 'hostCategoryName1 (2)',
'enabled' => 0,
'comments' => 'hostMassiveChangeComments'
);

protected $updatedHost1 = array(
'name' => 'host1Name',
'alias' => 'host1Alias',
'address' => 'host1@localhost',
'snmp_community' => 'snmp',
'snmp_version' => '2c',
'monitored_from' => 'Central',
'location' => 'Europe/Paris',
'templates' => array(
'generic-host'
),
'service_linked_to_template' => 0,
'check_command' => 'check_http',
'command_arguments' => 'hostCommandArgument',
'macros' => array(
'HOSTMACRONAME' => '22'
),
'check_period' => 'workhours',
'max_check_attempts' => 34,
'normal_check_interval' => 5,
'retry_check_interval' => 10,
'active_checks_enabled' => 2,
'passive_checks_enabled' => 0,
'notifications_enabled' => 1,
'contact_additive_inheritance' => 1,
'contacts' => 'Guest',
'contact_group_additive_inheritance' => 0,
'contact_groups' => 'Supervisors',
'notify_on_down' => 1,
'notify_on_unreachable' => 1,
'notify_on_recovery' => 1,
'notify_on_flapping' => 1,
'notify_on_downtime_scheduled' => 1,
'notify_on_none' => 1,
'notification_interval' => 17,
'notification_period' => 'none',
'first_notification_delay' => 4,
'recovery_notification_delay' => 3,
'parent_host_groups' => 'hostGroupName',
'parent_host_categories' => 'hostCategoryName2',
'parent_hosts' => 'Centreon-Server',
'child_hosts' => 'host3Name',
'obsess_over_host' => 2,
'acknowledgement_timeout' => 2,
'check_freshness' => 0,
'freshness_threshold' => 34,
'flap_detection_enabled' => 1,
'low_flap_threshold' => 67,
'high_flap_threshold' => 85,
'retain_status_information' => 2,
'retain_non_status_information' => 0,
'stalking_option_on_up' => 1,
'stalking_option_on_down' => 0,
'stalking_option_on_unreachable' => 1,
'event_handler_enabled' => 2,
'event_handler' => 'check_https',
'event_handler_arguments' => 'event_handler_arguments',
'url' => 'hostMassiveChangeUrl',
'notes' => 'hostMassiveChangeNotes',
'action_url' => 'hostMassiveChangeActionUrl',
'icon' => ' centreon (png)',
'alt_icon' => 'hostMassiveChangeIcon',
'status_map_image' => ' centreon (png)',
'geo_coordinates' => 'Paris',
'2d_coords' => '15,84',
'3d_coords' => '15,84,76',
'severity_level' => 'hostCategoryName1 (2)',
'enabled' => 0,
'comments' => 'hostMassiveChangeComments'
);

protected $updatedHost2 = array(
'name' => 'host2Name',
'alias' => 'host2Alias',
'address' => 'host2@localhost',
'snmp_community' => 'snmp',
'snmp_version' => '2c',
'monitored_from' => 'Central',
'location' => 'Europe/Paris',
'templates' => array(
'generic-host'
),
'service_linked_to_template' => 0,
'check_command' => 'check_http',
'command_arguments' => 'hostCommandArgument',
'macros' => array(
'HOSTMACRONAME' => '22'
),
'check_period' => 'workhours',
'max_check_attempts' => 34,
'normal_check_interval' => 5,
'retry_check_interval' => 10,
'active_checks_enabled' => 2,
'passive_checks_enabled' => 0,
'notifications_enabled' => 1,
'contact_additive_inheritance' => 1,
'contacts' => 'Guest',
'contact_group_additive_inheritance' => 0,
'contact_groups' => 'Supervisors',
'notify_on_down' => 1,
'notify_on_unreachable' => 1,
'notify_on_recovery' => 1,
'notify_on_flapping' => 1,
'notify_on_downtime_scheduled' => 1,
'notify_on_none' => 1,
'notification_interval' => 17,
'notification_period' => 'none',
'first_notification_delay' => 4,
'recovery_notification_delay' => 3,
'parent_host_groups' => 'hostGroupName',
'parent_host_categories' => 'hostCategoryName2',
'parent_hosts' => 'Centreon-Server',
'child_hosts' => 'host3Name',
'obsess_over_host' => 2,
'acknowledgement_timeout' => 2,
'check_freshness' => 0,
'freshness_threshold' => 34,
'flap_detection_enabled' => 1,
'low_flap_threshold' => 67,
'high_flap_threshold' => 85,
'retain_status_information' => 2,
'retain_non_status_information' => 0,
'stalking_option_on_up' => 1,
'stalking_option_on_down' => 0,
'stalking_option_on_unreachable' => 1,
'event_handler_enabled' => 2,
'event_handler' => 'check_https',
'event_handler_arguments' => 'event_handler_arguments',
'url' => 'hostMassiveChangeUrl',
'notes' => 'hostMassiveChangeNotes',
'action_url' => 'hostMassiveChangeActionUrl',
'icon' => ' centreon (png)',
'alt_icon' => 'hostMassiveChangeIcon',
'status_map_image' => ' centreon (png)',
'geo_coordinates' => 'Paris',
'2d_coords' => '15,84',
'3d_coords' => '15,84,76',
'severity_level' => 'hostCategoryName1 (2)',
'enabled' => 0,
'comments' => 'hostMassiveChangeComments'
);

/**
* @Given several hosts have been created with mandatory properties
*/
public function severalHostsHaveBeenCreatedWithMandatoryProperties()
{
$this->currentPage = new HostConfigurationPage($this);
$this->currentPage->setProperties($this->host1);
$this->currentPage->save();
$this->currentPage = new HostConfigurationPage($this);
$this->currentPage->setProperties($this->host2);
$this->currentPage->save();
$this->currentPage = new HostConfigurationPage($this);
$this->currentPage->setProperties($this->host3);
$this->currentPage->save();
$this->currentPage = new HostGroupConfigurationPage($this);
$this->currentPage->setProperties($this->hostGroup);
$this->currentPage->save();
$this->currentPage = new HostCategoryConfigurationPage($this);
$this->currentPage->setProperties($this->hostCategory1);
$this->currentPage->save();
$this->currentPage = new HostCategoryConfigurationPage($this);
$this->currentPage->setProperties($this->hostCategory2);
$this->currentPage->save();
}

/**
* @When I have applied Massive Change operation to several hosts
*/
public function iHaveAppliedMassiveChangeOperationToSeveralHosts()
{
$this->currentPage = new HostConfigurationListingPage($this);
$object = $this->currentPage->getEntry($this->host1['name']);
$this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check();
$object = $this->currentPage->getEntry($this->host2['name']);
$this->assertFind('css', 'input[type="checkbox"][name="select[' . $object['id'] . ']"]')->check();
$this->selectInList('select[name="o1"]', 'Massive Change');
$this->currentPage = new MassiveChangeHostConfigurationPage($this, false);
$this->currentPage->setProperties($this->updatedProperties);
$this->currentPage->save();
}

/**
* @Then all selected hosts are updated with the same values
*/
public function allSelectedHostsAreUpdatedWithTheSameValues()
{
$this->tableau = array();
try {
$this->spin(
function ($context) {
$this->currentPage = new HostConfigurationListingPage($this);
$this->currentPage = $this->currentPage->inspect($this->updatedHost1['name']);
$object = $this->currentPage->getProperties();
foreach ($this->updatedHost1 as $key => $value) {
if ($value != $object[$key]) {
$this->tableau[] = $key . '1';
}
}
$this->currentPage = new HostConfigurationListingPage($this);
$this->currentPage = $this->currentPage->inspect($this->updatedHost2['name']);
$object = $this->currentPage->getProperties();
foreach ($this->updatedHost2 as $key => $value) {
if ($value != $object[$key]) {
$this->tableau[] = $key . '2';
}
}
return count($this->tableau) == 0;
},
"Some properties are not being updated : ",
5
);
} catch (\Exception $e) {
$this->tableau = array_unique($this->tableau);
throw new \Exception("Some properties are not being updated : " . implode(',', $this->tableau));
}
}
}
Loading

0 comments on commit 44059e8

Please sign in to comment.