Skip to content

[Server] Keep test servers out of etc/conf and speed up Spark tests - #2159

Merged
yili-db merged 2 commits into
unitycatalog:mainfrom
yili-db:stack/run_test_fix
Nov 11, 2026
Merged

yili-db merged 2 commits into
unitycatalog:mainfrom
yili-db:stack/run_test_fix

Conversation

@yili-db

@yili-db yili-db commented Nov 9, 2026 •

Copy link
Copy Markdown
Collaborator

🥞 Stacked PR

Use this link to review incremental changes.


  • Add UnityCatalogServer.Builder.configurationFolder(Path), defaulting to etc/conf
    • Building a server rewrote etc/conf/certs.json and token.txt in place, shared by all tests
    • Only the signing keys, certs.json and token.txt move; server.properties, hibernate.properties and the log4j configuration are still read from etc/conf
  • Give each BaseServerTest its own @TempDir configurationFolder
    • Signing keys are generated once per JVM and copied in
    • Tests that sign tokens or read token.txt use that folder
    • UnityCatalogServerTest checks that the server writes certs.json and token.txt there
  • Add test-only Spark settings to the spark project
    • spark.databricks.delta.snapshotPartitions=2: Delta's default of 50 snapshot partitions dominates small test tables; cuts the slowest Delta suites by a fifth to a third
    • spark.ui.enabled=false and spark.ui.showConsoleProgress=false: no web UI port per Spark session and no progress bars in the test output

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

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

This pull request and its description were written by Isaac.

- Add `UnityCatalogServer.Builder.configurationFolder(Path)`, defaulting to `etc/conf`
  - Server starts rewrote `etc/conf/certs.json` and `token.txt` in place, shared by all tests
- Give each `BaseServerTest` its own `@TempDir` `configurationFolder`
  - Signing keys are generated once per JVM and copied in
  - Tests that sign tokens or read `token.txt` use that folder
- Add test-only Spark settings to the `spark` project
  - Spark UI off, `spark.databricks.delta.snapshotPartitions=2`
  - Cuts the slowest Delta suites by about a third

Signed-off-by: Yi Li <[email protected]>
@yili-db
yili-db marked this pull request as ready for review November 9, 2026 22:23
@yili-db

yili-db commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator Author

/review

@timothyw553 timothyw553 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.

LGTM. Two small nits and the approval remains after addressing.

setDefaults(unityCatalogServerBuilder);
this.shutdownTimeout = unityCatalogServerBuilder.serverProperties.getShutdownTimeout();
Path configurationFolder = Path.of("etc", "conf");
Path configurationFolder = unityCatalogServerBuilder.configurationFolder;

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.

nit: missing direct test for the new output folder


/**
* Sets the folder holding the signing keys, which the server creates if missing, and the {@code
* certs.json} and {@code token.txt} it writes on every start. Defaults to {@code etc/conf};

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.

nit: not during every start() - during construction. Calling start() again on the same server does not rewrite them.

Signed-off-by: Yi Li <[email protected]>
@yili-db
yili-db requested a review from timothyw553 November 9, 2026 23:37

@timothyw553 timothyw553 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.

LGTM.

@shba24 shba24 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.

Thanks Yi, this looks good to me; nothing blocks. One small nit inline. I also checked the REPLACE_EXISTING comment: without it, all 6 AwsCredRenewITTest tests fail with FileAlreadyExistsException, so it's needed.


@Test
public void startFailsWhenThePortIsTaken() throws Exception {
// The server setUp() built writes certs.json and token.txt to configurationFolder, next to the

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.

Nit (not a blocker): these configurationFolder checks and the null check aren't about the port, so if one fails the report names startFailsWhenThePortIsTaken. How about a separate method in this class, e.g. serverWritesCertsAndTokenToConfigurationFolder? Feel free to take or skip.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

[AI Assisted] Thanks! I folded them in on purpose: every test method here starts its own server in setUp(), so a separate method would add one more server start just for a few assertions on the server setUp() already started. The comment above the checks says what they verify, so a failure there should still be easy to place. Happy to split it if you feel strongly.

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.

Makes sense, saving a server start is worth it. Fine as is, thanks!

@yili-db

yili-db commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator Author

[AI Assisted] On the AI review note about the Spark test settings: I timed each one on LocalDeltaManagedTableReadWriteTest.

Settings Time
None of the four 168 s
All four 136 s
Without spark.sql.sources.parallelPartitionDiscovery.parallelism 136 s
Only spark.databricks.delta.snapshotPartitions=2 137 s

So snapshotPartitions=2 gives the whole gain, and I removed parallelPartitionDiscovery.parallelism. Spark only reads it when a scan lists more paths than spark.sql.sources.parallelPartitionDiscovery.threshold (32 by default), and these test tables are far smaller, so it had nothing to do here. The two UI settings stay for reasons other than speed: no web UI port per Spark session and no progress bars in the test output. build.sbt now says why for each setting.

@shba24 shba24 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.

LGTM, approving. The full suite also passes on top of this in #2160 (212 suites, 3152 tests, 0 failed through dev/run-tests.py), which runs 16 server JVMs at once, so the per-test configurationFolder holds up under parallel runs.

@yili-db
yili-db merged commit 303f05f into unitycatalog:main Nov 11, 2026
19 checks passed
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.

3 participants