From 39df4f89bb63a8286f01aa6f4791742d2c3493ce Mon Sep 17 00:00:00 2001 From: Rene Cannao Date: Thu, 5 Mar 2026 10:55:54 +0000 Subject: [PATCH] tests: Fix RESTAPI tests for isolated container environment - Use REGULAR_INFRA_DATADIR environment variable for script path resolution in reg_test_3223-restapi_return_codes-t (was hardcoded to cl.workdir) - Add verbose diagnostic output with PURPOSE and TEST SCENARIOS sections - Log the actual script base path being used for easier debugging - Consistent formatting with diag() headers across both tests --- .../reg_test_3223-restapi_return_codes-t.cpp | 25 +++++++++++------- ...eg_test_4001-restapi_scripts_num_fds-t.cpp | 26 ++++++++++++------- 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/test/tap/tests/reg_test_3223-restapi_return_codes-t.cpp b/test/tap/tests/reg_test_3223-restapi_return_codes-t.cpp index be29f7286..53eee2117 100644 --- a/test/tap/tests/reg_test_3223-restapi_return_codes-t.cpp +++ b/test/tap/tests/reg_test_3223-restapi_return_codes-t.cpp @@ -127,14 +127,19 @@ int main(int argc, char** argv) { } diag("=== Regression Test #3223: RESTAPI Script Execution & Return Codes ==="); - diag("This test ensures that ProxySQL RESTAPI correctly handles script execution"); - diag("and returns the expected HTTP status codes and script exit codes."); - diag("The test strategy is:"); - diag("1. Register multiple valid and faulty scripts in RESTAPI routes."); - diag("2. Issue POST/GET requests to these endpoints."); - diag("3. Verify HTTP return codes (200 for success, 400/424 for failures)."); - diag("4. Verify internal script error codes (exit codes, timeouts, signals)."); - diag("5. Check behavior with large outputs and partial flushes."); + diag(""); + diag("PURPOSE:"); + diag(" This test validates that ProxySQL's RESTAPI correctly handles script"); + diag(" execution and returns appropriate HTTP status codes and error codes."); + diag(""); + diag("TEST SCENARIOS:"); + diag(" - Valid requests: Scripts returning proper JSON output (200 OK)"); + diag(" - Invalid input: Malformed JSON or missing parameters (400 Bad Request)"); + diag(" - Script failures: Timeouts, permission errors, signals (424 Failed)"); + diag(" - Edge cases: Large outputs, partial flushes, closed pipes"); + diag(""); + diag("SCRIPT PATH: Using '%s' for script resolution", + getenv("REGULAR_INFRA_DATADIR") ? getenv("REGULAR_INFRA_DATADIR") : cl.workdir); diag("========================================================================="); plan(count_exp_tests(honest_requests, invalid_requests)); @@ -165,7 +170,9 @@ int main(int argc, char** argv) { MYSQL_QUERY(admin, "DELETE FROM restapi_routes"); // Configure restapi_routes to be used - string script_base_path { string { cl.workdir } + "reg_test_3223_scripts" }; + const char* d_env = getenv("REGULAR_INFRA_DATADIR"); + string script_base_path = (d_env ? string(d_env) + "/reg_test_3223_scripts" : string(cl.workdir) + "reg_test_3223_scripts"); + diag("Script base path: %s", script_base_path.c_str()); const ept_info_t dummy_ept { "dummy_ept_script", "%s.py", "POST", 1000 }; // Configure the valid requests diff --git a/test/tap/tests/reg_test_4001-restapi_scripts_num_fds-t.cpp b/test/tap/tests/reg_test_4001-restapi_scripts_num_fds-t.cpp index 4a4a79791..b059804f7 100644 --- a/test/tap/tests/reg_test_4001-restapi_scripts_num_fds-t.cpp +++ b/test/tap/tests/reg_test_4001-restapi_scripts_num_fds-t.cpp @@ -57,14 +57,20 @@ int main(int argc, char** argv) { } diag("=== Regression Test #4001: RESTAPI with High FD Usage ==="); - diag("This test verifies that the RESTAPI remains operational when ProxySQL"); - diag("is handling a large number of concurrent file descriptors (> FD_SETSIZE)."); - diag("The test strategy is:"); - diag("1. Elevate process FD limits."); - diag("2. Establish 1300 concurrent MySQL connections to ProxySQL."); - diag("3. While these connections are held, perform continuous RESTAPI requests."); - diag("4. Simultaneously create and destroy additional MySQL connections."); - diag("5. Verify that RESTAPI requests and connection operations remain stable."); + diag(""); + diag("PURPOSE:"); + diag(" This test verifies that the RESTAPI remains operational when ProxySQL"); + diag(" is handling a large number of concurrent file descriptors (> FD_SETSIZE)."); + diag(""); + diag("TEST SCENARIOS:"); + diag(" - Elevate process FD limits beyond FD_SETSIZE (1024)."); + diag(" - Establish 1300 concurrent MySQL connections to ProxySQL."); + diag(" - Perform continuous RESTAPI requests while connections are held."); + diag(" - Simultaneously create and destroy additional MySQL connections."); + diag(" - Verify RESTAPI requests and connection operations remain stable."); + diag(""); + diag("SCRIPT PATH: Using '%s' for script resolution", + getenv("REGULAR_INFRA_DATADIR") ? getenv("REGULAR_INFRA_DATADIR") : cl.workdir); diag("=========================================================="); diag("Setting new process limits beyond 'FD_SETSIZE'"); @@ -89,7 +95,9 @@ int main(int argc, char** argv) { return EXIT_FAILURE; } - const char* d_env = getenv("REGULAR_INFRA_DATADIR"); string script_base_path = (d_env ? string(d_env) + "/reg_test_3223_scripts" : string(cl.workdir) + "reg_test_3223_scripts"); + const char* d_env = getenv("REGULAR_INFRA_DATADIR"); + string script_base_path = (d_env ? string(d_env) + "/reg_test_3223_scripts" : string(cl.workdir) + "reg_test_3223_scripts"); + diag("Script base path: %s", script_base_path.c_str()); const ept_info_t dummy_ept { "dummy_ept_script", "%s.py", "POST", 1000 }; vector v_epts_info {};