Skip to content

Commit

Permalink
add resources files for import and keywords, and update tests to use it
Browse files Browse the repository at this point in the history
  • Loading branch information
sdepassio committed Mar 27, 2024
1 parent 444066f commit 5feba68
Show file tree
Hide file tree
Showing 19 changed files with 1,123 additions and 594 deletions.
22 changes: 2 additions & 20 deletions tests/functional/api/cloud-aws-cloudtrail.robot
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
*** Settings ***
Documentation AWS CloudTrail plugin
Library OperatingSystem
Library Process
Library String
Resource ${CURDIR}${/}..${/}..${/}resources/import.resource

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


*** Variables ***
${CENTREON_PLUGINS} ${CURDIR}${/}..${/}..${/}..${/}src${/}centreon_plugins.pl
${MOCKOON_JSON} ${CURDIR}${/}..${/}..${/}resources${/}mockoon${/}cloud-aws-cloudtrail.json

${CMD} perl ${CENTREON_PLUGINS} --plugin=cloud::aws::cloudtrail::plugin --custommode=paws --region=eu-west --aws-secret-key=secret --aws-access-key=key
Expand Down Expand Up @@ -195,18 +192,3 @@ AWS CloudTrail count events
... ${countevents_value.result}
... Wrong output result for count events of ${countevents_value}.{\n}Command output:{\n}${output}
END


*** Keywords ***
Start Mockoon
${process} Start Process
... mockoon-cli
... start
... --data
... ${MOCKOON_JSON}
... --port
... 3000
Sleep 5s

Stop Mockoon
Terminate All Processes
22 changes: 2 additions & 20 deletions tests/functional/api/cloud-azure-policyinsights-policystates.robot
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
*** Settings ***
Documentation Azure PolicyInsights PolicyStates plugin
Library OperatingSystem
Library Process
Library String
Resource ${CURDIR}${/}..${/}..${/}resources/import.resource

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


*** Variables ***
${CENTREON_PLUGINS} ${CURDIR}${/}..${/}..${/}..${/}src${/}centreon_plugins.pl
${MOCKOON_JSON} ${CURDIR}${/}..${/}..${/}resources${/}mockoon${/}cloud-azure-policyinsights-policystates.json

${LOGIN_ENDPOINT} http://localhost:3000/login
Expand Down Expand Up @@ -72,18 +69,3 @@ Azure PolicyInsights PolicyStates compliance
... ${compliance_value.result}
... Wrong output result for compliance of ${compliance_value}.{\n}Command output:{\n}${output}
END


*** Keywords ***
Start Mockoon
${process} Start Process
... mockoon-cli
... start
... --data
... ${MOCKOON_JSON}
... --port
... 3000
Sleep 5s

Stop Mockoon
Terminate All Processes
60 changes: 43 additions & 17 deletions tests/functional/api/storage-datacore-restapi.robot
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
*** Settings ***
Documentation datacore rest api plugin
Library Examples
Library OperatingSystem
Library Process
Library String
Resource ${CURDIR}${/}..${/}..${/}resources/import.resource

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


*** Variables ***
${CENTREON_PLUGINS} ${CURDIR}${/}..${/}..${/}..${/}src${/}centreon_plugins.pl
${MOCKOON_JSON} ${CURDIR}${/}..${/}..${/}resources${/}mockoon${/}storage-datacore-restapi.json
${MOCKOON_JSON} ${CURDIR}${/}..${/}..${/}resources${/}mockoon${/}storage-datacore-restapi.json

${CMD} perl ${CENTREON_PLUGINS} --plugin=storage::datacore::restapi::plugin --password=pass --username=user --port=3000 --hostname=127.0.0.1 --proto=http
${CMD} perl ${CENTREON_PLUGINS} --plugin=storage::datacore::restapi::plugin --password=pass --username=user --port=3000 --hostname=127.0.0.1 --proto=http


*** Test Cases ***
Expand All @@ -29,9 +26,23 @@ Datacore check pool usage
... ${result}
... Wrong output result for pool usage :\n\n ${output} \n\n ${result}\n\n

