Repository navigation
[Server] Keep test servers out of etc/conf and speed up Spark tests
#2159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,7 @@ | |
| import io.unitycatalog.server.utils.TestUtils; | ||
| import java.net.ServerSocket; | ||
| import java.net.URI; | ||
| import java.nio.file.Files; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Properties; | ||
|
|
@@ -43,12 +44,21 @@ public class UnityCatalogServerTest extends BaseServerTest { | |
|
|
||
| @Test | ||
| public void startFailsWhenThePortIsTaken() throws Exception { | ||
| // The server setUp() built writes certs.json and token.txt to configurationFolder, next to the | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit (not a blocker): these
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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! |
||
| // signing keys copied there. | ||
| String keyId = Files.readString(configurationFolder.resolve("key_id.txt")); | ||
| assertThat(Files.readString(configurationFolder.resolve("certs.json"))).contains(keyId); | ||
| assertThat(configurationFolder.resolve("token.txt")).isNotEmptyFile(); | ||
| assertThatThrownBy(() -> UnityCatalogServer.builder().configurationFolder(null)) | ||
| .isInstanceOf(NullPointerException.class); | ||
|
|
||
| try (ServerSocket occupied = new ServerSocket(0)) { | ||
| UnityCatalogServer server = | ||
| UnityCatalogServer.builder() | ||
| .port(occupied.getLocalPort()) | ||
| .serverProperties(new ServerProperties(serverProperties)) | ||
| .hibernateConfigurator(hibernateConfigurator) | ||
| .configurationFolder(configurationFolder) | ||
| .build(); | ||
| // BaseServerTest retries only a ServerPortBindException, so the cause is part of the | ||
| // contract, as is a close() that releases what the failed start left behind. | ||
|
|
@@ -72,6 +82,7 @@ public void failedConstructionClosesTheAuditSink() { | |
| .port(0) | ||
| .serverProperties(new ServerProperties(audited)) | ||
| .hibernateConfigurator(hibernateConfigurator) | ||
| .configurationFolder(configurationFolder) | ||
| .fileOperationsDecorator( | ||
| fileOperations -> { | ||
| throw new IllegalStateException("decorator failed"); | ||
|
|
@@ -92,6 +103,7 @@ public void closeClosesTheAuditSinkOnce() { | |
| .port(0) | ||
| .serverProperties(new ServerProperties(audited)) | ||
| .hibernateConfigurator(hibernateConfigurator) | ||
| .configurationFolder(configurationFolder) | ||
| .build(); | ||
| server.start(); | ||
| server.close(); | ||
|
|
||
There was a problem hiding this comment.
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