|
1 | 1 | use lib 't'; |
2 | 2 | use Test::APIcast::Blackbox 'no_plan'; |
3 | 3 |
|
| 4 | +require("http_proxy.pl"); |
| 5 | + |
| 6 | +sub large_body { |
| 7 | + my $res = ""; |
| 8 | + for (my $i=0; $i <= 1024; $i++) { |
| 9 | + $res = $res . "1111111 1111111 1111111 1111111\n"; |
| 10 | + } |
| 11 | + return $res; |
| 12 | +} |
| 13 | + |
| 14 | +$ENV{'LARGE_BODY'} = large_body(); |
| 15 | + |
| 16 | +require("policies.pl"); |
| 17 | + |
4 | 18 | run_tests(); |
5 | 19 |
|
6 | 20 | __DATA__ |
@@ -50,3 +64,101 @@ GET /?user_key= |
50 | 64 | "HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n5\r\nhello\r\n0\r\n\r\n" |
51 | 65 | --- response_body chomp |
52 | 66 | hello |
| 67 | +
|
| 68 | +
|
| 69 | +=== TEST 2: default configuration (buffered) with big file |
| 70 | +--- configuration |
| 71 | +{ |
| 72 | + "services": [ |
| 73 | + { |
| 74 | + "backend_version": 1, |
| 75 | + "proxy": { |
| 76 | + "api_backend": "http://test-upstream.lvh.me:$TEST_NGINX_SERVER_PORT/", |
| 77 | + "proxy_rules": [ |
| 78 | + { "pattern": "/", "http_method": "POST", "metric_system_name": "hits", "delta": 2 } |
| 79 | + ], |
| 80 | + "policy_chain": [ |
| 81 | + { |
| 82 | + "name": "buffering", |
| 83 | + "version": "builtin", |
| 84 | + "configuration": {} |
| 85 | + }, |
| 86 | + { |
| 87 | + "name": "apicast", |
| 88 | + "version": "builtin", |
| 89 | + "configuration": {} |
| 90 | + } |
| 91 | + ] |
| 92 | + } |
| 93 | + } |
| 94 | + ] |
| 95 | +} |
| 96 | +--- backend |
| 97 | +location /transactions/authrep.xml { |
| 98 | + content_by_lua_block { |
| 99 | + ngx.exit(200) |
| 100 | + } |
| 101 | +} |
| 102 | +--- upstream |
| 103 | +server_name test-upstream.lvh.me; |
| 104 | + location / { |
| 105 | + access_by_lua_block { |
| 106 | + ngx.say("yay, api backend") |
| 107 | + } |
| 108 | + } |
| 109 | +--- request eval |
| 110 | +"POST /?user_key= \n" . $ENV{LARGE_BODY} |
| 111 | +--- error_code: 200 |
| 112 | +--- error_log env |
| 113 | +a client request body is buffered to a temporary file |
| 114 | +--- no_error_log |
| 115 | +
|
| 116 | +
|
| 117 | +=== TEST 3: request buffering off (un-buffered) with big file |
| 118 | +--- configuration |
| 119 | +{ |
| 120 | + "services": [ |
| 121 | + { |
| 122 | + "backend_version": 1, |
| 123 | + "proxy": { |
| 124 | + "api_backend": "http://test-upstream.lvh.me:$TEST_NGINX_SERVER_PORT/", |
| 125 | + "proxy_rules": [ |
| 126 | + { "pattern": "/", "http_method": "POST", "metric_system_name": "hits", "delta": 2 } |
| 127 | + ], |
| 128 | + "policy_chain": [ |
| 129 | + { |
| 130 | + "name": "buffering", |
| 131 | + "version": "builtin", |
| 132 | + "configuration": { |
| 133 | + "request_buffering": false |
| 134 | + } |
| 135 | + }, |
| 136 | + { |
| 137 | + "name": "apicast", |
| 138 | + "version": "builtin", |
| 139 | + "configuration": {} |
| 140 | + } |
| 141 | + ] |
| 142 | + } |
| 143 | + } |
| 144 | + ] |
| 145 | +} |
| 146 | +--- backend |
| 147 | +location /transactions/authrep.xml { |
| 148 | + content_by_lua_block { |
| 149 | + ngx.exit(200) |
| 150 | + } |
| 151 | +} |
| 152 | +--- upstream |
| 153 | +server_name test-upstream.lvh.me; |
| 154 | + location / { |
| 155 | + access_by_lua_block { |
| 156 | + ngx.say("yay, api backend") |
| 157 | + } |
| 158 | + } |
| 159 | +--- request eval |
| 160 | +"POST /?user_key= \n" . $ENV{LARGE_BODY} |
| 161 | +--- error_code: 200 |
| 162 | +--- grep_error_log |
| 163 | +a client request body is buffered to a temporary file |
| 164 | +--- grep_error_log_out |
0 commit comments