diff --git a/test/tap/tests/test_digest_umap_aux-t.cpp b/test/tap/tests/test_digest_umap_aux-t.cpp index 477dac1f1f..c95aaffa32 100644 --- a/test/tap/tests/test_digest_umap_aux-t.cpp +++ b/test/tap/tests/test_digest_umap_aux-t.cpp @@ -174,7 +174,7 @@ int main(int argc, char** argv) { return EXIT_FAILURE; } - plan(1 + DUMMY_QUERIES.size() * 3); // always specify the number of tests that are going to be performed + plan(1 + DUMMY_QUERIES.size() * 5); // always specify the number of tests that are going to be performed MYSQL *proxy_admin = mysql_init(NULL); if (!mysql_real_connect(proxy_admin, cl.host, cl.admin_username, cl.admin_password, NULL, cl.admin_port, NULL, 0)) { @@ -199,6 +199,8 @@ int main(int argc, char** argv) { return EXIT_FAILURE; } + time_t init_time = time(NULL); + MYSQL_RES *res = NULL; for (const auto &query : DUMMY_QUERIES) { diag("Running: %s", query); @@ -243,6 +245,8 @@ int main(int argc, char** argv) { ); vector ds_vector_after = get_digest_stats(proxy_admin); + time_t final_time = time(NULL); + for (int i = 0; i < DUMMY_QUERIES.size(); i++) { ok( ds_vector_before[i].hostgroup == ds_vector_after[i].hostgroup && @@ -285,7 +289,24 @@ int main(int argc, char** argv) { ds_vector_before[i].last_seen, ds_vector_after[i].last_seen, ds_vector_before[i].sum_time, ds_vector_after[i].sum_time ); + + uint64_t bf_first_seen = ds_vector_before[i].first_seen; + ok( + init_time - 1 <= bf_first_seen && init_time + 1 >= bf_first_seen, + "'first_seen' within required time range - min: %ld, max: %ld, first_seen: %ld", + init_time - 1, init_time + 1, bf_first_seen + ); + + uint64_t bf_last_seen = ds_vector_before[i].last_seen; + ok( + init_time <= bf_last_seen && final_time >= bf_last_seen, + "'last_seen' within required time range - min: %ld, max: %ld, last_seen: %ld", + init_time, final_time, bf_last_seen + ); } + mysql_query(proxy_admin, "TRUNCATE TABLE stats.stats_mysql_query_digest"); + mysql_close(proxy_admin); + return exit_status(); }