Commits
108
108
* Function that checks how a running HA cluster info is displayed in system information widget or report.
109
109
*
110
110
* @param integer $dashboardid id of the dashboard that the widgets are located in.
111
111
*/
112
112
public function assertEnabledHACluster($dashboardid = null) {
113
113
global $DB;
114
114
self::$skip_fields = [];
115
115
$url = (!$dashboardid) ? 'zabbix.php?action=report.status' : 'zabbix.php?action=dashboard.view&dashboardid='.$dashboardid;
116
116
// Wait for frontend to get the new config from updated zabbix.conf.php file.
117
117
sleep((int) ini_get('opcache.revalidate_freq') + 1);
118
-
$this->page->login()->open($url);
118
+
$this->page->login()->open($url)->waitUntilReady();
119
119
120
120
// Not waiting for page to load to minimise the possibility of difference between the time in report and in constant.
121
121
$current_time = time();
122
-
$this->page->waitUntilReady();
123
122
124
123
if (!$dashboardid) {
125
124
$nodes_table = $this->query('xpath://table[@class="list-table sticky-header sticky-footer"]')->asTable()->one();
126
125
$server_address = $this->query('xpath://th[text()="Zabbix server is running"]/../td[2]')->one();
127
126
}
128
127
else {
129
128
$dashboard = CDashboardElement::find()->waitUntilReady()->one();
130
129
$nodes_table = $dashboard->getWidget('High availability nodes view')->query('xpath:.//table')->asTable()->one();
131
130
$server_address = $dashboard->getWidget('System stats view')->query('xpath:.//tbody/tr[1]/td[2]')->one();
132
131
}
139
138
'Standby node' => self::$standby_lastaccess
140
139
];
141
140
142
141
/**
143
142
* The below foreach cycle compares lastaccess as time difference for each node in the widget or part of report
144
143
* that displays the list of nodes and excludes corresponding element from screenshot.
145
144
*/
146
145
foreach ($nodes as $name => $lastaccess_db) {
147
146
$row = $nodes_table->findRow('Name', $name);
148
147
$last_seen = $row->getColumn('Last access');
148
+
self::$skip_fields[] = $last_seen;
149
149
150
150
/**
151
151
* Converting unix timestamp difference into difference in time units and creating an array of such reference
152
152
* values. This is required because several seconds might have passed from defining $current_time and
153
153
* loading the page. Afterwards, the presence of the actual last access value in this array is determined.
154
154
*/
155
-
$lastaccess_expected = [];
155
+
$last_expected = [];
156
156
157
157
for ($i = 0; $i <= 10; $i++) {
158
-
$lastaccess_expected[] = convertUnitsS($current_time - $lastaccess_db - $i);
158
+
$last_expected[] = convertUnitsS($current_time - $lastaccess_db - $i);
159
159
}
160
160
161
-
$lastaccess_actual = $last_seen->getText();
162
-
$this->assertTrue(in_array($lastaccess_actual, $lastaccess_expected));
163
-
164
-
self::$skip_fields[] = $last_seen;
161
+
$last_actual = $last_seen->getText();
162
+
$this->assertContains($last_actual, $last_expected, $last_actual.' not in ['.implode(', ', $last_expected).']');
165
163
166
164
// Check Zabbix server address and port for each record in the HA cluster nodes table.
167
165
if ($name === 'Active node') {
168
166
self::$skip_fields[] = $row->getColumn('Address');
169
167
$this->assertEquals($DB['SERVER'].':0', $row->getColumn('Address')->getText());
170
168
}
171
169
}
172
170
173
171
/**
174
172
* Check and hide the active Zabbix server address in widget that is working in System stats mode or in the part