-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add webhooks and functional-tests/assertions documentation (#397)
- Loading branch information
Showing
8 changed files
with
102 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Functional Tests and Assertions | ||
!!! TIP "Supported from version zooz/predator:1.5.0" | ||
|
||
Load tests are important to stress the system and see how it is dealing with the stress. The actual functionality and acceptance tests are not usually tested in load tests. | ||
For this, Predator offers running **functional tests with assertions**. | ||
|
||
## Creating a Functional Tests | ||
Functional tests are created in the same manner as the load tests. When creating functional tests, | ||
it's advised to add expectations so that you will be informed in the report if the acceptance tests passed or not. | ||
These expectations will be checked for each response received in the test and the report will display the assertion results. | ||
|
||
### Expectations | ||
The possible expectations that can be created to assert the response received: | ||
|
||
- statusCode | ||
- contentType | ||
- hasProperty | ||
- hasHeader | ||
- equals | ||
- matchesRegexp | ||
|
||
### Example | ||
|
||
A simlple functional test that sends a GET request to `http://www.google.com/` and asserts that the response received has: | ||
|
||
- statusCode: `200` | ||
- contentType: `application/json` | ||
- hasProperty: `body` | ||
|
||
![functional-test](images/expectations.png) | ||
|
||
## Running a Functional Tests | ||
In order to run the created test as a functional test and not a load test, the only difference is the actual load we run. | ||
For this we need to create a job with type `functional_test` and `arrival_count` as the rate parameter (instead of `arrival_rate` in load_tests). | ||
This means that for the test duration, the test will send the amount of requests that are configured in the `arrival_count` param. | ||
|
||
**Example**: A test duration of 10 minutes with `arrival_count = 600` will result in 1 request per second. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Webhooks | ||
!!! TIP "Supported from version zooz/predator:1.5.0" | ||
|
||
Webhooks are events that notify you on test progress. | ||
Webhooks are supported in Slack or JSON format for an easy server to server integration. | ||
You can define a global webhook which will be enabled for system-wide tests or an ad hoc webhook which will be optional on a specific test run. | ||
|
||
## Webhook Events | ||
The following test run events are supported when configuring a webhook: | ||
|
||
- **Started**: Sent when a test starts. | ||
- **In progress**: Sent after a test run receives its first statistics. | ||
- **API Failure**: Sent if there are 5xx status codes. | ||
- **Aborted**: Sent when a test is aborted. | ||
- **Failed**: Sent when a test fails to run. | ||
- **Finished**: Sent when a test finishes successfully. | ||
- **Benchmark Passed**: Sent when a test finishes successfully and receives an equal or higher score than the allowed threshold. | ||
- **Benchmark Failed**: Sent when a test finishes successfully and receives a lower score than the allowed threshold. | ||
|
||
## Setting Up | ||
Webhooks can be set up both in the UI and in the API. For further info please see our <u>[API Reference](apireference.md)</u>. | ||
|
||
### Global Webhook | ||
Global webhooks are invoked on all test runs. | ||
|
||
### Ad hoc Webhook | ||
Ad hoc webhooks can be paired with a specific test run (either by API/UI). | ||
|
||
## Webhook Formats | ||
|
||
### Slack | ||
Webhooks can be sent in as a Slack message to any Slack channel with a proper Slack webhook URL. | ||
|
||
### JSON | ||
For server to server integration, webhooks can also be sent as an HTTP `POST` request to a configured webhook URL with relevant data in JSON content-type regarding the test's progress and results. | ||
|
||
## Example | ||
A global webhook created in Slack format that will invoke a message to the configured Slack channel's URL on every test run that's in the following phases: | ||
|
||
- started | ||
- in_progress | ||
- aborted | ||
- failed | ||
- finished | ||
|
||
![webhooks](images/create-webhook.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters