Webservice for running Robot Framework tasks
Project description
Robot Task Webservice
A web service managing Robot Framework tasks/tests.
Goal
This web service shall start Robot Framework tasks/tests and return and cache the according reports.
Installation and Execution
Docker
You can run the image and map your test cases into the webservice with a volume :
docker run --rm --publish 5003:5003 \
--volume <host directory of test cases>:/robot/tests \
--env SUITE_FOLDER=tests \
ghcr.io/marketsquare/robotframework-webservice:master
You can also run the image and map your test cases and your variable files (separated by spaces) into the webservice with volumes :
docker run --rm --publish 5003:5003 \
--volume <host directory of test cases>:/robot/tests \
--volume <host directory of variable files>:/robot/variables \
--env SUITE_FOLDER=tests \
--env "VARIABLE_FILES=variables/variables.py variables/variables2.py" \
ghcr.io/marketsquare/robotframework-webservice:master
Podman
Almost as Docker, but you might need to attach the webservice to the host network:
podman run --network host -v ./examples:/robot/tasks --env SUITE_FOLDER=tasks rf-webservice:latest
Local
pip install robotframework-webservice
and execute from command line:
python -m RobotFrameworkService.main -p 5003 -t path_to_my_taskfolder
Usage
There are 2 types of endpoints:
- Execution
- Reporting
Execution
Endpoints that trigger execution of a robot task/test, for instance:
Call robot task/test:
http://localhost:5003/robotframework/run/mytask
Call robot task/test with variables:
http://localhost:5003/robotframework/run/mytask?myVariable1=42&anotherVariable=Mustermann
Response contains a header field x-request-id
that can be used to retrieve logs and reports of this execution asynchronously (see reporting endpoints)
There are endpoints for synchronous and asynchronous request:
# connection remains open for duration of my task/test
http://localhost:5003/robotframework/run/mytask
# connection closes immediately - result must be requested with the x-request-id
http://localhost:5003/robotframework/run/mytask/async
There is also the all-in-one endpoint POST http://localhost:5003/robotframework/run
which trigger execution of a robot files, test, task or suite.
It can be customized with options in JSON payload. All available options are documented in Swagger schema and examples.
Response contains a header field x-request-id
that can be used to retrieve logs and reports.
By default, execution is asynchronous, but it can be changed with sync option.
There is no limitation on executed Robot processes! It is easy to push the webservice in DOS with too many requests at once
Call robot test
curl -X 'POST' \
'http://localhost:5003/robotframework/run' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"paths": [
"examples"
],
"test": "Demonstration Test"
}'
Call robot task
curl -X 'POST' \
'http://localhost:5003/robotframework/run' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"paths": [
"examples"
],
"task": "Demonstration Task"
}'
Call robot task with variables
curl -X 'POST' \
'http://localhost:5003/robotframework/run' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"paths": [
"examples"
],
"task": "Task with more variables",
"variables": {
"firstname": "Max",
"lastname": "Mustermann"
}
}'
Reporting
Endpoints that provide log.html
and report.html
for a specific task execution. You require the x-request-id
from a previous response that triggered the execution.
Start web service
The web service starts automatically with uvicorn inside. Simply call:
python -m RobotFrameworkService.main
You can check available options with
python -m RobotFrameworkService.main --help
Example:
python -m RobotFrameworkService.main -p 5003 -t path_to_my_taskfolder
Example - Variablefiles:
You can provide variable files that are passed to all robot suites on execution:
python -m RobotFrameworkService.main -p 5003 -t path_to_my_taskfolder --variablefiles config/env/test.py
Custom WSGI server
You can start RobotFrameworkService with bare WSGI servers:
uvicorn RobotFrameworkService.main:app --port 5003
Or start web service with other WSGI server, i.e waitress:
waitress-serve --port 5003 RotbotFrameworkService.main:app
SwaggerUi
Swagger-UI is available under http://localhost:5003/docs
Demo-Tasks
This project contains some tasks, tests and variables for demonstration. They are located in examples
folder. You may add
your own task/test suites in that directory, if you like.
Task name with spaces in URL
Tasks may contain spaces, URL must not. Luckily, Robot Framework supports CamelCase as well as snake_case syntax.
Meaning: "Another Task" can be trigger in url with parameter AnotherTask
or another_task
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file robotframework_webservice-1.0.0.tar.gz
.
File metadata
- Download URL: robotframework_webservice-1.0.0.tar.gz
- Upload date:
- Size: 14.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 080d1b24f5aa9b9827dffc576d3d4f1520fd8c7112f0afbe402f2e76eac8a8a8 |
|
MD5 | 3ce8ed8087eea8ddfaaa8556cd81840f |
|
BLAKE2b-256 | 48866279aed323294143d3408c34800575c86d6d4784475bbdc3238698697873 |
File details
Details for the file robotframework_webservice-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: robotframework_webservice-1.0.0-py3-none-any.whl
- Upload date:
- Size: 14.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b6f7796f761fa07aeb3ca36a34c219131578f013dfae59aa9fc1c7e6f44341c |
|
MD5 | 9b332ef5bfe224e74a4123a6c451460c |
|
BLAKE2b-256 | c97139d3478986dce6464f2704dc0158a0ebb858d0a354b4e18f709e0f884247 |