Skip to content

Commit

Permalink
test(request termination) (#28)
Browse files Browse the repository at this point in the history
* doc(functional tests) update docs about writing functional tests

* test(request termination) test request termination plugin on a serviceless route
  • Loading branch information
hutchic authored Mar 27, 2019
1 parent 942df20 commit 3181745
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 1 deletion.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,11 @@ The Kong functional tests use (Tavern)[https://taverntesting.github.io/].
*Prerequisites*

- Docker
- A Packaged Kong Release (`make package-kong`)
- K8s and helm (`make setup-tests`)

```
make run_tests
make test
```

Will run the functional tests against the defaults specified in the Makefile prefixed with `TEST_`
Expand All @@ -112,6 +114,16 @@ TEST_PROXY_PORT?=8000
TEST_PROXY_URI?=$(TEST_PROXY_PROTOCOL)$(TEST_HOST):$(TEST_PROXY_PORT)
```

### Developing Functional Tests

With the same prerequisites as running functional tests

```
make test
make develop_tests
py.test test_your_test.tavern.yaml # Expect warnings about https and structure different
```

## Releasing a Kong Distribution

The same defaults that applied when creating a packaged version of Kong apply to releasing said package
Expand Down
59 changes: 59 additions & 0 deletions test/test_plugin-request-termination.tavern.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
test_name: Test the request termination plugin

stages:
- name: Create a route
request:
verify: false
url: "{tavern.env_vars.ADMIN_URI}/routes"
method: POST
json:
name: "requestterminationroute"
hosts:
- "requestterminationroute.com"
response:
status_code:
- 201
save:
body:
route_id: id
delay_after: 5
max_retries: 1
- name: Enable the request termination plugin
request:
verify: false
url: "{tavern.env_vars.ADMIN_URI}/routes/requestterminationroute/plugins/"
method: POST
json:
name: request-termination
config:
status_code: 418
message: "Im a teapot"
response:
strict: False
status_code: 201
save:
body:
plugin_id: id
delay_after: 5
max_retries: 1
- name: Use the request termination plugin
request:
url: "{tavern.env_vars.PROXY_URI}/request"
method: GET
headers:
host: requestterminationroute.com
response:
strict: False
status_code: 418
body:
message: "Im a teapot"
delay_after: 5
max_retries: 1
- name: Delete the route
request:
verify: false
url: "{tavern.env_vars.ADMIN_URI}/routes/requestterminationroute"
method: DELETE
response:
status_code: 204

0 comments on commit 3181745

Please sign in to comment.