From 45eadce110736796a69f1cce12504f644d07430e Mon Sep 17 00:00:00 2001 From: Rahim Kanji Date: Wed, 19 Mar 2025 15:54:40 +0500 Subject: [PATCH] Fixed TAP test --- .../tests/pgsql-copy_from_stdin_session_parameter-t.cpp | 9 ++++++--- test/tap/tests/pgsql-copy_from_test-t.cpp | 5 ++++- test/tap/tests/pgsql-copy_to_test-t.cpp | 7 +++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/test/tap/tests/pgsql-copy_from_stdin_session_parameter-t.cpp b/test/tap/tests/pgsql-copy_from_stdin_session_parameter-t.cpp index 51610bcf2..2d5a54e6a 100644 --- a/test/tap/tests/pgsql-copy_from_stdin_session_parameter-t.cpp +++ b/test/tap/tests/pgsql-copy_from_stdin_session_parameter-t.cpp @@ -147,7 +147,10 @@ void copy_stdin_test(PGconn* conn, const std::string& set_val, std::fstream& f_p return; } - usleep(1000); // Wait for the query to be sent + PQconsumeInput(conn); + while (PQisBusy(conn)) { + PQconsumeInput(conn); + } ok(check_logs_for_command(f_proxysql_log, ".*\\[INFO\\].* Switching to Fast Forward mode \\(Session Type:0x06\\)"), "Session Switched to fast forward mode"); @@ -213,7 +216,7 @@ void execute_test(bool with_ssl, bool diff_conn, std::fstream& f_proxysql_log) { for (int i = 0; i < MAX_ITERATION; i++) { if (!setupTestTable(backend_conn.get())) return; - + usleep(1000); const std::string& value = setIntervalStyle(backend_conn.get(), i, f_proxysql_log); if (value.empty()) @@ -237,7 +240,7 @@ void execute_test(bool with_ssl, bool diff_conn, std::fstream& f_proxysql_log) { if (!setupTestTable(backend_conn.get())) return; - + usleep(1000); const std::string& value = setIntervalStyle(backend_conn.get(), i, f_proxysql_log); if (value.empty()) diff --git a/test/tap/tests/pgsql-copy_from_test-t.cpp b/test/tap/tests/pgsql-copy_from_test-t.cpp index a76b4eae4..2db1b0669 100644 --- a/test/tap/tests/pgsql-copy_from_test-t.cpp +++ b/test/tap/tests/pgsql-copy_from_test-t.cpp @@ -654,7 +654,10 @@ void testSTDIN_MULTISTATEMENT(PGconn* admin_conn, PGconn* conn, std::fstream& f_ return; } - usleep(1000); // Wait for the query to be sent + PQconsumeInput(conn); + while (PQisBusy(conn)) { + PQconsumeInput(conn); + } ok(check_logs_for_command(f_proxysql_log, ".*\\[INFO\\].* Switching to Fast Forward mode \\(Session Type:0x06\\)"), "Session Switched to fast forward mode"); diff --git a/test/tap/tests/pgsql-copy_to_test-t.cpp b/test/tap/tests/pgsql-copy_to_test-t.cpp index a7f677530..e2518707b 100644 --- a/test/tap/tests/pgsql-copy_to_test-t.cpp +++ b/test/tap/tests/pgsql-copy_to_test-t.cpp @@ -362,7 +362,14 @@ void testMultistatementWithCopy(PGconn* admin_conn, PGconn* conn) { if (PQsendQuery(conn, "SELECT * FROM copy_test; COPY copy_test TO STDOUT") == 0) { fprintf(stderr, "Error sending query: %s", PQerrorMessage(conn)); PQfinish(conn); + return; + } + + PQconsumeInput(conn); + while (PQisBusy(conn)) { + PQconsumeInput(conn); } + // Check first result (SELECT statement) PGresult* res = PQgetResult(conn); if (PQresultStatus(res) != PGRES_TUPLES_OK) {