Commit version 24.12.13800

This commit is contained in:
2025-01-06 17:35:06 -05:00
parent b7f6a79c2c
commit 55d9218816
6133 changed files with 4239740 additions and 1374287 deletions

View File

@ -9,6 +9,10 @@ $config['install_dir'] = $base_dir;
// Base observium includes
include(__DIR__ . '/../includes/defaults.inc.php');
//include(dirname(__FILE__) . '/../config.php'); // Do not include user editable config here
include(__DIR__ . "/../includes/polyfill.inc.php");
include(__DIR__ . "/../includes/autoloader.inc.php");
include(__DIR__ . "/../includes/debugging.inc.php");
require_once(__DIR__ ."/../includes/constants.inc.php");
include(__DIR__ . '/../includes/common.inc.php');
include(__DIR__ . '/../includes/definitions.inc.php');
include(__DIR__ . '/data/test_definitions.inc.php'); // Fake definitions for testing
@ -60,7 +64,7 @@ class IncludesRewritesTest extends \PHPUnit\Framework\TestCase
public function providerRewriteEntityNameCsv()
{
return new CsvFileIterator(dirname(__FILE__) . '/data/providerRewriteEntityName.csv');
return new CsvFileIterator(__DIR__ . '/data/providerRewriteEntityName.csv');
}
/**
@ -215,6 +219,7 @@ class IncludesRewritesTest extends \PHPUnit\Framework\TestCase
array('rus', 'Russian Federation'),
array('Russian Federation', 'Russian Federation'),
array('russia', 'Russian Federation'),
array('South Korea', 'South Korea'),
);
}
@ -222,10 +227,10 @@ class IncludesRewritesTest extends \PHPUnit\Framework\TestCase
* @dataProvider providerRewriteDefinitionHardware
* @group hardware
*/
public function testRewriteDefinitionHardware($os, $id, $result)
public function testGetModelParam($os, $id, $result)
{
$device = array('os' => $os, 'sysObjectID' => $id);
$this->assertEquals($result, rewrite_definition_hardware($device));
$this->assertEquals($result, get_model_param($device, 'hardware'));
}
public function providerRewriteDefinitionHardware()
@ -422,85 +427,84 @@ class IncludesRewritesTest extends \PHPUnit\Framework\TestCase
);
}
/**
* @dataProvider providerProcessPortLabel
* @group process
*/
public function testProcessPortLabel($os, $array, $result)
{
// Port array template
$port = array(
'ifIndex' => '5',
//'ifDescr' => 'GigabitEthernet0/1',
'ifType' => 'ethernetCsmacd',
'ifMtu' => '1500',
'ifSpeed' => '1000000000',
'ifPhysAddress' => '4c:4e:35:fb:c7:20',
'ifAdminStatus' => 'up',
'ifOperStatus' => 'up',
'ifLastChange' => '0:0:01:03.68',
'ifInOctets' => '2336423782',
'ifInUcastPkts' => '56523160',
'ifInDiscards' => '0',
'ifInErrors' => '195562',
'ifInUnknownProtos' => '0',
'ifOutOctets' => '2769871040',
'ifOutUcastPkts' => '83292747',
'ifOutDiscards' => '0',
'ifOutErrors' => '0',
//'ifName' => 'Gi0/1',
'ifInMulticastPkts' => '1',
'ifInBroadcastPkts' => '21',
'ifOutMulticastPkts' => '16933',
'ifOutBroadcastPkts' => '2434835',
'ifHCInOctets' => '10926358374',
'ifHCInUcastPkts' => '56523160',
'ifHCInMulticastPkts' => '1',
'ifHCInBroadcastPkts' => '21',
'ifHCOutOctets' => '75784315072',
'ifHCOutUcastPkts' => '83292747',
'ifHCOutMulticastPkts' => '16933',
'ifHCOutBroadcastPkts' => '2434835',
'ifLinkUpDownTrapEnable' => 'enabled',
'ifHighSpeed' => '1000',
'ifPromiscuousMode' => 'false',
'ifConnectorPresent' => 'true',
//'ifAlias' => 'Po1#2',
'ifCounterDiscontinuityTime' => '0:0:00:32.81',
'dot3StatsDuplexStatus' => 'fullDuplex',
);
foreach ($array as $oid => $value)
{
$port[$oid] = $value;
/**
* @dataProvider providerProcessPortLabel
* @group process
*/
public function testProcessPortLabel($os, $array, $result) {
// Port array template
$port = [
'ifIndex' => '5',
//'ifDescr' => 'GigabitEthernet0/1',
'ifType' => 'ethernetCsmacd',
'ifMtu' => '1500',
'ifSpeed' => '1000000000',
'ifPhysAddress' => '4c:4e:35:fb:c7:20',
'ifAdminStatus' => 'up',
'ifOperStatus' => 'up',
'ifLastChange' => '0:0:01:03.68',
'ifInOctets' => '2336423782',
'ifInUcastPkts' => '56523160',
'ifInDiscards' => '0',
'ifInErrors' => '195562',
'ifInUnknownProtos' => '0',
'ifOutOctets' => '2769871040',
'ifOutUcastPkts' => '83292747',
'ifOutDiscards' => '0',
'ifOutErrors' => '0',
//'ifName' => 'Gi0/1',
'ifInMulticastPkts' => '1',
'ifInBroadcastPkts' => '21',
'ifOutMulticastPkts' => '16933',
'ifOutBroadcastPkts' => '2434835',
'ifHCInOctets' => '10926358374',
'ifHCInUcastPkts' => '56523160',
'ifHCInMulticastPkts' => '1',
'ifHCInBroadcastPkts' => '21',
'ifHCOutOctets' => '75784315072',
'ifHCOutUcastPkts' => '83292747',
'ifHCOutMulticastPkts' => '16933',
'ifHCOutBroadcastPkts' => '2434835',
'ifLinkUpDownTrapEnable' => 'enabled',
'ifHighSpeed' => '1000',
'ifPromiscuousMode' => 'false',
'ifConnectorPresent' => 'true',
//'ifAlias' => 'Po1#2',
'ifCounterDiscontinuityTime' => '0:0:00:32.81',
'dot3StatsDuplexStatus' => 'fullDuplex',
];
foreach ($array as $oid => $value) {
$port[$oid] = $value;
}
// Device array template
$device = [
'device_id' => 99999999,
'os' => $os,
];
// Process $port array
process_port_label($port, $device);
//var_dump($port);
// Select specific entries for validate
$test_array = [];
foreach ([ 'port_label', 'port_label_num', 'port_label_base', 'port_label_short' ] as $oid) {
$test_array[$oid] = $port[$oid];
}
// Additionally, test processing ifAlias on some entries
if (isset($result['ifAlias'])) {
$test_array['ifAlias'] = $port['ifAlias'];
}
$this->assertEquals($result, $test_array);
}
// Device array template
$device = array(
'device_id' => 99999999,
'os' => $os,
);
// Process $port array
process_port_label($port, $device);
//var_dump($port);
public function providerProcessPortLabel() {
// Select specific entries for validate
$test_array = array();
foreach (array('port_label', 'port_label_num', 'port_label_base', 'port_label_short') as $oid)
{
$test_array[$oid] = $port[$oid];
}
// Additionally test processing ifAlias on some entries
if (isset($result['ifAlias']))
{
$test_array['ifAlias'] = $port['ifAlias'];
}
$this->assertEquals($result, $test_array);
}
public function providerProcessPortLabel()
{
return array(
return [
array('ios', array('ifDescr' => 'GigabitEthernet0/1', 'ifName' => 'Gi0/1', 'ifAlias' => 'Po1#2'),
array('port_label' => 'GigabitEthernet0/1', 'port_label_num' => '0/1', 'port_label_base' => 'GigabitEthernet', 'port_label_short' => 'Gi0/1')),
array('ios', array('ifDescr' => 'FastEthernet0/1/1', 'ifName' => 'Fa0/1/1', 'ifAlias' => 'COMSTAR BGP link'),
@ -557,6 +561,11 @@ class IncludesRewritesTest extends \PHPUnit\Framework\TestCase
array('vrp', array('ifDescr' => 'XGigabitEthernet5/0/14', 'ifName' => 'XGigabitEthernet5/0/14', 'ifAlias' => ''),
array('port_label' => 'XGigabitEthernet5/0/14', 'port_label_num' => '5/0/14', 'port_label_base' => 'XGigabitEthernet', 'port_label_short' => 'XGi5/0/14')),
array('hh3c', array('ifDescr' => 'Ten-GigabitEthernet2/0/25', 'ifName' => 'Ten-GigabitEthernet2/0/25', 'ifAlias' => 'Ten-GigabitEthernet2/0/25 Interface'),
array('port_label' => 'Ten-GigabitEthernet2/0/25', 'port_label_num' => '2/0/25', 'port_label_base' => 'Ten-GigabitEthernet', 'port_label_short' => 'Te2/0/25')),
array('hh3c', array('ifDescr' => 'Vlan-interface1504', 'ifName' => 'Vlan-interface1504', 'ifAlias' => ''),
array('port_label' => 'Vlan-interface1504', 'port_label_num' => '1504', 'port_label_base' => 'Vlan-interface', 'port_label_short' => 'Vlan1504')),
array('routeros', array('ifDescr' => 'Core: sfp-sfpplus1- Trunk to 6509', 'ifName' => 'Core: sfp-sfpplus1- Trunk to 6509', 'ifAlias' => ''),
array('port_label' => 'Core: sfp-sfpplus1- Trunk to 6509', 'port_label_num' => '', 'port_label_base' => 'Core: sfp-sfpplus1- Trunk to 6509', 'port_label_short' => 'Core: sfp-sfpplus1- Trunk to 6509')),
@ -567,6 +576,15 @@ class IncludesRewritesTest extends \PHPUnit\Framework\TestCase
array('linux', array('ifDescr' => 'eth0.101', 'ifName' => 'eth0.101', 'ifAlias' => ''),
array('port_label' => 'eth0.101', 'port_label_num' => '0.101', 'port_label_base' => 'eth', 'port_label_short' => 'eth0.101')),
[ 'pve', [ 'ifDescr' => 'veth101i0', 'ifName' => 'veth101i0', 'ifAlias' => '' ],
[ 'port_label' => 'veth101i0', 'port_label_num' => '101i0', 'port_label_base' => 'veth', 'port_label_short' => 'veth101i0' ] ],
[ 'openbsd', [ 'ifDescr' => 'vether1', 'ifName' => 'vether1', 'ifAlias' => '' ],
[ 'port_label' => 'vether1', 'port_label_num' => '1', 'port_label_base' => 'vether', 'port_label_short' => 'vether1' ] ],
[ 'generic', [ 'ifDescr' => 'veth1bbfdc5', 'ifName' => 'veth1bbfdc5', 'ifAlias' => '' ],
[ 'port_label' => 'veth1bbfdc5', 'port_label_num' => '1bbfdc5', 'port_label_base' => 'veth', 'port_label_short' => 'veth1bbfdc5' ] ],
[ 'nutanix', [ 'ifDescr' => 'vethfd3fe3c0', 'ifName' => 'vethfd3fe3c0', 'ifAlias' => '' ],
[ 'port_label' => 'vethfd3fe3c0', 'port_label_num' => 'fd3fe3c0', 'port_label_base' => 'veth', 'port_label_short' => 'vethfd3fe3c0' ] ],
// port_label os definitions
array('vmware', array('ifDescr' => 'Device vmnic7 at 08:00.1 bnx2', 'ifName' => '', 'ifAlias' => ''),
array('port_label' => 'vmnic7', 'port_label_num' => '7', 'port_label_base' => 'vmnic', 'port_label_short' => 'vmnic7')),
@ -621,6 +639,12 @@ class IncludesRewritesTest extends \PHPUnit\Framework\TestCase
array('ekinops-360', array('ifDescr' => 'EKINOPS/C200/1/MGNT/GbE_RJ45#1', 'ifName' => 'EKINOPS/C200/1/MGNT/GbE_RJ45#1', 'ifAlias' => ''),
array('port_label' => '1/MGNT/GbE_RJ45#1', 'port_label_num' => '1', 'port_label_base' => '1/MGNT/GbE_RJ45#', 'port_label_short' => '1/MGNT/GbE_RJ45#1', 'ifAlias' => '')),
// os definition, multiple label_num
[ 'adtran-ta', [ 'ifDescr' => 'Shelf: 1, Slot: 11, Pon: 1, ONT: 1, ONT Serial No: ADTN21296399, ONT Reg ID:', 'ifName' => '', 'ifAlias' => 'Serial No: ADTN21296399' ],
[ 'port_label' => 'ONT 1/11/1/1', 'port_label_num' => '1/11/1/1', 'port_label_base' => 'ONT', 'port_label_short' => 'ONT 1/11/1/1' ] ],
[ 'adtran-ta', [ 'ifDescr' => 'PON-4, Splitter #1 Washington St', 'ifName' => '', 'ifAlias' => 'Splitter #1 Washington St' ],
[ 'port_label' => 'PON-4', 'port_label_num' => '4', 'port_label_base' => 'PON-', 'port_label_short' => 'PON-4' ] ],
// ifType_ifDescr
array('liebert', array('ifDescr' => '', 'ifType' => 'softwareLoopback'), // ++ ifType, ifIndex
array('port_label' => 'Loopback 5', 'port_label_num' => '5', 'port_label_base' => 'Loopback ', 'port_label_short' => 'Lo 5')),
@ -739,8 +763,8 @@ class IncludesRewritesTest extends \PHPUnit\Framework\TestCase
//array('generic', array('ifDescr' => 'microsens'),
// array('port_label' => 'microsens', 'port_label_num' => 'microsens', 'port_label_base' => '', 'port_label_short' => 'microsens')),
);
}
];
}
}
// EOF