Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: fixed test for http3. #2224

Merged
merged 7 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
dist: bionic
dist: focal

branches:
only:
Expand All @@ -24,6 +24,11 @@ addons:
- libtest-longstring-perl
- liblist-moreutils-perl
- libgd-dev
- time
- cmake
- libunwind-dev
- wget
- libbrotli1

cache:
directories:
Expand Down Expand Up @@ -56,19 +61,19 @@ env:
- TEST_NGINX_SLEEP=0.006
- MALLOC_PERTURB_=9
jobs:
- NGINX_VERSION=1.21.4 OPENSSL_VER=1.1.0l OPENSSL_PATCH_VER=1.1.0d
- NGINX_VERSION=1.21.4 OPENSSL_VER=1.1.1s OPENSSL_PATCH_VER=1.1.1f
- NGINX_VERSION=1.25.1 OPENSSL_VER=1.1.0l OPENSSL_PATCH_VER=1.1.0d
- NGINX_VERSION=1.25.1 OPENSSL_VER=1.1.1s OPENSSL_PATCH_VER=1.1.1f USE_PCRE2=Y
#- NGINX_VERSION=1.21.4 OPENSSL_VER=1.1.0l OPENSSL_PATCH_VER=1.1.0d
#- NGINX_VERSION=1.21.4 OPENSSL_VER=1.1.1s OPENSSL_PATCH_VER=1.1.1f
#- NGINX_VERSION=1.25.1 OPENSSL_VER=1.1.0l OPENSSL_PATCH_VER=1.1.0d
#- NGINX_VERSION=1.25.1 OPENSSL_VER=1.1.1s OPENSSL_PATCH_VER=1.1.1f USE_PCRE2=Y
- NGINX_VERSION=1.25.1 BORINGSSL=1 TEST_NGINX_USE_HTTP3=1 USE_PCRE2=Y
#- NGINX_VERSION=1.25.1 OPENSSL_VER=1.1.1s TEST_NGINX_USE_HTTP2=1

services:
- memcached
- redis
- mysql

before_install:
- sudo apt update
- sudo apt install --only-upgrade ca-certificates
- '! grep -n -P ''(?<=.{80}).+'' --color `find src -name ''*.c''` `find . -name ''*.h''` || (echo "ERROR: Found C source lines exceeding 80 columns." > /dev/stderr; exit 1)'
- '! grep -n -P ''\t+'' --color `find src -name ''*.c''` `find . -name ''*.h''` || (echo "ERROR: Cannot use tabs." > /dev/stderr; exit 1)'
- /usr/bin/env perl $(command -v cpanm) --sudo --notest Test::Nginx IPC::Run > build.log 2>&1 || (cat build.log && exit 1)
Expand All @@ -78,6 +83,9 @@ install:
- if [ "$USE_PCRE2" != "Y" ] && [ ! -f download-cache/pcre-$PCRE_VER.tar.gz ]; then wget -P download-cache https://downloads.sourceforge.net/project/pcre/pcre/${PCRE_VER}/pcre-${PCRE_VER}.tar.gz; fi
- if [ "$USE_PCRE2" = "Y" ] && [ ! -f download-cache/pcre2-$PCRE2_VER.tar.gz ]; then wget -P download-cache https://downloads.sourceforge.net/project/pcre/pcre2/${PCRE2_VER}/pcre2-${PCRE2_VER}.tar.gz; fi
- if [ ! -f download-cache/openssl-$OPENSSL_VER.tar.gz ]; then wget -P download-cache https://www.openssl.org/source/openssl-$OPENSSL_VER.tar.gz || wget -P download-cache https://www.openssl.org/source/old/${OPENSSL_VER//[a-z]/}/openssl-$OPENSSL_VER.tar.gz; fi
- if [ -n "$OPENSSL_VER" ] && [ ! -f download-cache/openssl-$OPENSSL_VER.tar.gz ]; then wget -P download-cache https://www.openssl.org/source/openssl-$OPENSSL_VER.tar.gz || wget -P download-cache https://www.openssl.org/source/old/${OPENSSL_VER//[a-z]/}/openssl-$OPENSSL_VER.tar.gz; fi
- wget https://github.com/openresty/openresty-deps-prebuild/releases/download/v20230902/boringssl-20230902-x64-focal.tar.gz
- wget https://github.com/openresty/openresty-deps-prebuild/releases/download/v20230902/curl-h3-x64-focal.tar.gz
- git clone https://github.com/openresty/test-nginx.git
- git clone https://github.com/openresty/openresty.git ../openresty
- git clone https://github.com/openresty/no-pool-nginx.git ../no-pool-nginx
Expand Down Expand Up @@ -108,7 +116,8 @@ before_script:
- 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;"

