forked from 3scale/APIcast
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapicast-policy-upstream-connection.t
61 lines (58 loc) · 1.45 KB
/
apicast-policy-upstream-connection.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
use lib 't';
use Test::APIcast::Blackbox 'no_plan';
run_tests();
__DATA__
=== TEST 1: Set timeouts
In this test we set some timeouts to 1s. To force a read timeout, the upstream
returns part of the response, then waits 3s (more than the timeout defined),
and after that, it returns the rest of the response.
This test uses the "ignore_response" section, because we know that the response
is not going to be complete and that makes the Test::Nginx framework raise an
error. With "ignore_response" that error is ignored.
--- configuration
{
"services": [
{
"id": 42,
"proxy": {
"api_backend": "http://example.com:80/",
"policy_chain": [
{
"name": "apicast.policy.upstream_connection",
"configuration": {
"connect_timeout": 1,
"send_timeout": 1,
"read_timeout": 1
}
},
{
"name": "apicast.policy.upstream",
"configuration": {
"rules": [
{
"regex": "/",
"url": "http://test:$TEST_NGINX_SERVER_PORT"
}
]
}
}
]
}
}
]
}
--- upstream
location / {
content_by_lua_block {
ngx.say("first part")
ngx.flush(true)
ngx.sleep(3)
ngx.say("yay, second part")
}
}
--- request
GET /
--- ignore_response
--- error_log
upstream timed out
--- error_code: