Skip to content

Commit 29fa190

Browse files
committed
Make AccountClientTest.testGetWorkspaceClientForUnifiedHost hermetic with FixtureServer
Replace real unified.databricks.com hostname with FixtureServer to prevent host metadata resolution from hitting live servers during tests. Co-authored-by: Isaac
1 parent 91389f1 commit 29fa190

File tree

1 file changed

+22
-18
lines changed

1 file changed

+22
-18
lines changed

databricks-sdk-java/src/test/java/com/databricks/sdk/AccountClientTest.java

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
import static org.junit.jupiter.api.Assertions.*;
44

55
import com.databricks.sdk.core.DatabricksConfig;
6+
import com.databricks.sdk.core.FixtureServer;
67
import com.databricks.sdk.core.HostType;
78
import com.databricks.sdk.service.provisioning.Workspace;
9+
import java.io.IOException;
810
import org.junit.jupiter.api.Test;
911

1012
public class AccountClientTest {
@@ -31,30 +33,32 @@ public void testGetWorkspaceClientForTraditionalAccount() {
3133
}
3234

3335
@Test
34-
public void testGetWorkspaceClientForUnifiedHost() {
35-
String unifiedHost = "https://unified.databricks.com";
36-
DatabricksConfig accountConfig =
37-
new DatabricksConfig()
38-
.setHost(unifiedHost)
39-
.setAccountId("test-account")
40-
.setToken("test-token");
36+
public void testGetWorkspaceClientForUnifiedHost() throws IOException {
37+
try (FixtureServer server = new FixtureServer()) {
38+
String unifiedHost = server.getUrl();
39+
DatabricksConfig accountConfig =
40+
new DatabricksConfig()
41+
.setHost(unifiedHost)
42+
.setAccountId("test-account")
43+
.setToken("test-token");
4144

42-
AccountClient accountClient = new AccountClient(accountConfig);
45+
AccountClient accountClient = new AccountClient(accountConfig);
4346

44-
Workspace workspace = new Workspace();
45-
workspace.setWorkspaceId(123456L);
46-
workspace.setDeploymentName("test-workspace");
47+
Workspace workspace = new Workspace();
48+
workspace.setWorkspaceId(123456L);
49+
workspace.setDeploymentName("test-workspace");
4750

48-
WorkspaceClient workspaceClient = accountClient.getWorkspaceClient(workspace);
51+
WorkspaceClient workspaceClient = accountClient.getWorkspaceClient(workspace);
4952

50-
// Should have the same host (unified hosts reuse the same host)
51-
assertEquals(unifiedHost, workspaceClient.config().getHost());
53+
// Should have the same host (non-matching DNS zone means SPOG path)
54+
assertEquals(unifiedHost, workspaceClient.config().getHost());
5255

53-
// Should have workspace ID set
54-
assertEquals("123456", workspaceClient.config().getWorkspaceId());
56+
// Should have workspace ID set
57+
assertEquals("123456", workspaceClient.config().getWorkspaceId());
5558

56-
// Host type is WORKSPACE (determined from URL pattern, not unified flag)
57-
assertEquals(HostType.WORKSPACE, workspaceClient.config().getHostType());
59+
// Host type is WORKSPACE (no resolved host type from metadata, URL doesn't match accounts pattern)
60+
assertEquals(HostType.WORKSPACE, workspaceClient.config().getHostType());
61+
}
5862
}
5963

6064
@Test

0 commit comments

Comments
 (0)