Address review feedback on TSDB tests

- Use cl.admin_host instead of cl.host for admin HTTP endpoints
- Don't log auth credentials (security issue)
- Fail fast when prerequisite SET/LOAD commands fail
- Assert on specific test_downsample_metric rows in hourly table
v3.0-issue5483
Rene Cannao 3 weeks ago
parent 809878c253
commit ca409366cb

@ -111,27 +111,45 @@ int main() {
diag("Enabling TSDB, Web, and REST API...");
int rc;
rc = mysql_query(admin, "SET tsdb-enabled='1'");
if (rc) diag("SET tsdb-enabled failed: %s", mysql_error(admin));
if (rc) {
diag("SET tsdb-enabled failed: %s", mysql_error(admin));
return EXIT_FAILURE;
}
drain_results(admin);
rc = mysql_query(admin, "SET tsdb-sample_interval='1'");
if (rc) diag("SET tsdb-sample_interval failed: %s", mysql_error(admin));
if (rc) {
diag("SET tsdb-sample_interval failed: %s", mysql_error(admin));
return EXIT_FAILURE;
}
drain_results(admin);
rc = mysql_query(admin, "SET admin-restapi_enabled='1'");
if (rc) diag("SET admin-restapi_enabled failed: %s", mysql_error(admin));
if (rc) {
diag("SET admin-restapi_enabled failed: %s", mysql_error(admin));
return EXIT_FAILURE;
}
drain_results(admin);
rc = mysql_query(admin, "SET admin-web_enabled='1'");
if (rc) diag("SET admin-web_enabled failed: %s", mysql_error(admin));
if (rc) {
diag("SET admin-web_enabled failed: %s", mysql_error(admin));
return EXIT_FAILURE;
}
drain_results(admin);
rc = mysql_query(admin, "LOAD TSDB VARIABLES TO RUNTIME");
if (rc) diag("LOAD TSDB VARIABLES failed: %s", mysql_error(admin));
if (rc) {
diag("LOAD TSDB VARIABLES failed: %s", mysql_error(admin));
return EXIT_FAILURE;
}
drain_results(admin);
rc = mysql_query(admin, "LOAD ADMIN VARIABLES TO RUNTIME");
if (rc) diag("LOAD ADMIN VARIABLES failed: %s", mysql_error(admin));
if (rc) {
diag("LOAD ADMIN VARIABLES failed: %s", mysql_error(admin));
return EXIT_FAILURE;
}
drain_results(admin);
// Verify the settings were applied
@ -154,9 +172,9 @@ int main() {
diag("Waiting for initialization and data collection (7s)...");
sleep(7);
// Use the same host as admin connection for HTTP endpoints
string base_url = string("https://") + cl.host + ":6080";
string rest_url = string("http://") + cl.host + ":6070";
// Use admin interface host for HTTP endpoints
string base_url = string("https://") + cl.admin_host + ":6080";
string rest_url = string("http://") + cl.admin_host + ":6070";
diag("Web dashboard URL: %s", base_url.c_str());
diag("REST API URL: %s", rest_url.c_str());
@ -186,7 +204,7 @@ int main() {
diag("Testing GET /api/tsdb/status");
response.clear();
string auth_creds = string(cl.admin_username) + ":" + string(cl.admin_password);
diag("Using authentication: %s", auth_creds.c_str());
diag("Using authentication with username: %s", cl.admin_username);
http_rc = http_get((rest_url + "/api/tsdb/status").c_str(), response, auth_creds.c_str());
ok(http_rc == 200, "API /api/tsdb/status returns 200 (got %ld)", http_rc);
if (http_rc != 200) {

@ -247,12 +247,16 @@ int main() {
// Also check for our specific test metric
string test_metric_count;
fetch_single_string(admin,
bool test_metric_ok = fetch_single_string(admin,
"SELECT COUNT(*) FROM stats_history.tsdb_metrics_hour WHERE metric_name='test_downsample_metric'",
test_metric_count);
diag("Test metric rows in tsdb_metrics_hour: %s", test_metric_count.c_str());
ok(ds_ok && atoi(ds_count.c_str()) > 0, "Downsample produced rows in tsdb_metrics_hour (count: %s)", ds_count.c_str());
ok(
ds_ok && test_metric_ok && atoi(test_metric_count.c_str()) > 0,
"Downsample produced rows for test_downsample_metric (metric rows: %s, total rows: %s)",
test_metric_count.c_str(), ds_count.c_str()
);
// Cleanup: remove test data
diag("Cleaning up test data...");

Loading…
Cancel
Save