Skip to content

Commit 39941d4

Browse files
tests: add two more test cases for body_filter_by_lua*.
1 parent 68acad1 commit 39941d4

File tree

3 files changed

+158
-2
lines changed

3 files changed

+158
-2
lines changed

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,13 @@ install:
9191
- git clone https://github.com/openresty/lua-resty-core.git ../lua-resty-core
9292
- git clone https://github.com/openresty/lua-resty-lrucache.git ../lua-resty-lrucache
9393
- git clone https://github.com/openresty/lua-resty-mysql.git ../lua-resty-mysql
94+
- git clone https://github.com/spacewander/lua-resty-rsa.git ../lua-resty-rsa
9495
- git clone https://github.com/openresty/lua-resty-string.git ../lua-resty-string
9596
- git clone https://github.com/openresty/stream-lua-nginx-module.git ../stream-lua-nginx-module
9697
- git clone -b v2.1-agentzh https://github.com/openresty/luajit2.git luajit2
9798

9899
before_script:
99-
- mysql -uroot -e 'create database ngx_test; grant all on ngx_test.* to "ngx_test"@"%" identified by "ngx_test"; flush privileges;'
100+
- mysql -uroot -e "create database ngx_test; CREATE USER 'ngx_test'@'%' IDENTIFIED BY 'ngx_test'; grant all on ngx_test.* to 'ngx_test'@'%'; flush privileges;"
100101

101102
script:
102103
- export PATH=$PWD/work/nginx/sbin:$PWD/openresty-devel-utils:$PATH
@@ -106,6 +107,7 @@ script:
106107
- sudo iptables -I OUTPUT -p tcp --dst 127.0.0.2 --dport 12345 -j DROP
107108
- sudo iptables -I OUTPUT -p udp --dst 127.0.0.2 --dport 12345 -j DROP
108109
- sudo ip route add prohibit 0.0.0.1/32
110+
- sudo sysctl -w kernel.pid_max=10000
109111
- cd luajit2/
110112
- make -j$JOBS CCDEBUG=-g Q= PREFIX=$LUAJIT_PREFIX CC=$CC XCFLAGS='-DLUA_USE_APICHECK -DLUA_USE_ASSERT -msse4.2' > build.log 2>&1 || (cat build.log && exit 1)
111113
- sudo make install PREFIX=$LUAJIT_PREFIX > build.log 2>&1 || (cat build.log && exit 1)

t/000--init.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ $ENV{TEST_NGINX_MYSQL_PORT} ||= 3306;
1111

1212
our $http_config = <<'_EOC_';
1313
# lua-resty-string is required for lua-resty-mysql
14-
lua_package_path "../lua-resty-mysql/lib/?.lua;../lua-resty-string/lib/?.lua;;";
14+
lua_package_path "../lua-resty-rsa/lib/?.lua;../lua-resty-mysql/lib/?.lua;../lua-resty-string/lib/?.lua;;";
1515
_EOC_
1616

1717
no_shuffle();

