Add tests for peth_port_ifindex in Juniper.pm

This commit is contained in:
Jeroen van Ingen
2018-10-08 12:37:23 +02:00
parent ab2be759af
commit b24da8c380
2 changed files with 28 additions and 1 deletions

View File

@@ -664,7 +664,7 @@ sub peth_port_ifindex {
# Only the power status from the first member in a virtual chassis is reported. # Only the power status from the first member in a virtual chassis is reported.
foreach my $i ( keys %$i_descr ) { foreach my $i ( keys %$i_descr ) {
# Juniper's port numbering is PHYS-FPC/PIC/PORT, only looking at PIC 0 # Juniper's port numbering is PHYS-FPC/PIC/PORT, only looking at PIC 0
if ($i_descr->{$i} =~ m/^(fe|ge|xe|et)-([0-9]+)\/([0]+)\/([0-9]+)$/) { if ($i_descr->{$i} =~ m/^(fe|ge|xe|et)-(\d+)\/(0)\/(\d+)$/) {
# Juniper port numbering begins at 0, but for PowerEthernet it begins at 1 # Juniper port numbering begins at 0, but for PowerEthernet it begins at 1
my $mod = $2+1; my $mod = $2+1;
my $port = $4+1; my $port = $4+1;

View File

@@ -79,8 +79,20 @@ sub setup : Tests(setup) {
'_e_contents_type' => 1, '_e_contents_type' => 1,
'_jnxContainersWithin' => 1, '_jnxContainersWithin' => 1,
# For PoE port mapping test
'_i_description' => 1,
'store' => { 'store' => {
'peth_port_status' => {'1.1' => 'searching', '1.2' => 'otherFault', '1.3' => 'deliveringPower'},
'i_index' => {504 => 504, 505 => 505, 506 => 506, 507 => 507, 508 => 508, 509 => 509},
'i_description' => {
504 => 'ge-0/0/0',
505 => 'ge-0/0/0.0',
506 => 'ge-0/0/1',
507 => 'ge-0/0/1.0',
508 => 'ge-0/0/2',
509 => 'ge-0/0/2.0',
},
'jnxExVlanPortAccessMode' => {'2.514' => 'access', '7.513' => 'trunk'}, 'jnxExVlanPortAccessMode' => {'2.514' => 'access', '7.513' => 'trunk'},
'jnx_v_name' => {2 => 'default', 3 => 'management'}, 'jnx_v_name' => {2 => 'default', 3 => 'management'},
'jnx_v_index' => {2 => 0, 3 => 120}, 'jnx_v_index' => {2 => 0, 3 => 120},
@@ -854,4 +866,19 @@ sub e_parent : Tests(3) {
cmp_deeply($test->{info}->e_parent(), {}, q(No data returns empty hash)); cmp_deeply($test->{info}->e_parent(), {}, q(No data returns empty hash));
} }
sub peth_port_ifindex : Tests(3) {
my $test = shift;
can_ok($test->{info}, 'peth_port_ifindex');
my $expected = {'1.1' => 504, '1.2' => 506, '1.3' => 508};
cmp_deeply($test->{info}->peth_port_ifindex(),
$expected, q(POE port 'ifIndex' mapping returns expected values));
$test->{info}->clear_cache();
cmp_deeply($test->{info}->peth_port_ifindex(),
{}, q(No data returns empty hash));
}
1; 1;