www-nginx: enable tests for OpenResty modules

This commits enables tests for (almost) all OpenResty www-nginx
packages.

Signed-off-by: Zurab Kvachadze <zurabid2016@gmail.com>
Part-of: https://github.com/gentoo/gentoo/pull/37590
Signed-off-by: Sam James <sam@gentoo.org>
This commit is contained in:
Zurab Kvachadze 2025-02-18 17:29:42 +01:00 committed by Sam James
parent 9971de6b8b
commit 5030183d01
No known key found for this signature in database
GPG Key ID: 738409F520DF9190
15 changed files with 410 additions and 15 deletions

View File

@ -5,6 +5,12 @@ EAPI=8
MY_PN="echo-nginx-module"
NGINX_MOD_S="${WORKDIR}/${MY_PN}-${PV}"
NGINX_MOD_OPENRESTY_TESTS=1
NGINX_MOD_TEST_LOAD_ORDER=(
www-nginx/ngx-lua-module
www-nginx/ngx-xss
)
inherit nginx-module
DESCRIPTION='An NGINX module bringing the power of "echo", "sleep", "time" and more to NGINX'
@ -16,4 +22,5 @@ SRC_URI="
LICENSE="BSD-2"
SLOT="0"
RESTRICT="test"
# Tests require NGINX to be built with debugging log enabled.
BDEPEND="test? ( www-servers/nginx[debug(-)] )"

View File

@ -8,6 +8,12 @@ NGINX_MOD_S="${WORKDIR}/${MY_PN}-${PV}"
NGINX_MOD_LINK_MODULES=( www-nginx/ngx_devel_kit )
NGINX_MOD_OPENRESTY_TESTS=1
NGINX_MOD_TEST_LOAD_ORDER=(
www-nginx/ngx-set-misc
www-nginx/ngx-echo
www-nginx/ngx-lua-module
)
inherit toolchain-funcs nginx-module
DESCRIPTION="An NGINX module that encrypts and decrypts NGINX variable values"
@ -19,8 +25,6 @@ SRC_URI="
LICENSE="BSD-2"
SLOT="0"
RESTRICT="test"
BDEPEND="virtual/pkgconfig"
DEPEND="dev-libs/openssl:="
RDEPEND="${DEPEND}"

View File

@ -7,6 +7,11 @@ MY_COMMIT="13425e897c19f4f4436c5ca4414dddd37fc65190"
MY_P="nginx-eval-module-${MY_COMMIT}"
NGINX_MOD_S="${WORKDIR}/${MY_P}"
NGINX_MOD_OPENRESTY_TESTS=1
NGINX_MOD_TEST_LOAD_ORDER=(
www-nginx/ngx-memc
www-nginx/ngx-echo
)
inherit nginx-module
DESCRIPTION="An NGINX module that stores subrequest response bodies into variables"
@ -18,4 +23,21 @@ SRC_URI="
LICENSE="BSD-2"
SLOT="0"
RESTRICT="test"
BDEPEND="test? ( net-misc/memcached )"
src_test() {
# Start memcached in background on a port 11211, the default port if
# environment variable TEST_NGINX_MEMCACHED_PORT is not set.
# memcached is enclosed in braces so that the not operator properly applies
# to the asynchronous invocation of memcached.
if ! { memcached -p 11211 & }
then
die "memcached failed"
fi
# Save the PID of the launched memcached instance.
local memcached_pid=$!
nginx-module_src_test
kill "${memcached_pid}" || die "kill failed"
}

View File

@ -5,6 +5,15 @@ EAPI=8
MY_PN="headers-more-nginx-module"
NGINX_MOD_S="${WORKDIR}/${MY_PN}-${PV}"
NGINX_MOD_OPENRESTY_TESTS=1
# ngx-headers-more must be loaded after ngx-lua-module module for test to work.
NGINX_MOD_TEST_LOAD_ORDER=(
www-nginx/ngx-lua-module
www-nginx/ngx-headers-more
www-nginx/ngx-eval
www-nginx/ngx-echo
)
inherit nginx-module
DESCRIPTION="Set, add, and clear arbitrary output headers in NGINX HTTP servers"
@ -16,4 +25,5 @@ SRC_URI="
LICENSE="BSD-2"
SLOT="0"
RESTRICT="test"
# Tests require NGINX to be built with debugging log enabled.
BDEPEND="test? ( www-servers/nginx[debug(-)] )"

