Skip to content

Commit

Permalink
tests(pdk) introduce TEST_NGINX_NXSOCK env var for PDK suite
Browse files Browse the repository at this point in the history
* refactor(tests) introduce extra setting for PDK testing

The pdk tests use local files for sockets and those cannot be
located on a mounted/shared filesystem. Hence an extra environment
variable for setting the location. This will allow to run the PDK
tests from Vagrant and Docker for example.

Variable is named TEST_NGINX_NXSOCK and should point to a
directory.

From Kong#3769
  • Loading branch information
Tieske authored and thibaultcha committed Sep 14, 2018
1 parent 8bb8af7 commit 303f33b
Show file tree
Hide file tree
Showing 45 changed files with 361 additions and 377 deletions.
6 changes: 3 additions & 3 deletions t/01-pdk/04-request/00-phase_checks.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use warnings FATAL => 'all';
use Test::Nginx::Socket::Lua;
use t::Util;

$ENV{TEST_NGINX_HTML_DIR} ||= html_dir();
$ENV{TEST_NGINX_NXSOCK} ||= html_dir();

plan tests => repeat_each() * (blocks() * 2);

Expand All @@ -17,7 +17,7 @@ qq{
$t::Util::HttpConfig
server {
listen unix:$ENV{TEST_NGINX_HTML_DIR}/nginx.sock;
listen unix:$ENV{TEST_NGINX_NXSOCK}/nginx.sock;
location / {
return 200;
Expand Down Expand Up @@ -232,7 +232,7 @@ qq{
}
--- config
location /t {
proxy_pass http://unix:$TEST_NGINX_HTML_DIR/nginx.sock;
proxy_pass http://unix:$TEST_NGINX_NXSOCK/nginx.sock;
set $upstream_uri '/t';
set $upstream_scheme 'http';
Expand Down
6 changes: 3 additions & 3 deletions t/01-pdk/04-request/01-get_scheme.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use Test::Nginx::Socket::Lua;
use File::Spec;
use t::Util;

$ENV{TEST_NGINX_HTML_DIR} ||= html_dir();
$ENV{TEST_NGINX_CERT_DIR} ||= File::Spec->catdir(server_root(), '..', 'certs');
$ENV{TEST_NGINX_NXSOCK} ||= html_dir();

plan tests => repeat_each() * (blocks() * 3);

Expand Down Expand Up @@ -39,7 +39,7 @@ qq{
$t::Util::HttpConfig
server {
listen unix:$ENV{TEST_NGINX_HTML_DIR}/nginx.sock ssl;
listen unix:$ENV{TEST_NGINX_NXSOCK}/nginx.sock ssl;
ssl_certificate $ENV{TEST_NGINX_CERT_DIR}/test.crt;
ssl_certificate_key $ENV{TEST_NGINX_CERT_DIR}/test.key;
Expand All @@ -59,7 +59,7 @@ qq{
--- config
location = /t {
proxy_ssl_verify off;
proxy_pass https://unix:$TEST_NGINX_HTML_DIR/nginx.sock;
proxy_pass https://unix:$TEST_NGINX_NXSOCK/nginx.sock;
}
--- request
GET /t
Expand Down
14 changes: 7 additions & 7 deletions t/01-pdk/04-request/02-get_host.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use Test::Nginx::Socket::Lua;
use File::Spec;
use t::Util;

$ENV{TEST_NGINX_HTML_DIR} ||= html_dir();
$ENV{TEST_NGINX_CERT_DIR} ||= File::Spec->catdir(server_root(), '..', 'certs');
$ENV{TEST_NGINX_NXSOCK} ||= html_dir();

plan tests => repeat_each() * (blocks() * 3);

Expand Down Expand Up @@ -39,7 +39,7 @@ qq{
$t::Util::HttpConfig
server {
listen unix:$ENV{TEST_NGINX_HTML_DIR}/nginx.sock ssl;
listen unix:$ENV{TEST_NGINX_NXSOCK}/nginx.sock ssl;
ssl_certificate $ENV{TEST_NGINX_CERT_DIR}/test.crt;
ssl_certificate_key $ENV{TEST_NGINX_CERT_DIR}/test.key;
Expand All @@ -59,7 +59,7 @@ qq{
--- config
location = /t {
proxy_ssl_verify off;
proxy_pass https://unix:$TEST_NGINX_HTML_DIR/nginx.sock;
proxy_pass https://unix:$TEST_NGINX_NXSOCK/nginx.sock;
}
--- request
GET /t
Expand All @@ -77,7 +77,7 @@ qq{
server {
server_name kong;
listen unix:$ENV{TEST_NGINX_HTML_DIR}/nginx.sock;
listen unix:$ENV{TEST_NGINX_NXSOCK}/nginx.sock;
location / {
content_by_lua_block {
Expand All @@ -95,7 +95,7 @@ qq{
--- config
location /t {
proxy_set_header Host "";
proxy_pass http://unix:$TEST_NGINX_HTML_DIR/nginx.sock;
proxy_pass http://unix:$TEST_NGINX_NXSOCK/nginx.sock;
}
--- request
GET /t
Expand Down Expand Up @@ -221,7 +221,7 @@ qq{
server {
server_name K0nG;
listen unix:$ENV{TEST_NGINX_HTML_DIR}/nginx.sock;
listen unix:$ENV{TEST_NGINX_NXSOCK}/nginx.sock;
location / {
content_by_lua_block {
Expand All @@ -239,7 +239,7 @@ qq{
--- config
location /t {
proxy_set_header Host "";
proxy_pass http://unix:$TEST_NGINX_HTML_DIR/nginx.sock;
proxy_pass http://unix:$TEST_NGINX_NXSOCK/nginx.sock;
}
--- request
GET /t
Expand Down
6 changes: 3 additions & 3 deletions t/01-pdk/04-request/04-get_forwarded_scheme.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use Test::Nginx::Socket::Lua;
use File::Spec;
use t::Util;

$ENV{TEST_NGINX_HTML_DIR} ||= html_dir();
$ENV{TEST_NGINX_CERT_DIR} ||= File::Spec->catdir(server_root(), '..', 'certs');
$ENV{TEST_NGINX_NXSOCK} ||= html_dir();

plan tests => repeat_each() * (blocks() * 3);

Expand Down Expand Up @@ -133,7 +133,7 @@ qq{
$t::Util::HttpConfig
server {
listen unix:$ENV{TEST_NGINX_HTML_DIR}/nginx.sock ssl;
listen unix:$ENV{TEST_NGINX_NXSOCK}/nginx.sock ssl;
ssl_certificate $ENV{TEST_NGINX_CERT_DIR}/test.crt;
ssl_certificate_key $ENV{TEST_NGINX_CERT_DIR}/test.key;
Expand All @@ -155,7 +155,7 @@ qq{
--- config
location = /t {
proxy_ssl_verify off;
proxy_pass https://unix:$TEST_NGINX_HTML_DIR/nginx.sock;
proxy_pass https://unix:$TEST_NGINX_NXSOCK/nginx.sock;
}
--- request
GET /t
Expand Down
18 changes: 9 additions & 9 deletions t/01-pdk/04-request/05-get_forwarded_host.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use Test::Nginx::Socket::Lua;
use File::Spec;
use t::Util;

$ENV{TEST_NGINX_HTML_DIR} ||= html_dir();
$ENV{TEST_NGINX_CERT_DIR} ||= File::Spec->catdir(server_root(), '..', 'certs');
$ENV{TEST_NGINX_NXSOCK} ||= html_dir();

plan tests => repeat_each() * (blocks() * 3);

Expand Down Expand Up @@ -41,7 +41,7 @@ qq{
$t::Util::HttpConfig
server {
listen unix:$ENV{TEST_NGINX_HTML_DIR}/nginx.sock ssl;
listen unix:$ENV{TEST_NGINX_NXSOCK}/nginx.sock ssl;
ssl_certificate $ENV{TEST_NGINX_CERT_DIR}/test.crt;
ssl_certificate_key $ENV{TEST_NGINX_CERT_DIR}/test.key;
Expand All @@ -61,7 +61,7 @@ qq{
--- config
location = /t {
proxy_ssl_verify off;
proxy_pass https://unix:$TEST_NGINX_HTML_DIR/nginx.sock;
proxy_pass https://unix:$TEST_NGINX_NXSOCK/nginx.sock;
}
--- request
GET /t
Expand All @@ -81,7 +81,7 @@ qq{
server {
server_name kong;
listen unix:$ENV{TEST_NGINX_HTML_DIR}/nginx.sock;
listen unix:$ENV{TEST_NGINX_NXSOCK}/nginx.sock;
location / {
content_by_lua_block {
Expand All @@ -99,7 +99,7 @@ qq{
--- config
location /t {
proxy_set_header Host "";
proxy_pass http://unix:$TEST_NGINX_HTML_DIR/nginx.sock;
proxy_pass http://unix:$TEST_NGINX_NXSOCK/nginx.sock;
}
--- request
GET /t
Expand Down Expand Up @@ -233,7 +233,7 @@ qq{
server {
server_name k0ng;
listen unix:$ENV{TEST_NGINX_HTML_DIR}/nginx.sock;
listen unix:$ENV{TEST_NGINX_NXSOCK}/nginx.sock;
location / {
content_by_lua_block {
Expand All @@ -251,7 +251,7 @@ qq{
--- config
location /t {
proxy_set_header Host "";
proxy_pass http://unix:$TEST_NGINX_HTML_DIR/nginx.sock;
proxy_pass http://unix:$TEST_NGINX_NXSOCK/nginx.sock;
}
--- request
GET /t
Expand Down Expand Up @@ -294,7 +294,7 @@ qq{
$t::Util::HttpConfig
server {
listen unix:$ENV{TEST_NGINX_HTML_DIR}/nginx.sock ssl;
listen unix:$ENV{TEST_NGINX_NXSOCK}/nginx.sock ssl;
ssl_certificate $ENV{TEST_NGINX_CERT_DIR}/test.crt;
ssl_certificate_key $ENV{TEST_NGINX_CERT_DIR}/test.key;
Expand All @@ -316,7 +316,7 @@ qq{
--- config
location = /t {
proxy_ssl_verify off;
proxy_pass https://unix:$TEST_NGINX_HTML_DIR/nginx.sock;
proxy_pass https://unix:$TEST_NGINX_NXSOCK/nginx.sock;
}
--- request
GET /t
Expand Down
6 changes: 3 additions & 3 deletions t/01-pdk/04-request/06-get_forwarded_port.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use warnings FATAL => 'all';
use Test::Nginx::Socket::Lua;
use t::Util;

$ENV{TEST_NGINX_HTML_DIR} ||= html_dir();
$ENV{TEST_NGINX_CERT_DIR} ||= File::Spec->catdir(server_root(), '..', 'certs');
$ENV{TEST_NGINX_NXSOCK} ||= html_dir();

plan tests => repeat_each() * (blocks() * 3);

Expand Down Expand Up @@ -134,7 +134,7 @@ qq{
$t::Util::HttpConfig
server {
listen unix:$ENV{TEST_NGINX_HTML_DIR}/nginx.sock ssl;
listen unix:$ENV{TEST_NGINX_NXSOCK}/nginx.sock ssl;
ssl_certificate $ENV{TEST_NGINX_CERT_DIR}/test.crt;
ssl_certificate_key $ENV{TEST_NGINX_CERT_DIR}/test.key;
Expand All @@ -154,7 +154,7 @@ qq{
--- config
location = /t {
proxy_ssl_verify off;
proxy_pass https://unix:$TEST_NGINX_HTML_DIR/nginx.sock;
proxy_pass https://unix:$TEST_NGINX_NXSOCK/nginx.sock;
}
--- request
GET /t
Expand Down
6 changes: 3 additions & 3 deletions t/01-pdk/05-client/00-phase_checks.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use warnings FATAL => 'all';
use Test::Nginx::Socket::Lua;
use t::Util;

$ENV{TEST_NGINX_HTML_DIR} ||= html_dir();
$ENV{TEST_NGINX_NXSOCK} ||= html_dir();

plan tests => repeat_each() * (blocks() * 2);

Expand All @@ -17,7 +17,7 @@ qq{
$t::Util::HttpConfig
server {
listen unix:$ENV{TEST_NGINX_HTML_DIR}/nginx.sock;
listen unix:$ENV{TEST_NGINX_NXSOCK}/nginx.sock;
location / {
return 200;
Expand Down Expand Up @@ -82,7 +82,7 @@ qq{
}
--- config
location /t {
proxy_pass http://unix:$TEST_NGINX_HTML_DIR/nginx.sock;
proxy_pass http://unix:$TEST_NGINX_NXSOCK/nginx.sock;
set $upstream_uri '/t';
set $upstream_scheme 'http';
Expand Down
6 changes: 3 additions & 3 deletions t/01-pdk/05-client/01-get_ip.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use warnings FATAL => 'all';
use Test::Nginx::Socket::Lua;
use t::Util;

$ENV{TEST_NGINX_HTML_DIR} ||= html_dir();
$ENV{TEST_NGINX_NXSOCK} ||= html_dir();

plan tests => repeat_each() * (blocks() * 3);

Expand Down Expand Up @@ -46,7 +46,7 @@ qq{
server {
server_name kong;
listen unix:$ENV{TEST_NGINX_HTML_DIR}/nginx.sock proxy_protocol;
listen unix:$ENV{TEST_NGINX_NXSOCK}/nginx.sock proxy_protocol;
location / {
real_ip_header proxy_protocol;
Expand All @@ -69,7 +69,7 @@ qq{
location = /t {
content_by_lua_block {
local sock = ngx.socket.tcp()
sock:connect("unix:$TEST_NGINX_HTML_DIR/nginx.sock")
sock:connect("unix:$TEST_NGINX_NXSOCK/nginx.sock")
local request = "PROXY TCP4 10.0.0.1 " ..
ngx.var.server_addr .. " " ..
Expand Down
10 changes: 5 additions & 5 deletions t/01-pdk/05-client/02-get_forwarded_ip.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use warnings FATAL => 'all';
use Test::Nginx::Socket::Lua;
use t::Util;

$ENV{TEST_NGINX_HTML_DIR} ||= html_dir();
$ENV{TEST_NGINX_NXSOCK} ||= html_dir();

plan tests => repeat_each() * (blocks() * 3);

Expand Down Expand Up @@ -102,7 +102,7 @@ qq{
server {
server_name kong;
listen unix:$ENV{TEST_NGINX_HTML_DIR}/nginx.sock proxy_protocol;
listen unix:$ENV{TEST_NGINX_NXSOCK}/nginx.sock proxy_protocol;
location / {
real_ip_header proxy_protocol;
Expand All @@ -124,7 +124,7 @@ qq{
location = /t {
content_by_lua_block {
local sock = ngx.socket.tcp()
sock:connect("unix:$TEST_NGINX_HTML_DIR/nginx.sock")
sock:connect("unix:$TEST_NGINX_NXSOCK/nginx.sock")
local request = "PROXY TCP4 10.0.0.1 " ..
ngx.var.server_addr .. " " ..
Expand Down Expand Up @@ -224,7 +224,7 @@ qq{
server {
server_name kong;
listen unix:$ENV{TEST_NGINX_HTML_DIR}/nginx.sock proxy_protocol;
listen unix:$ENV{TEST_NGINX_NXSOCK}/nginx.sock proxy_protocol;
location / {
real_ip_header proxy_protocol;
Expand All @@ -242,7 +242,7 @@ qq{
location = /t {
content_by_lua_block {
local sock = ngx.socket.tcp()
sock:connect("unix:$TEST_NGINX_HTML_DIR/nginx.sock")
sock:connect("unix:$TEST_NGINX_NXSOCK/nginx.sock")
local request = "PROXY TCP4 10.0.0.1 " ..
ngx.var.server_addr .. " " ..
Expand Down
6 changes: 3 additions & 3 deletions t/01-pdk/05-client/03-get_port.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use warnings FATAL => 'all';
use Test::Nginx::Socket::Lua;
use t::Util;

$ENV{TEST_NGINX_HTML_DIR} ||= html_dir();
$ENV{TEST_NGINX_NXSOCK} ||= html_dir();

plan tests => repeat_each() * (blocks() * 3);

Expand Down Expand Up @@ -58,7 +58,7 @@ qq{
server {
server_name kong;
listen unix:$ENV{TEST_NGINX_HTML_DIR}/nginx.sock proxy_protocol;
listen unix:$ENV{TEST_NGINX_NXSOCK}/nginx.sock proxy_protocol;
location / {
real_ip_header proxy_protocol;
Expand All @@ -80,7 +80,7 @@ qq{
location = /t {
content_by_lua_block {
local sock = ngx.socket.tcp()
sock:connect("unix:$TEST_NGINX_HTML_DIR/nginx.sock")
sock:connect("unix:$TEST_NGINX_NXSOCK/nginx.sock")
local request = "PROXY TCP4 10.0.0.1 " ..
ngx.var.server_addr .. " " ..
Expand Down
Loading

0 comments on commit 303f33b

Please sign in to comment.