Skip to content

[Server] Fix a double setUp in tests, and fail CI on etc/conf writes - #2167

Merged
yili-db merged 10 commits into
unitycatalog:mainfrom
yili-db:stack/run_test_followups
Nov 30, 2026
Merged

yili-db merged 10 commits into
unitycatalog:mainfrom
yili-db:stack/run_test_followups

Conversation

@yili-db

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

Copy link
Copy Markdown
Collaborator

🥞 Stacked PR

Use this link to review incremental changes.


  • 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 [Server] Keep test servers out of etc/conf and speed up Spark tests #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 [Server] Keep tests' files out of the checkout, and fail CI when they are not #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 ([Server] Configure OPA authorization in the server #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

  • 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.

@yili-db yili-db changed the title Fix the timestamp race in BaseModelCRUDTest.testModelCRUD [Server] Fix a model test race and a double setUp, and fail CI on etc/conf writes Nov 11, 2026
@yili-db
yili-db force-pushed the stack/run_test_followups branch from 1c4e0c0 to e77672e Compare November 11, 2026 01:51
@yili-db

yili-db commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator Author

/review

run: |
# A fresh checkout has only tracked files in etc/conf. A server built without its own
# configurationFolder writes its signing keys, certs.json and token.txt there.
written=$(git ls-files --others --ignored --exclude-standard -- ':(glob)etc/conf/**' ':(glob)**/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.

(ai assisted, not 100% sure what it means in the context of this PR) --ignored selects only ignored files. It does not include all untracked files. A passing test can create etc/conf/test-output.json, and this check still passes. This defeats the PR’s stated check for files left in configuration folders.

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] It was right: with --others, --ignored narrows the list to untracked files that match a .gitignore rule, so a new, unignored file in an etc/conf passed the check. Locally it missed etc/conf/extra.json and examples/cli/etc/conf/certs.json. The check now uses git status --porcelain --ignored --untracked-files=all, as shba24 suggested, which lists both kinds and also edits to tracked files. It lives in project/scripts/check_etc_conf.sh now.

