Skip to content

Make test fixtures portable to non-Maven build layouts - #897

Open
hectorcast-db wants to merge 1 commit into
mainfrom
fix-test-fixtures-portable-path
Open

Make test fixtures portable to non-Maven build layouts#897
hectorcast-db wants to merge 1 commit into
mainfrom
fix-test-fixtures-portable-path

Conversation

@hectorcast-db

Copy link
Copy Markdown
Contributor

What

Make TestOSUtils.resource() copy a test fixture — a single file or a whole
directory subtree, preserving its path — into a writable temp directory and
return that path, instead of chmod-ing the resource in place. Route
DatabricksConfigTest.testConfigFileScopes through the same helper instead of
hardcoding a relative HOME.

Why

TestOSUtils.resource() did getResource(file)new File(path).setExecutable(true).
That only works when test resources are exploded on disk as writable files
(Maven's target/test-classes). When the SDK is built and tested outside Maven —
for example with Bazel, where resources are served from a jar or a read-only tree —
File.setExecutable returns false and the tests fail.
DatabricksConfigTest.testConfigFileScopes had the same fragility: it hardcoded
HOME to the relative path src/test/resources/testdata, which only resolves when
the working directory is the module root.

The new helper handles both file: and jar: resource URLs and preserves the
resource's path (some tests assert on substrings like
testdata/corrupt/.databrickscfg). Behavior under mvn test is unchanged.

Tests

mvn test in CI. Verified out-of-band that DefaultProfileTest,
DatabricksConfigTest, and DatabricksAuthManualTest — which previously could not
locate/execute their fixtures outside Maven's layout — pass when the suite is built
with Bazel. The change is behavior-preserving for the Maven build.

@hectorcast-db
hectorcast-db deployed to test-trigger-is August 21, 2026 10:46 — with GitHub Actions Active
@hectorcast-db
hectorcast-db deployed to test-trigger-is August 21, 2026 10:47 — with GitHub Actions Active
TestOSUtils.resource() located a fixture via getResource() and chmod-ed it in
place. That only works when test resources are exploded on disk as writable
files (Maven's target/test-classes); it fails when they are served from a jar or
a read-only tree (e.g. building the SDK with Bazel), where File.setExecutable
returns false and the test fails. DatabricksConfigTest.testConfigFileScopes had
the same fragility, hardcoding HOME to the relative path
"src/test/resources/testdata", which only resolves from the module root.

Keep the in-place behavior when the resource is a writable file on disk, so the
returned path stays under target/test-classes and the tests' prefix-relative
path assertions (StaticEnv) still hold. Only when it cannot be chmod-ed in place
-- served from a jar or a read-only tree -- copy the resource (a single file or
a whole directory subtree, preserving its path) into a writable temp directory,
chmod the copy, and return that. Route testConfigFileScopes through the same
helper. Behavior under `mvn test` is unchanged.

Signed-off-by: Hector Castejon Diaz <hector.castejon@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
@hectorcast-db
hectorcast-db force-pushed the fix-test-fixtures-portable-path branch from 904294f to 4d8e8e6 Compare August 21, 2026 12:13
@hectorcast-db
hectorcast-db deployed to test-trigger-is August 21, 2026 12:13 — with GitHub Actions Active
@github-actions

Copy link
Copy Markdown
Contributor

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/sdk-java

Inputs:

  • PR number: 897
  • Commit SHA: 4d8e8e61474519319c921b9a2c55ed8dddcb0fdc

Checks will be approved automatically on success.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants