Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/actions/run-uc-unit-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ runs:
exit 1
fi

- name: Check that tests left etc/conf alone
shell: bash
run: bash project/scripts/check_etc_conf.sh

- name: Run license check
if: inputs.validation-mode == 'all-tests' && inputs.test-database == 'H2'
shell: bash
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/cross-spark-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,8 @@ jobs:
- name: Verify dev/run-tests.py
run: python3 project/tests/test_run_tests.py

- name: Verify project/scripts/check_etc_conf.sh
run: python3 project/tests/test_check_etc_conf.py

- name: Run cross-Spark build test
run: python3 project/tests/test_cross_spark_publish.py
2 changes: 2 additions & 0 deletions .github/workflows/upgrade-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ jobs:
UC_TEST_DATABASE: ${{ matrix.test-database }}
UC_TEST_UPGRADES: "true"
run: build/sbt -J-Xmx2G "server/testOnly io.unitycatalog.server.migrate.RealUpgradeTest"
- name: Check that tests left etc/conf alone
run: bash project/scripts/check_etc_conf.sh
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ Concrete review expectations for this repository:
- **Cover the branches.** Every new branch, error path, and boundary (empty, zero, negative, invalid, concurrent) needs a case. For combinations of boolean conditions, cover the combinations, not just one. Test both the enabled and disabled paths of any flag or capability that guards behavior.
- **Do not generate test bloat; reuse setup.** Do not add heavy tests for trivial data-holder classes with no logic. Do not repeat identical setup in every method: hoist shared setup into `@BeforeEach` and extend the shared base test classes (`BaseServerTest`, `BaseCRUDTest`) rather than re-creating their scaffolding, and reserve `@BeforeAll` for a genuinely immutable, expensive fixture. Collapse several near-identical cases that do not mutate state into one parameterized test, or one method that walks a list of input/expected pairs, instead of copy-pasting a method per input. Object, client, and server setup is expensive, and slow or bloated suites get flagged in review.
- **Stack:** JUnit 5 (`@BeforeEach`/`@AfterEach`/`@TempDir`), servers bound to a random port per test, schema reset between tests. Integration tests spanning server plus a client or connector go in `integration-tests/`.
- **Leave the checkout clean.** A test writes files under `@TempDir` or `target/`, never elsewhere in the repository; the unit test CI action fails when the tests leave a new or changed file that git does not ignore. A test that starts a child JVM with the test classpath passes on `-Djacoco-agent.destfile` when it is set, or the child writes `jacoco.exec` to the working directory.
- **Leave the checkout clean.** A test writes files under `@TempDir` or `target/`, never elsewhere in the repository; the unit test CI action fails when the tests leave a new or changed file that git does not ignore. Under any `etc/conf` it is stricter: it also fails on a new file that git ignores, such as the signing keys and `token.txt` a server writes, and on an edited or deleted tracked file; give a test server its own `configurationFolder` under `@TempDir`, as `BaseServerTest` and `TestServer.start` do. A test that starts a child JVM with the test classpath passes on `-Djacoco-agent.destfile` when it is set, or the child writes `jacoco.exec` to the working directory.
- **S3-compatible storage:** `s3://` paths in tests use emulated storage by default. `build/sbt testMinIO` (also `testSeaweedFS`, `testRustFS`, `testCeph`, `testGarage`, `testCephStaticKey` and `testGarageStaticKey`, or `UC_TEST_STORAGE=<storage>`, one of `SupportedStorage`) runs every project's tests on that storage in Docker; tests that need real storage skip without it, and `S3CompatibleCredentialScopeTest` also skips on storage without STS, whose keys carry no session policy.

## Contribution workflow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
import lombok.SneakyThrows;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
Expand Down Expand Up @@ -181,8 +182,10 @@ private void callQuietly(Callable call) {
}
}