@SneakyThrows
@BeforeEach
public void setUp() {
if (unityCatalogServer != null) {

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.

the new setup guard lacks a rejection test

@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, LGTM. I checked the fixes locally at e77672e: AwsCredRenewITTest, SdkModelCRUDTest and CliModelCRUDTest pass, and with the old beforeEach() pattern restored all 6 AwsCredRenewITTest tests fail with the new setUp() ran twice message.

Two notes, neither a blocker:

  • Inline: the etc/conf check only sees gitignored files.
  • Follow-up idea: on main, server/.../migrate/TestServer.java still builds its server without a configurationFolder and reads etc/conf/token.txt. A throwaway test calling TestServer.start(...) on a local merge of this PR into main wrote all five key/token files to etc/conf, and this step then failed as intended. But TestServer only runs in RealUpgradeTest, which upgrade-tests.yml runs directly with build/sbt, so the check never sees it there. Once #2159 is in, giving TestServer its own configurationFolder (and then adding the same check to upgrade-tests.yml) would close that gap. Adding the check there first would just turn that job red.

run: |
# A fresh checkout has only tracked files in etc/conf. A server built without its own
# configurationFolder writes its signing keys, certs.json and token.txt there.
written=$(git ls-files --others --ignored --exclude-standard -- ':(glob)etc/conf/**' ':(glob)**/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 a blocker): with --others, --ignored narrows the list to untracked files that match a .gitignore rule, so an untracked file that isn't ignored passes. That's narrower than the description's "untracked or ignored file". In a scratch clone at e77672e, with etc/conf/token.txt, etc/conf/private_key.der, connectors/spark/etc/conf/certs.json, etc/conf/extra.json and connectors/hadoop/etc/conf/certs.json present, this command listed only the first three.

It catches everything the server writes today (*.der, *.txt and certs.json are ignored in every etc/conf that tests write to), so this only matters for a new file name or an etc/conf with no ignore rules. How about:

written=$(git status --porcelain --ignored --untracked-files=all -- ':(glob)**/etc/conf/**')

In the same clone that listed all five files (as !!/??), also caught an edit or delete of a tracked file such as etc/conf/server.properties, and printed nothing on a clean tree and on trees where the full suite had just run. **/etc/conf/** also matches the root etc/conf, so one pathspec is enough. Or keep the command and say "ignored file" in the description. Feel free to take or skip.

yili-db added a commit that referenced this pull request Nov 11, 2026
…#2159)

## 🥞 Stacked PR
Use this
[link](https://github.com/unitycatalog/unitycatalog/pull/2159/files) to
review incremental changes.
-
[**stack/run_test_fix**](#2159)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2159/files)]
← _this PR_
-
[stack/run_test_parallel](#2160)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2160/files/31576409812482675a7f1844c20524b78bb865cd..2b2387dae243b48cb791c630df6fc77eecfd9b14)]
-
[stack/run_test_followups](#2167)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2167/files/2b2387dae243b48cb791c630df6fc77eecfd9b14..1c4e0c091b3b36ca2c5086a78260a936ebc4fb9c)]

---------
- 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**

- [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]>
@yili-db
yili-db force-pushed the stack/run_test_followups branch from e77672e to 2443069 Compare November 11, 2026 21:22
@yili-db

yili-db commented Nov 11, 2026

Copy link
Copy Markdown
Collaborator Author

[AI Assisted] @shba24 Thanks for tracing the TestServer gap. Since #2159 is in, I closed it here in e86d54a: TestServer.start takes a configurationFolder (both RealUpgradeTest methods pass one under their @TempDir), apiClient() reads token.txt from it, and upgrade-tests.yml now runs the same check_etc_conf.sh after the upgrade tests. OldServer already runs each release in its own etc/conf under the work dir, so only TestServer wrote to the repo's. Locally, upgradesAndKeepsTheData passed with UC_TEST_UPGRADES=true and the check found nothing afterwards.

@yili-db
yili-db requested a review from timothyw553 November 11, 2026 22:01
@yili-db
yili-db force-pushed the stack/run_test_followups branch from e86d54a to 43f6f6d Compare November 12, 2026 01:08
yili-db added a commit that referenced this pull request Nov 12, 2026
## 🥞 Stacked PR
Use this
[link](https://github.com/unitycatalog/unitycatalog/pull/2160/files) to
review incremental changes.
-
[**stack/run_test_parallel**](#2160)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2160/files)]
← _this PR_
-
[stack/run_test_followups](#2167)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2167/files/0e51e0ef2276ad0888e3717d27dd54401ec3b721..43f6f6da703254c2e2cdfe1ee2e5b6b77747e2aa)]

---------
- Add `project/TestParallelization.scala`, enabled only by
`TEST_PARALLELISM`
- Splits each project's suites into forked JVMs, longest first by
recorded durations
- Lifts sbt's default limit of one forked test JVM at a time across the
build, keeping sbt-assembly's own limit
- Fails to load the build if `TEST_PARALLELISM` is not a positive
integer
- Add `dev/run-tests.py`, running the same tests as `build/sbt test`
- Picks the JVM count from the CPUs it may use and the available memory,
capped by its cgroup memory limits, not counting reclaimable page cache
as used
- Rejects a `-p` below 1 and heap sizes without a unit; passes `-J-Xms`
with `-J-Xmx` so a small `--sbt-heap` still starts sbt
- Logs to `target/test-logs/`; the root project's `cleanKeepFiles` keeps
the log and suite durations across every `clean`, not only in parallel
runs
- Prints a failure summary with each failure's message, reports test
JVMs that exited early, shows sbt's errors when it fails before any test
runs, and warns if tests write `etc/conf`
  - Stops sbt and its test JVMs if the script fails or gets Ctrl-C
- Add `project/tests/test_run_tests.py`, run in the "Build Test" CI job
- Checks argument validation, the failure summary, the cgroup memory
math, the durations file and the forked test JVM limit
- Runs `dev/run-tests.py -p 2 clean client/test` end to end, asserting
both client test groups get suites
- Make the script the preferred way to run tests in `AGENTS.md` and
`README.md`
  - Clarify that `-J-Xmx` sets sbt's own heap, not the forked test JVMs'
- Full suite on a 32-core machine: 3.5-5.5 min, versus 26 min with
`build/sbt test`

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]>
@yili-db
yili-db force-pushed the stack/run_test_followups branch from acfa42b to 8e72754 Compare November 12, 2026 05:25
Comment on lines +7 to +8
changed=$(git status --porcelain --ignored --untracked-files=all -- ':(glob)**/etc/conf/**')
if [ -n "$changed" ]; then

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.

i think missing tests - but its not necessary if we dont need

Comment thread dev/run-tests.py Outdated
"""
paths = []
for depth in range(3):
paths += glob.glob(os.path.join(ROOT, *["*"] * depth, "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: glob("*") misses hidden files. in the code you removed os.listdir() they were included.

Comment thread dev/run-tests.py
@@ -357,11 +357,18 @@ def first_errors(log_path, limit=10):


def conf_stamps():

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): conf_stamps() depth and hidden-file handling has no test

conf_stamps() now globs etc/conf at depth 0, 1 and 2, keys results by relative path, uses listdir so hidden files count, and skips non-files. Nothing under project/tests exercises it; the new test only covers check_etc_conf.sh. This is a coverage gap, not a behavior bug: the current code handles all three depths.

For example: Changing range(3) to range(2) would stop watching connectors/spark/etc/conf, and the warning in main() would never fire for it, yet every CI check would still pass.

Add a case to the existing project/tests/test_run_tests.py that builds a temporary tree with an etc/conf at depth 0, 1 and 2 (one holding a hidden file) and asserts that conf_stamps() returns the relative path of each file. That keeps it in the current test file instead of adding a new one.

How about adding a small tree-based case to test_run_tests.py so a depth regression gets caught?

assert result.returncode == 0, f"a clean tree must pass:\n{result.stdout}{result.stderr}"

# Each case must fail and name the file: ignored, unignored in a module, hidden, edited.
cases = {

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): Deleted tracked file case is not covered

The header of check_etc_conf.sh says it fails on an edited or deleted tracked file, but the cases dict covers ignored, untracked, hidden and edited files only. The script fails on any non-empty porcelain output, so a deletion is caught today. A later change to the status filtering that dropped ' D' lines would still pass this test.

For example: Deleting etc/conf/server.properties and running the script should exit 1 and list ' D etc/conf/server.properties'. No case checks that.

# after the cases loop, before the final restored-tree check
(repo / "etc" / "conf" / "server.properties").unlink()
result = check(repo)
assert result.returncode == 1 and " D etc/conf/server.properties" in result.stdout, (
    f"a deleted tracked file must fail:\n{result.stdout}{result.stderr}")
git(repo, "checkout", "--", "etc/conf/server.properties")

Would you like to add the deletion case so the header's promise is tested?

@yili-db
yili-db force-pushed the stack/run_test_followups branch from 478a3cb to 990a868 Compare November 20, 2026 00:52
@yili-db yili-db changed the title [Server] Fix a model test race and a double setUp, and fail CI on etc/conf writes [Server] Fix a double setUp in tests, and fail CI on etc/conf writes Nov 20, 2026
@yili-db
yili-db requested a review from shba24 November 20, 2026 00:53
Comment thread dev/run-tests.py Outdated
# listdir, not glob("*"), so hidden files count too.
paths += [os.path.join(conf, name) for name in os.listdir(conf)]
return {os.path.relpath(path, ROOT): os.path.getmtime(path) for path in paths
if os.path.isfile(path)}

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.

Blocker: conf_stamps() does not watch files nested under etc/conf

conf_stamps() lists each etc/conf with os.listdir and then keeps only entries where os.path.isfile is true, so subdirectories are dropped and nothing inside them is visited. The earlier code recorded every listdir entry, so a new subdirectory used to show up as a warning. I read the code but did not run a test, so I could not settle this one. No server code writes into a subdirectory today (SecurityConfiguration and SecurityContext resolve files directly under configurationFolder), and the CI script still catches nested files, so the impact is low.

For example: A test creates etc/conf/keys/private_key.der. check_etc_conf.sh fails in CI, but the local runner prints no warning because conf_stamps() never looks inside keys/.

def conf_stamps():
    stamps = {}
    for depth in range(3):
        for conf in glob.glob(os.path.join(ROOT, *["*"] * depth, "etc", "conf")):
            # os.walk lists hidden files and nested directories too.
            for dirpath, _, names in os.walk(conf):
                for name in names:
                    path = os.path.join(dirpath, name)
                    stamps[os.path.relpath(path, ROOT)] = os.path.getmtime(path)
    return stamps

How about walking each etc/conf recursively and adding a nested file such as etc/conf/subdir/x to check_conf_stamps, which today asserts that the subdirectory is left out?

Comment thread project/tests/test_run_tests.py Outdated
stamps = run_tests.conf_stamps()
finally:
run_tests.ROOT = saved
assert sorted(stamps) == sorted(files), f"conf_stamps() watched {sorted(stamps)}"

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): check_conf_stamps never checks that a modified file changes its stamp

The test only compares sorted(stamps) with the expected file list and never looks at a timestamp value. The production code does call os.path.getmtime, so nothing is broken now. If conf_stamps() returned a constant for a watched file, though, this test would still pass and editing that file would no longer trigger the warning.

For example: conf_stamps() returns 0 for server/etc/conf/.hidden. The assertion on the key list still passes, and a test that edits that file is never reported.

before = run_tests.conf_stamps()
os.utime(Path(root) / files[1], (1, 1))
after = run_tests.conf_stamps()
assert before[files[1]] != after[files[1]], "an edited file must change its stamp"

How about touching one watched file with a new mtime and asserting the stamp changed, inside the same ROOT override?

Comment thread dev/run-tests.py Outdated
if not os.path.isdir(conf):
return {}
return {name: os.path.getmtime(os.path.join(conf, name)) for name in os.listdir(conf)}
"""Returns the mtime of each file in any etc/conf, by path; tests should never write them.

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): Docstring claims parity with the CI script, but the depth rules differ

The docstring says conf_stamps() works like project/scripts/check_etc_conf.sh. The script uses the pathspec ':(glob)/etc/conf/', which matches etc/conf at any depth. conf_stamps() uses range(3), so it stops at two module levels and does not recurse.

For example: A test writes a/b/c/etc/conf/token.txt. The CI script fails on it, but dev/run-tests.py prints no warning, so the word 'like' misleads a reader.

"""Returns the mtime of each file in any etc/conf, by path; tests should never write them.

    Covers the root and modules up to two levels deep (connectors/spark/etc/conf). Unlike
    project/scripts/check_etc_conf.sh in CI, it does not match deeper etc/conf directories.
    """

How about naming the local limits in the docstring, or making the scan recursive so the two checks agree?

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

the core fix looks good to me. i left a few comments on the CI checks, test isolation, and keeping the timeout changes out of this PR.



def git(repo: Path, *args: str) -> None:
subprocess.run(["git", "-c", "user.name=test", "-c", "[email protected]", *args],

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.

this temp repo still picks up the developer's global git config, so global ignore rules, commit signing, or hooks can make the test fail even when the script is fine. could we isolate git with GIT_CONFIG_GLOBAL and GIT_CONFIG_NOSYSTEM in both git() and check()?

+GIT_ENV = {
+    **os.environ,
+    "GIT_CONFIG_GLOBAL": os.devnull,
+    "GIT_CONFIG_NOSYSTEM": "1",
+}

@yili-db
yili-db force-pushed the stack/run_test_followups branch from 990a868 to f53d1b3 Compare November 21, 2026 01:51
@shba24
shba24 self-requested a review November 21, 2026 01:53
@yili-db

yili-db commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator Author

[AI Assisted] @timothyw553 Moved the timeout changes out as you asked: the EventLoopStallTest waits and the 5-second limit on waitForClockToPass are now #2330, and this PR is back to the setUp() and etc/conf fixes.

@yili-db
yili-db requested a review from timothyw553 November 21, 2026 01:56
yili-db and others added 9 commits November 24, 2026 23:17
- Its own `@BeforeEach beforeEach()` called `super.setUp()`, after JUnit had already run the inherited `setUp()`
  - 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
- Drop `REPLACE_EXISTING` from the signing-key copy, which only tolerated the second call

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Yi Li <[email protected]>
- A server built without its own `configurationFolder` writes its signing keys, `certs.json` and `token.txt` into `etc/conf`
  - Two tests regressed this way after `configurationFolder` was added
- After the tests, `run-uc-unit-tests` fails if any `etc/conf` holds an untracked or ignored file
  - A fresh CI checkout has only tracked files there, so a local server cannot cause a false failure

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Yi Li <[email protected]>
- `etc/conf` check: `git ls-files --others --ignored` listed only ignored files
  - Use `git status --porcelain --ignored --untracked-files=all`, which also catches unignored files and edits to tracked ones
  - Move it into `project/scripts/check_etc_conf.sh`
- Give `migrate/TestServer` its own `configurationFolder`, and run the check after the upgrade tests too
- Test that a second `setUp()` throws
- `waitForClockToPass` fails after 5 seconds instead of spinning forever
- `dev/run-tests.py` watches every `etc/conf`, not just the root one

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Yi Li <[email protected]>
…onFolder`

- unitycatalog#2078 added three server builds in `opaCannotRunWithAuthorizationDisabled` and `opaRequiresAUrlAndReleasesNativeAuthorizerOnClose` without one
- Those servers wrote their signing keys, `certs.json` and `token.txt` into `etc/conf`, failing `check_etc_conf.sh`

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Yi Li <[email protected]>
- `stopWaitsForBlockedRequestAndExecutorRemainsActive` failed in CI because the first request took more than 5s to reach its handler
- Wait up to 30s for things that should happen: a request reaching its handler, a response, an executor task, and the overlapping stream
  - Passing runs return as soon as they do, so the class still takes about 14s
- Keep the timings that are assertions: the 3s window in which `stop()` must still be waiting, and the 300ms client timeout that must fire

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Yi Li <[email protected]>
…_conf.sh`

- `dev/run-tests.py` listed `etc/conf` with `glob("*")`, which skips hidden files; list each directory with `os.listdir` instead
- Add `project/tests/test_check_etc_conf.py`, run in the "Build Test" CI job
  - Runs the script in a throwaway git repository
  - A clean tree passes; an ignored, unignored, hidden or edited file in any `etc/conf` fails and is listed

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Yi Li <[email protected]>
…le in `check_etc_conf.sh`

- `test_run_tests.py`: `check_conf_stamps` builds an `etc/conf` at depths 0, 1 and 2, one with a hidden file, and asserts every path is watched
- `test_check_etc_conf.py`: deleting a tracked `etc/conf` file must fail and be listed
- Wrap a long line in `migrate/TestServer` left by the rebase

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Yi Li <[email protected]>
- Restore `EventLoopStallTest` and the `waitForClockToPass` deadline in `BaseModelCRUDTest` to `main`, keeping this PR to the `setUp()` and `etc/conf` fixes

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Yi Li <[email protected]>
…_etc_conf.py`

- `conf_stamps()` walks each `etc/conf` with `os.walk`, so files in subdirectories count
  - The docstring states its depth limit next to the CI script's
- `check_conf_stamps` adds a nested file and checks that an edit changes the stamp
- `test_check_etc_conf.py` runs git with `GIT_CONFIG_GLOBAL` and `GIT_CONFIG_NOSYSTEM`, ignoring the developer's git configuration

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Yi Li <[email protected]>
@yili-db
yili-db force-pushed the stack/run_test_followups branch from f53d1b3 to 4a2287c Compare November 24, 2026 23:23

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

Reviewed at 4a2287c: no blocking issues found.

On lines this pull request does not change

AGENTS.md:218

Nit (not a blocker): Contributor guide describes the old, narrower CI checkout rule

AGENTS.md says the unit test CI action fails when tests leave a new or changed file that git does not ignore. With check_etc_conf.sh, the action also fails on ignored files and on edited or deleted tracked files under any etc/conf. A contributor reading the guide cannot tell this in advance.

For example: A test leaves etc/conf/token.txt, which .gitignore covers. The guide implies this passes, but check_etc_conf.sh reports !! etc/conf/token.txt and exits 1.

Extend the "Leave the checkout clean" bullet with one clause. The action also fails on any new file (ignored or not), or on an edited or deleted tracked file, under any etc/conf. Suggest giving a test server its own configurationFolder under @TempDir, as BaseServerTest and TestServer.start(db, storageRoot, configurationFolder) do.

Evidence
AGENTS.md:218: "the unit test CI action fails when the tests leave a new or changed file that git does not ignore." The head adds `.github/actions/run-uc-unit-tests/action.yml` step "Check that tests left etc/conf alone" running `project/scripts/check_etc_conf.sh`, which uses `git status --porcelain --ignored --untracked-files=all -- ':(glob)**/etc/conf/**'`. That fails on ignored files such as `etc/conf/token.txt`, so the sentence no longer covers what CI fails on. I searched AGENTS.md and the docs for `etc/conf` mentions of this check and found none.
How it was checked

Checked by 2 independent checks: CONFIRMED

How about adding that clause so contributors know about the stricter check before CI tells them?

assert result.returncode == 0, f"a clean tree must pass:\n{result.stdout}{result.stderr}"

# Each case must fail and name the file: ignored, unignored in a module, hidden, edited.
cases = {

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): Test misses files nested below etc/conf

All cases in cases are direct children of an etc/conf. A regression to ':(glob)**/etc/conf/*' would stop matching subdirectories, because a glob * does not cross /, yet every case would still pass. The nested case exists only in test_run_tests.py, which tests the Python conf_stamps() and not this script.

For example: Write etc/conf/keys/private_key.der. The current script lists ?? etc/conf/keys/private_key.der, and the regressed one lists nothing, with no test failure.

"etc/conf/keys/private_key.der": "?? etc/conf/keys/private_key.der",
Evidence
project/scripts/check_etc_conf.sh:7: `changed=$(git status --porcelain --ignored --untracked-files=all -- ':(glob)**/etc/conf/**')`. project/tests/test_check_etc_conf.py:42-47: `cases = {` followed by `"etc/conf/token.txt"`, `"examples/cli/etc/conf/certs.json"`, `"etc/conf/.hidden"`, and `"etc/conf/server.properties"`. All cases are directly inside an etc/conf directory. Replacing the final `**` with `*` leaves the test passing but misses a file under etc/conf/keys/.
How it was checked

Checked by 2 independent checks: CONFIRMED

Could we add this row to cases? The cleanup may also need to remove the empty keys/ directory.

Comment thread project/scripts/check_etc_conf.sh Outdated
#!/usr/bin/env bash
# Fails if any etc/conf directory differs from the checkout: a new file (ignored or not), or an
# edited or deleted tracked one. Run in CI after the tests: a server built without its own
# configurationFolder writes its signing keys, certs.json and token.txt into 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 a blocker): Comments say the server writes certs.json, but it no longer does

The comment here says a server without its own configurationFolder writes certs.json into etc/conf. The server documentation says it no longer writes that file. The same phrase appears in SchemaGateTest.java:33 and in the @param doc at TestServer.java:41.

For example: Start a server with no configurationFolder. etc/conf gets token.txt and the signing key files, but no certs.json.

Remove certs.json from the three comments (check_etc_conf.sh:4, SchemaGateTest.java:33, TestServer.java:41-42) and keep the references to token.txt and the signing keys. The .gitignore entries and the sample file name examples/cli/etc/conf/certs.json can stay.

Evidence
project/scripts/check_etc_conf.sh:4: `# configurationFolder writes its signing keys, certs.json and token.txt into etc/conf.` This says the server writes certs.json.
How it was checked

Checked by 2 independent checks: CONFIRMED

References:

Would you like to drop certs.json from those three comments?

result = check(repo)
assert result.returncode == 0, f"a clean tree must pass:\n{result.stdout}{result.stderr}"

# Each case must fail and name the file: ignored, unignored in a module, hidden, edited.

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): Dropping the etc/conf pathspec would not fail any test

Every dirty path in the test sits under an etc/conf, and the only passing assertions run on a clean tree. If the ':(glob)**/etc/conf/**' pathspec were removed from check_etc_conf.sh:7, the tests would stay green. CI would then fail on any target/ output.

For example: An untracked other/new.json plus an ignored other/x.txt in the temp repo: the scoped script must exit 0, but the test never creates them.

Before the first clean-tree check, create an untracked file and a gitignored file outside etc/conf, for example other/new.json and other/x.txt with a .gitignore entry other/*.txt. Assert that the script still exits 0.

Evidence
project/scripts/check_etc_conf.sh:8 `changed=$(git status --porcelain --ignored --untracked-files=all -- ':(glob)**/etc/conf/**')`. In project/tests/test_check_etc_conf.py the only passing assertions are on a clean tree (`assert result.returncode == 0, f"a clean tree must pass...`) and on the restored tree. Every other case writes under an etc/conf path and expects exit 1. I looked in the same file for a case that changes a file outside etc/conf. There is none. If the pathspec were dropped, the script would fail on any untracked or ignored file in the checkout (for example target/), and every listed case would still fail as expected, so the test would not notice.
How it was checked

Checked by 2 independent checks: CONFIRMED

How about adding that passing case so the pathspec scope is pinned?

assert left == 6 * gib, f"expected 6 GiB left under the parent's limit, got {left}"


def check_conf_stamps(run_tests) -> None:

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): Depth limit of conf_stamps() is not pinned by a test

check_conf_stamps creates etc/conf only at depths 0, 1 and 2. Changing range(3) to range(4) at dev/run-tests.py:367 would add no file to the result and the test would pass. That contradicts the docstring, which says deeper directories are not watched. The set(conf_before) | set(conf_after) union in main() is also untested, though that part predates this PR.

For example: Put a/b/c/etc/conf/deep.json in the temp root. It must not appear in conf_stamps(), but the fixture never creates it.

Add a/b/c/etc/conf/deep.json to the temp tree in check_conf_stamps without adding it to files, so the existing sorted(before) == sorted(files) assertion pins the limit. Optionally move the touched computation in main() into a tiny helper and test added, deleted and edited files. Skip the helper if it feels like surface added only for tests.

Evidence
dev/run-tests.py:359-366 `for depth in range(3): for conf in glob.glob(os.path.join(ROOT, *["*"] * depth, "etc", "conf")): ...` and main() builds `touched` from `set(conf_before) | set(conf_after)` and `conf_before.get(name) != conf_after.get(name)`. project/tests/test_run_tests.py `check_conf_stamps` only calls `conf_stamps()` twice and checks the watched file list and that `os.utime` changed one stamp. It never creates an etc/conf three levels deep to show it is excluded (the docstring says deeper ones are not looked for), and it never runs main()'s comparison, so an added or deleted file and the warning text have no test. Changing `range(3)` to `range(4)` still passes. Replacing `.get` with direct indexing in main() would also pass.
How it was checked

Checked by 2 independent checks: CONFIRMED

Would you like to add the depth fixture, and is the touched helper worth it?

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] Added the depth fixture in 30de299: a/b/c/etc/conf/deep.json is created but not in files, so range(4) now fails the test. I skipped the touched helper, since it would add code only for the test.

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.

You're right, and the depth part is settled. I ran check_conf_stamps against the head dev/run-tests.py, and it passes. I then changed range(3) to range(4) in conf_stamps() and ran it again. It failed with conf_stamps() watched ['a/b/c/etc/conf/deep.json', ...] from the equality assertion. So the deep.json fixture pins the upper bound, and the existing depth-2 file pins the lower bound.

I also checked your second point. The added/deleted/edited comparison is still inline in main() (dev/run-tests.py:393-397), and no test references it. That comparison was already at the base, and it only drives a printed warning. Leaving it inline is fine with me, so I'm happy to resolve this thread.

* {@code token.txt}, instead of the shared {@code etc/conf}
* @return the started server
*/
static TestServer start(TestDatabase db, Path storageRoot, Path 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 (not a blocker): Two adjacent Path parameters can be swapped without a compile error

TestServer.start takes storageRoot and configurationFolder next to each other, both Path. A swapped call compiles and runs. All four current call sites (SchemaGateTest, RealUpgradeTest) pass them in the right order, so this is only a note for future callers.

Cost of keeping it: A future test author transposes the two arguments. Keys and token.txt then land in the storage temp directory instead of etc/conf. That is still a @TempDir, so the checkout stays clean. The cost is repeated Path pairs at each new variant or caller, with a mix-up showing up only as a confused directory layout.

No change needed now. If more start variants or callers appear, group the two paths in a small record TestServerDirs(Path storageRoot, Path configurationFolder).

Evidence
server/src/test/java/io/unitycatalog/server/migrate/TestServer.java:45: `static TestServer start(TestDatabase db, Path storageRoot, Path configurationFolder) {`. Line 51 has the same pair after a `Properties` argument: `TestDatabase db, Properties hibernateProperties, Path storageRoot, Path configurationFolder`. Both parameters are `Path`, so the compiler cannot catch swapped arguments. Callers: `RealUpgradeTest.java:55` and `RealUpgradeTest.java:84` call `TestServer.start(db, storageRoot, workDir.resolve("conf"))`, and `SchemaGateTest.java:38` and `SchemaGateTest.java:51` use `(db, storageRoot, configurationFolder)`. I looked for a distinct type or a builder for these and found none.
How it was checked

Checked by 2 independent checks: NITPICK

Does it seem fine to leave this as is until another caller shows up?

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] Yes, leaving it as is: all four callers pass them in order, and a swap still writes into a @TempDir. A record makes sense once another variant or caller appears.

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.

You're right. I re-read the call sites at 30de299. All four callers pass the storage root first and the configuration folder second: RealUpgradeTest.java:55 and :84, and SchemaGateTest.java:38 and :51. Both overloads in TestServer.java forward the two paths to the private start in the same order.

A swap would also not dirty the checkout. In both tests the two paths come from @TempDir, or from a child of one, so the key and token files would still land in a temp directory. Keeping the signature is fine. A record can wait until another caller appears, as you say.

…ests

- `AGENTS.md`: CI also fails on ignored, edited or deleted files under any `etc/conf`
- Drop `certs.json` from comments: since unitycatalog#2081 the server writes only its signing keys and `token.txt`
- `test_check_etc_conf.py`
  - A nested file, `etc/conf/keys/private_key.der`, must fail
  - Untracked and ignored files outside `etc/conf` must not
- `check_conf_stamps`: an `etc/conf` three levels deep must not be watched

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Yi Li <[email protected]>
@yili-db

yili-db commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

[AI Assisted] @shba24 Added the clause to the "Leave the checkout clean" bullet in AGENTS.md (30de299): under any etc/conf, CI also fails on a new ignored file and on an edited or deleted tracked one, with a pointer to configurationFolder under @TempDir.

@yili-db
yili-db requested a review from shba24 November 25, 2026 07:59

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

Reviewed at 30de299: no blocking issues found.

@yili-db
yili-db merged commit 8fa9601 into unitycatalog:main Nov 30, 2026
32 of 34 checks passed
yili-db added a commit that referenced this pull request Dec 2, 2026
## 🥞 Stacked PR
Use this
[link](https://github.com/unitycatalog/unitycatalog/pull/2330/files) to
review incremental changes.
-
[stack/test_timeouts](#2330)
[[Files
changed](https://github.com/unitycatalog/unitycatalog/pull/2330/files)]

---------
-
`EventLoopStallTest.stopWaitsForBlockedRequestAndExecutorRemainsActive`
failed in CI because the first request took more than 5s to reach its
handler
- Wait up to 30s for things that should happen: a request reaching its
handler, a response, an executor task, the overlapping stream
- Keep the timings that are assertions: the 3s window in which `stop()`
must still be waiting, and the 300ms client timeout that must fire
- Size the timeouts to those waits, on the test servers only (production
defaults are unchanged)
- Each held request raises its own request timeout
(`ServiceRequestContext.setRequestTimeout`) above Armeria's 10s default,
which would otherwise fail it with a 500
  - The clients' response timeout matches it
- The shutdown test sets `server.shutdown-timeout` to 30s, as
`UnityCatalogServerShutdownTest` does, instead of relying on the 5s
default

Moved out of #2167 at review, to keep that PR to its test-isolation
fixes. The `waitForClockToPass` deadline moved on to #2419.

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.
- [ ] 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