diff --git a/tests/api.resource b/tests/api.resource new file mode 100644 index 0000000..e6b90ee --- /dev/null +++ b/tests/api.resource @@ -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} \ No newline at end of file diff --git a/tests/wordpress.robot b/tests/wordpress.robot index f84e0dd..698e520 100644 --- a/tests/wordpress.robot +++ b/tests/wordpress.robot @@ -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 @@ -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 \ No newline at end of file