Skip to content

Commit f28430b

Browse files
Add integration test for host metadata resolution (#719)
## 🥞 Stacked PR Use this [link](https://github.com/databricks/databricks-sdk-java/pull/719/files) to review incremental changes. - [**hectorcast-db/stack/port-7-integration-test-metadata**](#719) [[Files changed](https://github.com/databricks/databricks-sdk-java/pull/719/files)] - [hectorcast-db/stack/port-8-remove-unified-flag](#720) [[Files changed](https://github.com/databricks/databricks-sdk-java/pull/720/files/cbd81a9a8534a735250b64fe3957a3923b6da899..34394bc5a5eb92745574c42c336a326c8719cebd)] --------- ## Summary Port of Go SDK [#1546](databricks/databricks-sdk-go#1546). Adds an integration test verifying that `config.resolve()` populates `accountId`, `workspaceId`, and `discoveryUrl` from the host's `/.well-known/databricks-config` endpoint. **Changes:** - `HostMetadataIT`: integration test for metadata resolution (requires `DATABRICKS_HOST` via `ucws` env context) `NO_CHANGELOG=true` ## Test plan - [x] All unit tests pass (no production code changes) - [x] `HostMetadataIT` runs against live workspace
1 parent f3156e2 commit f28430b

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.databricks.sdk.integration;
2+
3+
import static org.junit.jupiter.api.Assertions.*;
4+
5+
import com.databricks.sdk.core.DatabricksConfig;
6+
import com.databricks.sdk.integration.framework.EnvContext;
7+
import com.databricks.sdk.integration.framework.EnvOrSkip;
8+
import com.databricks.sdk.integration.framework.EnvTest;
9+
import org.junit.jupiter.api.Test;
10+
import org.junit.jupiter.api.extension.ExtendWith;
11+
import org.slf4j.Logger;
12+
import org.slf4j.LoggerFactory;
13+
14+
/**
15+
* Integration test for host metadata resolution via /.well-known/databricks-config. Port of Go SDK
16+
* #1546.
17+
*/
18+
@ExtendWith(EnvTest.class)
19+
@EnvContext("ucws")
20+
public class HostMetadataIT {
21+
private static final Logger LOG = LoggerFactory.getLogger(HostMetadataIT.class);
22+
23+
@Test
24+
void testResolvePopulatesFieldsFromMetadata(@EnvOrSkip("DATABRICKS_HOST") String host) {
25+
DatabricksConfig config =
26+
new DatabricksConfig().setHost(host).setExperimentalIsUnifiedHost(true);
27+
config.resolve();
28+
29+
LOG.info(
30+
"Resolved metadata for {}: accountId={}, workspaceId={}, discoveryUrl={}",
31+
host,
32+
config.getAccountId(),
33+
config.getWorkspaceId(),
34+
config.getDiscoveryUrl());
35+
36+
// After resolve(), host metadata should have been resolved
37+
assertNotNull(config.getDiscoveryUrl(), "Expected discoveryUrl to be populated after resolve");
38+
assertFalse(config.getDiscoveryUrl().isEmpty(), "Expected non-empty discoveryUrl");
39+
assertNotNull(config.getAccountId(), "Expected accountId to be populated after resolve");
40+
assertFalse(config.getAccountId().isEmpty(), "Expected non-empty accountId");
41+
}
42+
}

0 commit comments

Comments
 (0)