Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import static io.polaris.service.context.DefaultContextResolver.REALM_PROPERTY_KEY;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.Assertions.fail;

import io.dropwizard.testing.ConfigOverride;
import io.dropwizard.testing.ResourceHelpers;
Expand Down Expand Up @@ -65,7 +64,6 @@
import org.apache.iceberg.exceptions.NoSuchNamespaceException;
import org.apache.iceberg.exceptions.NoSuchTableException;
import org.apache.iceberg.exceptions.RESTException;
import org.apache.iceberg.exceptions.ServiceFailureException;
import org.apache.iceberg.hadoop.HadoopFileIO;
import org.apache.iceberg.io.ResolvingFileIO;
import org.apache.iceberg.rest.RESTSessionCatalog;
Expand Down Expand Up @@ -308,14 +306,8 @@ public void testIcebergListNamespaces() throws IOException {

@Test
public void testConfigureCatalogCaseSensitive() throws IOException {
try {
RESTSessionCatalog sessionCatalog = newSessionCatalog("TESTCONFIGURECATALOGCASESENSITIVE");
fail("Expected exception connecting to catalog");
} catch (ServiceFailureException e) {
fail("Unexpected service failure exception", e);
} catch (RESTException e) {
LoggerFactory.getLogger(getClass()).info("Caught expected rest exception", e);
}
assertThatThrownBy(() -> newSessionCatalog("TESTCONFIGURECATALOGCASESENSITIVE"))
.isInstanceOf(RESTException.class);
}

@Test
Expand Down Expand Up @@ -400,12 +392,8 @@ public void testIcebergDropNamespaceInExternalCatalog(TestInfo testInfo) throws
List<Namespace> namespaces = sessionCatalog.listNamespaces(sessionContext);
assertThat(namespaces).isNotNull().hasSize(1).containsExactly(ns);
sessionCatalog.dropNamespace(sessionContext, ns);
try {
sessionCatalog.loadNamespaceMetadata(sessionContext, ns);
Assertions.fail("Expected exception when loading namespace after drop");
} catch (NoSuchNamespaceException e) {
LOGGER.info("Received expected exception {}", e.getMessage());
}
assertThatThrownBy(() -> sessionCatalog.loadNamespaceMetadata(sessionContext, ns))
.isInstanceOf(NoSuchNamespaceException.class);
}
}

Expand All @@ -417,21 +405,21 @@ public void testIcebergCreateTablesInExternalCatalog(TestInfo testInfo) throws I
SessionCatalog.SessionContext sessionContext = SessionCatalog.SessionContext.createEmpty();
Namespace ns = Namespace.of("db1");
sessionCatalog.createNamespace(sessionContext, ns);
try {
sessionCatalog
.buildTable(
sessionContext,
TableIdentifier.of(ns, "the_table"),
new Schema(
List.of(Types.NestedField.of(1, false, "theField", Types.StringType.get()))))
.withLocation("file:///tmp/tables")
.withSortOrder(SortOrder.unsorted())
.withPartitionSpec(PartitionSpec.unpartitioned())
.create();
Assertions.fail("Expected failure calling create table in external catalog");
} catch (BadRequestException e) {
LOGGER.info("Received expected exception {}", e.getMessage());
}
assertThatThrownBy(
() ->
sessionCatalog
.buildTable(
sessionContext,
TableIdentifier.of(ns, "the_table"),
new Schema(
List.of(
Types.NestedField.of(
1, false, "theField", Types.StringType.get()))))
.withLocation("file:///tmp/tables")
.withSortOrder(SortOrder.unsorted())
.withPartitionSpec(PartitionSpec.unpartitioned())
.create())
.isInstanceOf(BadRequestException.class);
}
}

Expand Down Expand Up @@ -571,19 +559,17 @@ public void testIcebergUpdateTableInExternalCatalog(TestInfo testInfo) throws IO
sessionCatalog.registerTable(sessionContext, tableIdentifier, metadataLocation);
Table table = sessionCatalog.loadTable(sessionContext, tableIdentifier);
((ResolvingFileIO) table.io()).setConf(new Configuration());
try {
table
.newAppend()
.appendFile(
new TestHelpers.TestDataFile(
location + "/path/to/file.parquet",
new PartitionData(PartitionSpec.unpartitioned().partitionType()),
10L))
.commit();
Assertions.fail("Should fail when committing an update to external catalog");
} catch (BadRequestException e) {
LOGGER.info("Received expected exception {}", e.getMessage());
}
assertThatThrownBy(
() ->
table
.newAppend()
.appendFile(
new TestHelpers.TestDataFile(
location + "/path/to/file.parquet",
new PartitionData(PartitionSpec.unpartitioned().partitionType()),
10L))
.commit())
.isInstanceOf(BadRequestException.class);
}
}

Expand Down Expand Up @@ -626,12 +612,8 @@ public void testIcebergDropTableInExternalCatalog(TestInfo testInfo) throws IOEx
Table table = sessionCatalog.loadTable(sessionContext, tableIdentifier);
assertThat(table).isNotNull();
sessionCatalog.dropTable(sessionContext, tableIdentifier);
try {
sessionCatalog.loadTable(sessionContext, tableIdentifier);
Assertions.fail("Expected failure loading table after drop");
} catch (NoSuchTableException e) {
LOGGER.info("Received expected exception {}", e.getMessage());
}
assertThatThrownBy(() -> sessionCatalog.loadTable(sessionContext, tableIdentifier))
.isInstanceOf(NoSuchTableException.class);
}
}

Expand All @@ -640,25 +622,22 @@ public void testWarehouseNotSpecified() throws IOException {
try (RESTSessionCatalog sessionCatalog = new RESTSessionCatalog()) {
String emptyEnvironmentVariable = "env:__NULL_ENV_VARIABLE__";
assertThat(EnvironmentUtil.resolveAll(Map.of("", emptyEnvironmentVariable)).get("")).isNull();
sessionCatalog.initialize(
"snowflake",
Map.of(
"uri",
"http://localhost:" + EXT.getLocalPort() + "/api/catalog",
OAuth2Properties.CREDENTIAL,
snowmanCredentials.clientId() + ":" + snowmanCredentials.clientSecret(),
OAuth2Properties.SCOPE,
BasePolarisAuthenticator.PRINCIPAL_ROLE_ALL,
"warehouse",
emptyEnvironmentVariable,
"header." + REALM_PROPERTY_KEY,
realm));
fail("Expected exception due to null warehouse");
} catch (ServiceFailureException e) {
fail("Unexpected service failure exception", e);
} catch (RESTException e) {
LoggerFactory.getLogger(getClass()).info("Caught expected rest exception", e);
assertThat(e).isInstanceOf(BadRequestException.class);
assertThatThrownBy(
() ->
sessionCatalog.initialize(
"snowflake",
Map.of(
"uri",
"http://localhost:" + EXT.getLocalPort() + "/api/catalog",
OAuth2Properties.CREDENTIAL,
snowmanCredentials.clientId() + ":" + snowmanCredentials.clientSecret(),
OAuth2Properties.SCOPE,
BasePolarisAuthenticator.PRINCIPAL_ROLE_ALL,
"warehouse",
emptyEnvironmentVariable,
"header." + REALM_PROPERTY_KEY,
realm)))
.isInstanceOf(BadRequestException.class);
}
}
}