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

V2.6.0 fix test ssl pollout #4456

Merged
merged 2 commits into from
Feb 21, 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
50 changes: 50 additions & 0 deletions test/tap/tap/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1713,3 +1713,53 @@ void check_query_count(MYSQL* admin, vector<uint32_t> queries, uint32_t hg) {
dump_conn_stats(admin, { hg });
}
};

const char* get_env_str(const char* envname, const char* envdefault) {

const char* envval = std::getenv(envname);

if (envval != NULL)
return envval;

return envdefault;
};

int get_env_int(const char* envname, int envdefault) {

const char* envval = std::getenv(envname);
int res = envdefault;

if (envval != NULL)
res = strtol(envval, NULL, 0);
// diag("%s: %s='%s' >>> %d", __FUNCTION__, envname, envval, res);

return res;
};

bool get_env_bool(const char* envname, bool envdefault) {

const char* envval = std::getenv(envname);
int res = envdefault;

if (envval != NULL) {
if (strcasecmp(envval, "true") == 0) {
res = 1;
} else if (strcasecmp(envval, "false") == 0) {
res = 0;
} else if (strcasecmp(envval, "yes") == 0) {
res = 1;
} else if (strcasecmp(envval, "no") == 0) {
res = 0;
} else if (strcasecmp(envval, "on") == 0) {
res = 1;
} else if (strcasecmp(envval, "off") == 0) {
res = 0;
} else {
res = strtol(envval, NULL, 0);
}
}

// diag("%s: %s='%s' >>> %d", __FUNCTION__, envname, envval, res);

return (bool) res;
};
11 changes: 11 additions & 0 deletions test/tap/tap/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -643,4 +643,15 @@ void check_conn_count(MYSQL* admin, const std::string& conn_type, uint32_t conn_
void check_query_count(MYSQL* admin, uint32_t queries, uint32_t hg);
void check_query_count(MYSQL* admin, std::vector<uint32_t> queries, uint32_t hg);

/**
* @brief fetches and converts env var value to str/int/bool if possible otherwise uses default
* @details helper function for fetching str/int/bool from env
* @param envname - name for the env variable
* @param envdefault - default value to use
* @return str/int/bool value or default
*/
const char* get_env_str(const char* envname, const char* envdefault);
int get_env_int(const char* envname, int envdefault);
bool get_env_bool(const char* envname, bool envdefault);

#endif // #define UTILS_H
2 changes: 1 addition & 1 deletion test/tap/tests/reg_test_3765_ssl_pollout-t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ int create_connections(const conn_opts_t& conn_opts, uint32_t cons_num, std::vec
const uint32_t ADMIN_CONN_NUM = 100;
const uint32_t MYSQL_CONN_NUM = 100;
const uint32_t REPORT_INTV_SEC = 5;
const double MAX_ALLOWED_CPU_USAGE = 13.0;
double MAX_ALLOWED_CPU_USAGE = (double) get_env_int("TAP_MAX_ALLOWED_CPU_USAGE", 13);

int get_idle_conns_cpu_usage(CommandLine& cl, uint64_t mode, double& idle_cpu_ms, double& final_cpu_ms) {
// get ProxySQL idle cpu usage
Expand Down
Loading