Skip to content

Commit

Permalink
Add docs on testing
Browse files Browse the repository at this point in the history
  • Loading branch information
dennypradipta committed Aug 9, 2023
1 parent b351051 commit 69c7211
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ npm start

After you run the simulator, you can access the Swagger API Documentations by visiting http://localhost:8000/docs

## Examples

To test how the API works, there are Monika configuration examples in the `examples` folder.

1. Testing the delayed response: `examples/monika-sample-1-delay.yml`
2. Testing the incorrect status code: `examples/monika-sample-1-status.yml`
3. Testing multiple probes: `examples/monika-sample-2.yml`
4. Testing the chaining request feature: `examples/monika-sample-3.yml`
5. Testing the incorrect response body: `examples/monika-sample-4-error.yml`

You can run the configurations above by running `monika -c <path_to_monika_configuration`

## License

Monika Alert Simulator is licensed under MIT.
17 changes: 17 additions & 0 deletions examples/monika-sample-1-delay.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
notifications:
- id: unique-id-desktop
type: desktop
probes:
- id: "1"
name: Localhost
description: Check status
interval: 1
incidentThreshold: 3
recoveryThreshold: 3
requests:
- method: GET
timeout: 10000
url: http://localhost:8000/api/delay
alerts:
- assertion: response.time > 800
message: Probe not accessible
17 changes: 17 additions & 0 deletions examples/monika-sample-1-status.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
notifications:
- id: unique-id-desktop
type: desktop
probes:
- id: "1"
name: Localhost
description: Check status
interval: 1
incidentThreshold: 3
recoveryThreshold: 3
requests:
- method: GET
timeout: 10000
url: http://localhost:8000/api/status
alerts:
- assertion: response.status != 200
message: Status is not 200, please check
30 changes: 30 additions & 0 deletions examples/monika-sample-2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
notifications:
- id: unique-id-desktop
type: desktop
probes:
- id: "1"
name: Status
description: Check status
interval: 1
incidentThreshold: 3
recoveryThreshold: 3
requests:
- method: GET
timeout: 10000
url: http://localhost:8000/api/status
alerts:
- assertion: response.status != 200
message: Status not 200
- id: "2"
name: Delay
description: Check delay
interval: 1
incidentThreshold: 3
recoveryThreshold: 3
requests:
- method: GET
timeout: 10000
url: http://localhost:8000/api/delay
alerts:
- assertion: response.time > 800
message: Probe not accessible
26 changes: 26 additions & 0 deletions examples/monika-sample-3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
notifications:
- id: unique-id-desktop
type: desktop
probes:
- id: "1"
name: Chaining
description: Check chaining
interval: 1
incidentThreshold: 3
recoveryThreshold: 3
requests:
- method: POST
timeout: 10000
url: http://localhost:8000/api/login
headers:
Content-Type: application/json
body: {}
alerts:
- assertion: response.status != 200
message: Status not 200
- method: GET
timeout: 10000
url: http://localhost:8000/api/user/{{ responses.[0].body.data.uid }}
alerts:
- assertion: response.status != 200
message: Status not 200
17 changes: 17 additions & 0 deletions examples/monika-sample-4-error.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
notifications:
- id: unique-id-desktop
type: desktop
probes:
- id: "1"
name: Check body
description: Check body error
interval: 1
incidentThreshold: 3
recoveryThreshold: 3
requests:
- method: GET
timeout: 10000
url: http://localhost:8000/api/body
alerts:
- assertion: response.body.status == "error"
message: Body status is error

0 comments on commit 69c7211

Please sign in to comment.