Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
itoussies committed Dec 24, 2024
1 parent 25d4c1e commit f9c9244
Show file tree
Hide file tree
Showing 9 changed files with 800 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/storage/netapp/ontap/restapi/mode/volumes.pm
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ sub manage_selection {
total_latency => (defined($_->{metric}->{latency}->{total})) ? ($_->{metric}->{latency}->{total} / 1000) : undef,
};

if (defined($self->{option_results}->{filter_volume_name}) && $self->{option_results}->{filter_volume_name} ne '' ) {
if (defined($_->{space}->{logical_space})) {
$self->{volumes}->{$name}->{total_logical_space} = $_->{space}->{logical_space}->{used} + $_->{space}->{logical_space}->{available};
$self->{volumes}->{$name}->{logical_used_space} = $_->{space}->{logical_space}->{used};
$self->{volumes}->{$name}->{logical_free_space} = $_->{space}->{logical_space}->{available};
Expand Down Expand Up @@ -351,27 +351,27 @@ Filter volumes by vserver name (can be a regexp).
=item B<--unknown-status>
Define the conditions to match for the status to be UNKNOWN.
You can use the following variables: C<%{state}>, C<%{display}>
You can use the following variables: %{state}, %{display}
=item B<--warning-status>
Define the conditions to match for the status to be WARNING.
You can use the following variables: C<%{state}>, C<%{display}>.
You can use the following variables: %{state}, %{display}.
=item B<--critical-status>
Define the conditions to match for the status to be CRITICAL (default: C<%{state} !~ /online/i>).
You can use the following variables: C<%{state}>, C<%{display}>.
Define the conditions to match for the status to be CRITICAL (default: '%{state} !~ /online/i').
You can use the following variables: %{state}, %{display}.
=item B<--warning-*> B<--critical-*>
Thresholds.
Can be: C<usage>' (B), C<usage-free> (B), C<usage-prct> (%),
C<logical-usage> (B), C<logical-usage-free> (B), C<logical-usage-prct> (%),
C<read> (B/s), C<read-iops>, C<write> (B/s), C<write-iops>,
C<read-latency> (ms), C<write-latency> (ms), C<total-latency> (ms),
C<other-latency> (ms), C<other> (B/s), C<total> (B/s),
C<other-iops>, C<total-iops>.
Can be: usage' (B), usage-free (B), usage-prct (%),
logical-usage (B), logical-usage-free (B), logical-usage-prct (%),
read (B/s), read-iops, write (B/s), write-iops,
read-latency (ms), write-latency (ms), total-latency (ms),
other-latency (ms), other (B/s), total (B/s),
other-iops, total-iops.
=back
Expand Down
38 changes: 38 additions & 0 deletions tests/storage/netapp/ontap/restapi/aggregates.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
*** Settings ***
Documentation Netapp Ontap Restapi Aggregates plugin
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource

Suite Setup Start Mockoon ${MOCKOON_JSON}
Suite Teardown Stop Mockoon
Test Timeout 120s


*** Variables ***
${MOCKOON_JSON} ${CURDIR}${/}netapp.json

${cmd} ${CENTREON_PLUGINS}
... --plugin=storage::netapp::ontap::restapi::plugin
... --hostname=${HOSTNAME}
... --port=${APIPORT}
... --proto=http
... --api-username=username
... --api-password=password
... --mode=aggregates


*** Test Cases ***
Aggregates ${tc}
[Tags] storage netapp ontapp api aggregates mockoon
${command} Catenate
... ${CMD}
... ${extra_options}

Ctn Run Command And Check Result As Strings ${command} ${expected_result}

Examples: tc extra_options expected_result --
... 1 ${EMPTY} OK: Aggregates 'aggregate1' state: online, space usage total: 9.46 GB used: 1.99 MB (0.02%) free: 9.46 GB (100.00%), other : skipped (no value(s)), read iops: 500, write iops: 200, other-iops : skipped (no value(s)), total iops: 1000, read latency: 500 µs, write latency: 200 µs, other-latency : skipped (no value(s)), total latency: 1000 µs | 'aggregate1#aggregate.space.usage.bytes'=2088960B;;;0;10156769280 'aggregate1#aggregate.space.free.bytes'=10156560384B;;;0;10156769280 'aggregate1#aggregate.space.usage.percentage'=0.02%;;;0;100 'aggregate1#aggregate.io.read.usage.bytespersecond'=500B/s;;;; 'aggregate1#aggregate.io.write.usage.bytespersecond'=200B/s;;;0; 'aggregate1#aggregate.io.total.usage.bytespersecond'=1000B/s;;;0; 'aggregate1#aggregate.io.read.usage.iops'=500iops;;;0; 'aggregate1#aggregate.io.write.usage.iops'=200iops;;;0; 'aggregate1#aggregate.io.total.usage.iops'=1000iops;;;0; 'aggregate1#aggregate.io.read.latency.microseconds'=500µs;;;0; 'aggregate1#aggregate.io.write.latency.microseconds'=200µs;;;0; 'aggregate1#aggregate.io.total.latency.microseconds'=1000µs;;;0;
... 2 --warning-status='\\\%{state} !~ /notonline/i' WARNING: Aggregates 'aggregate1' state: online | 'aggregate1#aggregate.space.usage.bytes'=2088960B;;;0;10156769280 'aggregate1#aggregate.space.free.bytes'=10156560384B;;;0;10156769280 'aggregate1#aggregate.space.usage.percentage'=0.02%;;;0;100 'aggregate1#aggregate.io.read.usage.bytespersecond'=500B/s;;;; 'aggregate1#aggregate.io.write.usage.bytespersecond'=200B/s;;;0; 'aggregate1#aggregate.io.total.usage.bytespersecond'=1000B/s;;;0; 'aggregate1#aggregate.io.read.usage.iops'=500iops;;;0; 'aggregate1#aggregate.io.write.usage.iops'=200iops;;;0; 'aggregate1#aggregate.io.total.usage.iops'=1000iops;;;0; 'aggregate1#aggregate.io.read.latency.microseconds'=500µs;;;0; 'aggregate1#aggregate.io.write.latency.microseconds'=200µs;;;0; 'aggregate1#aggregate.io.total.latency.microseconds'=1000µs;;;0;
... 3 --critical-status='\\\%{state} !~ /notonline/i' CRITICAL: Aggregates 'aggregate1' state: online | 'aggregate1#aggregate.space.usage.bytes'=2088960B;;;0;10156769280 'aggregate1#aggregate.space.free.bytes'=10156560384B;;;0;10156769280 'aggregate1#aggregate.space.usage.percentage'=0.02%;;;0;100 'aggregate1#aggregate.io.read.usage.bytespersecond'=500B/s;;;; 'aggregate1#aggregate.io.write.usage.bytespersecond'=200B/s;;;0; 'aggregate1#aggregate.io.total.usage.bytespersecond'=1000B/s;;;0; 'aggregate1#aggregate.io.read.usage.iops'=500iops;;;0; 'aggregate1#aggregate.io.write.usage.iops'=200iops;;;0; 'aggregate1#aggregate.io.total.usage.iops'=1000iops;;;0; 'aggregate1#aggregate.io.read.latency.microseconds'=500µs;;;0; 'aggregate1#aggregate.io.write.latency.microseconds'=200µs;;;0; 'aggregate1#aggregate.io.total.latency.microseconds'=1000µs;;;0;
... 6 --warning-usage-prct=50:50 WARNING: Aggregates 'aggregate1' used : 0.02 % | 'aggregate1#aggregate.space.usage.bytes'=2088960B;;;0;10156769280 'aggregate1#aggregate.space.free.bytes'=10156560384B;;;0;10156769280 'aggregate1#aggregate.space.usage.percentage'=0.02%;50:50;;0;100 'aggregate1#aggregate.io.read.usage.bytespersecond'=500B/s;;;; 'aggregate1#aggregate.io.write.usage.bytespersecond'=200B/s;;;0; 'aggregate1#aggregate.io.total.usage.bytespersecond'=1000B/s;;;0; 'aggregate1#aggregate.io.read.usage.iops'=500iops;;;0; 'aggregate1#aggregate.io.write.usage.iops'=200iops;;;0; 'aggregate1#aggregate.io.total.usage.iops'=1000iops;;;0; 'aggregate1#aggregate.io.read.latency.microseconds'=500µs;;;0; 'aggregate1#aggregate.io.write.latency.microseconds'=200µs;;;0; 'aggregate1#aggregate.io.total.latency.microseconds'=1000µs;;;0;
... 7 --critical-usage-prct=50:50 CRITICAL: Aggregates 'aggregate1' used : 0.02 % | 'aggregate1#aggregate.space.usage.bytes'=2088960B;;;0;10156769280 'aggregate1#aggregate.space.free.bytes'=10156560384B;;;0;10156769280 'aggregate1#aggregate.space.usage.percentage'=0.02%;;50:50;0;100 'aggregate1#aggregate.io.read.usage.bytespersecond'=500B/s;;;; 'aggregate1#aggregate.io.write.usage.bytespersecond'=200B/s;;;0; 'aggregate1#aggregate.io.total.usage.bytespersecond'=1000B/s;;;0; 'aggregate1#aggregate.io.read.usage.iops'=500iops;;;0; 'aggregate1#aggregate.io.write.usage.iops'=200iops;;;0; 'aggregate1#aggregate.io.total.usage.iops'=1000iops;;;0; 'aggregate1#aggregate.io.read.latency.microseconds'=500µs;;;0; 'aggregate1#aggregate.io.write.latency.microseconds'=200µs;;;0; 'aggregate1#aggregate.io.total.latency.microseconds'=1000µs;;;0;
36 changes: 36 additions & 0 deletions tests/storage/netapp/ontap/restapi/cluster.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
*** Settings ***
Documentation Netapp Ontap Restapi Cluster plugin
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource

Suite Setup Start Mockoon ${MOCKOON_JSON}
Suite Teardown Stop Mockoon
Test Timeout 120s


*** Variables ***
${MOCKOON_JSON} ${CURDIR}${/}netapp.json

${cmd} ${CENTREON_PLUGINS}
... --plugin=storage::netapp::ontap::restapi::plugin
... --hostname=${HOSTNAME}
... --port=${APIPORT}
... --proto=http
... --api-username=username
... --api-password=password
... --mode=cluster


*** Test Cases ***
Cluster ${tc}
[Tags] storage netapp ontapp api cluster mockoon
${command} Catenate
... ${CMD}
... ${extra_options}

Ctn Run Command And Check Result As Strings ${command} ${expected_result}

Examples: tc extra_options expected_result --
... 1 ${EMPTY} OK: cluster 'cluster1' other : skipped (no value(s)), read iops: 200, write iops: 100, other-iops : skipped (no value(s)), total iops: 1000, read latency: 200 ms, write latency: 100 ms, other-latency : skipped (no value(s)), total latency: 1000 ms - node 'node-01' state: online [link status: string] | 'cluster1#cluster.io.read.usage.bytespersecond'=0B/s;;;; 'cluster1#cluster.io.write.usage.bytespersecond'=0B/s;;;0; 'cluster1#cluster.io.total.usage.bytespersecond'=0B/s;;;0; 'cluster1#cluster.io.read.usage.iops'=200iops;;;0; 'cluster1#cluster.io.write.usage.iops'=100iops;;;0; 'cluster1#cluster.io.total.usage.iops'=1000iops;;;0; 'cluster.io.read.latency.milliseconds'=200ms;;;0; 'cluster1#cluster.io.write.latency.milliseconds'=100ms;;;0; 'cluster1#cluster.io.total.latency.milliseconds'=1000ms;;;0;
... 2 --warning-node-status='\\\%{state} !~ /notonline/i' WARNING: cluster 'cluster1' node 'node-01' state: online [link status: string] | 'cluster1#cluster.io.read.usage.bytespersecond'=0B/s;;;; 'cluster1#cluster.io.write.usage.bytespersecond'=0B/s;;;0; 'cluster1#cluster.io.total.usage.bytespersecond'=0B/s;;;0; 'cluster1#cluster.io.read.usage.iops'=200iops;;;0; 'cluster1#cluster.io.write.usage.iops'=100iops;;;0; 'cluster1#cluster.io.total.usage.iops'=1000iops;;;0; 'cluster.io.read.latency.milliseconds'=200ms;;;0; 'cluster1#cluster.io.write.latency.milliseconds'=100ms;;;0; 'cluster1#cluster.io.total.latency.milliseconds'=1000ms;;;0;
... 3 --critical-node-status='\\\%{state} !~ /notonline/i' CRITICAL: cluster 'cluster1' node 'node-01' state: online [link status: string] | 'cluster1#cluster.io.read.usage.bytespersecond'=0B/s;;;; 'cluster1#cluster.io.write.usage.bytespersecond'=0B/s;;;0; 'cluster1#cluster.io.total.usage.bytespersecond'=0B/s;;;0; 'cluster1#cluster.io.read.usage.iops'=200iops;;;0; 'cluster1#cluster.io.write.usage.iops'=100iops;;;0; 'cluster1#cluster.io.total.usage.iops'=1000iops;;;0; 'cluster.io.read.latency.milliseconds'=200ms;;;0; 'cluster1#cluster.io.write.latency.milliseconds'=100ms;;;0; 'cluster1#cluster.io.total.latency.milliseconds'=1000ms;;;0;
39 changes: 39 additions & 0 deletions tests/storage/netapp/ontap/restapi/hardware.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
*** Settings ***
Documentation Netapp Ontap Restapi Quotas plugin
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource

Suite Setup Start Mockoon ${MOCKOON_JSON}
Suite Teardown Stop Mockoon
Test Timeout 120s


*** Variables ***
${MOCKOON_JSON} ${CURDIR}${/}netapp.json

${cmd} ${CENTREON_PLUGINS}
... --plugin=storage::netapp::ontap::restapi::plugin
... --hostname=${HOSTNAME}
... --port=${APIPORT}
... --proto=http
... --api-username=username
... --api-password=password
... --mode=quotas


*** Test Cases ***
Quotas ${tc}
[Tags] storage netapp ontapp api quotas mockoon
${command} Catenate
... ${CMD}
... ${extra_options}

Ctn Run Command And Check Result As Strings ${command} ${expected_result}

Examples: tc extra_options expected_result --
... 1 ${EMPTY} OK: All 4 components are ok [1/1 bays, 1/1 disks, 1/1 frus, 1/1 shelfs]. | 'hardware.bay.count'=1;;;; 'hardware.disk.count'=1;;;; 'hardware.fru.count'=1;;;; 'hardware.shelf.count'=1;;;;
... 2 --component='bay' OK: All 1 components are ok [1/1 bays]. | 'hardware.bay.count'=1;;;;
... 3 --component='disk' OK: All 1 components are ok [1/1 disks]. | 'hardware.disk.count'=1;;;;
... 4 --component='fru' OK: All 1 components are ok [1/1 frus]. | 'hardware.fru.count'=1;;;;
... 5 --component='shelf' OK: All 1 components are ok [1/1 shelfs]. | 'hardware.shelf.count'=1;;;;

36 changes: 36 additions & 0 deletions tests/storage/netapp/ontap/restapi/luns.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
*** Settings ***
Documentation Netapp Ontap Restapi Luns plugin
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}resources/import.resource

Suite Setup Start Mockoon ${MOCKOON_JSON}
Suite Teardown Stop Mockoon
Test Timeout 120s


*** Variables ***
${MOCKOON_JSON} ${CURDIR}${/}netapp.json

${cmd} ${CENTREON_PLUGINS}
... --plugin=storage::netapp::ontap::restapi::plugin
... --hostname=${HOSTNAME}
... --port=${APIPORT}
... --proto=http
... --api-username=username
... --api-password=password
... --mode=luns


*** Test Cases ***
Luns ${tc}
[Tags] storage netapp ontapp api luns mockoon
${command} Catenate
... ${CMD}
... ${extra_options}

Ctn Run Command And Check Result As Strings ${command} ${expected_result}

Examples: tc extra_options expected_result --
... 1 ${EMPTY} OK: Lun '/vol/volume1/qtree1/lun1' state: online [container state: string]
... 2 --warning-status='\\\%{state} !~ /notonline/i' WARNING: Lun '/vol/volume1/qtree1/lun1' state: online [container state: string]
... 3 --critical-status='\\\%{state} !~ /notonline/i' CRITICAL: Lun '/vol/volume1/qtree1/lun1' state: online [container state: string]
Loading

0 comments on commit f9c9244

Please sign in to comment.