Skip to content

Commit

Permalink
Merge pull request #34 from remi-picard/#21-variablefiles-in-docker
Browse files Browse the repository at this point in the history
#21 Integate variablefiles in docker image
  • Loading branch information
Noordsestern authored Jan 31, 2024
2 parents 4d472b0 + 88be073 commit a327b2c
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 17 deletions.
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM python:3.11

ENV SUITE_FOLDER .
ENV VARIABLE_FILES ""
ENV PORT 5003

WORKDIR robot
Expand All @@ -10,4 +11,6 @@ RUN pip install robotframework-webservice

EXPOSE ${PORT}

ENTRYPOINT exec python -m RobotFrameworkService.main -p ${PORT} -t ${SUITE_FOLDER}
COPY docker-entrypoint.sh entrypoint.sh
RUN chmod +x entrypoint.sh
ENTRYPOINT ["/robot/entrypoint.sh"]
34 changes: 21 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,36 @@

# Robot Task Webservice

A web service managing Robot Framework tasks.
A web service managing Robot Framework tasks/tests.

# Goal

This web service shall start Robot Framework tasks and return and cache the according reports.
This web service shall start Robot Framework tasks/tests and return and cache the according reports.

# Installation and Execution
*Default docker image does not support variable files, yet*

## Docker
You can run the image and map your test cases into the webservice with a volume :
```
docker pull ghcr.io/marketsquare/robotframework-webservice:master
docker run --rm --publish 5003:5003 \
--volume <host directory of test cases>:/robot/tests \
--env SUITE_FOLDER=tests \
ghcr.io/marketsquare/robotframework-webservice:master
```
After that you can run the image and map your test cases in to the webservice with a volumen:
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 -v <host directory of test cases>:/robot/tests --env SUITE_FOLDER=tests rf-webservice:latest
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 ./tasks:/robot/tasks --env SUITE_FOLDER=tasks rf-webservice:latest
podman run --network host -v ./examples:/robot/tasks --env SUITE_FOLDER=tasks rf-webservice:latest
```

## Local
Expand All @@ -43,13 +51,13 @@ There are 2 types of endpoints:
2. Reporting

## Execution
Endpoints that trigger execution of a robot task, for instance:
Endpoints that trigger execution of a robot task/test, for instance:

Call robot task:
Call robot task/test:

http://localhost:5003/robotframework/run/mytask

Call robot task with variables:
Call robot task/test with variables:

http://localhost:5003/robotframework/run/mytask?myVariable1=42&anotherVariable=Mustermann

Expand All @@ -58,7 +66,7 @@ Response contains a header field `x-request-id` that can be used to retrieve log
There are endpoints for synchronous and asynchronous request:

```
# connection remains open for duration of my task
# 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
Expand Down Expand Up @@ -107,8 +115,8 @@ Swagger-UI is available under `http://localhost:5003/docs`

# Demo-Tasks

This project contains some tasks for demonstration. They are located in ``tasks`` folder. You may add
your own task suites in that directory, if you like.
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

Expand Down
2 changes: 1 addition & 1 deletion RobotFrameworkService/Config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Config:
class Default:
taskfolder = "tasks"
taskfolder = "examples"
variablefiles = None
debugfile = None

Expand Down
9 changes: 9 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

if [ -n "${VARIABLE_FILES}" ]; then
variablefiles="--variablefiles ${VARIABLE_FILES}"
else
variablefiles=""
fi

exec python -m RobotFrameworkService.main --port "${PORT}" --taskfolder "${SUITE_FOLDER}" ${variablefiles}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
*** Task ***
*** Tasks ***
Another task
Log ABCDEFG
2 changes: 1 addition & 1 deletion tasks/demotask.robot → examples/tasks/demotask.robot
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
*** Task ***
*** Tasks ***
Demonstration Task
Log Hello World!
File renamed without changes.
7 changes: 7 additions & 0 deletions examples/tests/demotest.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*** Variables ***
${hello} Hello
${who} John Doe

*** Test Cases ***
Demonstration Test
Log ${hello} ${who}
1 change: 1 addition & 0 deletions examples/variables/variables.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello = "Hi"
1 change: 1 addition & 0 deletions examples/variables/variables2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
who = "World!"

0 comments on commit a327b2c

Please sign in to comment.