Skip to content

Conversation

@alinaliBQ
Copy link

@alinaliBQ alinaliBQ commented Jun 6, 2025

Enable mock test.
Goal:

  • run applicable tests once using mock server and once using remote server.

Inside the mock tests (that use FlightSQLODBCMockTestBase), a mock in-memory SQLite server at localhost:<port> is set up before every test case and teardown afterwards. <port> is any available port. The port value is saved to get the connection string for the mock server.

graph TD;
    A[FlightSQLODBCTestBase]-->B[FlightSQLODBCMockTestBase];
    A-->C[FlightSQLODBCRemoteTestBase];
Loading

If we want a test to be run with remote server, use TEST_F(FlightSQLODBCRemoteTestBase, <TestName>). In general, tests that run with mock server should also be runnable with remote server.

If environment variable ARROW_FLIGHT_SQL_ODBC_CONN is not set, the remote server tests are automatically skipped. This makes running tests with only mock server easier.

@alinaliBQ alinaliBQ force-pushed the enable-mock-test branch 3 times, most recently from b375245 to b58ed06 Compare June 6, 2025 23:58
alinaliBQ added 2 commits June 9, 2025 14:26
So the tests can be skipped when `TEST_CONNECT_STR` is not set.
Comment on lines 964 to -981

EXPECT_GT(message_length, 200);
Copy link
Author

Choose a reason for hiding this comment

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

The error message from mock server is only 129 characters, so I adjusted this check

Copy link
Author

Choose a reason for hiding this comment

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

We want to enable builds on clang64 and MinGW too. The driver should work on any Win32 platform

Comment on lines +203 to +204
Copy link
Author

Choose a reason for hiding this comment

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

We need to use this to indicate where we're getting the function when using TYPED_TEST

Comment on lines 78 to 85
Copy link
Author

Choose a reason for hiding this comment

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

Copy link

Choose a reason for hiding this comment

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

The ServerAuthHandler is sort of deprecated. This was for an older implementation of stateful authentication in Flight.

We should instead use a Server middleware to authenticate the token. That would intercept the headers and let you view the token header. This should run with every request (as it is stateless authentication). There might be one already written for this.

Copy link
Author

Choose a reason for hiding this comment

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

I didn't find an existing server that takes in a token as authentication but I did find middleware that does a username/password authentication check first, and then does a header token check (cpp/src/arrow/flight/flight_test.cc#L931-L932). Based on this, I wrote the mock server middleware to do just 1 layer of token check

Comment on lines 151 to 164
Copy link
Author

Choose a reason for hiding this comment

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

Mock server setup and teardown is based on cpp/src/arrow/flight/sql/server_test.cc

@alinaliBQ alinaliBQ force-pushed the enable-mock-test branch 2 times, most recently from 493b2c3 to 2620adf Compare June 10, 2025 18:41
@alinaliBQ alinaliBQ marked this pull request as ready for review June 10, 2025 19:01
@alinaliBQ alinaliBQ requested a review from jduo June 11, 2025 17:37
@alinaliBQ alinaliBQ merged commit 8853731 into apache-odbc Jun 12, 2025
22 of 24 checks passed
alinaliBQ added a commit that referenced this pull request Jun 17, 2025
* Add todo for noauth validation

* mock server with token auth

Add tests

* run same test with both modes

* Enable ODBC tests in workflow

* Switch current test cases to use FlightSQLODBCTestBase

So the tests can be skipped when `TEST_CONNECT_STR` is not set.

* Change tests to run on both mock and remote modes

Wrap usage of TEST_CONNECT_STR where possible

* Rename test fixtures and make connection string functions virtual

* Fix lint issue

* Attempt to enable ODBC build on Windows platforms

* Attempt to fix clang64 and MinGW errors

* Attempt to register ODBC

* Address James' comments

Use constant string for token

* use ServerMiddleware to validate token
@alinaliBQ alinaliBQ deleted the enable-mock-test branch June 17, 2025 22:10
alinaliBQ added a commit that referenced this pull request Jul 31, 2025
* Add todo for noauth validation

* mock server with token auth

Add tests

* run same test with both modes

* Enable ODBC tests in workflow

* Switch current test cases to use FlightSQLODBCTestBase

So the tests can be skipped when `TEST_CONNECT_STR` is not set.

* Change tests to run on both mock and remote modes

Wrap usage of TEST_CONNECT_STR where possible

* Rename test fixtures and make connection string functions virtual

* Fix lint issue

* Attempt to enable ODBC build on Windows platforms

* Attempt to fix clang64 and MinGW errors

* Attempt to register ODBC

* Address James' comments

Use constant string for token

* use ServerMiddleware to validate token
alinaliBQ added a commit that referenced this pull request Aug 20, 2025
* Add todo for noauth validation

* mock server with token auth

Add tests

* run same test with both modes

* Enable ODBC tests in workflow

* Switch current test cases to use FlightSQLODBCTestBase

So the tests can be skipped when `TEST_CONNECT_STR` is not set.

* Change tests to run on both mock and remote modes

Wrap usage of TEST_CONNECT_STR where possible

* Rename test fixtures and make connection string functions virtual

* Fix lint issue

* Attempt to enable ODBC build on Windows platforms

* Attempt to fix clang64 and MinGW errors

* Attempt to register ODBC

* Address James' comments

Use constant string for token

* use ServerMiddleware to validate token
alinaliBQ added a commit that referenced this pull request Aug 26, 2025
* Add todo for noauth validation

* mock server with token auth

Add tests

* run same test with both modes

* Enable ODBC tests in workflow

* Switch current test cases to use FlightSQLODBCTestBase

So the tests can be skipped when `TEST_CONNECT_STR` is not set.

* Change tests to run on both mock and remote modes

Wrap usage of TEST_CONNECT_STR where possible

* Rename test fixtures and make connection string functions virtual

* Fix lint issue

* Attempt to enable ODBC build on Windows platforms

* Attempt to fix clang64 and MinGW errors

* Attempt to register ODBC

* Address James' comments

Use constant string for token

* use ServerMiddleware to validate token
alinaliBQ added a commit that referenced this pull request Sep 9, 2025
* Add todo for noauth validation

* mock server with token auth

Add tests

* run same test with both modes

* Enable ODBC tests in workflow

* Switch current test cases to use FlightSQLODBCTestBase

So the tests can be skipped when `TEST_CONNECT_STR` is not set.

* Change tests to run on both mock and remote modes

Wrap usage of TEST_CONNECT_STR where possible

* Rename test fixtures and make connection string functions virtual

* Fix lint issue

* Attempt to enable ODBC build on Windows platforms

* Attempt to fix clang64 and MinGW errors

* Attempt to register ODBC

* Address James' comments

Use constant string for token

* use ServerMiddleware to validate token
alinaliBQ added a commit that referenced this pull request Sep 25, 2025
* Add todo for noauth validation

* mock server with token auth

Add tests

* run same test with both modes

* Enable ODBC tests in workflow

* Switch current test cases to use FlightSQLODBCTestBase

So the tests can be skipped when `TEST_CONNECT_STR` is not set.

* Change tests to run on both mock and remote modes

Wrap usage of TEST_CONNECT_STR where possible

* Rename test fixtures and make connection string functions virtual

* Fix lint issue

* Attempt to enable ODBC build on Windows platforms

* Attempt to fix clang64 and MinGW errors

* Attempt to register ODBC

* Address James' comments

Use constant string for token

* use ServerMiddleware to validate token
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants