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
pull/5435/head
Rene Cannao 3 months ago
parent eaecc26d22
commit 39df4f89bb

@ -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

@ -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<ept_info_t> v_epts_info {};

Loading…
Cancel
Save