Source
'server' => array_merge(self::$case_configuration[self::COMPONENT_SERVER], $this->serverConfigurationProvider_cacheSize()[self::COMPONENT_SERVER])
<?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__).'/../include/CIntegrationTest.php';
/**
* Test suite for High availability
*
* @backup ha_node
*/
class testHighAvailability extends CIntegrationTest {
const STANDALONE_NAME = '<standalone server>';
const NODE1_NAME = 'node1';
const NODE2_NAME = 'node2';
/**
* @required-components server, server_ha1
* @inheritdoc
*/
public function prepareData() {
$socketDir = $this->getConfigurationValue(self::COMPONENT_SERVER_HANODE1, 'SocketDir');
if (file_exists($socketDir) === false) {
mkdir($socketDir);
}
return true;
}
/**
* Component configuration provider for standalone mode
* Used to test if server quits gracefully when cache size is too low
*
* @return array
*/
public function serverConfigurationProvider_cacheSize() {
return [
self::COMPONENT_SERVER => [
'HANodeName' => self::NODE1_NAME,
'CacheSize' => '256K',
'ListenPort' => PHPUNIT_PORT_PREFIX.self::SERVER_HANODE1_PORT_SUFFIX
]
];
}
/**
* Component configuration provider for 2 nodes (Active + standby)
*
* @return array
*/
public function serverConfigurationProvider_ha() {
return [
self::COMPONENT_SERVER => [
'HANodeName' => self::NODE1_NAME,
'ListenPort' => PHPUNIT_PORT_PREFIX.self::SERVER_HANODE1_PORT_SUFFIX
],
self::COMPONENT_SERVER_HANODE1 => [
'HANodeName' => self::NODE2_NAME,
'NodeAddress' => 'localhost:'.self::getConfigurationValue(self::COMPONENT_SERVER_HANODE1, 'ListenPort')
]
];
}
/**
* Launching Zabbix server in stand-alone mode
*
* @required-components server_ha1
*/
public function testHighAvailability_checkStandaloneModeStartup() {
$this->assertFalse($this->isLogLinePresent(self::COMPONENT_SERVER_HANODE1, '"'.self::NODE1_NAME.'" node started in "active" mode'));
return true;
}
/**
* Launching High availability cluster with 2 nodes (Active + standby)
*
* @required-components server, server_ha1