-
Notifications
You must be signed in to change notification settings - Fork 3.9k
GH-46575: [C++][FlightRPC] Add Diagnostic tests #47764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
|
||
| namespace arrow::flight::sql::odbc { | ||
|
|
||
| TYPED_TEST(FlightSQLODBCTestBase, TestSQLGetDiagFieldWForConnectFailure) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment here, we can subclass the base fixture and create a specific fixture for this file.
| // Allocate an environment handle | ||
| SQLRETURN ret = SQLAllocEnv(&env); | ||
|
|
||
| EXPECT_EQ(SQL_SUCCESS, ret); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test will continue even if EXPECT_ fails. Usually these kinds of checks should be ASSERT.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be more concise to just ASSERT_EQ(SQL_SUCCESS, SQLAllocEnv(&env)) and so on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, updated the code to use ASSERT_EQ
| // Test is disabled because driver manager on Windows does not pass through SQL_NTS | ||
| // This test case can be potentially used on macOS/Linux | ||
| GTEST_SKIP(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the test name starts with DISABLED_, GTest will ignore the test automatically
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to use DISABLED_ and removed GTEST_SKIP
19da64d to
4f4bbc0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In-progress of addressing comments. The team is still working on improving the subclass logic for separate test fixture (discussion is in #47788)
| // Allocate an environment handle | ||
| SQLRETURN ret = SQLAllocEnv(&env); | ||
|
|
||
| EXPECT_EQ(SQL_SUCCESS, ret); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, updated the code to use ASSERT_EQ
| // Test is disabled because driver manager on Windows does not pass through SQL_NTS | ||
| // This test case can be potentially used on macOS/Linux | ||
| GTEST_SKIP(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to use DISABLED_ and removed GTEST_SKIP
| public: | ||
| using List = std::list<T>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| public: | |
| using List = std::list<T>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, removed using List
| template <typename T> | ||
| class ErrorsOdbcV2Test : public T { | ||
| public: | ||
| using List = std::list<T>; | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| template <typename T> | |
| class ErrorsOdbcV2Test : public T { | |
| public: | |
| using List = std::list<T>; | |
| }; | |
| template <typename T> | |
| class ErrorsOdbcV2Test : public T { | |
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
| // Free connection handle | ||
| EXPECT_EQ(SQL_SUCCESS, SQLFreeHandle(SQL_HANDLE_DBC, conn)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe consider an RAII helper to free resources in tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added RAII helper for this (ErrorsHandleTest)
| // API not implemented error from driver manager | ||
| EXPECT_EQ(std::wstring(L"IM001"), std::wstring(sql_state)); | ||
|
|
||
| EXPECT_TRUE(!std::wstring(message).empty()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EXPECT_FALSE?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup good catch, fixed
4f4bbc0 to
99d8ec6
Compare
99d8ec6 to
eddea34
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed comments
| public: | ||
| using List = std::list<T>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, removed using List
| template <typename T> | ||
| class ErrorsOdbcV2Test : public T { | ||
| public: | ||
| using List = std::list<T>; | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
| // Free connection handle | ||
| EXPECT_EQ(SQL_SUCCESS, SQLFreeHandle(SQL_HANDLE_DBC, conn)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added RAII helper for this (ErrorsHandleTest)
| // API not implemented error from driver manager | ||
| EXPECT_EQ(std::wstring(L"IM001"), std::wstring(sql_state)); | ||
|
|
||
| EXPECT_TRUE(!std::wstring(message).empty()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup good catch, fixed
| static constexpr std::string_view authorization_header = "authorization"; | ||
| static constexpr std::string_view bearer_prefix = "Bearer "; | ||
| static constexpr std::string_view test_token = "t0k3n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we keep to the naming scheme? kAuthorizationHeader etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requires SQLDriverConnect Implementation Co-authored-by: rscales <[email protected]>
* the test suite fixture is still being worked on Co-authored-by: justing-bq <[email protected]>
- rebased onto master Use RAII helper for allocating and freeing env/conn handles
eddea34 to
2768502
Compare
### Rationale for this change ODBC needs to provide diagnostic information so users can debug the error ### What changes are included in this PR? - Implementation of SQLGetDiagField and SQLGetDiagRec Tests are included in separate PR (see #47764) ### Are these changes tested? Tests will be in a separate PR (see #47764). Other APIs depend on SQLGetDiagField and SQLGetDiagRec to get error reporting functionality, and tests for SQLGetDiagField and SQLGetDiagRec depend on other APIs for creating errors, as these diagnostic APIs alone do not initiate any errors. Changes tested locally ### Are there any user-facing changes? No * GitHub Issue: #46575 Authored-by: Alina (Xi) Li <[email protected]> Signed-off-by: Sutou Kouhei <[email protected]>
Rationale for this change
Putting the tests for diagnostics in a separate PR from #47763, because non-diagnostic ODBC APIs are required to get diagnostics.
What changes are included in this PR?
Are these changes tested?
PR depends on #47971 for tests to work.
Tested locally.
Are there any user-facing changes?
No