Use global variables for tests (usefull for local tests) + robotidy

This commit is contained in:
Sophie Depassio 2024-07-10 16:21:28 +02:00
parent af73ab03be
commit e4215a80d5
27 changed files with 135 additions and 91 deletions

View File

@ -1,5 +1,6 @@
*** Settings ***
Documentation This is the documentation for the import resource file.
Documentation This is the documentation for the import resource file.
Library Examples
Library OperatingSystem
Library String

View File

@ -1,12 +1,19 @@
*** Settings ***
Documentation Centreon Plugins for Robot Framework
Library Process
*** Variables ***
${CENTREON_PLUGINS} perl ${CURDIR}${/}..${/}..${/}src${/}centreon_plugins.pl
${CENTREON_PLUGINS} perl ${CURDIR}${/}..${/}..${/}src${/}centreon_plugins.pl
# one we use package, we need to remove the "perl" part to be sure the plugin is executable and is correctly formated
# with a shebang at the top.
${PERCENT} %
${HOSTNAME} 127.0.0.1
${APIPORT} 3000
${SNMPPORT} 2024
${SNMPVERSION} 2c
${PERCENT} %
*** Keywords ***
Start Mockoon
@ -19,5 +26,6 @@ Start Mockoon
... --port
... 3000
Sleep 10s
Stop Mockoon
Terminate All Processes
Terminate All Processes

View File

@ -36,12 +36,45 @@
}
],
"responseMode": null
},
{
"uuid": "f912f745-85f5-4313-9852-682f55b256bb",
"type": "http",
"documentation": "",
"method": "get",
"endpoint": "api/v2/unified_jobs",
"responses": [
{
"uuid": "158d9bce-bc86-4411-8977-afac4a1eaedd",
"body": "{\n \"count\": 1,\n \"next\": {{#if (lt (queryParam 'page') 2)}}\"/api/v2/unified_jobs\"{{else}}null{{/if}},\n \"previous\": {{#if (gte (queryParam 'page') 2)}}\"/api/v2/unified_jobs\"{{else}}null{{/if}},\n \"results\": [\n {\n \"allow_simultaneous\": false,\n \"artifacts\": {},\n \"canceled_on\": null,\n \"controller_node\": \"\",\n \"created\": \"2018-02-01T08:00:00.000000Z\",\n \"description\": \"\",\n \"diff_mode\": false,\n \"elapsed\": 0,\n \"execution_node\": \"\",\n \"extra_vars\": \"{}\",\n \"failed\": false,\n \"finished\": null,\n \"force_handlers\": false,\n \"forks\": 0,\n \"id\": 1,\n \"instance_group\": null,\n \"inventory\": null,\n \"job_explanation\": \"\",\n \"job_slice_count\": 1,\n \"job_slice_number\": 0,\n \"job_tags\": \"\",\n \"job_template\": 1,\n \"job_type\": \"run\",\n \"launch_type\": \"manual\",\n \"limit\": \"\",\n \"modified\": \"2018-02-01T08:00:00.000000Z\",\n \"name\": \"\",\n \"organization\": null,\n \"passwords_needed_to_start\": [],\n \"playbook\": \"\",\n \"project\": null,\n \"related\": {\n \"activity_stream\": \"/api/v2/jobs/1/activity_stream/\",\n \"cancel\": \"/api/v2/jobs/1/cancel/\",\n \"create_schedule\": \"/api/v2/jobs/1/create_schedule/\",\n \"credentials\": \"/api/v2/jobs/1/credentials/\",\n \"job_events\": \"/api/v2/jobs/1/job_events/\",\n \"job_host_summaries\": \"/api/v2/jobs/1/job_host_summaries/\",\n \"job_template\": \"/api/v2/job_templates/1/\",\n \"labels\": \"/api/v2/jobs/1/labels/\",\n \"notifications\": \"/api/v2/jobs/1/notifications/\",\n \"relaunch\": \"/api/v2/jobs/1/relaunch/\",\n \"stdout\": \"/api/v2/jobs/1/stdout/\",\n \"unified_job_template\": \"/api/v2/job_templates/1/\"\n },\n \"scm_branch\": \"\",\n \"scm_revision\": \"\",\n \"skip_tags\": \"\",\n \"start_at_task\": \"\",\n \"started\": null,\n \"status\": \"new\",\n \"summary_fields\": {\n \"credentials\": [],\n \"job_template\": {\n \"description\": \"\",\n \"id\": 1,\n \"name\": \"\"\n },\n \"labels\": {\n \"count\": 0,\n \"results\": []\n },\n \"unified_job_template\": {\n \"description\": \"\",\n \"id\": 1,\n \"name\": \"\",\n \"unified_job_type\": \"job\"\n },\n \"user_capabilities\": {\n \"delete\": true,\n \"start\": false\n }\n },\n \"timeout\": 0,\n \"type\": \"job\",\n \"unified_job_template\": 1,\n \"url\": \"/api/v2/jobs/1/\",\n \"use_fact_cache\": false,\n \"verbosity\": 0,\n \"webhook_credential\": null,\n \"webhook_guid\": \"\",\n \"webhook_service\": \"\"\n }\n ]\n}",
"latency": 0,
"statusCode": 200,
"label": "",
"headers": [],
"bodyType": "INLINE",
"filePath": "",
"databucketID": "",
"sendFileAsBody": false,
"rules": [],
"rulesOperator": "OR",
"disableTemplating": false,
"fallbackTo404": false,
"default": true,
"crudKey": "id",
"callbacks": []
}
],
"responseMode": null
}
],
"rootChildren": [
{
"type": "route",
"uuid": "781bf78c-43f7-4da1-9515-1d324b7a59d1"
},
{
"type": "route",
"uuid": "f912f745-85f5-4313-9852-682f55b256bb"
}
],
"proxyMode": false,

