Skip to content

Commit 3aec164

Browse files
gopalldbclaude
andauthored
Fix metadata thrift recordings (#1236)
## Summary - Re-recorded WireMock stubs for 7 metadata tests that had invalid 403 "RBAC: access denied" recordings (GetTypeInfo, GetProcedures, GetProcedureColumns, GetFunctions, GetExportedKeys, GetVersionColumns, GetAttributes) - Added new Thrift recordings for GetIndexInfo test - Fixed flaky `testSetAndGetSchema` and `testSetAndGetCatalog` in ConnectionIntegrationTests by adding `safeClose()` helper that skips `connection.close()` in THRIFT + REPLAY mode ## Root Cause **8 Metadata test failures:** The original Thrift recordings were captured with an expired/unauthorized token, resulting in 403 responses being recorded as WireMock stubs. When replayed in CI, the 403 caused `getValidJDBCConnection()` to throw, and the `setUp()` method's catch block silently swallowed the error, leaving `connection=null` which NPE'd in each test. **Flaky ConnectionIntegrationTests:** `testSetAndGetSchema` and `testSetAndGetCatalog` execute statements (SET CATALOG, USE SCHEMA) which generate `CloseOperation` Thrift calls during `conn.close()`. WireMock uses exact binary body matching (`binaryEqualTo`) for these stubs, but stub registration order from disk is non-deterministic. When stubs load in the wrong order, WireMock returns 404 for CloseOperation calls. This is the same known issue that all other fake service test classes already work around by skipping `connection.close()` in THRIFT + REPLAY mode. ## Test plan - [x] All 7 re-recorded metadata tests verified to pass in THRIFT_SERVER + REPLAY mode - [x] Full MetadataIntegrationTests suite (46 tests) passes with 0 failures - [x] ConnectionIntegrationTests (17 tests) passes with 0 failures, 3 consecutive runs - [x] All 5 test classes (150 tests total) pass 3/3 consecutive runs in both THRIFT and SQL_EXEC replay modes - [x] No regressions in other existing fake service test classes 🤖 Generated with [Claude Code](https://claude.com/claude-code) NO_CHANGELOG=true --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 48534f8 commit 3aec164

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

src/test/java/com/databricks/jdbc/integration/fakeservice/tests/ConnectionIntegrationTests.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
import static com.databricks.jdbc.integration.IntegrationTestUtil.*;
44
import static org.junit.jupiter.api.Assertions.*;
55

6+
import com.databricks.jdbc.api.impl.DatabricksConnection;
7+
import com.databricks.jdbc.common.DatabricksClientType;
68
import com.databricks.jdbc.common.DatabricksJdbcUrlParams;
79
import com.databricks.jdbc.exception.DatabricksSQLException;
810
import com.databricks.jdbc.integration.fakeservice.AbstractFakeServiceIntegrationTests;
911
import com.databricks.jdbc.integration.fakeservice.FakeServiceConfigLoader;
12+
import com.databricks.jdbc.integration.fakeservice.FakeServiceExtension;
1013
import java.sql.*;
1114
import java.util.Properties;
1215
import org.junit.jupiter.api.Test;
@@ -94,7 +97,7 @@ void testSetAndGetCatalog() throws SQLException {
9497
conn.setCatalog(testCatalog);
9598
assertEquals(testCatalog, conn.getCatalog(), "getCatalog() should return what was set");
9699

97-
conn.close();
100+
safeClose(conn);
98101
}
99102

100103
// --- Connection properties and management tests ---
@@ -154,7 +157,7 @@ void testSetAndGetSchema() throws SQLException {
154157
conn.setSchema(testSchema);
155158
assertEquals(testSchema, conn.getSchema(), "getSchema() should return what was set");
156159

157-
conn.close();
160+
safeClose(conn);
158161
}
159162

160163
@Test
@@ -244,6 +247,23 @@ void testGetTransactionIsolation() throws SQLException {
244247
conn.close();
245248
}
246249

250+
/**
251+
* Closes the connection, but skips the close in Thrift REPLAY mode due to WireMock stub matching
252+
* issues with CloseOperation/CloseSession binary bodies.
253+
*/
254+
private void safeClose(Connection conn) throws SQLException {
255+
if (conn != null) {
256+
if (((DatabricksConnection) conn).getConnectionContext().getClientType()
257+
== DatabricksClientType.THRIFT
258+
&& getFakeServiceMode() == FakeServiceExtension.FakeServiceMode.REPLAY) {
259+
// Hacky fix
260+
// Wiremock has error in stub matching for close operation in THRIFT + REPLAY mode
261+
} else {
262+
conn.close();
263+
}
264+
}
265+
}
266+
247267
private Properties createConnectionProperties(Properties extraProps) {
248268
Properties connProps = new Properties();
249269
connProps.putAll(extraProps);

0 commit comments

Comments
 (0)