|
| 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 = new DatabricksConfig().setHost(host); |
| 26 | + config.resolve(); |
| 27 | + |
| 28 | + LOG.info( |
| 29 | + "Resolved metadata for {}: accountId={}, workspaceId={}, discoveryUrl={}", |
| 30 | + host, |
| 31 | + config.getAccountId(), |
| 32 | + config.getWorkspaceId(), |
| 33 | + config.getDiscoveryUrl()); |
| 34 | + |
| 35 | + // After resolve(), host metadata should have been resolved |
| 36 | + assertNotNull(config.getDiscoveryUrl(), "Expected discoveryUrl to be populated after resolve"); |
| 37 | + assertFalse(config.getDiscoveryUrl().isEmpty(), "Expected non-empty discoveryUrl"); |
| 38 | + assertNotNull(config.getAccountId(), "Expected accountId to be populated after resolve"); |
| 39 | + assertFalse(config.getAccountId().isEmpty(), "Expected non-empty accountId"); |
| 40 | + } |
| 41 | +} |
0 commit comments