BoxLang icon indicating copy to clipboard operation
BoxLang copied to clipboard

Tests - Drop OLD committed bx-derby; install bx-derby upon build

Open michaelborn opened this issue 4 months ago • 7 comments

Description

The BoxLang Core repo relies on the bx-derby module to provide a packaged version of Apache Derby for most JDBC tests. This bx-derby version has previously been committed to the repository, but this causes numerous issues:

  1. The committed bx-derby version is old and out of date
  2. We are not testing updated versions of bx-derby

Hence, this PR updates the gradle build to install bx-derby during test compilation. The bx-derby module is then loaded into the boxlang runtime via a custom function in BaseJDBCTest.java.

Note we have special treatment here for bx-derby as it is the only DB driver required to run JDBC tests. The MySQL tests, MSSQL tests, etc. all use @EnableIf() to auto-disable if the module is present; whereas the vast majority JDBC tests rely on apache derby and do not use @EnableIf().

Checklist

  • [X] My code follows the style guidelines of this project cfformat
  • [X] I have commented my code, particularly in hard-to-understand areas
  • [X] New and existing unit tests pass locally with my changes

michaelborn avatar Oct 12 '25 02:10 michaelborn

Feedback left in Slack. Also, please resolve any co-pilot comments above which are no longer relevant.

bdw429s avatar Oct 13 '25 17:10 bdw429s

The dump failure can be resolved by rebasing with dev. There are still other failures, however.

bdw429s avatar Oct 20 '25 20:10 bdw429s

I rebased against development and dropped all custom derby logic from the build.gradle. Seeing if tests pass.

michaelborn avatar Oct 21 '25 20:10 michaelborn

@michaelborn status on this?

lmajano avatar Nov 01 '25 13:11 lmajano

Ok, I'm stuck now on the setUp() and teardown methods in BaseJDBCTest. Both these methods expect a derby database to be available:

ortus.boxlang.runtime.types.exceptions.BoxRuntimeException: Unable to create datasource connection to URL [jdbc:derby:memory:0f0ba54a-4126-4547-99d0-0638b0c4d3d0;create=true] : Failed to get driver instance for jdbcUrl=jdbc:derby:memory:0f0ba54a-4126-4547-99d0-0638b0c4d3d0;create=true
	at app//ortus.boxlang.runtime.jdbc.DataSource.<init>(DataSource.java:94)
	at app//ortus.boxlang.runtime.jdbc.DataSource.fromStruct(DataSource.java:119)
	at app//ortus.boxlang.runtime.jdbc.DataSource.fromStruct(DataSource.java:107)
	at app//tools.JDBCTestUtils.constructTestDataSource(JDBCTestUtils.java:216)
	at app//ortus.boxlang.runtime.bifs.global.jdbc.BaseJDBCTest.setUp(BaseJDBCTest.java:39)

Needs some thought on a path forward.

https://github.com/ortus-boxlang/BoxLang/blob/f5c7caf6d0f50168023935cbea4f8ca5efa03131/src/test/java/ortus/boxlang/runtime/bifs/global/jdbc/BaseJDBCTest.java#L39

michaelborn avatar Nov 07 '25 22:11 michaelborn

Ready for review and merge, as long as this CI run passes with bx-derby installed.

michaelborn avatar Nov 08 '25 03:11 michaelborn

Stuck on these test failures:

🧪 - src/test/java/ortus/boxlang/runtime/components/jdbc/DBInfoTest.java | ortus.boxlang.runtime.types.exceptions.DatabaseException: Unable to read foreign key info
     🧪 - src/test/java/ortus/boxlang/runtime/components/jdbc/DBInfoTest.java | ortus.boxlang.runtime.types.exceptions.DatabaseException: Unable to read foreignkeys metadata
     🧪 - src/test/java/ortus/boxlang/runtime/components/jdbc/DBInfoTest.java | org.opentest4j.AssertionFailedError: Unexpected exception thrown: ortus.boxlang.runtime.types.exceptions.DatabaseException: No current connection.
     🧪 - src/test/java/ortus/boxlang/runtime/components/jdbc/DBInfoTest.java | org.opentest4j.AssertionFailedError: Unexpected exception thrown: java.lang.IllegalStateException: Can't overwrite cause with java.sql.SQLTransientConnectionException: HikariPool-11 - Connection is not available, request timed out after 5000ms (total=13, active=13, idle=0, waiting=0)
     🧪 - src/test/java/ortus/boxlang/runtime/components/jdbc/DBInfoTest.java | org.opentest4j.AssertionFailedError: Unexpected exception thrown: java.lang.IllegalStateException: Can't overwrite cause with java.sql.SQLTransientConnectionException: HikariPool-11 - Connection is not available, request timed out after 5000ms (total=13, active=13, idle=0, waiting=0)
     🧪 - src/test/java/ortus/boxlang/runtime/components/jdbc/DBInfoTest.java | org.opentest4j.AssertionFailedError: Unexpected exception thrown: java.lang.IllegalStateException: Can't overwrite cause with java.sql.SQLTransientConnectionException: HikariPool-11 - Connection is not available, request timed out after 5000ms (total=13, active=13, idle=0, waiting=0)
     🧪 - src/test/java/ortus/boxlang/runtime/components/jdbc/DBInfoTest.java | org.opentest4j.AssertionFailedError: Unexpected exception thrown: java.lang.IllegalStateException: Can't overwrite cause with java.sql.SQLTransientConnectionException: HikariPool-11 - Connection is not available, request timed out after 5000ms (total=13, active=13, idle=0, waiting=0)
     🧪 - src/test/java/ortus/boxlang/runtime/components/jdbc/DBInfoTest.java | java.lang.IllegalStateException: Can't overwrite cause with java.sql.SQLTransientConnectionException: HikariPool-11 - Connection is not available, request timed out after 5000ms (total=13, active=13, idle=0, waiting=0)
     🧪 - src/test/java/ortus/boxlang/runtime/services/DataSourceServiceTest.java | expected to be true
     🧪 - src/test/java/ortus/boxlang/runtime/services/DataSourceServiceTest.java | expected to be true
     🧪 - src/test/java/ortus/boxlang/runtime/services/DataSourceServiceTest.java | value of: getNames().asList().onlyElement()
     🧪 - src/test/java/ortus/boxlang/runtime/services/DataSourceServiceTest.java | expected instance of: ortus.boxlang.runtime.jdbc.DataSource

michaelborn avatar Nov 10 '25 19:11 michaelborn