@SneakyThrows
@BeforeEach
public void beforeEach() throws Exception {
@Override
public void setUp() {
super.setUp();
session = createSparkSession();

Expand Down
21 changes: 15 additions & 6 deletions dev/run-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,20 @@ 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?

"""Returns the mtime of each file in etc/conf, which tests should never write."""
conf = os.path.join(ROOT, "etc", "conf")
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 an etc/conf, by path; tests should never write them.

Covers etc/conf at the root and in modules up to two levels deep (connectors/spark/etc/conf),
with everything under it, hidden files included. Unlike project/scripts/check_etc_conf.sh in
CI, it does not look for deeper etc/conf directories.
"""
stamps = {}
for depth in range(3):
for conf in glob.glob(os.path.join(ROOT, *["*"] * depth, "etc", "conf")):
for directory, _, names in os.walk(conf):
for name in names:
path = os.path.join(directory, name)
stamps[os.path.relpath(path, ROOT)] = os.path.getmtime(path)
return stamps


def elapsed(start):
Expand All @@ -384,7 +393,7 @@ def main():
touched = sorted(name for name in set(conf_before) | set(conf_after)
if conf_before.get(name) != conf_after.get(name))
if touched:
print(f"Warning: tests wrote etc/conf: {', '.join(touched)}. A test likely started a "
print(f"Warning: tests changed {', '.join(touched)}. A test likely started a "
"server without its own configurationFolder.")
return returncode

Expand Down
12 changes: 12 additions & 0 deletions project/scripts/check_etc_conf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/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 and token.txt into etc/conf.
set -euo pipefail

changed=$(git status --porcelain --ignored --untracked-files=all -- ':(glob)**/etc/conf/**')
if [ -n "$changed" ]; then
Comment on lines +7 to +8

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

echo "::error::Tests changed etc/conf; give each test server its own configurationFolder:"
echo "$changed"
exit 1
fi
84 changes: 84 additions & 0 deletions project/tests/test_check_etc_conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env python3
"""Check project/scripts/check_etc_conf.sh against a throwaway git repository."""

import os
import subprocess
import tempfile
from pathlib import Path


UC_ROOT = Path(__file__).resolve().parents[2]
SCRIPT = UC_ROOT / "project" / "scripts" / "check_etc_conf.sh"
# Ignore the developer's global and system git configuration (excludes, signing, hooks), so only
# the throwaway repository's own rules apply.
GIT_ENV = {**os.environ, "GIT_CONFIG_GLOBAL": os.devnull, "GIT_CONFIG_NOSYSTEM": "1"}


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",
+}

cwd=repo, env=GIT_ENV, check=True, capture_output=True)


def check(repo: Path) -> subprocess.CompletedProcess:
return subprocess.run(["bash", str(SCRIPT)], cwd=repo, env=GIT_ENV, capture_output=True,
text=True)


def main() -> None:
with tempfile.TemporaryDirectory() as tmp:
repo = Path(tmp)
git(repo, "init", "-q")
(repo / "etc" / "conf").mkdir(parents=True)
(repo / "etc" / "conf" / "server.properties").write_text("server.env=dev\n")
# Like the real .gitignore: the generated files are ignored in etc/conf.
(repo / ".gitignore").write_text("etc/conf/*.txt\nother/*.txt\n")
git(repo, "add", ".")
git(repo, "commit", "-q", "-m", "init")
# Untracked and ignored files outside etc/conf are none of the script's business, so they
# stay for the whole test: every passing check below also pins that.
(repo / "other").mkdir()
(repo / "other" / "new.json").write_text("x")
(repo / "other" / "x.txt").write_text("x")

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?

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?

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.

"etc/conf/token.txt": "!! etc/conf/token.txt",
"etc/conf/keys/private_key.der": "?? etc/conf/keys/private_key.der",
"examples/cli/etc/conf/certs.json": "?? examples/cli/etc/conf/certs.json",
"etc/conf/.hidden": "?? etc/conf/.hidden",
"etc/conf/server.properties": " M etc/conf/server.properties",
}
for path, expected in cases.items():
file = repo / path
original = file.read_text() if file.exists() else None
file.parent.mkdir(parents=True, exist_ok=True)
file.write_text("written by a test\n")
result = check(repo)
assert result.returncode == 1 and expected in result.stdout, (
f"{path}: expected a failure listing {expected!r}, got exit {result.returncode}:\n"
f"{result.stdout}{result.stderr}")
if original is None:
file.unlink()
if file.parent != repo / "etc" / "conf" and not any(file.parent.iterdir()):
file.parent.rmdir()
else:
file.write_text(original)

tracked = repo / "etc" / "conf" / "server.properties"
tracked.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")

result = check(repo)
assert result.returncode == 0, f"the restored tree must pass:\n{result.stdout}"
print("PASS: check_etc_conf.sh fails on new, ignored, hidden, edited and deleted files in any "
"etc/conf")


if __name__ == "__main__":
main()
24 changes: 24 additions & 0 deletions project/tests/test_run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,29 @@ def check_cgroup_memory(run_tests) -> None:
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.

# etc/conf at the root and in modules one and two levels deep, with a hidden file and a file
# in a subdirectory.
files = ["etc/conf/a.properties", "etc/conf/keys/private_key.der", "server/etc/conf/.hidden",
"connectors/spark/etc/conf/b.json"]
saved = run_tests.ROOT
with tempfile.TemporaryDirectory() as root:
# Three levels deep is past the limit, so this one must not be watched.
for name in files + ["a/b/c/etc/conf/deep.json"]:
(Path(root) / name).parent.mkdir(parents=True, exist_ok=True)
(Path(root) / name).write_text("x")
run_tests.ROOT = root
try:
before = run_tests.conf_stamps()
# An edited file must change its stamp, or the warning would never fire for it.
os.utime(Path(root) / files[2], (1, 1))
after = run_tests.conf_stamps()
finally:
run_tests.ROOT = saved
assert sorted(before) == sorted(files), f"conf_stamps() watched {sorted(before)}"
assert before[files[2]] != after[files[2]], f"editing {files[2]} did not change its stamp"


def check_concurrency_limit() -> None:
command = [str(UC_ROOT / "build" / "sbt"), "-no-colors", "-batch",
"show Global / concurrentRestrictions"]
Expand Down Expand Up @@ -163,6 +186,7 @@ def main() -> None:
check_sbt_errors_shown(run_tests)
check_durations_file(run_tests)
check_cgroup_memory(run_tests)
check_conf_stamps(run_tests)
check_concurrency_limit()
check_parallel_run()
print("PASS: dev/run-tests.py validates its arguments and runs client/test in 2 test JVMs")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public void opaCannotRunWithAuthorizationDisabled() {
.port(0)
.serverProperties(properties)
.hibernateConfigurator(hibernateConfigurator)
.configurationFolder(configurationFolder)
.build())
.isInstanceOf(BaseException.class)
.hasMessage(
Expand All @@ -90,6 +91,7 @@ public void opaRequiresAUrlAndReleasesNativeAuthorizerOnClose() throws Exception
.port(0)
.serverProperties(properties)
.hibernateConfigurator(hibernateConfigurator)
.configurationFolder(configurationFolder)
.build())
.isInstanceOf(BaseException.class)
.hasMessageContaining("server.authorization.opa.decision-url is required");
Expand All @@ -102,6 +104,7 @@ public void opaRequiresAUrlAndReleasesNativeAuthorizerOnClose() throws Exception
.port(0)
.serverProperties(properties)
.hibernateConfigurator(hibernateConfigurator)
.configurationFolder(configurationFolder)
.build();
try (Connection connection = hibernateConfigurator.getDataSource().getConnection()) {
connection.createStatement().execute("CREATE TABLE callers_table (id INT)");
Expand Down Expand Up @@ -281,6 +284,10 @@ public void startFailsWhenThePortIsTaken() throws Exception {
assertThat(configurationFolder.resolve("token.txt")).isNotEmptyFile();
assertThatThrownBy(() -> UnityCatalogServer.builder().configurationFolder(null))
.isInstanceOf(NullPointerException.class);
// A second setUp() in the same test fails before it starts another server.
assertThatThrownBy(this::setUp)
.isInstanceOf(IllegalStateException.class)
.hasMessageContaining("setUp() ran twice in one test");

try (ServerSocket occupied = new ServerSocket(0)) {
UnityCatalogServer server =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.unitycatalog.server.base;

import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;

import com.linecorp.armeria.server.ServerPortBindException;
import io.unitycatalog.server.UnityCatalogServer;
import io.unitycatalog.server.persist.utils.FileOperations;
Expand Down Expand Up @@ -114,6 +112,11 @@ protected FileOperations decorateFileOperations(FileOperations fileOperations) {
@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

throw new IllegalStateException(
"setUp() ran twice in one test, starting a second server: override setUp() instead of "
+ "calling it from another @BeforeEach method");
}
if (serverConfig == null) {
throw new IllegalArgumentException("Server config is required");
}
Expand Down Expand Up @@ -150,11 +153,9 @@ private static synchronized void copySigningKeys(Path target) throws IOException
}
signingKeysFolder = folder;
}
// Replace: setUp() runs twice in one test when a subclass declares another @BeforeEach method
// that calls super.setUp(), instead of overriding setUp().
try (Stream<Path> keys = Files.list(signingKeysFolder)) {
for (Path key : keys.toList()) {
Files.copy(key, target.resolve(key.getFileName()), REPLACE_EXISTING);
Files.copy(key, target.resolve(key.getFileName()));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void upgradesAndKeepsTheData(@TempDir Path workDir, @TempDir Path storageRoot) {
}

new SchemaMigrator(db.dataSource()).upgradeSchema();
try (TestServer server = TestServer.start(db, storageRoot)) {
try (TestServer server = TestServer.start(db, storageRoot, workDir.resolve("conf"))) {
copies.forEach(copy -> copy.assertReadBack(server.apiClient()));
}
}
Expand Down Expand Up @@ -81,7 +81,7 @@ void upgradesAnOlderDatabaseOnceItIsRepaired(@TempDir Path workDir, @TempDir Pat
repair();
migrator.upgradeSchema();

try (TestServer server = TestServer.start(db, storageRoot)) {
try (TestServer server = TestServer.start(db, storageRoot, workDir.resolve("conf"))) {
for (String release : List.of("v0.4.0", "v0.7.0")) {
String name = catalogOf(release);
assertThat(new CatalogsApi(server.apiClient()).getCatalog(name, false).getName())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ public class SchemaGateTest {

@TempDir Path storageRoot;

// The server's signing keys and token.txt, instead of the shared etc/conf.
@TempDir Path configurationFolder;

@Test
void refusesToStartOnADatabaseThatIsNotSetUp() {
assertThatThrownBy(() -> TestServer.start(db, storageRoot))
assertThatThrownBy(() -> TestServer.start(db, storageRoot, configurationFolder))
.hasMessageContaining("The database has no Unity Catalog schema yet")
.hasMessageContaining("bin/start-uc-server --upgrade-schema");
assertThat(new SchemaMigrator(db.dataSource()).state()).isEqualTo(SchemaState.EMPTY);
Expand All @@ -45,7 +48,7 @@ void setsUpAnInMemoryDatabaseAtStart() throws ApiException {
inMemory.setProperty("hibernate.connection.driver_class", "org.h2.Driver");
inMemory.setProperty("hibernate.connection.url", "jdbc:h2:mem:gate;DB_CLOSE_DELAY=-1");

try (TestServer server = TestServer.start(db, inMemory, storageRoot)) {
try (TestServer server = TestServer.start(db, inMemory, storageRoot, configurationFolder)) {
assertThat(
new CatalogsApi(server.apiClient())
.listCatalogs(null, null, /* includeBrowse= */ false)
Expand Down
Loading
Loading