JetBrains / Exposed

Kotlin SQL Framework
http://jetbrains.github.io/Exposed/
Apache License 2.0
8.1k stars 677 forks source link

test: Properly drop all leaking test table objects #1994

Closed bog-walk closed 5 months ago

bog-walk commented 5 months ago

If tests/shared/dml/SelectTests/testInList08() is run locally on all containers together via gradle task test, this results in false exceptions from certain databases: MySQL, PostgreSQL, MariaDB. The same exceptions are shown if the entire SelectTests suite is run with one of those databases:

ERROR: duplicate key value violates unique constraint "board_name_unique" Detail: Key (name)=(Board1) already exists.

java.sql.BatchUpdateException: Duplicate entry 'Board1' for key 'board_name_unique'

This occurs because that test uses 2 table resources without closing them at the end (usually handled via withTables). This can be confirmed by adding println(SchemaUtils.listTables()) to any unrelated unit test in the class and running all tests in the class. The 2 tables not included in withTables will be logged as open and active in the database.

Presumably this does not lead to failing CI because each container opens, runs tests, and closes separately 🤔

Other unit tests that don't drop tables at the end were found and edited, either by calling SchemaUtils.drop() directly or including the table in withX().

Aditional: