Private GIT

Skip to content
Snippets Groups Projects
Commit cf15d3f7 authored by Matthieu Kermagoret's avatar Matthieu Kermagoret
Browse files

Strengthen metric limit acceptance test.

parent ace11599
Branches
Tags
No related merge requests found
......@@ -8,6 +8,6 @@ Feature: Limit metrics in chart
Scenario: Display message and button in performance page
Given a service with several metrics
When i display the chart in performance page
When I display the chart in performance page
Then a message says that the chart will not be displayed
And a button is available to display the chart
......@@ -23,6 +23,7 @@ class LimitMetricInChartContext extends CentreonContext
*/
public function aServiceWithSeveralMetrics()
{
// Create host.
$hostConfig = new HostConfigurationPage($this);
$hostProperties = array(
'name' => $this->hostName,
......@@ -37,6 +38,7 @@ class LimitMetricInChartContext extends CentreonContext
$hostConfig->setProperties($hostProperties);
$hostConfig->save();
// Create service.
$serviceConfig = new ServiceConfigurationPage($this);
$serviceProperties = array(
'description' => $this->serviceName,
......@@ -50,50 +52,48 @@ class LimitMetricInChartContext extends CentreonContext
$serviceConfig->setProperties($serviceProperties);
$serviceConfig->save();
// Ensure service is monitored.
$this->restartAllPollers();
sleep(7);
// Send multiple perfdata.
$perfdata = '';
for ($i = 0; $i < 20 ; $i++) {
$perfdata .= 'test' . $i . '=1s ';
}
sleep(5);
$this->submitServiceResult($this->hostName, $this->serviceName, 'OK', 'OK', $perfdata);
$self = $this;
// Ensure perfdata were processed.
$this->spin(
function($context) use ($self) {
$page = new ServiceMonitoringDetailsPage($self, $self->hostName, $self->serviceName);
function($context) {
$page = new ServiceMonitoringDetailsPage(
$context,
$context->hostName,
$context->serviceName
);
$properties = $page->getProperties();
if (count($properties['perfdata']) < 20) {
return false;
}
return true;
},
'Cannot get performance data of ' . $self->hostName . ' / ' . $self->serviceName
'Cannot get performance data of ' . $this->hostName . ' / ' . $this->serviceName
);
}
/**
* @When i display the chart in performance page
* @When I display the chart in performance page
*/
public function iDisplayTheChartInPerformancePage()
{
$this->chartPage = new GraphMonitoringPage($this);
$this->chartPage->setFilterbyChart($this->hostName, $this->serviceName);
sleep(3);
if (!$this->chartPage->hasChart($this->hostName, $this->serviceName)) {
throw new \Exception('Chart ' . $this->hostName . ' - ' . $this->serviceName . ' does not exist.');
}
}
/**
* @When i display the chart in service details page
*/
public function iDisplayTheChartInServiceDetailsPage()
{
new ServiceMonitoringDetailsPage($this, $this->hostName, $this->serviceName);
$this->chartPage = new GraphServiceDetailsMonitoringPage($this);
$this->spin(
function ($context) {
return $this->chartPage->hasChart($this->hostName, $this->serviceName);
},
'Chart ' . $this->hostName . ' - ' . $this->serviceName . ' does not exist.'
);
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment