Skip to content

Commit d6ab4f0

Browse files
committed
WIP: Debugging Trafficserver upgrade.
1 parent f678fd3 commit d6ab4f0

File tree

4 files changed

+109
-17
lines changed

4 files changed

+109
-17
lines changed

templates/etc/test-env/nginx/apis.conf.etlua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,12 @@ server {
155155

156156
local upload_size = 0
157157
local chunk_size = 4096
158-
local form = upload:new(chunk_size)
158+
local form, form_err = upload:new(chunk_size)
159+
if not form then
160+
ngx.log(ngx.ERR, "new upload failed: ", form_err)
161+
ngx.exit(500)
162+
end
163+
159164
while true do
160165
local typ, res, err = form:read()
161166
if typ == "body" then

templates/etc/trafficserver/records.yaml.etlua

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,10 @@ records:
5353
warning: E
5454

5555
# Enable for debug logging.
56-
# debug:
57-
# enabled: 1
58-
# tags: ".*"
56+
debug:
57+
enabled: 1
58+
# tags: ".*"
59+
tags: "http_hdrs|http_tproxy|http_trans"
5960

6061
error:
6162
logfile:
@@ -92,6 +93,11 @@ records:
9293
sock_option_flag_out: 3
9394

9495
http:
96+
# request_buffer_enabled: 0
97+
# post_copy_size: 100M
98+
# keep_alive_post_out: 0
99+
# max_post_size: "1000000"
100+
95101
server_ports: <%- json_encode(config["trafficserver"]["port"]) %>
96102

97103
# Increase timeouts to match the timeouts in other pieces of the stack.
@@ -167,6 +173,8 @@ records:
167173
# Don't perform caching when the request contains cookies.
168174
cache_responses_to_cookies: 0
169175

176+
post_method: 0
177+
170178
cache:
171179
ram_cache:
172180
size: <%- json_encode(config["trafficserver"]["records"]["cache"]["ram_cache"]["size"]) %>

test/apis/test_web_app_large_body.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,14 @@ def test_fails_with_large_body_above_default_limit
5151
assert_operator(body.bytesize, :>, 1 * 1024 * 1024) # 1MB
5252
assert_operator(body.bytesize, :<, 1.1 * 1024 * 1024) # 1.1MB
5353

54-
response = Typhoeus.put("https://127.0.0.1:9081/api-umbrella/v1/users/#{user.id}.json", http_options.deep_merge(admin_token).deep_merge({
55-
:headers => { "Content-Type" => "application/json" },
56-
:body => body,
57-
}))
54+
response = nil
55+
100.times do
56+
response = Typhoeus.post("https://127.0.0.1:9081/api-umbrella/v1/users/#{user.id}.json", http_options.deep_merge(admin_token).deep_merge({
57+
:headers => { "Content-Type" => "application/json" },
58+
:body => body,
59+
}))
60+
ap response.code
61+
end
5862
assert_response_code(413, response)
5963

6064
user.reload

test/proxy/test_uploads.rb

Lines changed: 84 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,102 @@
22

33
class Test::Proxy::TestUploads < Minitest::Test
44
include ApiUmbrellaTestHelpers::Setup
5-
parallelize_me!
5+
# parallelize_me!
66

77
def setup
88
super
99
setup_server
1010
end
1111

12-
def test_large_uploads
12+
def test_no_multipart_post_request_body_size_limit
13+
file_size = 20 * 1024 * 1024 # 20MB
14+
with_file_of_size(file_size) do |file|
15+
response = Typhoeus.post("http://127.0.0.1:9080/api/upload", http_options.deep_merge({
16+
:body => { :upload => file },
17+
}))
18+
19+
assert_response_code(200, response)
20+
data = MultiJson.load(response.body)
21+
assert_equal(file_size, data["upload_size"])
22+
end
23+
end
24+
25+
def test_no_post_request_body_size_limit
26+
file_size = 20 * 1024 * 1024 # 20MB
27+
with_file_of_size(file_size) do |file|
28+
response = Typhoeus.post("http://127.0.0.1:9080/api/info/?post", http_options.deep_merge({
29+
:body => file.read,
30+
}))
31+
32+
assert_response_code(200, response)
33+
data = MultiJson.load(response.body)
34+
assert_equal(file_size, data.fetch("headers").fetch("content-length").to_i)
35+
end
36+
end
37+
38+
def test_no_put_request_body_size_limit
39+
file_size = 20 * 1024 * 1024 # 20MB
40+
with_file_of_size(file_size) do |file|
41+
# 100.times do
42+
1.times do
43+
file.rewind
44+
response = Typhoeus.put("http://127.0.0.1:9080/api/info/?put", http_options.deep_merge({
45+
:body => file.read,
46+
}))
47+
48+
assert_response_code(200, response)
49+
data = MultiJson.load(response.body)
50+
assert_equal(file_size, data.fetch("headers").fetch("content-length").to_i)
51+
end
52+
end
53+
end
54+
55+
def test_no_patch_request_body_size_limit
56+
file_size = 20 * 1024 * 1024 # 20MB
57+
with_file_of_size(file_size) do |file|
58+
# 100.times do
59+
1.times do
60+
file.rewind
61+
response = Typhoeus.patch("http://127.0.0.1:9080/api/info/?patch", http_options.deep_merge({
62+
:body => file.read,
63+
}))
64+
65+
assert_response_code(200, response)
66+
data = MultiJson.load(response.body)
67+
assert_equal(file_size, data.fetch("headers").fetch("content-length").to_i)
68+
end
69+
end
70+
end
71+
72+
def test_no_get_request_body_size_limit
73+
file_size = 20 * 1024 * 1024 # 20MB
74+
with_file_of_size(file_size) do |file|
75+
# 100.times do
76+
1.times do
77+
file.rewind
78+
response = Typhoeus.get("http://127.0.0.1:9080/api/info/?get", http_options.deep_merge({
79+
:body => file.read,
80+
}))
81+
82+
assert_response_code(200, response)
83+
data = MultiJson.load(response.body)
84+
assert_equal(file_size, data.fetch("headers").fetch("content-length").to_i)
85+
end
86+
end
87+
end
88+
89+
private
90+
91+
def with_file_of_size(file_size)
1392
file_size = 20 * 1024 * 1024 # 20MB
1493
file = Tempfile.new("large")
1594
chunk_size = 1024 * 1024
1695
chunks = file_size / chunk_size
1796
chunks.times { file.write(SecureRandom.random_bytes(chunk_size)) }
97+
file.flush
98+
file.rewind
1899

19-
response = Typhoeus.post("http://127.0.0.1:9080/api/upload", http_options.deep_merge({
20-
:body => { :upload => file },
21-
}))
22-
23-
assert_response_code(200, response)
24-
data = MultiJson.load(response.body)
25-
assert_equal(file_size, data["upload_size"])
100+
yield file
26101
ensure
27102
file.close
28103
file.unlink

0 commit comments

Comments
 (0)