Skip to content

Commit c0ecbf3

Browse files
committed
adding robot test example data
1 parent 36505a9 commit c0ecbf3

File tree

5 files changed

+72
-17
lines changed

5 files changed

+72
-17
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
log.html
2+
output.xml
3+
report.html

README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ You need to have [docker](https://www.docker.com/) installed.
1111
To later send seed demo data as test results you can either use
1212
* [Postman](https://www.getpostman.com/),
1313
* [Newman](https://github.com/postmanlabs/newman#getting-started),
14-
* or [cURL](https://curl.haxx.se/)
14+
* [cURL](https://curl.haxx.se/)
15+
* or [Robotframework](https://robotframework.org/) with [RequestsLibrary](https://github.com/bulkan/robotframework-requests)
1516

1617
## How to run it
1718

@@ -45,37 +46,39 @@ curl -X POST \
4546
-H 'Content-Type: application/json' \
4647
-H 'Postman-Token: 1b71cf1e-cb7f-44d2-87cd-0bb9d7754e6a' \
4748
-d '{
48-
"environment" : "Staging",
49-
"test_title" : "the-test-test",
50-
"result" : "PASS",
49+
"environment" : "Staging",
50+
"test_title" : "the-test-test",
51+
"result" : "PASS",
5152
"report" : "All test steps have passed."
52-
53+
5354
}'
5455
curl -X POST \
5556
http://localhost:8060/ \
5657
-H 'Cache-Control: no-cache' \
5758
-H 'Content-Type: application/json' \
5859
-H 'Postman-Token: 764d202c-5f1f-4068-9f39-2359e024e63d' \
5960
-d '{
60-
"environment" : "Production",
61-
"test_title" : "the-test-test",
62-
"result" : "PASS",
61+
"environment" : "Production",
62+
"test_title" : "the-test-test",
63+
"result" : "PASS",
6364
"report" : "All test steps have passed."
64-
65+
6566
}'
6667
curl -X POST \
6768
http://localhost:8060/ \
6869
-H 'Cache-Control: no-cache' \
6970
-H 'Content-Type: application/json' \
7071
-H 'Postman-Token: d4eea417-95d8-49aa-bcd7-e3d75a499573' \
7172
-d '{
72-
"environment" : "Staging",
73-
"test_title" : "the-test-test",
74-
"result" : "FAIL",
73+
"environment" : "Staging",
74+
"test_title" : "the-test-test",
75+
"result" : "FAIL",
7576
"report" : "Test failed on step 23\nCould not find UI object."
76-
77+
7778
}'
7879
```
80+
* or use these robot framework tests to populate some example test results
81+
`robot robot-tests`
7982

8083
## Find data in Kibana
8184

@@ -90,8 +93,5 @@ In your browser go to http://localhost:80 to see the Kibana frontend.
9093
3. Go to discover and select the fields you are interested in to have a less convoluted view.
9194
![index pattern](/images/selected-fields.png)
9295

93-
4. Build some nice visualisations in the Visualize section.
96+
4. Build some nice visualisations in the Visualize section.
9497
I highly recommend using a [tutorial](https://www.digitalocean.com/community/tutorials/how-to-use-kibana-dashboards-and-visualizations) to get into this.
95-
96-
97-
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
*** Settings ***
2+
Library RequestsLibrary
3+
Resource Variables.robot
4+
5+
6+
*** Keywords ***
7+
Create API session
8+
Create Session logstash ${URL}
9+
10+
Post example 1 test results
11+
&{headers}= Create Dictionary Content-type=application/json
12+
&{data}= Create Dictionary environment=Staging test_title=Example 1 result=PASS report=All test steps have passed.
13+
${resp}= Post Request logstash / json=${data} headers=${headers}
14+
Should Be Equal As Strings ${resp.status_code} 200
15+
Log ${resp.content}
16+
17+
Post example 2 test results
18+
&{headers}= Create Dictionary Content-type=application/json
19+
&{data}= Create Dictionary environment=Production test_title=Example 2 result=FAIL report=Test step 1 failed with an error.
20+
${resp}= Post Request logstash / json=${data} headers=${headers}
21+
Should Be Equal As Strings ${resp.status_code} 200
22+
Log ${resp.content}
23+
24+
Post example 3 test results
25+
&{headers}= Create Dictionary Content-type=application/json
26+
&{data}= Create Dictionary environment=Production test_title=Example 3 result=PASS report=All test steps have passed.
27+
${resp}= Post Request logstash / json=${data} headers=${headers}
28+
Should Be Equal As Strings ${resp.status_code} 200
29+
Log ${resp.content}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*** Variables ***
2+
${URL} http://localhost:8060
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
*** Settings ***
2+
Documentation Example of an API test using the Requests Library
3+
... call the API.
4+
... The first test case valides the response code.
5+
... The second test case valides the respons time.
6+
... The third test cases iterates over a json response
7+
... to filter by a partial string match.
8+
9+
Resource Resources/Keywords.robot
10+
11+
Suite Setup Create API session
12+
13+
*** Test Cases ***
14+
Example 1
15+
Post example 1 test results
16+
17+
Example 2
18+
Post example 2 test results
19+
20+
Example 3
21+
Post example 3 test results

0 commit comments

Comments
 (0)