get result always is multiline, should fix a lot of errors

This commit is contained in:
omercier 2025-08-12 16:09:05 +02:00
parent 9520d8b3e4
commit 6429dbda88
6 changed files with 12 additions and 15 deletions

View File

@ -25,7 +25,7 @@ Container usage ${tc}
... --subnet='127.0.0.1/32'
... ${extraoptions}
Ctn Run Command And Check Result As Json ${command} ${expected_result}
Ctn Run Command Without Connector And Check Result As Json ${command} ${expected_result}
Examples: tc extraoptions expected_result --
... 1 ${EMPTY} {"end_time":1747232859,"discovered_items":1,"results":[{"hostname":"localhost","ip":"127.0.0.1","hostnames":[{"type":"PTR","name":"localhost"}],"vendor":null,"status":"up","addresses":[{"address":"127.0.0.1","type":"ipv4"}],"os_accuracy":null,"os":null,"services":null,"type":"unknown"}],"duration":0,"start_time":1747232859}

View File

@ -25,7 +25,7 @@ Check if ${test_desc} on Centreon
[Tags] centreon collections http
${command} Catenate
... ${CMD} --config=${CURDIR}/${collection}
Ctn Run Command And Check Result As Strings ${command} ${expected_result} ${tc}
Ctn Run Command And Check Result As Strings ${command} ${expected_result}
Examples: test_desc collection expected_result --
... authentication succeeds collection-centreon-web-check-auth.collection.json OK: Authentication resulted in 200 HTTP code

View File

@ -8,7 +8,6 @@ Test Timeout 120s
*** Variables ***
${MOCKOON_JSON} ${CURDIR}${/}vault-authentication-hashicorp.json
${CMD} ${CENTREON_PLUGINS} --plugin apps::protocols::snmp::plugin --hostname=${HOSTNAME}
@ -37,7 +36,7 @@ check hashicorp vault manager${Name}
Ctn Run Command And Check Result As Strings ${command} ${expected_result}
Examples: Name path-param expected_result --
... default path --auth-path='' --auth-settings="password=secrethashicorpPassword" OK: current value is: Linux centreon-devbox 5.10.0-28-amd64 #1 SMP Debian 5.10.209-2 (2024-01-31) x86_64
... wrong path --auth-path='specific-url' --auth-settings="password=secrethashicorpPassword" OK: current value is: Linux centreon-devbox 5.10.0-28-amd64 #1 SMP Debian 5.10.209-2 (2024-01-31) x86_64
... wrong password --auth-path='' --auth-settings="password=WrongPassword" UNKNOWN: 401 Unauthorized
Examples: Name path-param expected_result --
... default path --auth-path='' --auth-settings="password=secrethashicorpPassword" OK: current value is: Linux centreon-devbox 5.10.0-28-amd64 #1 SMP Debian 5.10.209-2 (2024-01-31) x86_64
... wrong path --auth-path='specific-url' --auth-settings="password=secrethashicorpPassword" OK: current value is: Linux centreon-devbox 5.10.0-28-amd64 #1 SMP Debian 5.10.209-2 (2024-01-31) x86_64
... wrong password --auth-path='' --auth-settings="password=WrongPassword" UNKNOWN: 401 Unauthorized

View File

@ -28,7 +28,7 @@ Discovery ${tc}
... ${CMD}
... ${extra_options}
Ctn Run Command And Check Result As Regexp ${command} ${expected_regexp}
Ctn Run Command Without Connector And Check Result As Regexp ${command} ${expected_regexp}
Examples: tc extraoptions expected_regexp --
... 1 ${EMPTY} "discovered_items":3

View File

@ -199,8 +199,8 @@ def ctn_extract_multiline_result_from_log(tc, log_path="/tmp/connector.log", out
for line in lines:
if not in_result:
m = re.search(r'reporting check result #(\d+).*output:(.*)', line)
if m and str(m.group(1)) == str(tc):
m = re.search(r'reporting check result #(\d+) check:' + str(tc) + ' .*output:(.*)', line)
if m:
result_lines.append(m.group(2).strip())
in_result = True
else:

View File

@ -109,8 +109,8 @@ Ctn Verify Command Without Connector Output
Ctn Connector Log Contains Result
[Arguments] ${tc}
${result}= Grep File /tmp/connector.log reporting check result
#\d+ check:${tc}${SPACE}
${result}= Grep File /tmp/connector.log reporting check result*check:${tc}
IF "${result}" == ''
${toto}= Grep File /tmp/connector.log .
@ -125,7 +125,6 @@ Ctn Wait Until Connector Result Available
... ${timeout}
... .2
... File Should Not Be Empty /tmp/connector.log
File Should Not Be Empty /tmp/connector.log
Wait Until Keyword Succeeds
... ${timeout}
... .2
@ -136,13 +135,12 @@ Ctn Run Command With Connector And Return Result
Remove File /tmp/connector.output
Remove File /tmp/connector.command.log
Create File /tmp/connector.log
File Should Be Empty /tmp/connector.log
Ctn Send To Connector ${tc} ${command} ${timeout}
Ctn Wait Until Connector Result Available ${tc} ${timeout}
# 1. Extract the result from the log and write to /tmp/connector.output
Ctn Extract Result From Log ${tc}
Ctn Extract Multiline Result From Log ${tc} timeout=${timeout}
# 2. Read the file
${output} Get File /tmp/connector.output
${output} Strip String ${output}