test/tap/tests: drain in-flight monitor cycle in pgsql-servers_ssl_params-t

The test samples PgSQL_Monitor_ssl_connections_OK immediately after
LOAD PGSQL SERVERS TO RUNTIME, then sleeps 5s and checks the counter
did not advance (TLSv1 pin should have broken SSL). A monitor connect
cycle scheduled with the OLD params can land AFTER ok_before is taken
but BEFORE the sleep, succeeding and falsely bumping the counter.

Poll for two consecutive equal 1s samples so ok_before is recorded
after the new config has taken effect and the counter has plateaued.
v3.0-slim-dbdeployer-images
Rene Cannao 1 month ago
parent 96c686dafa
commit 25c8fd1609

@ -499,8 +499,20 @@ static void test_monitor_uses_per_server_row(PGconn* admin) {
exec_ok(admin, q.str().c_str());
exec_ok(admin, "LOAD PGSQL SERVERS TO RUNTIME");
// Drain any monitor connect cycle scheduled with the pre-LOAD config.
// Why: the monitor thread may already be mid-cycle when LOAD runs; that
// in-flight connect was scheduled with the OLD SSL params (no TLSv1 pin)
// and will succeed and bump the counter AFTER we sample ok_before. Wait
// until two consecutive 1s samples are equal — meaning the new config
// is in effect and the counter has plateaued.
long ok_before = getMonitorValue(admin, "PgSQL_Monitor_ssl_connections_OK");
diag("With TLSv1 per-server pin, ssl OK before wait: %ld", ok_before);
for (int i = 0; i < 10; i++) {
usleep(1000000); // 1s — longer than the test's monitor connect interval
long sample = getMonitorValue(admin, "PgSQL_Monitor_ssl_connections_OK");
if (sample == ok_before) break;
ok_before = sample;
}
diag("With TLSv1 per-server pin, ssl OK before wait (post-drain): %ld", ok_before);
usleep(5000000); // 5 seconds — multiple monitor cycles

Loading…
Cancel
Save