From 6885521711775871f0643fa1cb86e674639cbed9 Mon Sep 17 00:00:00 2001 From: sfarouq-ext <116093375+sfarouq-ext@users.noreply.github.com> Date: Fri, 31 Jan 2025 15:29:11 +0100 Subject: [PATCH] ENH add new test storage::purestorage::flasharray::v2::restapi MODE (alerts) --- .../flasharray/v2/restapi/mode/alerts.pm | 4 +++- .../flasharray/v2/restapi/alerts.robot | 23 +++++++++---------- .../flasharray/v2/restapi/mokoon.json | 9 ++------ 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/storage/purestorage/flasharray/v2/restapi/mode/alerts.pm b/src/storage/purestorage/flasharray/v2/restapi/mode/alerts.pm index 22b5ffd77c..95991e2afd 100644 --- a/src/storage/purestorage/flasharray/v2/restapi/mode/alerts.pm +++ b/src/storage/purestorage/flasharray/v2/restapi/mode/alerts.pm @@ -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'); } diff --git a/tests/storage/purestorage/flasharray/v2/restapi/alerts.robot b/tests/storage/purestorage/flasharray/v2/restapi/alerts.robot index 1e817ac926..3cb0bea3d6 100644 --- a/tests/storage/purestorage/flasharray/v2/restapi/alerts.robot +++ b/tests/storage/purestorage/flasharray/v2/restapi/alerts.robot @@ -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} @@ -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 \ No newline at end of file + 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; \ No newline at end of file diff --git a/tests/storage/purestorage/flasharray/v2/restapi/mokoon.json b/tests/storage/purestorage/flasharray/v2/restapi/mokoon.json index bf7bdce8fe..babc4ca802 100644 --- a/tests/storage/purestorage/flasharray/v2/restapi/mokoon.json +++ b/tests/storage/purestorage/flasharray/v2/restapi/mokoon.json @@ -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": "",