Test: Fix test_unsupported_queries for isolated CI environment

Use REGULAR_INFRA_DATADIR environment variable to locate the
load_data_local_datadir files in the shared volume when running
in containerized CI environment. Falls back to cl.workdir for
local testing.
pull/5435/head
Rene Cannao 2 months ago
parent 6f7aa050e7
commit 032ca6511d

@ -170,9 +170,10 @@ using mysql_res_row = std::vector<std::string>;
void helper_test_load_data_local_infile(
const CommandLine& cl, MYSQL* proxysql, int exp_err=0, bool test_for_success=true
) {
std::string datafile {
std::string { cl.workdir } + "load_data_local_datadir/insert_data.txt"
};
const char* d_env = getenv("REGULAR_INFRA_DATADIR");
std::string datafile = (d_env ? std::string(d_env) + "/load_data_local_datadir/insert_data.txt"
: std::string(cl.workdir) + "load_data_local_datadir/insert_data.txt");
diag("Data file path: %s", datafile.c_str());
bool table_prep_success = true;
@ -363,9 +364,10 @@ void test_failing_load_data_local_infile(
const CommandLine& cl, MYSQL* proxysql, int exp_err=0, bool test_for_success=true
) {
// Supply an invalid file
std::string datafile {
std::string { cl.workdir } + "load_data_local_datadir/non_existing_file.txt"
};
const char* d_env = getenv("REGULAR_INFRA_DATADIR");
std::string datafile = (d_env ? std::string(d_env) + "/load_data_local_datadir/non_existing_file.txt"
: std::string(cl.workdir) + "load_data_local_datadir/non_existing_file.txt");
diag("Data file path: %s", datafile.c_str());
bool table_prep_success = true;
@ -500,6 +502,25 @@ int main(int argc, char** argv) {
return -1;
}
// Verbose test header
diag("================================================================================");
diag("Test: test_unsupported_queries-t");
diag("================================================================================");
diag("This test verifies that unsupported queries return the expected error codes,");
diag("and that conditionally-enabled queries work correctly when enabled/disabled.");
diag("");
diag("Test scenarios:");
diag(" - Unsupported queries (LOAD DATA LOCAL INFILE) should fail with error 1047");
diag(" - Conditionally enabled queries should work when enabled");
diag(" - Conditionally enabled queries should fail when disabled");
diag("");
diag("Connection parameters:");
diag(" - Host: %s", cl.host);
diag(" - Port: %d", cl.port);
diag(" - Admin Port: %d", cl.admin_port);
diag("================================================================================");
diag("");
// perform a different connection per query
for (const auto& unsupported_query : unsupported_queries) {
MYSQL* proxysql_mysql = mysql_init(NULL);

Loading…
Cancel
Save