Skip to content

Commit

Permalink
tests(proxy-wasm) on_foreign_function context checks
Browse files Browse the repository at this point in the history
  • Loading branch information
casimiro committed Jan 2, 2025
1 parent 8822833 commit 88186ad
Show file tree
Hide file tree
Showing 27 changed files with 358 additions and 38 deletions.
16 changes: 16 additions & 0 deletions t/03-proxy_wasm/hfuncs/contexts/002-set_tick_period.t
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,19 @@ can only set tick_period in root context
--- no_error_log
[crit]
[alert]



=== TEST 10: proxy_wasm contexts - set_tick_period on_foreign_function
--- wasm_modules: context_checks
--- config
location /t {
proxy_wasm context_checks 'on_foreign_function=set_tick_period';
return 200;
}
--- ignore_response_body
--- error_log
can only set tick_period in root context
--- no_error_log
[crit]
[alert]
16 changes: 16 additions & 0 deletions t/03-proxy_wasm/hfuncs/contexts/100-proxy_log.t
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,19 @@ proxy_log msg
--- no_error_log
[error]
[crit]



=== TEST 10: proxy_wasm contexts - proxy_log on_foreign_function
--- wasm_modules: context_checks
--- config
location /t {
proxy_wasm context_checks 'on_foreign_function=proxy_log';
return 200;
}
--- ignore_response_body
--- error_log
proxy_log msg
--- no_error_log
[error]
[crit]
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,19 @@ should not be retrievable after on_response_body since buffers are consumed
can only set request headers before response is produced
--- no_error_log
[crit]



=== TEST 10: proxy_wasm contexts - add_http_request_header on_foreign_function
--- wasm_modules: context_checks
--- config
location /t {
proxy_wasm context_checks 'on_foreign_function=add_request_header|foo=bar';
return 200;
}
--- ignore_response_body
--- error_log
[error]
can only set request headers before response is produced
--- no_error_log
[crit]
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,19 @@ add_response_header status: 0
--- no_error_log
[error]
[crit]



=== TEST 14: proxy_wasm contexts - add_http_response_header on_foreign_function
--- wasm_modules: context_checks
--- config
location /t {
proxy_wasm context_checks 'on_foreign_function=add_response_header|:foo=bar';
return 200;
}
--- ignore_response_body
--- error_log
[error]
can only set response headers before "on_response_body"
--- no_error_log
[crit]
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,19 @@ should not be retrievable after on_response_body since buffers are consumed
can only set request headers before response is produced
--- no_error_log
[crit]



=== TEST 10: proxy_wasm contexts - set_http_request_headers on_foreign_function
--- wasm_modules: context_checks
--- config
location /t {
proxy_wasm context_checks 'on_foreign_function=set_request_headers|foo=bar';
return 200;
}
--- ignore_response_body
--- error_log
[error]
can only set request headers before response is produced
--- no_error_log
[crit]
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,19 @@ set_response_headers status: 0
--- no_error_log
[error]
[crit]



=== TEST 14: proxy_wasm contexts - set_http_response_headers on_foreign_function
--- wasm_modules: context_checks
--- config
location /t {
proxy_wasm context_checks 'on_foreign_function=set_response_headers|:foo=bar';
return 200;
}
--- ignore_response_body
--- error_log
[error]
can only set response headers before "on_response_body"
--- no_error_log
[crit]
Original file line number Diff line number Diff line change
Expand Up @@ -184,3 +184,19 @@ should not be retrievable after on_response_body since buffers are consumed
can only set request headers before response is produced
--- no_error_log
[crit]



=== TEST 10: proxy_wasm contexts - set_http_request_header on_foreign_function
--- wasm_modules: context_checks
--- config
location /t {
proxy_wasm context_checks 'on_foreign_function=set_request_header|:foo=bar';
return 200;
}
--- ignore_response_body
--- error_log
[error]
can only set request headers before response is produced
--- no_error_log
[crit]
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,19 @@ set_response_header status: 0
--- no_error_log
[error]
[crit]