script:
- export PATH=$PWD/work/nginx/sbin:$PWD/openresty-devel-utils:$PATH
- sudo tar -C / -xf curl-h3-x64-focal.tar.gz
- export PATH=$PWD/work/nginx/sbin:$PWD/openresty-devel-utils:/opt/curl-h3/bin:$PATH
- ngx-releng > check.txt || true
- lines=`wc -l check.txt | awk '{print $1}'`; if [ $lines -gt 5 ]; then cat check.txt; exit 1; fi
- sudo iptables -I OUTPUT 1 -p udp --dport 10086 -j REJECT
Expand All @@ -128,13 +137,8 @@ script:
- cd lua-cjson/ && make -j$JOBS && sudo make install && cd ..
- if [ "$USE_PCRE2" != "Y" ]; then tar zxf download-cache/pcre-$PCRE_VER.tar.gz; cd pcre-$PCRE_VER/; ./configure --prefix=$PCRE_PREFIX --enable-jit --enable-utf --enable-unicode-properties > build.log 2>&1 || (cat build.log && exit 1); make -j$JOBS > build.log 2>&1 || (cat build.log && exit 1); sudo PATH=$PATH make install > build.log 2>&1 || (cat build.log && exit 1); cd ..; fi
- if [ "$USE_PCRE2" = "Y" ]; then tar zxf download-cache/pcre2-$PCRE2_VER.tar.gz; cd pcre2-$PCRE2_VER/; ./configure --prefix=$PCRE2_PREFIX --enable-jit --enable-utf > build.log 2>&1 || (cat build.log && exit 1); make -j$JOBS > build.log 2>&1 || (cat build.log && exit 1); sudo PATH=$PATH make install > build.log 2>&1 || (cat build.log && exit 1); cd ..; fi
- tar zxf download-cache/openssl-$OPENSSL_VER.tar.gz
- cd openssl-$OPENSSL_VER/
- patch -p1 < ../../openresty/patches/openssl-$OPENSSL_PATCH_VER-sess_set_get_cb_yield.patch
- ./config shared enable-ssl3 enable-ssl3-method -g --prefix=$OPENSSL_PREFIX -DPURIFY > build.log 2>&1 || (cat build.log && exit 1)
- make -j$JOBS > build.log 2>&1 || (cat build.log && exit 1)
- sudo make PATH=$PATH install_sw > build.log 2>&1 || (cat build.log && exit 1)
- cd ..
- if [ -n "$OPENSSL_VER" ]; then tar zxf download-cache/openssl-$OPENSSL_VER.tar.gz; cd openssl-$OPENSSL_VER/; patch -p1 < ../../openresty/patches/openssl-$OPENSSL_PATCH_VER-sess_set_get_cb_yield.patch; ./config shared enable-ssl3 enable-ssl3-method -g --prefix=$OPENSSL_PREFIX -DPURIFY > build.log 2>&1 || (cat build.log && exit 1); make -j$JOBS > build.log 2>&1 || (cat build.log && exit 1); sudo make PATH=$PATH install_sw > build.log 2>&1 || (cat build.log && exit 1); cd ..; fi
- if [ -n "$BORINGSSL" ]; then sudo mkdir -p /opt/ssl && sudo tar -C /opt/ssl -xf boringssl-20230902-x64-focal.tar.gz --strip-components=1; fi
- export NGX_BUILD_CC=$CC
- sh util/build-without-ssl.sh $NGINX_VERSION > build.log 2>&1 || (cat build.log && exit 1)
- sh util/build-with-dd.sh $NGINX_VERSION > build.log 2>&1 || (cat build.log && exit 1)
Expand All @@ -145,6 +149,8 @@ script:
- ldd `which nginx`|grep -E 'luajit|ssl|pcre'
- export LD_PRELOAD=$PWD/mockeagain/mockeagain.so
- export LD_LIBRARY_PATH=$PWD/mockeagain:$LD_LIBRARY_PATH
- export TEST_NGINX_HTTP3_CRT=$PWD/t/cert/http3/http3.crt
- export TEST_NGINX_HTTP3_KEY=$PWD/t/cert/http3/http3.key
- export TEST_NGINX_RESOLVER=8.8.4.4
- dig +short myip.opendns.com @resolver1.opendns.com || exit 0
- dig +short @$TEST_NGINX_RESOLVER openresty.org || exit 0
Expand Down
6 changes: 6 additions & 0 deletions src/ngx_http_lua_socket_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -5099,6 +5099,12 @@ ngx_http_lua_req_socket(lua_State *L)
}
#endif

