Skip to content

Commit

Permalink
ENH add new test storage::purestorage::flasharray::v2::restapi MODE (…
Browse files Browse the repository at this point in the history
…alerts)
  • Loading branch information
sfarouq-ext committed Jan 31, 2025
1 parent 063f440 commit 6885521
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 20 deletions.
4 changes: 3 additions & 1 deletion src/storage/purestorage/flasharray/v2/restapi/mode/alerts.pm
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ sub manage_selection {

my $last_time;
if (defined($self->{option_results}->{memory})) {
$self->{statefile_cache}->read(statefile => 'purestorage_' . $self->{mode} . '_' . $options{custom}->get_connection_infos());
#use Data::Dumper;
#print Dumper($options{custom});
$self->{statefile_cache}->read(statefile => 'purestorage_' . $self->{mode} . '_' . $options{custom}->get_connection_info());
$last_time = $self->{statefile_cache}->get(name => 'last_time');
}

Expand Down
23 changes: 11 additions & 12 deletions tests/storage/purestorage/flasharray/v2/restapi/alerts.robot
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ Test Timeout 120s

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

${HOSTNAME} 127.0.0.1
${APIPORT} 3000
${CMD} ${CENTREON_PLUGINS}
... --plugin=storage::purestorage::flasharray::v2::restapi::plugin
... --hostname=host.docker.internal
... --hostname=${HOSTNAME}
... --proto='http'
... --api-version='2.4'
... --api-token='token'
... --port=3000
... --debug
... --port=${APIPORT}

*** Test Cases ***
alerts ${tc}
Expand All @@ -27,12 +27,11 @@ alerts ${tc}
... ${CMD}
... --mode=alerts
... ${extra_options}
Ctn Verify Command Output ${command} ${expected_result}
Ctn Run Command And Check Result As Strings ${command} ${expected_result}

Examples: tc extra_options expected_result --
... 1 --verbose --help lolipop
... 2 --verbose CRITICAL: License
... 3 --filter-category WARNING: License
... 4 --warning-status WARNING: License
... 5 --critical-status CRITICAL: License
... 6 --memory CRITICAL: License
Examples: tc extra_options expected_result --
... 1 --filter-category='array' CRITICAL: 2 problem(s) detected | 'alerts.detected.count'=2;;;0;
... 2 --warning-status='\\\%{state} = "warning"' CRITICAL: 2 problem(s) detected | 'alerts.detected.count'=2;;;0;
... 3 --critical-status='\\\%{component_name} eq "ch0"' CRITICAL: 1 problem(s) detected | 'alerts.detected.count'=1;;;0;
... 4 --memory=1 CRITICAL: 2 problem(s) detected | 'alerts.detected.count'=2;;;0;
... 5 --warning-status='\\\%{state} ne "closing" and \\\%{severity} =~ /warning/i and \\\%{flagged} and \\\%{code} eq "45"' --filter-category='array' CRITICAL: 2 problem(s) detected | 'alerts.detected.count'=2;;;0;
9 changes: 2 additions & 7 deletions tests/storage/purestorage/flasharray/v2/restapi/mokoon.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,11 @@
"responses": [
{
"uuid": "31a6a6d7-7c12-4269-9783-14c6e42be22e",
"body": "{\n \"created\": 1733184307111,\n \"description\": \"(hardware:ct0.fc3): increased invalid TX word count Expected: , Actual: 2\",\n \"state\": \"closing\",\n \"component_type\": \"hardware\",\n \"name\": \"81088063\",\n \"id\": \"85198c1eda7145a788a682eea667e06b\",\n \"code\": 45,\n \"severity\": \"warning\",\n \"category\": \"array\",\n \"flagged\": true,\n \"updated\": 1733184311263,\n \"closed\": 1733184318917,\n \"notified\": null,\n \"component_name\": \"ct0.fc3\",\n \"expected\": \"\",\n \"actual\": \"2\",\n \"knowledge_base_url\": \"https://support.purestorage.com/?cid=Alert_0045\",\n \"issue\": \"increased invalid TX word count\",\n \"summary\": \"(hardware:ct0.fc3): increased invalid TX word count\"\n}",
"body": "{\r\n \"continuation_token\": null,\r\n \"items\": [\r\n {\r\n \"created\": 1737462338078,\r\n \"state\": \"open\",\r\n \"description\": \"(drive:ch0.nvb1): failure Expected: healthy, Actual: failed\",\r\n \"component_type\": \"drive\",\r\n \"name\": \"81204734\",\r\n \"id\": \"5576557655765576557655765576\",\r\n \"code\": 60,\r\n \"category\": \"array\",\r\n \"severity\": \"critical\",\r\n \"flagged\": false,\r\n \"updated\": 1738059644723,\r\n \"closed\": null,\r\n \"notified\": null,\r\n \"component_name\": \"ch0.nvb1\",\r\n \"expected\": \"healthy\",\r\n \"actual\": \"failed\",\r\n \"knowledge_base_url\": \"https://support.purestorage.com/?cid=Alert_0060\",\r\n \"summary\": \"(drive:ch0.nvb1): failure\",\r\n \"issue\": \"failure\"\r\n },\r\n {\r\n \"created\": 1737464651017,\r\n \"state\": \"open\",\r\n \"description\": \"(shelf:ch0): shelf drive failures(s) Expected: 0, Actual: 1\",\r\n \"component_type\": \"shelf\",\r\n \"name\": \"81204806\",\r\n \"id\": \"f823f823f823f823f823f823f823\",\r\n \"code\": 60,\r\n \"category\": \"array\",\r\n \"severity\": \"critical\",\r\n \"flagged\": true,\r\n \"updated\": 1738059644699,\r\n \"closed\": null,\r\n \"notified\": null,\r\n \"component_name\": \"ch0\",\r\n \"expected\": \"0\",\r\n \"actual\": \"1\",\r\n \"knowledge_base_url\": \"https://support.purestorage.com/?cid=Alert_0060\",\r\n \"summary\": \"(shelf:ch0): shelf drive failures(s)\",\r\n \"issue\": \"shelf drive failures(s)\"\r\n }\r\n ],\r\n \"more_items_remaining\": false,\r\n \"total_item_count\": null\r\n}",
"latency": 0,
"statusCode": 200,
"label": "",
"headers": [
{
"key": "x-auth-token",
"value": "token"
}
],
"headers": [],
"bodyType": "INLINE",
"filePath": "",
"databucketID": "",
Expand Down

0 comments on commit 6885521

Please sign in to comment.