Skip to content

GH-49783: [C++][FlightRPC][ODBC] Reuse connections across test suite#49784

Open
justing-bq wants to merge 1 commit intoapache:mainfrom
Bit-Quill:gh-49783-reuse-test-connections
Open

GH-49783: [C++][FlightRPC][ODBC] Reuse connections across test suite#49784
justing-bq wants to merge 1 commit intoapache:mainfrom
Bit-Quill:gh-49783-reuse-test-connections

Conversation

@justing-bq
Copy link
Copy Markdown
Contributor

@justing-bq justing-bq commented Apr 17, 2026

Rationale for this change

We avoid crashing tests on Linux if we minimize the number of connect/disconnect attempts. So now we are reusing the same connection as much as possible throughout the tests.

What changes are included in this PR?

All our necessary connections happen during global SetUp() and then they get disconnected during global TearDown().
Test Fixture SetUp logic is now about updating pointers to the correct environment, connection, and statement handles for those tests.

Are these changes tested?

Yes.

Are there any user-facing changes?

No.

Co-Authored-By: Alina (Xi) Li <96995091+alinaliBQ@users.noreply.github.com>
@justing-bq justing-bq requested a review from lidavidm as a code owner April 17, 2026 19:57
@github-actions
Copy link
Copy Markdown

⚠️ GitHub issue #49783 has been automatically assigned in GitHub to PR creator.

@justing-bq
Copy link
Copy Markdown
Contributor Author

@lidavidm @kou
Please take a look when you have a chance.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the Flight SQL ODBC C++ test suite to reuse ODBC environment/connection handles across the entire test run (global SetUp/TearDown), reducing connect/disconnect churn that can crash tests on Linux.

Changes:

  • Introduces shared handle pools (remote/mock, ODBC v2/v3, plus “non-connection” handles) and rewires fixtures to point env/conn/stmt at the appropriate shared handles.
  • Moves remote/mock connection establishment into a global ::testing::Environment and updates helper APIs (Connect, Disconnect, etc.) to accept explicit handle references.
  • Adjusts a few tests to use the new connection helper signature and adds a Windows-only CMake source tweak.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
cpp/src/arrow/flight/sql/odbc/tests/odbc_test_suite.h Adds shared handle structs/pools and updates test base APIs to take explicit handles.
cpp/src/arrow/flight/sql/odbc/tests/odbc_test_suite.cc Implements a global test environment that connects once and reuses handles across suites/tests.
cpp/src/arrow/flight/sql/odbc/tests/connection_info_test.cc Updates handle-based tests to call ConnectWithString(..., conn).
cpp/src/arrow/flight/sql/odbc/tests/connection_attr_test.cc Allocates a local env/conn for a DM-only attribute test and uses new helpers.
cpp/src/arrow/flight/sql/odbc/tests/CMakeLists.txt Adds a Windows-only extra source intended to address a Windows crash.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +45 to +48
# Resolve segmentation fault error on Windows platform due to Arrow Compute Library Initialization
if(WIN32)
list(APPEND ARROW_FLIGHT_SQL_ODBC_TEST_SRCS ../../../../compute/test_env.cc)
endif()
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding ../../../../compute/test_env.cc introduces a second main() (see cpp/src/arrow/compute/test_env.cc), which will likely cause a linker error (multiple definition of main) or unintentionally override the test runner entrypoint on Windows. Instead, initialize Arrow Compute from an existing global test environment (e.g., call arrow::compute::Initialize() inside OdbcTestEnvironment::SetUp() under #ifdef _WIN32) or add a small helper source that registers the compute environment but does not define main().

Suggested change
# Resolve segmentation fault error on Windows platform due to Arrow Compute Library Initialization
if(WIN32)
list(APPEND ARROW_FLIGHT_SQL_ODBC_TEST_SRCS ../../../../compute/test_env.cc)
endif()
# Do not add ../../../../compute/test_env.cc here: it defines its own main(),
# which would conflict with this test target's runner on Windows. Any Arrow
# Compute initialization must be performed from the existing ODBC test
# environment or from a helper source that does not define main().

Copilot uses AI. Check for mistakes.
inline OdbcHandles mock_odbcv2_handles;
inline OdbcHandles mock_non_connection_handles;

// These handles are meant to point to to the relevant handle above
Copy link

Copilot AI Apr 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in comment: "point to to" -> "point to".

Suggested change
// These handles are meant to point to to the relevant handle above
// These handles are meant to point to the relevant handle above

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants