fix(test/tap): revert two semantic regressions from cleanup commits

Two recent "cleanup" commits on this branch silently changed test behavior
and caused the tests to fail under myrun2.

1) kill_connection2-t.cpp (regressed in 3f0cd6a0c):
   The "cleanup - replace NULL with nullptr, convert loops to range-based"
   commit flipped one assertion from ok(rc == 0, ...) to ok(rc != 0, ...)
   on the first DO 1 batch after a 12s sleep. With
   mysql-max_transaction_time=17000 (17s), the connection is still alive
   at 12s by design — ProxySQL only kills it at ~18s. The original test
   correctly expected rc == 0 there; the second DO 1 batch (after +12s =
   24s total) continues to correctly expect rc != 0.

2) max_connections_ff-t.cpp (regressed in da655099e):
   The "static analysis narrowing conversions" commit introduced an
   integer overflow by wrapping a chrono::nanoseconds count in
   static_cast<int>(). For the 8000ms test the elapsed time is ~8e9 ns,
   which overflows int32 (max ~2.147e9) and wraps negative, producing
   "Waited: -0.589502" and a failed assertion. The 2000ms test happened
   to fit under 2.147e9 ns and kept passing, hiding the bug.
   Use static_cast<double> for the nanoseconds count, and drop the
   unnecessary int casts on connect_timeout / poll_timeout — those are
   already long, so long / 1000.0 is a valid double.
lint-tap-tests-static-analysis
Rene Cannao 1 month ago
parent 3babaada88
commit 13a43e2ffe

@ -201,7 +201,7 @@ int main(int argc, char** argv) {
for (auto& conn : conns) {
MYSQL * mysql = conn;
int rc = run_q(mysql, "DO 1");
ok(rc != 0, (rc == 0 ? "Connection still alive" : "Connection killed"));
ok(rc == 0, (rc == 0 ? "Connection still alive" : "Connection killed"));
}
diag("Sleeping for 12 seconds");

@ -408,13 +408,13 @@ int test_ff_sess_exceeds_max_conns(const CommandLine& cl, MYSQL* proxy_admin, lo
hrc::time_point end = hrc::now();
duration = end - start;
double duration_s = static_cast<int>(duration.count()) / pow(10,9);
double duration_s = static_cast<double>(duration.count()) / pow(10,9);
diag("Query completed - Error: %d, ErrMsg: %s", m_errno, m_error);
diag("Time waited: %lf seconds", duration_s);
const double srv_conn_to_s = static_cast<int>(connect_timeout) / 1000.0;
const double poll_to_s = static_cast<int>(poll_timeout) / 1000.0;
const double srv_conn_to_s = connect_timeout / 1000.0;
const double poll_to_s = poll_timeout / 1000.0;
const double grace = 500 / 1000.0;
ok(

Loading…
Cancel
Save