Skip to content

Commit

Permalink
Add reg test for frontend/backend conns SSL errors
Browse files Browse the repository at this point in the history
  • Loading branch information
JavierJF committed Aug 8, 2024
1 parent f3ea2e6 commit b19106a
Show file tree
Hide file tree
Showing 5 changed files with 892 additions and 34 deletions.
35 changes: 32 additions & 3 deletions test/tap/tap/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1586,10 +1586,16 @@ sq3_res_t sqlite3_execute_stmt(sqlite3* db, const string& query) {
return res;
}

json fetch_internal_session(MYSQL* proxy) {
int rc = mysql_query_t(proxy, "PROXYSQL INTERNAL SESSION");
json fetch_internal_session(MYSQL* proxy, bool verbose) {
int rc = 0;

if (verbose) {
rc = mysql_query_t(proxy, "PROXYSQL INTERNAL SESSION");
} else {
rc = mysql_query(proxy, "PROXYSQL INTERNAL SESSION");
}

if (rc ) {
if (rc) {
return json {};
} else {
MYSQL_RES* myres = mysql_store_result(proxy);
Expand All @@ -1601,6 +1607,29 @@ json fetch_internal_session(MYSQL* proxy) {
}
}

map<string, double> parse_prometheus_metrics(const string& s) {
vector<string> lines { split(s, '\n') };
map<string, double> metrics_map {};

for (const string ln : lines) {
const vector<string> line_values { split(ln, ' ') };

if (ln.empty() == false && ln[0] != '#') {
if (line_values.size() > 2) {
size_t delim_pos_st = ln.rfind("} ");
string metric_key = ln.substr(0, delim_pos_st);
string metric_val = ln.substr(delim_pos_st + 2);

metrics_map.insert({metric_key, stod(metric_val)});
} else {
metrics_map.insert({line_values.front(), stod(line_values.back())});
}
}
}

return metrics_map;
}

struct cols_table_info_t {
vector<string> names;
vector<size_t> widths;
Expand Down
12 changes: 11 additions & 1 deletion test/tap/tap/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -682,8 +682,18 @@ int64_t get_elem_idx(const T& e, const std::vector<T>& v) {
/**
* @brief Returns a 'JSON' object holding 'PROXYSQL INTERNAL SESSION' contents.
* @param proxy And already openned connection to ProxySQL.
* @param verbose Wether to log or not the issued queries.
*/
nlohmann::json fetch_internal_session(MYSQL* proxy);
nlohmann::json fetch_internal_session(MYSQL* proxy, bool verbose=true);

/**
* @brief Extract the metrics values from the output of:
* - The admin command 'SHOW PROMETHEUS METRICS'.
* - Querying the RESTAPI metrics endpoint.
* @param s ProxySQL prometheus exporter output.
* @return A map of metrics identifiers and values.
*/
std::map<std::string, double> parse_prometheus_metrics(const std::string& s);

/**
* @brief Returns a string table representation of the supplied resultset.
Expand Down
Loading

0 comments on commit b19106a

Please sign in to comment.