Examples: warning-bytesallocatedpercentage critical-bytesallocatedpercentage warning-oversubscribed critical-oversubscribed result --
... 2 5 -1 3 CRITICAL: Bytes Allocated : 12 % WARNING: Over subscribed bytes : 0 | 'datacore.pool.bytesallocated.percentage'=12%;0:2;0:5;0;100 'datacore.pool.oversubscribed.bytes'=0bytes;0:-1;0:3;0;
... 70 80 10 20 OK: Bytes Allocated : 12 % - Over subscribed bytes : 0 | 'datacore.pool.bytesallocated.percentage'=12%;0:70;0:80;0;100 'datacore.pool.oversubscribed.bytes'=0bytes;0:10;0:20;0;
Examples:
... warning-bytesallocatedpercentage
... critical-bytesallocatedpercentage
... warning-oversubscribed
... critical-oversubscribed
... result
... --
... 2
... 5
... -1
... 3
... CRITICAL: Bytes Allocated : 12 % WARNING: Over subscribed bytes : 0 | 'datacore.pool.bytesallocated.percentage'=12%;0:2;0:5;0;100 'datacore.pool.oversubscribed.bytes'=0bytes;0:-1;0:3;0;
... 70
... 80
... 10
... 20
... OK: Bytes Allocated : 12 % - Over subscribed bytes : 0 | 'datacore.pool.bytesallocated.percentage'=12%;0:70;0:80;0;100 'datacore.pool.oversubscribed.bytes'=0bytes;0:10;0:20;0;

Datacore check alert count
[Documentation] Check Datacore pool usage
Expand All @@ -44,9 +55,23 @@ Datacore check alert count
... ${result}
... Wrong output result for alert count :\n\n ${output} \n\n ${result}\n\n

Examples: warning-error critical-error warning-warning critical-warning result --
... 0 1 5 5 WARNING: number of error alerts : 1 | 'datacore.event.error.count'=1;0:0;0:1;0; 'datacore.alerts.warning.count'=1;0:5;0:5;0; 'datacore.alerts.info.count'=0;;;0; 'datacore.alerts.trace.count'=0;;;0;
... 5 5 5 5 OK: number of error alerts : 1, number of warning alerts : 1, number of info alerts : 0, number of trace alerts : 0 | 'datacore.event.error.count'=1;0:5;0:5;0; 'datacore.alerts.warning.count'=1;0:5;0:5;0; 'datacore.alerts.info.count'=0;;;0; 'datacore.alerts.trace.count'=0;;;0;
Examples:
... warning-error
... critical-error
... warning-warning
... critical-warning
... result
... --
... 0
... 1
... 5
... 5
... WARNING: number of error alerts : 1 | 'datacore.event.error.count'=1;0:0;0:1;0; 'datacore.alerts.warning.count'=1;0:5;0:5;0; 'datacore.alerts.info.count'=0;;;0; 'datacore.alerts.trace.count'=0;;;0;
... 5
... 5
... 5
... 5
... OK: number of error alerts : 1, number of warning alerts : 1, number of info alerts : 0, number of trace alerts : 0 | 'datacore.event.error.count'=1;0:5;0:5;0; 'datacore.alerts.warning.count'=1;0:5;0:5;0; 'datacore.alerts.info.count'=0;;;0; 'datacore.alerts.trace.count'=0;;;0;

Datacore check status monitor
[Documentation] Check Datacore pool usage
Expand All @@ -59,8 +84,9 @@ Datacore check status monitor
... ${result}
... Wrong output result for status monitor :\n${output} \nresult:\n${result}\n\n

Examples: result --
... CRITICAL: 'State of HostVM2' status : 'Critical', message is 'Connected'
Examples: result --
... CRITICAL: 'State of HostVM2' status : 'Critical', message is 'Connected'


*** Keywords ***
Start Mockoon
Expand All @@ -74,4 +100,4 @@ Start Mockoon
Sleep 5s

Stop Mockoon
Terminate All Processes
Terminate All Processes
12 changes: 4 additions & 8 deletions tests/functional/database/database-mysql.robot
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
*** Settings ***
Documentation Database Mysql plugin
Library OperatingSystem
Library Process
Library String
Resource ${CURDIR}${/}..${/}..${/}resources/import.resource

Test Timeout 120s


*** Variables ***
${CENTREON_PLUGINS} ${CURDIR}${/}..${/}..${/}..${/}src${/}centreon_plugins.pl

