I need your help with the following problem:
As part of my robot framework test I have to execute some verification via Linux CLI too. I have imported the SSHLibrary and I can connect properly to my Linux box:
*** Keywords ***
Verify Service On All Nodes
Open Connection ${host} prompt=REGEXP:[$|#]
login ${user} ${user_pass}
SSHLibrary.Read Until Prompt
write su - \n
Read Until Password:
Write ${root_pass}\n
BuiltIn.sleep 10
SSHLibrary.Set Client Configuration prompt=~]
Read Until Prompt
Write verify #this stepp calls a shell script which does the required check
BuiltIn.sleep 90
SSHLibrary.Read Until Prompt
${output} SSHLibrary.Read Until Prompt
Log ${output}
The above snippet logs the output of my verify script into the report properly, but I'd like to go a step further.
I've written a Python function which validates the output of the above script.
def verify_service_state(ab11, ab12, s):
import re
servers = [ab11, ab12]
for i in servers:
r1 = re.search(r"^Checking listening ports on " + (i) + " for roles: \(AB\)" + "\nThere were no errors reported.", s, re.MULTILINE)
if (r1):
print("Listening ports are open " + (i))
else:
print("Not all listening ports are open on " + (i))
r2 = re.search(r"^Checking process counts on " + (i) + " for roles: \(AB\)" + "\nThere were no errors reported.", s, re.MULTILINE)
if (r2):
print("There were no errors reported on " + (i))
else:
print("Not all services are working as expected on " + (i))
I've created a RF library based on this post: Creating a robot framework library from existing python package However, it's not clear how can I pass the attributes to my function.