View File

@ -3,21 +3,21 @@ Documentation Check the hosts mode with api custom mode
Resource ${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}resources/import.resource
Suite Setup Start Mockoon ${MOCKOON_JSON}
Suite Teardown Stop Mockoon
Test Timeout 120s
Test Setup Set Test Variable ${cnt} ${1}
Test Teardown Set Test Variable ${cnt} ${cnt + 1}
*** Variables ***
${CMD} ${CENTREON_PLUGINS}
... --plugin=apps::automation::ansible::tower::plugin
... --custommode=api
... --hostname=host.docker.internal
... --username=username
... --password=password
... --port=3000
${MOCKOON_JSON} ${CURDIR}${/}ansible_tower.json
${CMD} ${CENTREON_PLUGINS}
... --plugin=apps::automation::ansible::tower::plugin
... --custommode=api
... --hostname=${HOSTNAME}
... --username=username
... --password=password
... --port=${APIPORT}
*** Test Cases ***

View File

@ -15,6 +15,7 @@ ${CMD} ${CENTREON_PLUGINS}
... --no-ps
... --command-options=${CURDIR}/nodeintegrationservice-2022.json
*** Test Cases ***
HyperV 2022 ${tc}/3
[Documentation] Apps Microsoft HyperV 2022
@ -34,4 +35,3 @@ HyperV 2022 ${tc}/3
... 1 ${EMPTY} CRITICAL: 1 problem(s) detected
... 2 VSERVER05 OK: VM 'VSERVER05' 0 problem(s) detected - VM 'VSERVER05' 0 problem(s) detected
... 3 VSERVER07 CRITICAL: VM 'VSERVER07' 1 problem(s) detected

View File

@ -11,9 +11,13 @@ Test Timeout 120s
*** Variables ***
${MOCKOON_JSON} ${CURDIR}${/}collection-centreon-web.mockoon.json
${CMD} ${CENTREON_PLUGINS} --plugin apps::protocols::http::plugin --mode collection
... --constant='hostname=127.0.0.1' --constant='protocol=http' --constant='port=3000'
... --constant='username=admin' --constant='password=myPassword'
${CMD} ${CENTREON_PLUGINS} --plugin=apps::protocols::http::plugin
... --mode collection
... --constant='hostname=${HOSTNAME}'
... --constant='protocol=http'
... --constant='port=${APIPORT}'
... --constant='username=admin'
... --constant='password=myPassword'
*** Test Cases ***

View File

