Skip to content

Commit ce7c3ad

Browse files
committed
fix bug in test / the test should have failed before
1 parent 27fdecd commit ce7c3ad

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

runtime/service/src/intTest/java/org/apache/polaris/service/it/RestCatalogMinIOSpecialIT.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import io.quarkus.test.junit.TestProfile;
3131
import java.io.IOException;
3232
import java.io.InputStream;
33+
import java.net.InetAddress;
3334
import java.net.URI;
3435
import java.util.List;
3536
import java.util.Map;
@@ -223,19 +224,24 @@ public void testCreateTable(boolean pathStyle) throws IOException {
223224
}
224225

225226
@Test
226-
public void testInternalEndpoints() throws IOException {
227+
public void testInternalEndpoints() throws Exception {
228+
// Note: this test passed "before", although it should have always failed, because
229+
// 's3.example.com' cannot be resolved.
230+
231+
// Here, we replace 'localhost' with the IP address.
232+
var uri = URI.create(endpoint);
233+
var address = InetAddress.getByName(uri.getHost()).getHostAddress();
234+
var endpointByAddress =
235+
new URI(uri.getScheme(), null, address, uri.getPort(), "/", null, null).toString();
227236
try (RESTCatalog restCatalog =
228237
createCatalog(
229-
Optional.of("http://s3.example.com"),
230-
Optional.of(endpoint),
231-
false,
232-
Optional.of(endpoint))) {
238+
Optional.of(endpointByAddress), Optional.of(endpoint), false, Optional.of(endpoint))) {
233239
LoadTableResponse loadTableResponse = doTestCreateTable(restCatalog);
234-
assertThat(loadTableResponse.config()).containsEntry("s3.endpoint", "http://s3.example.com");
240+
assertThat(loadTableResponse.config()).containsEntry("s3.endpoint", endpointByAddress);
235241
}
236242
}
237243

238-
public LoadTableResponse doTestCreateTable(RESTCatalog restCatalog) throws IOException {
244+
public LoadTableResponse doTestCreateTable(RESTCatalog restCatalog) {
239245
catalogApi.createNamespace(catalogName, "test-ns");
240246
TableIdentifier id = TableIdentifier.of("test-ns", "t1");
241247
Table table = restCatalog.createTable(id, SCHEMA);

0 commit comments

Comments
 (0)