=== TEST 14: proxy_wasm contexts - set_http_response_header on_foreign_function
--- wasm_modules: context_checks
--- config
location /t {
proxy_wasm context_checks 'on_foreign_function=set_response_header|:foo=bar';
return 200;
}
--- ignore_response_body
--- error_log
[error]
can only set response headers before "on_response_body"
--- no_error_log
[crit]
16 changes: 16 additions & 0 deletions t/03-proxy_wasm/hfuncs/contexts/113-proxy_get_http_request_body.t
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,19 @@ get_request_body_buffer status: 0
--- no_error_log
[error]
[crit]



=== TEST 10: proxy_wasm contexts - get_http_request_body on_foreign_function
--- wasm_modules: context_checks
--- config
location /t {
proxy_wasm context_checks 'on_foreign_function=get_request_body_buffer';
return 200;
}
--- ignore_response_body
--- error_log
[error]
can only get request body during "on_request_body"
--- no_error_log
[crit]
16 changes: 16 additions & 0 deletions t/03-proxy_wasm/hfuncs/contexts/114-proxy_set_http_request_body.t
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,19 @@ can only set request body during "on_request_body"
can only set request body during "on_request_body"
--- no_error_log
[crit]



=== TEST 10: proxy_wasm contexts - set_http_request_body on_foreign_function
--- wasm_modules: context_checks
--- config
location /t {
proxy_wasm context_checks 'on_foreign_function=set_request_body_buffer';
return 200;
}
--- ignore_response_body
--- error_log
[error]
can only set request body during "on_request_body"
--- no_error_log
[crit]
16 changes: 16 additions & 0 deletions t/03-proxy_wasm/hfuncs/contexts/115-proxy_get_http_response_body.t
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,19 @@ get_response_body_buffer status: 0
can only get response body during "on_response_body"
--- no_error_log
[crit]



=== TEST 10: proxy_wasm contexts - set_http_response_body on_foreign_function
--- wasm_modules: context_checks
--- config
location /t {
proxy_wasm context_checks 'on_foreign_function=get_response_body_buffer';
return 200;
}
--- ignore_response_body
--- error_log
[error]
can only get response body during "on_response_body"
--- no_error_log
[crit]
16 changes: 16 additions & 0 deletions t/03-proxy_wasm/hfuncs/contexts/116-proxy_set_http_response_body.t
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,19 @@ should not be retrievable after on_response_body since buffers are consumed
can only set response body during "on_response_body"
--- no_error_log
[crit]



=== TEST 10: proxy_wasm contexts - set_http_response_body on_foreign_function
--- wasm_modules: context_checks
--- config
location /t {
proxy_wasm context_checks 'on_foreign_function=set_response_body_buffer';
return 200;
}
--- ignore_response_body
--- error_log
[error]
can only set response body during "on_response_body"
--- no_error_log
[crit]
26 changes: 21 additions & 5 deletions t/03-proxy_wasm/hfuncs/contexts/130-proxy_dispatch_http.t
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ __DATA__
--- must_die: 0
--- error_log
[error]
can only send HTTP dispatch during "on_request_headers", "on_request_body", "on_dispatch_response", "on_tick"
can only send HTTP dispatch during "on_request_headers", "on_request_body", "on_tick", "on_dispatch_response", "on_foreign_function"
--- no_error_log
[crit]

Expand All @@ -41,7 +41,7 @@ can only send HTTP dispatch during "on_request_headers", "on_request_body", "on_
--- must_die: 0
--- error_log
[error]
can only send HTTP dispatch during "on_request_headers", "on_request_body", "on_dispatch_response", "on_tick"
can only send HTTP dispatch during "on_request_headers", "on_request_body", "on_tick", "on_dispatch_response", "on_foreign_function"
--- no_error_log
[crit]