@ -16,9 +16,9 @@ SNMP Collection - Sputnik Environment ${tc}/3
${command} Catenate
... ${CMD}
... --mode=collection
... --hostname=127.0.0.1
... --snmp-version=2c
... --snmp-port=2024
... --hostname=${HOSTNAME}
... --snmp-version=${SNMPVERSION}
... --snmp-port=${SNMPPORT}
... --snmp-community=apps/protocols/snmp/collection-sputnik
... --config=${CURDIR}${/}..${/}..${/}..${/}..${/}..${/}src/contrib/collection/snmp/sputnik-environment.json

View File

@ -9,7 +9,7 @@ Test Timeout 120s
*** Variables ***
${MOCKOON_JSON} ${CURDIR}${/}vault-authentication-hashicorp.json
${CMD} ${CENTREON_PLUGINS} --plugin apps::protocols::snmp::plugin --hostname=127.0.0.1
${CMD} ${CENTREON_PLUGINS} --plugin apps::protocols::snmp::plugin --hostname=${HOSTNAME}
*** Test Cases ***
@ -19,16 +19,16 @@ check hashicorp vault manager${Name}
${cmd_hashicorp} Catenate
... ${CMD}
... --pass-manager=hashicorpvault
... --vault-address=127.0.0.1
... --vault-port=3000
... --vault-address=${HOSTNAME}
... --vault-port=${APIPORT}
... --vault-protocol=http
... --auth-method=userpass
... --auth-settings="username=hcvaultuser"
... --secret-path="path/of/the/secret"
... --snmp-port=2024
... --snmp-port=${SNMPPORT}
... --map-option="snmp_community=\\%{value_path/of/the/secret}"
... --mode=string-value
... --snmp-version=2c
... --snmp-version=${SNMPVERSION}
... --snmp-community=apps/protocols/snmp/snmp-single-oid
... --oid='.1.3.6.1.2.1.1.1.0' ${path-param}
... --format-ok='current value is: \\%{details_ok}'

View File

@ -11,29 +11,30 @@ Test Timeout 120s
*** Variables ***
${MOCKOON_JSON} ${CURDIR}${/}cloud-azure-policyinsights-policystates.json
${LOGIN_ENDPOINT} http://localhost:3000/login
${BASE_URL} http://${HOSTNAME}:${APIPORT}
${LOGIN_ENDPOINT} ${BASE_URL}/login
${CMD} ${CENTREON_PLUGINS} --plugin=cloud::azure::policyinsights::policystates::plugin --subscription=subscription --tenant=tenant --client-id=client_id --client-secret=secret --statefile-dir=/tmp/cache/ --login-endpoint=${LOGIN_ENDPOINT}
&{compliance_value1}
... endpoint=http://localhost:3000/ok
... endpoint=${BASE_URL}/ok
... policyname=
... resourcelocation=
... resourcetype=
... result=OK: Number of non compliant policies: 0 - All compliances states are ok | 'policies.non_compliant.count'=0;;;0;
&{compliance_value2}
... endpoint=http://localhost:3000/oknextlink
... endpoint=${BASE_URL}/oknextlink
... policyname=9daedab3-fb2d-461e-b861-71790eead4f6
... resourcelocation=
... resourcetype=
... result=OK: Number of non compliant policies: 0 - All compliances states are ok | 'policies.non_compliant.count'=0;;;0;
&{compliance_value3}
... endpoint=http://localhost:3000/nok1
... endpoint=${BASE_URL}/nok1
... policyname=9daedab3-fb2d-461e-b861-71790eead4f6
... resourcelocation=fr
... resourcetype=
... result=CRITICAL: Compliance state for policy '9daedab3-fb2d-461e-b861-71790eead4f6' on resource 'mypubip1' is 'NonCompliant' | 'policies.non_compliant.count'=1;;;0;
&{compliance_value4}
... endpoint=http://localhost:3000/nok2
... endpoint=${BASE_URL}/nok2
... policyname=9daedab3-fb2d-461e-b861-71790eead4f6
... resourcelocation=fr
... resourcetype=ip

View File

@ -10,8 +10,8 @@ Test Timeout 120s
${CMD} ${CENTREON_PLUGINS}
... --plugin=hardware::devices::camera::avigilon::snmp::plugin
... --mode=memory
... --hostname=127.0.0.1
... --snmp-port=2024
... --hostname=${HOSTNAME}
... --snmp-port=${SNMPPORT}
*** Test Cases ***