${CMD} perl ${CENTREON_PLUGINS} --plugin=database::mysql::plugin
${CMD} perl ${CENTREON_PLUGINS} --plugin=database::mysql::plugin

&{sql_string_test1}
... result=UNKNOWN: Need to specify data_source arguments.
... result=UNKNOWN: Need to specify data_source arguments.
@{sql_string_tests}
... &{sql_string_test1}
... &{sql_string_test1}


*** Test Cases ***
Expand Down
65 changes: 48 additions & 17 deletions tests/functional/linux/os-linux-list-systemdservices.robot
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
*** Settings ***
Documentation Linux Local list-systemdservices
Library OperatingSystem
Library String
Library Examples
Resource ${CURDIR}${/}..${/}..${/}resources/import.resource

Test Timeout 120s


*** Variables ***
${CENTREON_PLUGINS} ${CURDIR}${/}..${/}..${/}..${/}src${/}centreon_plugins.pl
${CMD} perl ${CENTREON_PLUGINS} --plugin=os::linux::local::plugin
${PERCENT} %

${CMD} perl ${CENTREON_PLUGINS} --plugin=os::linux::local::plugin
${PERCENT} %
${COND} ${PERCENT}\{sub\} =~ /exited/ && ${PERCENT}{display} =~ /network/'

${COND} ${PERCENT}\{sub\} =~ /exited/ && ${PERCENT}{display} =~ /network/'

*** Test Cases ***
List-Systemdservices v219 ${tc}/4
Expand All @@ -34,11 +31,28 @@ List-Systemdservices v219 ${tc}/4
... ${expected_result}
... \nWrong output result for command:\n${command}\n\nExpected:\n${expected_result}\nCommand output:\n${output}\n

Examples: tc filtername filterdescription expected_result --
... 1 toto ${EMPTY} List systemd services:
... 2 NetworkManager.service ${EMPTY} List systemd services: \n\'NetworkManager.service\' [desc = Network Manager] [load = loaded] [active = active] [sub = running]
... 3 ${EMPTY} toto List systemd services:
... 4 ${EMPTY} Permit User Sessions List systemd services: \n\'systemd-user-sessions.service\' [desc = Permit User Sessions] [load = loaded] [active = active] [sub = exited]
Examples:
... tc
... filtername
... filterdescription
... expected_result
... --
... 1
... toto
... ${EMPTY}
... List systemd services:
... 2
... NetworkManager.service
... ${EMPTY}
... List systemd services: \n\'NetworkManager.service\' [desc = Network Manager] [load = loaded] [active = active] [sub = running]
... 3
... ${EMPTY}
... toto
... List systemd services:
... 4
... ${EMPTY}
... Permit User Sessions
... List systemd services: \n\'systemd-user-sessions.service\' [desc = Permit User Sessions] [load = loaded] [active = active] [sub = exited]

List-Systemdservices v252 ${tc}/4
[Documentation] Systemd version >= 248
Expand All @@ -57,8 +71,25 @@ List-Systemdservices v252 ${tc}/4
... ${expected_result}
... \nWrong output result for command:\n${command}\n\nExpected:\n${expected_result}\nCommand output:\n${output}\n

Examples: tc filtername filterdescription expected_result --
... 1 toto ${EMPTY} List systemd services:
... 2 NetworkManager.service ${EMPTY} List systemd services: \n\'NetworkManager.service\' [desc = Network Manager] [load = loaded] [active = active] [sub = running]
... 3 ${EMPTY} toto List systemd services:
... 4 ${EMPTY} Permit User Sessions List systemd services: \n\'systemd-user-sessions.service\' [desc = Permit User Sessions] [load = loaded] [active = active] [sub = exited]
Examples:
... tc
... filtername
... filterdescription
... expected_result
... --
... 1
... toto
... ${EMPTY}
... List systemd services:
... 2
... NetworkManager.service
... ${EMPTY}
... List systemd services: \n\'NetworkManager.service\' [desc = Network Manager] [load = loaded] [active = active] [sub = running]
... 3
... ${EMPTY}
... toto
... List systemd services:
... 4
... ${EMPTY}
... Permit User Sessions
... List systemd services: \n\'systemd-user-sessions.service\' [desc = Permit User Sessions] [load = loaded] [active = active] [sub = exited]
Loading

0 comments on commit 5feba68

Please sign in to comment.