Fix GaussDB Compatibility and State Pollution Issues in Test Suite #7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This pull request addresses multiple issues in the test suite to improve compatibility with GaussDB and fix state pollution in the
test_copy_from_leaks
test. The changes include fixes for invalid SQL statements, unsupported features in GaussDB, and improvements to test reliability by ensuring proper transaction commits. Additionally, the test suite has been updated to handle new authentication error messages and improve error message parsing using regex.Changes Made
GaussDB Compatibility:
SELECT
queries with no columns to prevent errors in GaussDB.NOTIFY
statements andSCROLL CURSOR
.sample_binary_str
in_test_copy.py
to ensure compatibility with GaussDB'sCOPY BINARY
format.State Pollution Fix:
conn.commit()
after table drop and create operations intest_copy_from_leaks
(both synchronous and asynchronous versions) to prevent state pollution during multiple iterations of the test. This resolves inconsistenttimedelta
values causing assertion failures inFormat.TEXT
tests.Test Assertion Improvements:
test_generators.py
.test_errors.py
to improve robustness.Test Suite Cleanup:
SELECT
, empty table creation) that were not relevant for GaussDB.statusmessage
,test_no_prepare
).scrollable=False
by default, asSCROLL CURSOR
is not supported in GaussDB.Code Quality:
test_copy_async.py
to improve visibility into test results.Why
The test suite was failing when run against GaussDB due to several compatibility issues, including invalid SQL queries (e.g., empty
SELECT
statements, empty table definitions), unsupported features (e.g.,NOTIFY
,SCROLL CURSOR
), and state pollution intest_copy_from_leaks
causing inconsistenttimedelta
values. These failures were critical as they prevented reliable testing of thepsycopg
library on GaussDB, a key target database. Additionally, changes in authentication error messages required updates to test assertions, and direct attribute checks for error messages were brittle, necessitating a shift to regex-based parsing. This PR ensures the test suite is robust, compatible with GaussDB, and maintains consistency with PostgreSQL.Testing
pytest tests/test_copy.py --test-dsn "${DSN}" -s -v
and confirmed all tests pass, includingtest_copy_from_leaks[Format.TEXT-True]
andtest_copy_from_leaks[Format.TEXT-False]
.pytest tests/test_copy_async.py::test_copy_from_leaks --test-dsn "${DSN}" -s -v
to verify async tests remain stable.NOTIFY
,SCROLL CURSOR
, empty tables).COPY
operations.Additional Notes
COPY
operations). Thetimedelta
issues intest_copy_from_leaks
were partly due to inconsistent serialization ofinterval
types, which may also affect Hive-to-PostgreSQL data pipelines. Users exporting Hive data to CSV (as discussed in the context ofINSERT OVERWRITE DIRECTORY
) should ensureinterval
fields are cast to strings to avoid format mismatches.NOTIFY
andSCROLL CURSOR
necessitated skipping or modifying related tests. These changes do not impact PostgreSQL compatibility but ensure the test suite is robust for both databases.interval
type handling intest_copy.py
to prevent futuretimedelta
mismatches, potentially by adding a tolerance-based comparison fortimedelta
values. If Hive integration becomes a primary focus, additional tests for CSV import/export compatibility could be added.test_copy_async.py
can be extended to other tests if further issues arise. Users are encouraged to inspectresult
andwant
outputs when debugging similar issues.