Expand Down Expand Up @@ -132,7 +132,7 @@ dispatch failed: no :method
--- ignore_response_body
--- error_log
[error]
can only send HTTP dispatch during "on_request_headers", "on_request_body", "on_dispatch_response", "on_tick"
can only send HTTP dispatch during "on_request_headers", "on_request_body", "on_tick", "on_dispatch_response", "on_foreign_function"
--- no_error_log
[crit]

Expand All @@ -149,7 +149,7 @@ can only send HTTP dispatch during "on_request_headers", "on_request_body", "on_
--- ignore_response_body
--- error_log
[error]
can only send HTTP dispatch during "on_request_headers", "on_request_body", "on_dispatch_response", "on_tick"
can only send HTTP dispatch during "on_request_headers", "on_request_body", "on_tick", "on_dispatch_response", "on_foreign_function"
--- no_error_log
[crit]

Expand All @@ -164,6 +164,22 @@ can only send HTTP dispatch during "on_request_headers", "on_request_body", "on_
}
--- error_log
[error]
can only send HTTP dispatch during "on_request_headers", "on_request_body", "on_dispatch_response", "on_tick"
can only send HTTP dispatch during "on_request_headers", "on_request_body", "on_tick", "on_dispatch_response", "on_foreign_function"
--- no_error_log
[crit]



=== TEST 10: proxy_wasm contexts - dispatch_http_call on_foreign_function
--- wasm_modules: context_checks
--- config
location /t {
proxy_wasm context_checks 'on_foreign_function=dispatch_http_call';
return 200;
}
--- ignore_response_body
--- error_log
[error]
dispatch failed: no :method
--- no_error_log
[crit]
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,19 @@ can only call resolve_lua during "on_request_headers", "on_request_body", "on_ti
can only call resolve_lua during "on_request_headers", "on_request_body", "on_tick", "on_dispatch_response", "on_foreign_function"
--- no_error_log
[crit]



=== TEST 10: proxy_wasm contexts - call_resolve_lua on_foreign_function
--- wasm_modules: context_checks
--- config
location /t {
proxy_wasm context_checks 'on_foreign_function=call_resolve_lua';
return 200;
}
--- ignore_response_body
--- error_log
[error]
cannot resolve, missing name
--- no_error_log
[crit]
19 changes: 19 additions & 0 deletions t/03-proxy_wasm/hfuncs/contexts/metrics/001-proxy_define_metric.t
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,22 @@ define_metric status: 0
--- no_error_log
[error]
[crit]



=== TEST 10: proxy_wasm contexts - define_metric on_foreign_function
--- main_config
wasm {
module context_checks $TEST_NGINX_CRATES_DIR/context_checks.wasm;
}
--- config
location /t {
proxy_wasm context_checks 'on_foreign_function=define_metric';
return 200;
}
--- ignore_response_body
--- error_log
define_metric status: 0
--- no_error_log
[error]
[crit]
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,22 @@ increment_metric status: 0
--- no_error_log
[error]
[crit]



=== TEST 10: proxy_wasm contexts - increment_metric on_foreign_function
--- main_config
wasm {
module context_checks $TEST_NGINX_CRATES_DIR/context_checks.wasm;
}
--- config
location /t {
proxy_wasm context_checks 'on_foreign_function=increment_metric';
return 200;
}
--- ignore_response_body
--- error_log
increment_metric status: 0
--- no_error_log
[error]
[crit]
19 changes: 19 additions & 0 deletions t/03-proxy_wasm/hfuncs/contexts/metrics/020-proxy_record_metric.t
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,22 @@ record_metric status: 0
--- no_error_log
[error]
[crit]



=== TEST 10: proxy_wasm contexts - record_metric on_foreign_function
--- main_config
wasm {
module context_checks $TEST_NGINX_CRATES_DIR/context_checks.wasm;
}
--- config
location /t {
proxy_wasm context_checks 'on_foreign_function=record_metric';
return 200;
}
--- ignore_response_body
--- error_log
record_metric status: 0
--- no_error_log
[error]
[crit]
Loading

0 comments on commit 88186ad

Please sign in to comment.