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

chore(*) isolate test suites by Wasm target #594

Merged
merged 3 commits into from
Sep 26, 2024
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
14 changes: 13 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ jobs:
ssl: ssl
debug: debug
hup: no_hup
# wasm32-unknown-unknown
- runtime: wasmtime
wasmtime: 23.0.2
os: ubuntu-latest
cc: gcc-12
ngx: 1.27.1
ipc: no_ipc
ssl: no_ssl
debug: debug
hup: no_hup
wasm_target: wasm32-unknown-unknown
# Old Nginx
- label: old_nginx
os: ubuntu-latest
Expand Down Expand Up @@ -146,6 +157,7 @@ jobs:
ssl: ${{ matrix.ssl }}
debug: ${{ matrix.debug }}
hup: ${{ matrix.hup }}
wasm_target: ${{ matrix.wasm_target }}
module_type: ${{ matrix.module_type }}
coverage: true
secrets: inherit
Expand All @@ -162,7 +174,7 @@ jobs:
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
carryforward: 'unit-ngx_1.27.1-wasmer-no_ipc-ssl-debug-no_hup-static,unit-ngx_1.27.1-wasmer-no_ipc-ssl-no_debug-no_hup-static,unit-ngx_1.27.1-wasmtime-no_ipc-ssl-debug-hup-static,unit-ngx_1.27.1-wasmtime-no_ipc-ssl-debug-hup-dynamic,unit-ngx_1.27.1-v8-no_ipc-ssl-debug-no_hup-static,unit-ngx_1.21.6-wasmer-no_ipc-ssl-debug-no_hup-static,unit-ngx_1.27.1-wasmer-no_ipc-no_ssl-no_debug-no_hup-static,unit-openresty_1.25.3.2-wasmtime-no_ipc-ssl-debug-no_hup-static,unit-openresty_1.25.3.2-wasmtime-no_ipc-ssl-debug-no_hup-dynamic,unit-ngx_1.27.1-wasmtime-ipc-no_ssl-debug-no_hup-static'
carryforward: 'unit-ngx_1.27.1-wasmer-no_ipc-ssl-debug-no_hup-static,unit-ngx_1.27.1-wasmer-no_ipc-ssl-no_debug-no_hup-static,unit-ngx_1.27.1-wasmtime-no_ipc-ssl-debug-hup-static,unit-ngx_1.27.1-wasmtime-no_ipc-ssl-debug-hup-dynamic,unit-ngx_1.27.1-v8-no_ipc-ssl-debug-no_hup-static,unit-ngx_1.27.1-wasmtime-no_ipc-no_ssl-debug-no_hup-static-wasm32-unknown-unknown,unit-ngx_1.21.6-wasmer-no_ipc-ssl-debug-no_hup-static,unit-ngx_1.27.1-wasmer-no_ipc-no_ssl-no_debug-no_hup-static,unit-openresty_1.25.3.2-wasmtime-no_ipc-ssl-debug-no_hup-static,unit-openresty_1.25.3.2-wasmtime-no_ipc-ssl-debug-no_hup-dynamic,unit-ngx_1.27.1-wasmtime-ipc-no_ssl-debug-no_hup-static'

valgrind:
name: 'Valgrind'
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/job-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ on:
hup:
required: true
type: string
wasm_target:
required: false
type: string
module_type:
required: true
type: string
Expand All @@ -64,6 +67,7 @@ env:
TEST_NGINX_TIMEOUT: 60
TEST_NGINX_EXTERNAL_TIMEOUT: 60s
TEST_NGINX_EXTERNAL_RESOLVER: 127.0.0.1:8053
TEST_NGINX_CARGO_RUSTTARGET: ${{ inputs.wasm_target }}

jobs:
tests:
Expand Down Expand Up @@ -103,6 +107,10 @@ jobs:
uses: dtolnay/rust-toolchain@stable
with:
target: wasm32-wasip1
- name: Add wasm32-unknown-unknown target
if: ${{ inputs.wasm_target == 'wasm32-unknown-unknown' }}
run: |
rustup target add wasm32-unknown-unknown
- name: Setup Go
if: ${{ !env.ACT }}
uses: actions/setup-go@v5
Expand Down Expand Up @@ -170,6 +178,9 @@ jobs:
else
name="$name-static"
fi
if [ -n "${{ inputs.wasm_target }}" ]; then
name="$name-${{ inputs.wasm_target }}"
fi
echo "name=$name" >> $GITHUB_OUTPUT
- name: Coveralls Upload
if: ${{ !env.ACT && inputs.coverage }}
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ setup:

