Source
$this->link = 'zabbix.php?action=item.list&filter_set=1&context=template&filter_hostids[0]='.self::INHERITANCE_TEMPLATEID;
<?php
/*
** 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 Affero General Public License as published by the Free Software Foundation, version 3.
**
** 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 Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
require_once dirname(__FILE__).'/../common/testFormPreprocessing.php';
require_once dirname(__FILE__).'/../../include/helpers/CDataHelper.php';
/**
* @backup items,users
* @onBefore setRowsPerPage
*/
class testFormPreprocessingItem extends testFormPreprocessing {
public $link = 'zabbix.php?action=item.list&filter_set=1&context=host&filter_hostids[0]='.self::HOSTID;
public $button = 'Create item';
public $success_message = 'Item added';
public $fail_message = 'Cannot add item';
const HOSTID = 40001; // 'Simple form test host'
const INHERITANCE_TEMPLATEID = 15000; // 'Inheritance test template'
const INHERITANCE_HOSTID = 15001; // 'Template inheritance test host'
public function getItemPreprocessingPrometheusData() {
return array_merge($this->getPrometheusData(), [
[
[
'expected' => TEST_BAD,
'fields' => [
'Name' => 'Item Prometeus wrong first parameter - LLD macro',
'Key' => 'wrong-first-parameter-macro'
],
'preprocessing' => [
['type' => 'Prometheus pattern', 'parameter_1' => '{#METRICNAME}==1']
],
'error' => 'Invalid parameter "/1/preprocessing/1/params/1": invalid Prometheus pattern.'
]
],
[
[
'expected' => TEST_BAD,
'fields' => [
'Name' => 'Item Prometeus wrong second parameter - LLD macro',
'Key' => 'wrong-second-parameter-macro'
],
'preprocessing' => [
[
'type' => 'Prometheus pattern',
'parameter_1' => 'cpu_usage_system',
'parameter_2' => 'label',
'parameter_3' => '{#LABELNAME}'
]
],
'error' => 'Invalid parameter "/1/preprocessing/1/params/3": invalid Prometheus label.'
]
],
[
[
'expected' => TEST_BAD,
'fields' => [
'Name' => 'Item Prometheus to JSON wrong first parameter - LLD macro',
'Key' => 'json-wrong-first-parameter-macro'
],
'preprocessing' => [
['type' => 'Prometheus to JSON', 'parameter_1' => '{#METRICNAME}==1']
],
'error' => 'Invalid parameter "/1/preprocessing/1/params/1": invalid Prometheus pattern.'
]
]
]);
}
/**
* @dataProvider getItemPreprocessingValidationData
* @dataProvider getItemPreprocessingCreateData
* @dataProvider getItemPreprocessingPrometheusData
* @dataProvider getCustomOnFailValidationData
*/