You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Const strings where appropriate and improved test for statistics
Changed the get_variable_id_for_name, and knows_variable_name to use const string &. Changed immutable strings to to be const as well. Added details comment to test_admin_stats-t.cpp test. In the test code, improved documentation, set a valid interval for metrics insertion, and added the commands to set the interval. Changed the sleep time to be the inteval plus a second should be long enough to let new metrics data be added. Put additional sleep before test 2. Fixed incorrect column index usage in test 4 result set. Reformulated test 5, to check the number of records inserted after new interval is correct.
/** @brief Map with the key being the variable_name and the value being the variable_id, used for history_mysql_variables data. Matches the history_mysql_variables_lookup. */
MYSQL_QUERY(proxysql_admin, "LOAD ADMIN VARIABLES TO RUNTIME");
53
64
54
65
// If on a fresh install, wait long enough for the first run of stats to be created
55
66
// The lookup table will be empty until the first run!
56
-
sleep(new_stats_interval_sec * 2);
57
-
67
+
sleep(new_stats_interval_sec + 1);
68
+
58
69
// Test 1: Lookup table has at least 50 rows
59
70
int64_t lookup_row_count = 0;
60
71
MYSQL_QUERY(proxysql_admin, "SELECT COUNT(*) FROM history_mysql_status_variables_lookup");
@@ -72,7 +83,9 @@ int main(int argc, char** argv) {
72
83
lookup_row_count
73
84
);
74
85
75
-
// Test 2: Distinct timestamps in
86
+
sleep(new_stats_interval_sec + 1);
87
+
88
+
// Test 2: There are multiple distinct timestaps present in history table
76
89
int64_t distinct_timestamp_count = 0;
77
90
MYSQL_QUERY(proxysql_admin, "SELECT COUNT(DISTINCT(timestamp)) FROM history_mysql_status_variables");
78
91
result = mysql_store_result(proxysql_admin);
@@ -118,20 +131,20 @@ int main(int argc, char** argv) {
118
131
distinct_var_ids_in_lookup
119
132
);
120
133
121
-
// Test 4: Check that for each variable_id has same number of rows in history table
134
+
// Test 4: Each variable_id has same number of rows in history table
122
135
123
-
//@note: As the CI tests are done on a fresh install, these should match in this instance
136
+
// As the CI tests are done on a fresh install, these should match in this instance
124
137
// In practice, they could differ if new metrics variables are added.
125
138
126
139
std::vector<int64_t> rows_per_var_id;
127
140
time_t two_mins_ago = time(nullptr) - 60*2;
128
-
string query = "SELECT variable_id, COUNT(*) FROM history_mysql_status_variables WHERE timestamp < " + std::to_string(two_mins_ago) + " GROUP BY variable_id";
141
+
conststring query = "SELECT variable_id, COUNT(*) FROM history_mysql_status_variables WHERE timestamp < " + to_string(two_mins_ago) + " GROUP BY variable_id";
0 commit comments