.PHONY: test
test:
@util/test.sh t/0*
@util/test.sh t/

.PHONY: test-build
test-build:
Expand Down
2 changes: 1 addition & 1 deletion config
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ NGX_WASM_SRCS="\
$ngx_addon_dir/src/wasm/wrt/ngx_wrt_utils.c \
$ngx_addon_dir/src/wasm/vm/ngx_wavm.c \
$ngx_addon_dir/src/wasm/vm/ngx_wavm_host.c \
$ngx_addon_dir/src/wasm/wasi/ngx_wasi_host.c"
$ngx_addon_dir/src/wasm/wasi/ngx_wasi_preview1_host.c"

NGX_WASM_CORE_SRCS="\
$ngx_addon_dir/src/wasm/ngx_wasm_core_module.c \
Expand Down
2 changes: 1 addition & 1 deletion src/wasm/wasi/ngx_wasi.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#define WASI_ERRNO_NOTSUP 58


extern ngx_wavm_host_def_t ngx_wasi_host;
extern ngx_wavm_host_def_t ngx_wasip1_host;


#endif /* _NGX_WASI_H_INCLUDED_ */
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ static ngx_wavm_host_func_def_t ngx_wasi_hfuncs[] = {
};


ngx_wavm_host_def_t ngx_wasi_host = {
ngx_string("ngx_wasi"),
ngx_wavm_host_def_t ngx_wasip1_host = {
ngx_string("ngx_wasi_preview1"),
ngx_wasi_hfuncs,
};
2 changes: 1 addition & 1 deletion src/wasm/wrt/ngx_wrt_v8.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ ngx_v8_link_module(ngx_wrt_module_t *module, ngx_array_t *hfuncs,
name.data = (u_char *) importname->data;

hfunc = ngx_wavm_host_hfunc_create(module->engine->pool,
&ngx_wasi_host, &name);
&ngx_wasip1_host, &name);

if (hfunc) {
dd(" -> wasi resolved: \"%.*s\"",
Expand Down
2 changes: 1 addition & 1 deletion src/wasm/wrt/ngx_wrt_wasmer.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ ngx_wasmer_link_module(ngx_wrt_module_t *module, ngx_array_t *hfuncs,
name.data = (u_char *) importname->data;

hfunc = ngx_wavm_host_hfunc_create(module->engine->pool,
&ngx_wasi_host, &name);
&ngx_wasip1_host, &name);

if (hfunc) {
dd(" -> wasi resolved by host function: \"%.*s\"",
Expand Down
10 changes: 5 additions & 5 deletions src/wasm/wrt/ngx_wrt_wasmtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,17 +280,17 @@ ngx_wasmtime_init_engine(ngx_wrt_engine_t *engine, wasm_config_t *config,

nwasi = 0;

for (i = 0; ngx_wasi_host.funcs[i].ptr; i++) {
for (i = 0; ngx_wasip1_host.funcs[i].ptr; i++) {
nwasi++;
}

engine->pool = pool;
engine->wasi_hfuncs = ngx_pcalloc(pool, sizeof(ngx_wavm_hfunc_t *) * nwasi);

for (i = 0; ngx_wasi_host.funcs[i].ptr; i++) {
def = &ngx_wasi_host.funcs[i];
for (i = 0; ngx_wasip1_host.funcs[i].ptr; i++) {
def = &ngx_wasip1_host.funcs[i];

hfunc = ngx_wavm_host_hfunc_create(pool, &ngx_wasi_host, &def->name);
hfunc = ngx_wavm_host_hfunc_create(pool, &ngx_wasip1_host, &def->name);

err->res = wasmtime_linker_define_func(engine->linker,
wasi_module,
Expand All @@ -316,7 +316,7 @@ ngx_wasmtime_destroy_engine(ngx_wrt_engine_t *engine)
{
size_t i;

for (i = 0; ngx_wasi_host.funcs[i].ptr; i++) {
for (i = 0; ngx_wasip1_host.funcs[i].ptr; i++) {
wasm_functype_delete(engine->wasi_hfuncs[i]->functype);
}

Expand Down
2 changes: 1 addition & 1 deletion t/03-proxy_wasm/hfuncs/101-proxy_get_current_time.t
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ should produce a log with the current time (ms as ~ns)
--- response_body
ok
--- error_log eval
qr/\[info\] .*? now: 2.*? UTC/,
qr/\[info\] .*? now: SystemTime\(\d+\.\d+s\)/,
--- no_error_log
[error]
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use strict;
use lib '.';
use t::TestWasmX;

skip_no_wasi();

our $nginxV = $t::TestWasmX::nginxV;

plan_tests(4);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use strict;
use lib '.';
use t::TestWasmX;

skip_no_wasi();

plan_tests(3);
run_tests();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use strict;
use lib '.';
use t::TestWasmX;

skip_no_wasi();

plan_tests(3);
run_tests();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use strict;
use lib '.';
use t::TestWasmX;

skip_no_wasi();

plan_tests(3);
run_tests();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use strict;
use lib '.';
use t::TestWasmX;

skip_no_wasi();

plan_tests(3);
run_tests();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use strict;
use lib '.';
use t::TestWasmX;

skip_no_wasi();

plan_tests(3);
run_tests();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use strict;
use lib '.';
use t::TestWasmX;

skip_no_wasi();

plan_tests(3);
run_tests();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use strict;
use lib '.';
use t::TestWasmX;

skip_no_wasi();

plan_tests(3);
run_tests();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use strict;
use lib '.';
use t::TestWasmX;

skip_no_wasi();

plan_tests(3);
run_tests();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use strict;
use lib '.';
use t::TestWasmX;

skip_no_wasi();

plan_tests(3);
run_tests();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use strict;
use lib '.';
use t::TestWasmX;

skip_no_wasi();

plan_tests(3);
run_tests();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use strict;
use lib '.';
use t::TestWasmX;

skip_no_wasi();

plan_tests(3);
run_tests();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use strict;
use lib '.';
use t::TestWasmX;

skip_no_wasi();

plan_tests(3);
run_tests();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use strict;
use lib '.';
use t::TestWasmX;

skip_no_wasi();

plan_tests(3);
run_tests();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use strict;
use lib '.';
use t::TestWasmX;

skip_no_wasi();

plan_tests(3);
run_tests();

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion t/10-build/001-build_options.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use strict;
use lib '.';
use t::TestBuild;

skip_valgrind();
skip_no_test_nginx();

our $buildroot = $t::TestBuild::buildroot;
our $openssl_ver = get_variable_from_makefile("OPENSSL");
Expand Down
2 changes: 1 addition & 1 deletion t/10-build/002-runtime_linking.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use strict;
use lib '.';
use t::TestBuild;

skip_valgrind();
skip_no_test_nginx();

our $buildroot = $t::TestBuild::buildroot;

Expand Down
2 changes: 1 addition & 1 deletion t/10-build/003-dynamic_module.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use strict;
use lib '.';
use t::TestBuild;

skip_valgrind();
skip_no_test_nginx();

our $buildroot = $t::TestBuild::buildroot;

Expand Down
2 changes: 1 addition & 1 deletion t/10-build/004-ngx_wasm_rs_linking.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use strict;
use lib '.';
use t::TestBuild;

skip_valgrind();
skip_no_test_nginx();

our $buildroot = $t::TestBuild::buildroot;

Expand Down
9 changes: 9 additions & 0 deletions t/TestBuild.pm
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ our $buildroot = $ENV{NGX_BUILD_DIR_BUILDROOT};
our @EXPORT = qw(
$buildroot
skip_valgrind
skip_no_test_nginx
get_variable_from_makefile
run_tests
);
Expand Down Expand Up @@ -45,6 +46,14 @@ sub skip_valgrind {
}
}

sub skip_no_test_nginx {
if (!defined $ENV{TEST_NGINX_NO_TEST_NGINX}
|| $ENV{TEST_NGINX_NO_TEST_NGINX} != 1)
{
plan(skip_all => "skip without build test mode (\$TEST_NGINX_NO_TEST_NGINX=1)");
}
}

sub get_variable_from_makefile($) {
my $name = shift;

Expand Down
7 changes: 7 additions & 0 deletions t/TestWasmX.pm
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ our @EXPORT = qw(
skip_no_debug
skip_no_go_sdk
skip_no_assemblyscript_sdk
skip_no_wasi
);

$ENV{TEST_NGINX_USE_HUP} ||= 0;
Expand Down Expand Up @@ -103,6 +104,12 @@ sub skip_no_assemblyscript_sdk {
}
}

sub skip_no_wasi {
if ($ENV{TEST_NGINX_CARGO_RUSTTARGET} !~ m/wasi/) {
plan(skip_all => "skip without WASI target (\$TEST_NGINX_CARGO_RUSTTARGET is set to \"$ENV{TEST_NGINX_CARGO_RUSTTARGET}\")");
}
}

sub load_nginx_modules (@) {
splice @nginx_modules, 0, 0, @_;
}
Expand Down
Loading
Loading