Source
xxxxxxxxxx
<?php
/*
** Zabbix
** Copyright (C) 2001-2025 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
require_once dirname(__FILE__).'/../include/CIntegrationTest.php';
require_once dirname(__FILE__).'/../include/helpers/CDataHelper.php';
/**
* Test suite for trigger linking.
*
* @required-components server
* @configurationDataProvider serverConfigurationProvider
* @hosts test_trigger_linking
* @backup history
*/
class testTriggerLinking extends CIntegrationTest {
const HOST_NAME = 'test_trigger_linking';
const TEMPLATE_NAME_PRE = 'strata_template_name';
const ITEM_NAME_PRE = 'strata_item_name';
const ITEM_KEY_PRE = 'strata_item_key';
const TAG_NAME_PRE = 'strata_tag';
const TAG_VALUE_PRE = 'strata_value';
const TRIGGER_DESCRIPTION_PRE = 'strata_trigger_description';
const TRIGGER_DESCRIPTION_SAME_ALL = 'zstrata_same_description_on_all_templates';
const TRIGGER_PRIORITY = 4;
const TRIGGER_STATUS = 1;
const TRIGGER_COMMENTS_PRE = 'strata_comment';
const TRIGGER_URL_PRE = 'strata_url';
const TRIGGER_TYPE = 1;
const TRIGGER_RECOVERY_MODE = 1;
const TRIGGER_CORRELATION_MODE = 1;
const TRIGGER_CORRELATION_TAG_PRE = 'strata_correlation_tag';
const TRIGGER_CORRELATION_TAG_FOR_NEW_TEMPLATE = 'Xtag';
const TRIGGER_MANUAL_CLOSE = 1;
const TRIGGER_OPDATA_PRE = 'strata_opdata';
const TRIGGER_EVENT_NAME_PRE = 'strata_event_name';
const NUMBER_OF_TEMPLATES = 10;
const NUMBER_OF_TRIGGERS_PER_TEMPLATE = 20;
private static $templateids = array();
private static $stringids = array();
/* Template X will be linked after the initial set of templates get linked and then unliked (without clear). */
private static $templateX_ID;
private static $templateX_name = 'templateX';
/* Linking initial set of templates, need an ID to delete this, as during the second linking
only templateX will be linked. */
private static $firstActionID;
private function createTemplates() {
for ($i = 0; $i < self::NUMBER_OF_TEMPLATES; $i++) {
$response = $this->call('template.create', [
'host' => self::TEMPLATE_NAME_PRE . "_" . $i,
'groups' => [
'groupid' => 1
]]);
$ep = json_encode($response, JSON_PRETTY_PRINT);
$this->assertArrayHasKey('templateids', $response['result'], $ep);
$this->assertArrayHasKey(0, $response['result']['templateids'], $ep);
array_push(self::$templateids, $response['result']['templateids'][0]);
}
/* Create special template X, that will have trigger description (but not expression) conflict
with triggers from the first template. It will be linked in a separate action from
all other templates. (when agent2 with new host metadata starts). */
$response = $this->call('template.create', [