zbxTestLogin('zabbix.php?action=discovery.list'); $this->zbxTestCheckTitle('Configuration of discovery rules'); $this->zbxTestCheckHeader('Discovery rules'); $this->zbxTestTextPresent('Displaying'); $this->zbxTestTextPresent(['Name', 'IP range', 'Proxy', 'Interval', 'Checks', 'Status']); $this->zbxTestTextPresent(['Enable', 'Disable', 'Delete']); } // returns all discovery rules public static function allRules() { return CDBHelper::getDataProvider('SELECT druleid,name FROM drules'); } /** * @dataProvider allRules */ public function testPageNetworkDiscovery_SimpleUpdate($drule) { $sqlDRules = 'SELECT * FROM drules WHERE druleid='.$drule['druleid']; $sqlDChecks = 'SELECT * FROM dchecks WHERE druleid='.$drule['druleid'].' ORDER BY dcheckid'; $oldHashDRules = CDBHelper::getHash($sqlDRules); $oldHashDChecks = CDBHelper::getHash($sqlDChecks); $this->zbxTestLogin('zabbix.php?action=discovery.list'); $this->zbxTestCheckTitle('Configuration of discovery rules'); $this->zbxTestClickLinkText($drule['name']); $dialog = COverlayDialogElement::find()->one()->waitUntilReady(); $dialog->query('button:Update')->waitUntilClickable()->one()->click(); $dialog->ensureNotPresent(); $this->zbxTestCheckTitle('Configuration of discovery rules'); $this->zbxTestTextPresent('Discovery rule updated'); $this->zbxTestTextPresent($drule['name']); $this->assertEquals($oldHashDRules, CDBHelper::getHash($sqlDRules)); $this->assertEquals($oldHashDChecks, CDBHelper::getHash($sqlDChecks)); } /** * @dataProvider allRules * @backupOnce drules */ public function testPageNetworkDiscovery_MassDelete($drule) { $this->zbxTestLogin('zabbix.php?action=discovery.list'); $this->zbxTestCheckTitle('Configuration of discovery rules'); $this->zbxTestCheckboxSelect('druleids_'.$drule['druleid']); $this->query('button:Delete')->waitUntilClickable()->one()->click(); $this->zbxTestAcceptAlert(); $this->zbxTestCheckTitle('Configuration of discovery rules'); $this->assertMessage(TEST_GOOD, 'Discovery rule deleted'); $this->assertEquals(0, CDBHelper::getCount('SELECT * FROM drules WHERE druleid='.$drule['druleid'])); $this->assertEquals(0, CDBHelper::getCount('SELECT * FROM dchecks WHERE druleid='.$drule['druleid'])); } public function testPageNetworkDiscovery_MassDisableAll() { DBexecute('UPDATE drules SET status='.DRULE_STATUS_ACTIVE); $this->zbxTestLogin('zabbix.php?action=discovery.list'); $this->zbxTestCheckTitle('Configuration of discovery rules'); $this->zbxTestCheckboxSelect('all_drules'); $this->query('button:Disable')->waitUntilClickable()->one()->click(); $this->zbxTestAcceptAlert(); $this->zbxTestCheckTitle('Configuration of discovery rules'); $this->assertMessage(TEST_GOOD, 'Discovery rules disabled'); $this->assertEquals(0, CDBHelper::getCount('SELECT * FROM drules WHERE status='.DRULE_STATUS_ACTIVE)); } /** * @dataProvider allRules */ public function testPageNetworkDiscovery_MassDisable($drule) { DBexecute('UPDATE drules SET status='.DRULE_STATUS_ACTIVE.' WHERE druleid='.$drule['druleid']); $this->zbxTestLogin('zabbix.php?action=discovery.list'); $this->zbxTestCheckTitle('Configuration of discovery rules'); $this->zbxTestCheckboxSelect('druleids_'.$drule['druleid']); $this->query('button:Disable')->waitUntilClickable()->one()->click(); $this->zbxTestAcceptAlert(); $this->zbxTestCheckTitle('Configuration of discovery rules'); $this->assertMessage(TEST_GOOD, 'Discovery rule disabled'); $this->assertEquals(1, CDBHelper::getCount( 'SELECT *'. ' FROM drules'. ' WHERE druleid='.$drule['druleid']. ' AND status='.DRULE_STATUS_DISABLED )); } public function testPageNetworkDiscovery_MassEnableAll() { DBexecute('UPDATE drules SET status='.DRULE_STATUS_DISABLED); $this->zbxTestLogin('zabbix.php?action=discovery.list'); $this->zbxTestCheckTitle('Configuration of discovery rules'); $this->zbxTestCheckboxSelect('all_drules'); $this->query('button:Enable')->waitUntilClickable()->one()->click(); $this->zbxTestAcceptAlert(); $this->zbxTestCheckTitle('Configuration of discovery rules'); $this->assertMessage(TEST_GOOD, 'Discovery rules enabled'); $this->assertEquals(0, CDBHelper::getCount('SELECT * FROM drules WHERE status='.DRULE_STATUS_DISABLED)); } /** * @dataProvider allRules */ public function testPageNetworkDiscovery_MassEnable($drule) { DBexecute('UPDATE drules SET status='.DRULE_STATUS_DISABLED.' WHERE druleid='.$drule['druleid']); $this->zbxTestLogin('zabbix.php?action=discovery.list'); $this->zbxTestCheckTitle('Configuration of discovery rules'); $this->zbxTestCheckboxSelect('druleids_'.$drule['druleid']); $this->query('button:Enable')->waitUntilClickable()->one()->click(); $this->zbxTestAcceptAlert(); $this->zbxTestCheckTitle('Configuration of discovery rules'); $this->assertMessage(TEST_GOOD, 'Discovery rule enabled'); $this->assertEquals(1, CDBHelper::getCount( 'SELECT *'. ' FROM drules'. ' WHERE druleid='.$drule['druleid']. ' AND status='.DRULE_STATUS_ACTIVE )); } }