View File

@ -0,0 +1,30 @@
From f9adf29df987a0c2d067e43fc4a6b43aabb42f26 Mon Sep 17 00:00:00 2001
From: Zurab Kvachadze <zurabid2016@gmail.com>
Date: Thu, 13 Feb 2025 19:52:15 +0100
Subject: [PATCH] bugs.t: skip test relying on rds_json
libdrizzle, a dependency of rds-json-nginx-module, is not packaged by
Gentoo.
This commit skips the test relying on rds-json-nginx-module.
Signed-off-by: Zurab Kvachadze <zurabid2016@gmail.com>
---
t/bugs.t | 1 +
1 file changed, 1 insertion(+)
diff --git a/t/bugs.t b/t/bugs.t
index 8d05e43..82f846e 100644
--- a/t/bugs.t
+++ b/t/bugs.t
@@ -16,6 +16,7 @@ run_tests();
__DATA__
=== TEST 1: used with rds_json
+--- SKIP
--- config
location /foo {
rds_json_ret 100 '你好';
--
2.45.3

View File

@ -8,6 +8,15 @@ NGINX_MOD_S="${WORKDIR}/${MY_PN}-${PV}"
NGINX_MOD_LINK_MODULES=( www-nginx/ngx_devel_kit )
NGINX_MOD_OPENRESTY_TESTS=1
# ngx-iconv must be loaded after ngx-lua-module.
NGINX_MOD_TEST_LOAD_ORDER=(
www-nginx/ngx-lua-module
www-nginx/ngx-iconv
www-nginx/ngx-echo
www-nginx/ngx-set-misc
www-nginx/ngx-headers-more
)
inherit nginx-module
DESCRIPTION="A character conversion NGINX module using libiconv"
@ -19,7 +28,9 @@ SRC_URI="
LICENSE="BSD-2"
SLOT="0"
RESTRICT="test"
DEPEND="virtual/libiconv"
RDEPEND="${DEPEND}"
PATCHES=(
"${FILESDIR}/${PN}-0.14-skip-rds-json-tests.patch"
)

View File

@ -0,0 +1,26 @@
From 9d8b6160d92a2899e28d4a610a884d160e4a1f38 Mon Sep 17 00:00:00 2001
From: Zurab Kvachadze <zurabid2016@gmail.com>
Date: Sat, 15 Feb 2025 17:58:35 +0100
Subject: [PATCH] Skip invalid tests
Signed-off-by: Zurab Kvachadze <zurabid2016@gmail.com>
---
t/sanity.t | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/t/sanity.t b/t/sanity.t
index b913f21..f2b22b2 100644
--- a/t/sanity.t
+++ b/t/sanity.t
@@ -1,6 +1,7 @@
# vim:set ft= ts=4 sw=4 et fdm=marker:
-use Test::Nginx::Socket::Lua;
+use Test::Nginx::Socket::Lua skip_all =>
+ 'uses arbitrary hostname with no corresponding server directive';
#worker_connections(1014);
#master_on();
--
2.45.3

View File

@ -11,6 +11,11 @@ NGINX_MOD_S="${WORKDIR}/${MY_PN}-${PV}"
NGINX_MOD_LINK_MODULES=( www-nginx/ngx-lua-module )
NGINX_MOD_OPENRESTY_TESTS=1
NGINX_MOD_TEST_LOAD_ORDER=(
www-nginx/ngx-lua-module
www-nginx/ngx-echo
)
inherit flag-o-matic lua-single nginx-module
DESCRIPTION="An NGINX C module exposing ngx-lua-module's Lua APIs for NGINX upstreams"
@ -24,12 +29,14 @@ SLOT="0"
REQUIRED_USE="${LUA_REQUIRED_USE}"
RESTRICT="test"
BDEPEND="virtual/pkgconfig"
DEPEND="${LUA_DEPS}"
RDEPEND="${DEPEND}"
PATCHES=(
"${FILESDIR}/${PN}-0.07-skip-invalid-tests.patch"
)
src_configure() {
ngx_mod_append_libs "$(lua_get_LIBS)"
append-cflags "$(lua_get_CFLAGS)"

View File

@ -0,0 +1,31 @@
From 8ff96cb366e1ed0a78533501b33ca29c378ca808 Mon Sep 17 00:00:00 2001
From: Zurab Kvachadze <zurabid2016@gmail.com>
Date: Tue, 11 Feb 2025 15:35:40 +0100
Subject: [PATCH] t/stats.t: skip broken test
The CI utilises iptables to drop connections on hardcoded port 12345.
The drop behaviour is required by the "timeout" test. Since tests are
run unprivileged in Gentoo, iptables can not be used and the test fails.
This commit skips the "timeout" test.
Signed-off-by: Zurab Kvachadze <zurabid2016@gmail.com>
---
t/stats.t | 1 +
1 file changed, 1 insertion(+)
diff --git a/t/stats.t b/t/stats.t
index f412b42..39bc3dd 100644
--- a/t/stats.t
+++ b/t/stats.t
@@ -30,6 +30,7 @@ __DATA__
=== TEST 2: timeout
+--- SKIP
--- config
memc_connect_timeout 10ms;
memc_send_timeout 10ms;
--
2.45.3

View File

@ -6,6 +6,13 @@ EAPI=8
MY_PN="memc-nginx-module"
NGINX_MOD_S="${WORKDIR}/${MY_PN}-${PV}"
NGINX_MOD_OPENRESTY_TESTS=1
NGINX_MOD_TEST_LOAD_ORDER=(
www-nginx/ngx-lua-module
www-nginx/ngx-eval
www-nginx/ngx-echo
www-nginx/ngx-set-misc
)
inherit nginx-module
DESCRIPTION="An extended version of the standard NGINX memcached module"
@ -17,4 +24,25 @@ SRC_URI="
LICENSE="BSD-2"
SLOT="0"
RESTRICT="test"
BDEPEND="test? ( net-misc/memcached )"
PATCHES=(
"${FILESDIR}/${PN}-0.20-stats_t-do-not-run-timeout-test.patch"
)
src_test() {
# Start memcached in background on a port 11211, the default port if
# environment variable TEST_NGINX_MEMCACHED_PORT is not set.
# memcached is enclosed in braces so that the not operator properly applies
# to the asynchronous invocation of memcached.
if ! { memcached -p 11211 & }
then
die "memcached failed"
fi
# Save the PID of the launched memcached instance.
local memcached_pid=$!
nginx-module_src_test
kill "${memcached_pid}" || die "killing memcached failed"
}

View File

@ -0,0 +1,31 @@
From 25337a9db440d2afb406a78b113e9a8ea0f3fcde Mon Sep 17 00:00:00 2001
From: Zurab Kvachadze <zurabid2016@gmail.com>
Date: Thu, 13 Feb 2025 19:43:54 +0100
Subject: [PATCH] hashed-upstream.t: skip the test
The "hashed-upstream.t" test utilises the upstream_list command. I do
not know which module provides this command and so far I have been
unsuccessful to find anything online.
Signed-off-by: Zurab Kvachadze <zurabid2016@gmail.com>
---
t/hashed-upstream.t | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/t/hashed-upstream.t b/t/hashed-upstream.t
index fdebd15..6e3a912 100644
--- a/t/hashed-upstream.t
+++ b/t/hashed-upstream.t
@@ -1,7 +1,8 @@
# vi:filetype=
use lib 'lib';
-use Test::Nginx::Socket;
+use Test::Nginx::Socket skip_all =>
+ 'not working at all';
#repeat_each(3);
--
2.45.3

View File

@ -8,6 +8,11 @@ NGINX_MOD_S="${WORKDIR}/${MY_PN}-${PV}"
NGINX_MOD_LINK_MODULES=( www-nginx/ngx_devel_kit )
NGINX_MOD_OPENRESTY_TESTS=1
NGINX_MOD_TEST_LOAD_ORDER=(
www-nginx/ngx-echo
www-nginx/ngx-iconv
)
inherit toolchain-funcs nginx-module
DESCRIPTION="An NGINX module that adds various set_xxx directives to NGINX's rewrite module"
@ -21,14 +26,13 @@ SLOT="0"
IUSE="+hmac"
RESTRICT="test"
BDEPEND="virtual/pkgconfig"
DEPEND="hmac? ( dev-libs/openssl:= )"
RDEPEND="${DEPEND}"
PATCHES=(
"${FILESDIR}/${PN}-0.33-hmac-configurable.patch"
"${FILESDIR}/${PN}-0.33-skip-hashed-upstream_t-test.patch"
)
src_configure() {

View File

@ -0,0 +1,147 @@
From e69195edbb7c38135743c4a0c19a6d78d0e7467a Mon Sep 17 00:00:00 2001
From: Zurab Kvachadze <zurabid2016@gmail.com>
Date: Thu, 13 Feb 2025 21:41:35 +0100
Subject: [PATCH] t: Disable invalid tests
Signed-off-by: Zurab Kvachadze <zurabid2016@gmail.com>
---
t/000_init.t | 3 ++-
t/conditional-get.t | 3 ++-
t/drizzle-main.t | 3 ++-
t/eval.t | 3 ++-
t/methods.t | 3 ++-
t/postgres-main.t | 3 ++-
t/proxy.t | 3 ++-
t/redis.t | 3 ++-
t/timeout.t | 3 ++-
9 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/t/000_init.t b/t/000_init.t
index b611e6c..06663e6 100644
--- a/t/000_init.t
+++ b/t/000_init.t
@@ -1,7 +1,8 @@
# vi:filetype=
use lib 'lib';
-use Test::Nginx::Socket;
+use Test::Nginx::Socket skip_all =>
+ 'Gentoo does not package neither ngx_postgres nor drizzle';
repeat_each(1);
diff --git a/t/conditional-get.t b/t/conditional-get.t
index b652ee6..82daf84 100644
--- a/t/conditional-get.t
+++ b/t/conditional-get.t
@@ -1,7 +1,8 @@
# vi:filetype=
use lib 'lib';
-use Test::Nginx::Socket;
+use Test::Nginx::Socket skip_all =>
+ 'uses arbitrary hostname as proxy_pass';
#repeat_each(100);
diff --git a/t/drizzle-main.t b/t/drizzle-main.t
index 5ff11eb..150ce52 100644
--- a/t/drizzle-main.t
+++ b/t/drizzle-main.t
@@ -1,7 +1,8 @@
# vi:filetype=
use lib 'lib';
-use Test::Nginx::Socket;
+use Test::Nginx::Socket skip_all =>
+ 'drizzle is not packaged by Gentoo';
#repeat_each(100);
diff --git a/t/eval.t b/t/eval.t
index c109463..bda4dc9 100644
--- a/t/eval.t
+++ b/t/eval.t
@@ -1,7 +1,8 @@
# vi:filetype=
use lib 'lib';
-use Test::Nginx::Socket;
+use Test::Nginx::Socket skip_all =>
+ 'Gentoo does not package drizzle';
repeat_each(3);
diff --git a/t/methods.t b/t/methods.t
index 9a57b38..f48e37d 100644
--- a/t/methods.t
+++ b/t/methods.t
@@ -1,7 +1,8 @@
# vi:filetype=
use lib 'lib';
-use Test::Nginx::Socket;
+use Test::Nginx::Socket skip_all =>
+ 'uses arbitrary hostname as proxy_pass';
#repeat_each(2);
diff --git a/t/postgres-main.t b/t/postgres-main.t
index ccc00c4..b1e53ea 100644
--- a/t/postgres-main.t
+++ b/t/postgres-main.t
@@ -1,7 +1,8 @@
# vi:filetype=
use lib 'lib';
-use Test::Nginx::Socket;
+use Test::Nginx::Socket skip_all =>
+ 'ngx_postgres is not packaged by Gentoo';
#repeat_each(100);
diff --git a/t/proxy.t b/t/proxy.t
index f3e6a31..9eb8678 100644
--- a/t/proxy.t
+++ b/t/proxy.t
@@ -1,7 +1,8 @@
# vi:filetype=
use lib 'lib';
-use Test::Nginx::Socket;
+use Test::Nginx::Socket skip_all =>
+ 'Gentoo does not package drizzle';
#repeat_each(100);
diff --git a/t/redis.t b/t/redis.t
index 8af2ff0..ff10a5c 100644
--- a/t/redis.t
+++ b/t/redis.t
@@ -1,7 +1,8 @@
# vi:ft=
use lib 'lib';
-use Test::Nginx::Socket;
+use Test::Nginx::Socket skip_all =>
+ 'relies on horribly outdated Redis 2.x';
#repeat_each(2);
diff --git a/t/timeout.t b/t/timeout.t
index 9357658..b9a8827 100644
--- a/t/timeout.t
+++ b/t/timeout.t
@@ -1,7 +1,8 @@
# vi:filetype=
use lib 'lib';
-use Test::Nginx::Socket;
+use Test::Nginx::Socket skip_all =>
+ 'uses arbitrary hostname as proxy_pass';
repeat_each(2);
--
2.45.3

View File

@ -6,6 +6,17 @@ EAPI=8
MY_PN="srcache-nginx-module"
NGINX_MOD_S="${WORKDIR}/${MY_PN}-${PV}"
NGINX_MOD_OPENRESTY_TESTS=1
# ngx-srcache must be after ngx-xss, but before ngx-lua-module. The former might
# be due to the fact that both ngx-xss and ngx-srcache are filters. As for the
# latter, I just don't know.
NGINX_MOD_TEST_LOAD_ORDER=(
www-nginx/ngx-xss
www-nginx/ngx-srcache
www-nginx/ngx-lua-module
www-nginx/ngx-echo
www-nginx/ngx-memc
)
inherit nginx-module
DESCRIPTION="An NGINX module enabling transparent subrequest-based caching"
@ -17,4 +28,26 @@ SRC_URI="
LICENSE="BSD-2"
SLOT="0"
RESTRICT="test"
# Tests require NGINX to be built with debugging log enabled.
BDEPEND="test? ( www-servers/nginx[debug(-)] )"
PATCHES=(
"${FILESDIR}/${PN}-0.33-disable-invalid-tests.patch"
)
src_test() {
# Start memcached in background on a port 11211, the default port if
# environment variable TEST_NGINX_MEMCACHED_PORT is not set.
# memcached is enclosed in braces so that the not operator properly applies
# to the asynchronous invocation of memcached.
if ! { memcached -p 11211 & }
then
die "memcached failed"
fi
# Save the PID of the launched memcached instance.
local memcached_pid=$!
nginx-module_src_test
kill "${memcached_pid}" || die "killing memcached failed"
}

View File

@ -6,6 +6,12 @@ EAPI=8
MY_PN="xss-nginx-module"
NGINX_MOD_S="${WORKDIR}/${MY_PN}-${PV}"
# Strangely, 10-year-old tests work perfectly.
NGINX_MOD_OPENRESTY_TESTS=1
NGINX_MOD_TEST_LOAD_ORDER=(
www-nginx/ngx-lua-module
www-nginx/ngx-echo
)
inherit nginx-module
DESCRIPTION="Native support for cross-site scripting (XSS) in NGINX"
@ -17,8 +23,6 @@ SRC_URI="
LICENSE="BSD-2"
SLOT="0"
RESTRICT="test"
PATCHES=(
"${FILESDIR}/${PN}-0.06-add-dynamic-build-support.patch"
)