t/082-body-filter-2.t

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,157 @@ waiting body filter busy buffer to be sent
6060
lua say response has busy bufs
6161
--- no_error_log
6262
[error]
63+
64+
65+
66+
=== TEST 2: arg[1] not change and say long string
67+
--- config
68+
location /t {
69+
header_filter_by_lua_block {ngx.header.content_length = nil}
70+
body_filter_by_lua_block {
71+
local function anyting_not_change_arg1()
72+
return
73+
end
74+
anyting_not_change_arg1()
75+
}
76+
content_by_lua_block {
77+
for i = 1, 100 do
78+
ngx.say("12345678901234567890")
79+
end
80+
}
81+
}
82+
--- request
83+
GET /t
84+
--- response_body eval
85+
("12345678901234567890\n" x 100)
86+
--- no_error_log
87+
[error]
88+
[alert]
89+
[crit]
90+
91+
92+
93+
=== TEST 3: arg[1] not change and chunked_transfer_encoding off
94+
--- config
95+
location /t {
96+
header_filter_by_lua_block {ngx.header.content_length = nil}
97+
body_filter_by_lua_block {
98+
local function anyting_not_change_arg1()
99+
return
100+
end
101+
anyting_not_change_arg1()
102+
}
103+
chunked_transfer_encoding off;
104+
content_by_lua_block {
105+
for i = 1, 100 do
106+
ngx.say("12345678901234567890123456789012345678901234567890".."_"..tostring(i/3))
107+
end
108+
}
109+
}
110+
--- request
111+
GET /t
112+
--- response_body
113+
12345678901234567890123456789012345678901234567890_0.33333333333333
114+
12345678901234567890123456789012345678901234567890_0.66666666666667
115+
12345678901234567890123456789012345678901234567890_1
116+
12345678901234567890123456789012345678901234567890_1.3333333333333
117+
12345678901234567890123456789012345678901234567890_1.6666666666667
118+
12345678901234567890123456789012345678901234567890_2
119+
12345678901234567890123456789012345678901234567890_2.3333333333333
120+
12345678901234567890123456789012345678901234567890_2.6666666666667
121+
12345678901234567890123456789012345678901234567890_3
122+
12345678901234567890123456789012345678901234567890_3.3333333333333
123+
12345678901234567890123456789012345678901234567890_3.6666666666667
124+
12345678901234567890123456789012345678901234567890_4
125+
12345678901234567890123456789012345678901234567890_4.3333333333333
126+
12345678901234567890123456789012345678901234567890_4.6666666666667
127+
12345678901234567890123456789012345678901234567890_5
128+
12345678901234567890123456789012345678901234567890_5.3333333333333
129+
12345678901234567890123456789012345678901234567890_5.6666666666667
130+
12345678901234567890123456789012345678901234567890_6
131+
12345678901234567890123456789012345678901234567890_6.3333333333333
132+
12345678901234567890123456789012345678901234567890_6.6666666666667
133+
12345678901234567890123456789012345678901234567890_7
134+
12345678901234567890123456789012345678901234567890_7.3333333333333
135+
12345678901234567890123456789012345678901234567890_7.6666666666667
136+
12345678901234567890123456789012345678901234567890_8
137+
12345678901234567890123456789012345678901234567890_8.3333333333333
138+
12345678901234567890123456789012345678901234567890_8.6666666666667
139+
12345678901234567890123456789012345678901234567890_9
140+
12345678901234567890123456789012345678901234567890_9.3333333333333
141+
12345678901234567890123456789012345678901234567890_9.6666666666667
142+
12345678901234567890123456789012345678901234567890_10
143+
12345678901234567890123456789012345678901234567890_10.333333333333
144+
12345678901234567890123456789012345678901234567890_10.666666666667
145+
12345678901234567890123456789012345678901234567890_11
146+
12345678901234567890123456789012345678901234567890_11.333333333333
147+
12345678901234567890123456789012345678901234567890_11.666666666667
148+
12345678901234567890123456789012345678901234567890_12
149+
12345678901234567890123456789012345678901234567890_12.333333333333
150+
12345678901234567890123456789012345678901234567890_12.666666666667
151+
12345678901234567890123456789012345678901234567890_13
152+
12345678901234567890123456789012345678901234567890_13.333333333333
153+
12345678901234567890123456789012345678901234567890_13.666666666667
154+
12345678901234567890123456789012345678901234567890_14
155+
12345678901234567890123456789012345678901234567890_14.333333333333
156+
12345678901234567890123456789012345678901234567890_14.666666666667
157+
12345678901234567890123456789012345678901234567890_15
158+
12345678901234567890123456789012345678901234567890_15.333333333333
159+
12345678901234567890123456789012345678901234567890_15.666666666667
160+
12345678901234567890123456789012345678901234567890_16
161+
12345678901234567890123456789012345678901234567890_16.333333333333
162+
12345678901234567890123456789012345678901234567890_16.666666666667
163+
12345678901234567890123456789012345678901234567890_17
164+
12345678901234567890123456789012345678901234567890_17.333333333333
165+
12345678901234567890123456789012345678901234567890_17.666666666667
166+
12345678901234567890123456789012345678901234567890_18
167+
12345678901234567890123456789012345678901234567890_18.333333333333
168+
12345678901234567890123456789012345678901234567890_18.666666666667
169+
12345678901234567890123456789012345678901234567890_19
170+
12345678901234567890123456789012345678901234567890_19.333333333333
171+
12345678901234567890123456789012345678901234567890_19.666666666667
172+
12345678901234567890123456789012345678901234567890_20
173+
12345678901234567890123456789012345678901234567890_20.333333333333
174+
12345678901234567890123456789012345678901234567890_20.666666666667
175+
12345678901234567890123456789012345678901234567890_21
176+
12345678901234567890123456789012345678901234567890_21.333333333333
177+
12345678901234567890123456789012345678901234567890_21.666666666667
178+
12345678901234567890123456789012345678901234567890_22
179+
12345678901234567890123456789012345678901234567890_22.333333333333
180+
12345678901234567890123456789012345678901234567890_22.666666666667
181+
12345678901234567890123456789012345678901234567890_23
182+
12345678901234567890123456789012345678901234567890_23.333333333333
183+
12345678901234567890123456789012345678901234567890_23.666666666667
184+
12345678901234567890123456789012345678901234567890_24
185+
12345678901234567890123456789012345678901234567890_24.333333333333
186+
12345678901234567890123456789012345678901234567890_24.666666666667
187+
12345678901234567890123456789012345678901234567890_25
188+
12345678901234567890123456789012345678901234567890_25.333333333333
189+
12345678901234567890123456789012345678901234567890_25.666666666667
190+
12345678901234567890123456789012345678901234567890_26
191+
12345678901234567890123456789012345678901234567890_26.333333333333
192+
12345678901234567890123456789012345678901234567890_26.666666666667
193+
12345678901234567890123456789012345678901234567890_27
194+
12345678901234567890123456789012345678901234567890_27.333333333333
195+
12345678901234567890123456789012345678901234567890_27.666666666667
196+
12345678901234567890123456789012345678901234567890_28
197+
12345678901234567890123456789012345678901234567890_28.333333333333
198+
12345678901234567890123456789012345678901234567890_28.666666666667
199+
12345678901234567890123456789012345678901234567890_29
200+
12345678901234567890123456789012345678901234567890_29.333333333333
201+
12345678901234567890123456789012345678901234567890_29.666666666667
202+
12345678901234567890123456789012345678901234567890_30
203+
12345678901234567890123456789012345678901234567890_30.333333333333
204+
12345678901234567890123456789012345678901234567890_30.666666666667
205+
12345678901234567890123456789012345678901234567890_31
206+
12345678901234567890123456789012345678901234567890_31.333333333333
207+
12345678901234567890123456789012345678901234567890_31.666666666667
208+
12345678901234567890123456789012345678901234567890_32
209+
12345678901234567890123456789012345678901234567890_32.333333333333
210+
12345678901234567890123456789012345678901234567890_32.666666666667
211+
12345678901234567890123456789012345678901234567890_33
212+
12345678901234567890123456789012345678901234567890_33.333333333333
213+
--- no_error_log
214+
[error]
215+
[alert]
216+
[crit]

0 commit comments

Comments
 (0)