View File

@ -10,8 +10,8 @@ Test Timeout 120s
${CMD} ${CENTREON_PLUGINS}
... --plugin=hardware::devices::camera::avigilon::snmp::plugin
... --mode=storage
... --hostname=127.0.0.1
... --snmp-port=2024
... --hostname=${HOSTNAME}
... --snmp-port=${SNMPPORT}
*** Test Cases ***

View File

@ -10,8 +10,8 @@ Test Timeout 120s
${CMD} ${CENTREON_PLUGINS}
... --plugin=hardware::devices::camera::avigilon::snmp::plugin
... --mode=temperature
... --hostname=127.0.0.1
... --snmp-port=2024
... --hostname=${HOSTNAME}
... --snmp-port=${SNMPPORT}
*** Test Cases ***

View File

@ -7,9 +7,6 @@ Test Timeout 120s
*** Variables ***
${HOSTADDRESS} 127.0.0.1
${SNMPPORT} 2024
${SNMPVERSION} 2c
${SNMPCOMMUNITY} hardware/kvm/avocent/acs/8000/avocent8000
@ -93,7 +90,7 @@ Run Avocent 8000 Plugin
... ${CENTREON_PLUGINS}
... --plugin=hardware::kvm::avocent::acs::8000::snmp::plugin
... --mode=${mode}
... --hostname=${HOSTADDRESS}
... --hostname=${HOSTNAME}
... --snmp-version=${SNMPVERSION}
... --snmp-port=${SNMPPORT}
... --snmp-community=${SNMPCOMMUNITY}

View File

@ -7,7 +7,7 @@ Test Timeout 120s
*** Variables ***
${CMD} ${CENTREON_PLUGINS} --plugin=hardware::sensors::apc::snmp::plugin --mode=sensors --hostname=127.0.0.1 --snmp-version=2c --snmp-port=2024
${CMD} ${CENTREON_PLUGINS} --plugin=hardware::sensors::apc::snmp::plugin --mode=sensors --hostname=${HOSTNAME} --snmp-version=${SNMPVERSION} --snmp-port=${SNMPPORT}
*** Test Cases ***

View File

@ -16,9 +16,9 @@ Sputnik UPS - Environment ${tc}/9
${command} Catenate
... ${CMD}
... --mode=environment
... --hostname=127.0.0.1
... --snmp-version=2c
... --snmp-port=2024
... --hostname=${HOSTNAME}
... --snmp-version=${SNMPVERSION}
... --snmp-port=${SNMPPORT}
... --snmp-community=hardware/ups/inmatics/sputnik/snmp/hardware-ups-sputnik
# Append options to command

View File

@ -16,9 +16,9 @@ Battery ${tc}/4
${command} Catenate
... ${CMD}
... --mode=battery
... --hostname=127.0.0.1
... --snmp-version=2c
... --snmp-port=2024
... --hostname=${HOSTNAME}
... --snmp-version=${SNMPVERSION}
... --snmp-port=${SNMPPORT}
... --snmp-community=hardware/ups/socomec/netvision/snmp/battery
# Append options to command

View File

@ -65,9 +65,9 @@ Hardware UPS Standard SNMP input lines
${command} Catenate
... ${CMD}
... --mode=input-lines
... --hostname=127.0.0.1
... --snmp-version=2c
... --snmp-port=2024
... --hostname=${HOSTNAME}
... --snmp-version=${SNMPVERSION}
... --snmp-port=${SNMPPORT}
... --snmp-community=${ups_standard_test.snmpcommunity}
${length} Get Length ${ups_standard_test.warningpower}
IF ${length} > 0

View File

@ -7,7 +7,7 @@ Test Timeout 120s
*** Variables ***
${CMD} ${CENTREON_PLUGINS} --plugin=network::aruba::instant::snmp::plugin --mode=ap-usage --hostname=127.0.0.1 --snmp-version=2c --snmp-port=2024
${CMD} ${CENTREON_PLUGINS} --plugin=network::aruba::instant::snmp::plugin --mode=ap-usage --hostname=${HOSTNAME} --snmp-version=${SNMPVERSION} --snmp-port=${SNMPPORT}
&{ap_usage_test_1}
... documentation=Test AP usage without filters

View File