#if (NGX_HTTP_V3)
if (r->http_version == NGX_HTTP_VERSION_30) {
return luaL_error(L, "http v3 not supported yet");
}
#endif

if (!raw && r->headers_in.chunked) {
lua_pushnil(L);
lua_pushliteral(L, "chunked request bodies not supported yet");
Expand Down
12 changes: 10 additions & 2 deletions t/001-set.t
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,16 @@ API disabled in the context of set_by_lua*
GET /lua
--- response_body_like: 500 Internal Server Error
--- error_code: 500
--- error_log
API disabled in the context of set_by_lua*
--- error_log eval
my $err_log;

if (defined $ENV{TEST_NGINX_USE_HTTP3}) {
$err_log = "http v3 not supported yet";
} else {
$err_log = "API disabled in the context of set_by_lua*";
}

$err_log;



Expand Down
5 changes: 4 additions & 1 deletion t/005-exit.t
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ GET /lua
--- error_log
attempt to set status 404 via ngx.exit after sending out the response status 200
--- no_error_log
alert
[alert]
--- response_body
hi

Expand Down Expand Up @@ -123,6 +123,7 @@ GET /api?user=agentz


=== TEST 6: working with ngx_auth_request (simplest form, w/o ngx_memc)
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
--- http_config eval
"
lua_package_cpath '$::LuaCpath';
Expand Down Expand Up @@ -195,6 +196,7 @@ Logged in 56


=== TEST 7: working with ngx_auth_request (simplest form)
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
--- http_config eval
"
lua_package_cpath '$::LuaCpath';
Expand Down Expand Up @@ -267,6 +269,7 @@ Logged in 56


=== TEST 8: working with ngx_auth_request
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
--- http_config eval
"
lua_package_cpath '$::LuaCpath';
Expand Down
26 changes: 25 additions & 1 deletion t/014-bugs.t
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,14 @@ Hi"

=== TEST 8: github issue 37: header bug
https://github.com/chaoslawful/lua-nginx-module/issues/37

https://datatracker.ietf.org/doc/html/rfc7540#section-8.1.2
Just as in HTTP/1.x, header field names are strings of ASCII
characters that are compared in a case-insensitive fashion. However,
header field names MUST be converted to lowercase prior to their
encoding in HTTP/2. A request or response containing uppercase
header field names MUST be treated as malformed

--- config
location /sub {
content_by_lua '
Expand All @@ -220,8 +228,17 @@ https://github.com/chaoslawful/lua-nginx-module/issues/37
--- request
GET /lua
--- raw_response_headers_like eval
".*Set-Cookie: TestCookie1=foo\r
my $headers;

if (defined $ENV{TEST_NGINX_USE_HTTP3}) {
$headers = ".*set-cookie: TestCookie1=foo\r
set-cookie: TestCookie2=bar.*"
} else {
$headers = ".*Set-Cookie: TestCookie1=foo\r
Set-Cookie: TestCookie2=bar.*"
}

$headers;



Expand Down Expand Up @@ -714,6 +731,7 @@ Content-Type: application/json; charset=utf-8


=== TEST 32: hang on upstream_next (from kindy)
--- no_http2
--- no_check_leak
--- http_config
upstream xx {
Expand Down Expand Up @@ -770,6 +788,10 @@ eof found in body stream

=== TEST 34: testing a segfault when using ngx_poll_module + ngx_resolver
See more details here: http://mailman.nginx.org/pipermail/nginx-devel/2013-January/003275.html

http3 may cache the dns result.
so need to skip for http3
--- skip_eval: 2:$ENV{TEST_NGINX_USE_HTTP3}
--- config
location /t {
set $myserver nginx.org;
Expand All @@ -786,6 +808,8 @@ See more details here: http://mailman.nginx.org/pipermail/nginx-devel/2013-Janua
[alert]
--- error_log eval
qr/(?:send|recv)\(\) failed \(\d+: Connection refused\) while resolving/
--- curl_error eval
qr/curl: \(28\) Operation timed out after \d+ milliseconds with 0 bytes received/



Expand Down
2 changes: 2 additions & 0 deletions t/015-status.t
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@ GET /t
--- error_code: 101
--- no_error_log
[error]
--- skip_eval: 3:$ENV{TEST_NGINX_USE_HTTP3}
--- no_http2



Expand Down
82 changes: 63 additions & 19 deletions t/016-resp-header.t
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ GET /read
Content-Length: 3
--- response_body chop
Hel
--- skip_eval: 3:defined($ENV{TEST_NGINX_USE_HTTP3}) || defined($ENV{TEST_NGINX_USE_HTTP2})



Expand Down Expand Up @@ -113,8 +114,16 @@ Hello
}
--- request
GET /read
--- raw_response_headers_like chomp
X-Foo: a\r\n.*?X-Foo: bc\r\n
--- raw_response_headers_like eval
my $headers;

if (defined($ENV{TEST_NGINX_USE_HTTP3}) || defined($ENV{TEST_NGINX_USE_HTTP2})) {
$headers = qr/x-foo: a\r\n.*?x-foo: bc\r\n/
} else {
$headers = qr/X-Foo: a\r\n.*?X-Foo: bc\r\n/
}

$headers;
--- response_body
Hello

Expand Down Expand Up @@ -184,8 +193,16 @@ Hello
}
--- request
GET /read
--- raw_response_headers_like chomp
X-Foo: a\r\n.*?X-Foo: abc\r\n
--- raw_response_headers_like eval
my $headers;

if (defined($ENV{TEST_NGINX_USE_HTTP3}) || defined($ENV{TEST_NGINX_USE_HTTP2})) {
$headers = "x-foo: a\r\n.*?x-foo: abc\r\n"
} else {
$headers = "X-Foo: a\r\n.*?X-Foo: abc\r\n"
}

$headers;
--- response_body
Hello

Expand All @@ -203,8 +220,17 @@ Hello
--- request
GET /lua
--- raw_response_headers_like eval
".*Foo: a\r
Foo: b.*"
my $headers;

if (defined($ENV{TEST_NGINX_USE_HTTP3}) || defined($ENV{TEST_NGINX_USE_HTTP2})) {
$headers = ".*foo: a\r
foo: b.*";
} else {
$headers = ".*Foo: a\r
Foo: b.*";
}

$headers;
--- response_body


Expand All @@ -222,8 +248,17 @@ Foo: b.*"
--- request
GET /lua
--- raw_response_headers_like eval
".*Foo: a\r
Foo: b.*"
my $headers;

if (defined($ENV{TEST_NGINX_USE_HTTP3}) || defined($ENV{TEST_NGINX_USE_HTTP2})) {
$headers = ".*foo: a\r
foo: b.*";
} else {
$headers = ".*Foo: a\r
Foo: b.*";
}

$headers;
--- response_body


Expand Down Expand Up @@ -278,7 +313,7 @@ hello
--- error_log
attempt to set ngx.header.HEADER after sending out response headers
--- no_error_log eval
["alert", "warn"]
["[alert]", "[warn]"]



Expand Down Expand Up @@ -1071,8 +1106,8 @@ GET /t
--- more_headers
Foo: bar
Bah: baz
--- response_headers
Location: http://localhost:$ServerPort/t/
--- response_headers_like
Location: https?://localhost:\d+/t/
--- response_body_like: 301 Moved Permanently
--- error_code: 301
--- no_error_log
Expand All @@ -1094,8 +1129,8 @@ GET /t
Foo: bar
Bah: baz
--- response_body_like: 301 Moved Permanently
--- response_headers
Location: http://localhost:$ServerPort/t/
--- response_headers_like
Location: https?://localhost:\d+/t/
--- error_code: 301
--- no_error_log
[error]
Expand All @@ -1115,8 +1150,8 @@ GET /t
--- more_headers
Foo: bar
Bah: baz
--- response_headers
Location: http://localhost:$ServerPort/t/
--- response_headers_like
Location: https?://localhost:\d+/t/
Foo: /t/
--- response_body_like: 301 Moved Permanently
--- error_code: 301
Expand All @@ -1139,8 +1174,8 @@ GET /t
--- more_headers
Foo: bar
Bah: baz
--- response_headers
Location: http://localhost:$ServerPort/t/
--- response_headers_like
Location: https?://localhost:\d+/t/
Foo: /t/
--- response_body_like: 301 Moved Permanently
--- error_code: 301
Expand All @@ -1159,8 +1194,16 @@ Foo: /t/
}
--- request
GET /lua
--- raw_response_headers_like chop
cache-Control: private
--- raw_response_headers_like eval
my $headers;

if (defined($ENV{TEST_NGINX_USE_HTTP3}) || defined($ENV{TEST_NGINX_USE_HTTP2})) {
$headers = "cache-control: private"
} else {
$headers = "cache-Control: private"
}

$headers;
--- response_body
Cache-Control: private

Expand Down Expand Up @@ -1509,6 +1552,7 @@ hi
--- error_log
my Transfer-Encoding: chunked
my transfer-encoding: chunked
--- skip_eval: 6:defined($ENV{TEST_NGINX_USE_HTTP3}) || defined($ENV{TEST_NGINX_USE_HTTP2})



Expand Down
Loading
Loading