Skip to content

[Server] Keep tests' files out of the checkout, and fail CI when they are not - #2334

Merged
yili-db merged 5 commits into
unitycatalog:mainfrom
shba24:fix-child-jvm-jacoco-file
Nov 23, 2026
Merged

yili-db merged 5 commits into
unitycatalog:mainfrom
shba24:fix-child-jvm-jacoco-file

Conversation

@shba24

@shba24 shba24 commented Nov 22, 2026 •

Copy link
Copy Markdown
Collaborator

PR Checklist

  • A description of the changes is added to the description of this PR.
  • If there is a related issue, make sure it is linked to this PR.
  • If you've fixed a bug or added code that should be tested, add tests!
  • If you've added or modified a feature, documentation in docs is updated

Description of changes

After the tests run, server/jacoco.exec and examples/sample-database/jacoco.exec show up in git status as untracked files. They come from two tests that start a child JVM: HibernateConfiguratorTest.refusesASchemaActionSetAsASystemProperty (added in #2117) and SampleDatabaseTest.ignoresTheDeploymentEnvironmentVariables (added in #2116). Each starts a child JVM with the test's classpath, which holds the coverage-instrumented classes, but not the -Djacoco-agent.destfile option that sbt-jacoco gives the test JVM. Without it, JaCoCo writes its default jacoco.exec to the working directory.

Both tests now pass the option on to the child when it is set, so the child's coverage goes into the module's target/jacoco/data/jacoco.exec with the rest. The other tests that start processes are fine: the upgrade tests' OldServer runs a released jar without coverage classes, and the start-uc-server tests use a fake java.

So it does not come back, the unit test action now records git status before the coverage tests and fails if they create or change a file in the checkout that git does not ignore (as the Helm workflow does for helm/), and AGENTS.md's testing conventions say where tests may write.

How I checked

build/sbt "server/testOnly io.unitycatalog.server.persist.utils.HibernateConfiguratorTest":

  • On main (dcec3cf): 21 passed, then git status shows ?? server/jacoco.exec. That file lists only HibernateConfigurator and RequestContextDataProvider, the classes the child JVM loads.
  • With this change: 21 passed, git status shows no new file, and server/target/jacoco/data/jacoco.exec now holds the child's HibernateConfigurator data.

build/sbt "sampleDatabase/testOnly io.unitycatalog.server.utils.SampleDatabaseTest":

  • On main: 65 passed, then git status shows ?? examples/sample-database/jacoco.exec.
  • With this change: 65 passed, and git status shows no new file.

server/javafmtCheckAll and sampleDatabase/javafmtCheckAll pass.

dev/run-tests.py with these fixes: 237 suites, 3851 tests, 0 failed, and no file in the checkout is new or changed afterwards, so the new CI check passes on main plus this PR. The check's comparison was also run on a scratch repository: a file present before the tests passes, a new untracked file fails, and a tracked file that was clean before the tests and changed after fails.

This pull request and its description were written by Isaac.

…JVM in target

refusesASchemaActionSetAsASystemProperty starts a child JVM with the
test's classpath, which holds the coverage-instrumented classes, but
not the -Djacoco-agent.destfile option that sbt-jacoco gives the test
JVM. The child's JaCoCo runtime then writes jacoco.exec to the working
directory, and server/jacoco.exec shows up as an untracked file after
the server tests. Pass the option on when it is set.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
…target

ignoresTheDeploymentEnvironmentVariables starts a child JVM with the
test's classpath but not the test JVM's -Djacoco-agent.destfile, so
examples/sample-database/jacoco.exec showed up as an untracked file.
Pass the option on when it is set, as HibernateConfiguratorTest does.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
@shba24 shba24 changed the title [Server] Keep the coverage file of HibernateConfiguratorTest's child JVM in target [Server] Keep the coverage file of tests' child JVMs in target Nov 22, 2026
The unit test action records git status before the coverage tests and
fails if the tests created or changed a file in the checkout. AGENTS.md
says where tests may write and how a child JVM keeps its coverage file
in target.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
@shba24 shba24 changed the title [Server] Keep the coverage file of tests' child JVMs in target [Server] Keep tests' files out of the checkout, and fail CI when they are not Nov 22, 2026
@shba24
shba24 marked this pull request as draft November 22, 2026 18:27
@shba24

shba24 commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator Author

/review

@shba24

shba24 commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator Author

/review

@shba24
shba24 marked this pull request as ready for review November 22, 2026 20:11
@yili-db

yili-db commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator

/review

@yili-db yili-db left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[AI Assisted] Approve at 97ba66d.

I ran the server and sample-database coverage tests on main and on head in fresh clones. On main, server/jacoco.exec and examples/sample-database/jacoco.exec are left in the checkout and the new check fails. On head, both modules leave nothing behind and the check passes. A Spark connector suite also leaves nothing in the checkout.

Note: #2167 also adds a post-test check to .github/actions/run-uc-unit-tests/action.yml, so the two checks will need reconciling there.

@yili-db
yili-db merged commit e671ccb into unitycatalog:main Nov 23, 2026
24 checks passed
shba24 added a commit to shba24/unitycatalog that referenced this pull request Nov 24, 2026
No conflicts. Brings in ownership transfer (unitycatalog#2149), pool metrics (unitycatalog#2284)
and the check that tests leave the checkout clean (unitycatalog#2334).

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
yili-db added a commit that referenced this pull request Nov 30, 2026
…2167)

## 🥞 Stacked PR
Use this
[link](https://github.com/unitycatalog/unitycatalog/pull/2167/files) to
review incremental changes.
-
[stack/run_test_followups](#2167)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2167/files)]

---------
- Stop `BaseCredRenewITTest` from starting two servers per test
- Its own `@BeforeEach beforeEach()` called `super.setUp()` after JUnit
had already run the inherited `setUp()`, and the first server was never
closed
  - Override `setUp()` instead
- `BaseServerTest.setUp()` now fails if a server is already running, so
the pattern cannot return silently; `UnityCatalogServerTest` checks that
- Drop `REPLACE_EXISTING` from the signing-key copy, which only
tolerated the second call
- Fail CI when tests write to `etc/conf`
- A server built without its own `configurationFolder` writes its
signing keys, `certs.json` and `token.txt` there; two tests added on
`main` while #2159 was open did exactly that
- `project/scripts/check_etc_conf.sh` fails if any `etc/conf` differs
from the checkout: a new file, ignored or not, or an edited or deleted
tracked one
- `run-uc-unit-tests` runs it after the tests, next to the
clean-checkout step from #2334, which skips ignored files such as the
generated keys; `upgrade-tests.yml` runs it after the upgrade tests
- A fresh CI checkout has only tracked files there, so a local server
cannot cause a false failure
- Give `migrate/TestServer`, used by `RealUpgradeTest` and
`SchemaGateTest`, its own `configurationFolder`
- Give the three server builds in the OPA tests of
`UnityCatalogServerTest` (#2078) their own `configurationFolder`; CI
failed this check on them
- `project/tests/test_check_etc_conf.py`, run in the "Build Test" job,
checks the script in a throwaway git repository, including a deleted
tracked file
- `dev/run-tests.py` watches every `etc/conf` locally, at the root and
in modules up to two levels deep, including hidden files and
subdirectories; `test_run_tests.py` checks it

Tested with `dev/run-tests.py` on `main` at #2357: 240 suites, 3971
tests, 0 failures; afterwards the checkout was clean and
`check_etc_conf.sh` found nothing.
`RealUpgradeTest.upgradesAndKeepsTheData` passed with
`UC_TEST_UPGRADES=true`. With the old `beforeEach()` pattern restored,
every `AwsCredRenewITTest` test fails with the new `setUp()` message.

The test timeout changes that were here moved to #2330.

Signed-off-by: Yi Li <[email protected]>

**PR Checklist**

- [x] A description of the changes is added to the description of this
PR.
- [ ] If there is a related issue, make sure it is linked to this PR.
- [x] If you've fixed a bug or added code that should be tested, add
tests!
- [ ] If you've added or modified a feature, documentation in `docs` is
updated

**Description of changes**

<!-- Please state what you've changed and how it might affect the users.
-->

This pull request and its description were written by Isaac.

---------

Signed-off-by: Yi Li <[email protected]>
Co-authored-by: Isaac <[email protected]>
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