@ -10,15 +10,16 @@ Test Timeout 120s
*** Variables ***
${MOCKOON_JSON} ${CURDIR}${/}meraki.mockoon.json
${CMD} ${CENTREON_PLUGINS} --plugin=network::cisco::meraki::cloudcontroller::restapi::plugin
... --api-token=EEECGFCGFCGF
${CMD} ${CENTREON_PLUGINS} --plugin=network::cisco::meraki::cloudcontroller::restapi::plugin
... --api-token=EEECGFCGFCGF
... --statefile-dir=/dev/shm/
*** Test Cases ***
Create cache from API
[Tags] meraki api vpn network cache
${output} Run
... ${CMD} --mode=cache --proto http --port 3000 --hostname=127.0.0.1
... ${CMD} --mode=cache --proto=http --port=${APIPORT} --hostname=${HOSTNAME}
${output} Strip String ${output}
Should Be Equal As Strings
@ -43,4 +44,3 @@ Check if ${test_desc} works
... all links .* OK: vpn tunnel 'C3PO-R2P2-BB88' status: dormant [mode: spoke] | 'vpn.tunnels.online.count'=0;;;0;1 'vpn.tunnels.offline.count'=0;;;0;1 'vpn.tunnels.dormant.count'=1;;1:;0;1
... empty filter ${EMPTY} OK: vpn tunnel 'C3PO-R2P2-BB88' status: dormant [mode: spoke] | 'vpn.tunnels.online.count'=0;;;0;1 'vpn.tunnels.offline.count'=0;;;0;1 'vpn.tunnels.dormant.count'=1;;1:;0;1
... absurd filter toto CRITICAL: Vpn tunnels dormant: 0 | 'vpn.tunnels.online.count'=0;;;0;0 'vpn.tunnels.offline.count'=0;;;0;0 'vpn.tunnels.dormant.count'=0;;1:;0;0

View File

@ -17,8 +17,8 @@ check psu components ${tc}/2
${command} Catenate
... ${CMD}
... --mode=health
... --hostname='127.0.0.1'
... --snmp-port='2024'
... --hostname=${HOSTNAME}
... --snmp-port=${SNMPPORT}
... --snmp-community='network/citrix/netscaler/snmp/mode/components/${community}'
... --component=psu
... --alternative-status-mapping='${alternative_status_mapping}'

View File

@ -306,9 +306,9 @@ Network Fortinet Fortigate SNMP link monitor
${command} Catenate
... ${CMD}
... --mode=link-monitor
... --hostname=127.0.0.1
... --snmp-version=2c
... --snmp-port=2024
... --hostname=${HOSTNAME}
... --snmp-version=${SNMPVERSION}
... --snmp-port=${SNMPPORT}
... --snmp-community=network/fortinet/fortigate/snmp/linkmonitor
${length} Get Length ${fortinet_fortigate_linkmonitor_test.filterid}
IF ${length} > 0
@ -399,9 +399,9 @@ Network Fortinet Fortigate SNMP list link monitor
${command} Catenate
... ${CMD}
... --mode=list-link-monitors
... --hostname=127.0.0.1
... --snmp-version=2c
... --snmp-port=2024
... --hostname=${HOSTNAME}
... --snmp-version=${SNMPVERSION}
... --snmp-port=${SNMPPORT}
... --snmp-community=network/fortinet/fortigate/snmp/linkmonitor
${length} Get Length ${fortinet_fortigate_listlinkmonitors_test.filterstate}
IF ${length} > 0

View File

@ -508,9 +508,9 @@ Network Teldat SNMP cells radio
${command} Catenate
... ${CMD}
... --mode=cells-radio
... --hostname=127.0.0.1
... --snmp-version=2c
... --snmp-port=2024
... --hostname=${HOSTNAME}
... --snmp-version=${SNMPVERSION}
... --snmp-port=${SNMPPORT}
... --snmp-community=network/teldat/snmp/teldat
${length} Get Length ${teldat_cellsradio_test.filtercellid}
IF ${length} > 0
@ -623,9 +623,9 @@ Network Teldat SNMP CPU
${command} Catenate
... ${CMD}
... --mode=cpu
... --hostname=127.0.0.1
... --snmp-version=2c
... --snmp-port=2024
... --hostname=${HOSTNAME}
... --snmp-version=${SNMPVERSION}
... --snmp-port=${SNMPPORT}
... --snmp-community=network/teldat/snmp/teldat
${length} Get Length ${teldat_cpu_test.warningcpuutilization5s}
IF ${length} > 0
@ -680,9 +680,9 @@ Network Teldat SNMP Memory
${command} Catenate
... ${CMD}
... --mode=memory
... --hostname=127.0.0.1
... --snmp-version=2c
... --snmp-port=2024
... --hostname=${HOSTNAME}
... --snmp-version=${SNMPVERSION}
... --snmp-port=${SNMPPORT}
... --snmp-community=network/teldat/snmp/teldat
${length} Get Length ${teldat_memory_test.warningusage}
IF ${length} > 0

View File

@ -7,7 +7,7 @@ Test Timeout 120s
*** Variables ***
${CMD} ${CENTREON_PLUGINS} --plugin=os::linux::snmp::plugin
${CMD} ${CENTREON_PLUGINS} --plugin=os::linux::snmp::plugin
*** Test Cases ***
@ -17,9 +17,9 @@ List diskio ${tc}
${command} Catenate
... ${CMD}
... --mode=list-diskio
... --hostname=127.0.0.1
... --snmp-version=2
... --snmp-port=2024
... --hostname=${HOSTNAME}
... --snmp-version=${SNMPVERSION}
... --snmp-port=${SNMPPORT}
... --disco-show
... --snmp-community=${snmpcommunity}
${output} Run ${command}
@ -32,5 +32,5 @@ List diskio ${tc}
... Wrong output result for command:{\n}{\n}${command}{\n}{\n}Command output:{\n}{\n}${output}
Examples: tc snmpcommunity expected_result --
... 1 os/linux/snmp/list-diskio 10
... 2 os/linux/snmp/list-diskio-2 4
... 1 os/linux/snmp/list-diskio 10
... 2 os/linux/snmp/list-diskio-2 4

View File

@ -10,8 +10,8 @@ Test Timeout 120s
${CMD} ${CENTREON_PLUGINS}
... --plugin=os::linux::snmp::plugin
... --mode=interfaces
... --hostname=127.0.0.1
... --snmp-port=2024
... --hostname=${HOSTNAME}
... --snmp-port=${SNMPPORT}
... --snmp-community=os/linux/snmp/network-interfaces
... --statefile-dir=/tmp/cache/

View File

@ -10,8 +10,8 @@ Test Timeout 120s
${CMD} ${CENTREON_PLUGINS}
... --plugin=os::windows::snmp::plugin
... --mode=service
... --hostname=127.0.0.1
... --snmp-port=2024
... --hostname=${HOSTNAME}
... --snmp-port=${SNMPPORT}
*** Test Cases ***

View File

@ -11,7 +11,7 @@ Test Timeout 120s
*** Variables ***
${MOCKOON_JSON} ${CURDIR}${/}storage-datacore-api.json
${CMD} ${CENTREON_PLUGINS} --plugin=storage::datacore::restapi::plugin --password=pass --username=user --port=3000 --hostname=127.0.0.1 --proto=http
${CMD} ${CENTREON_PLUGINS} --plugin=storage::datacore::restapi::plugin --password=pass --username=user --port=${APIPORT} --hostname=${HOSTNAME} --proto=http
*** Test Cases ***

View File

@ -63,9 +63,9 @@ Components
${command} Catenate
... ${CMD}
... --mode=components
... --hostname=127.0.0.1
... --snmp-version=2
... --snmp-port=2024
... --hostname=${HOSTNAME}
... --snmp-version=${SNMPVERSION}
... --snmp-port=${SNMPPORT}
... --snmp-community=${check_components_test.snmpcommunity}
${output} Run ${command}
@ -81,9 +81,9 @@ Uptime
${command} Catenate
... ${CMD}
... --mode=uptime
... --hostname=127.0.0.1
... --snmp-version=2
... --snmp-port=2024
... --hostname=${HOSTNAME}
... --snmp-version=${SNMPVERSION}
... --snmp-port=${SNMPPORT}
... --snmp-community=${test_item.snmpcommunity}
... --warning-uptime=${test_item.warning}
... --critical-uptime=${test_item.critical}