Skip to content

Commit

Permalink
fix robot tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stephdl committed May 16, 2024
1 parent 39cf484 commit 21a783c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
14 changes: 14 additions & 0 deletions tests/api.resource
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
*** Settings ***
Library SSHLibrary

*** Keywords ***
Run task
[Arguments] ${action} ${input} ${decode_json}=${TRUE} ${rc_expected}=0
${stdout} ${stderr} ${rc} = Execute Command api-cli run ${action} --data '${input}' return_stdout=True return_stderr=True return_rc=True
Should Be Equal As Integers ${rc_expected} ${rc} Run task ${action} failed!${\n}${stderr}
IF ${decode_json} and len($stdout) > 0
${response} = Evaluate json.loads('''${stdout}''') modules=json
ELSE
${response} = Set Variable ${stdout}
END
[Return] ${response}
25 changes: 20 additions & 5 deletions tests/wordpress.robot
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
*** Settings ***
Library SSHLibrary
Resource api.resource

*** Keywords ***
Retry test
[Arguments] ${keyword}
Wait Until Keyword Succeeds 60 seconds 1 second ${keyword}

Backend URL is reachable
${rc} = Execute Command curl -f ${backend_url}
... return_rc=True return_stdout=False
Should Be Equal As Integers ${rc} 0


*** Test Cases ***
Check if wordpress is installed correctly
Expand All @@ -10,16 +22,19 @@ Check if wordpress is installed correctly
Set Suite Variable ${module_id} ${output.module_id}

Check if wordpress can be configured
${rc} = Execute Command api-cli run module/${module_id}/configure-module --data '{}'
${rc} = Execute Command api-cli run module/${module_id}/configure-module --data '{"host":"wordpress.fqdn.test","http2https":true,"lets_encrypt":true}'
... return_rc=True return_stdout=False
Should Be Equal As Integers ${rc} 0

Retrieve wordpress backend URL
# Assuming the test is running on a single node cluster
${response} = Run task module/traefik1/get-route {"instance":"${module_id}"}
Set Suite Variable ${backend_url} ${response['url']}

Check if wordpress works as expected
${rc} = Execute Command curl -f http://127.0.0.1/wordpress/
... return_rc=True return_stdout=False
Should Be Equal As Integers ${rc} 0
Retry test Backend URL is reachable

Check if wordpress is removed correctly
${rc} = Execute Command remove-module --no-preserve ${module_id}
... return_rc=True return_stdout=False
Should Be Equal As Integers ${rc} 0
Should Be Equal As Integers ${rc} 0

0 comments on commit 21a783c

Please sign in to comment.