dimas-b commented on code in PR #3729: URL: https://github.com/apache/polaris/pull/3729#discussion_r2850105303
########## integration-tests/src/main/java/org/apache/polaris/service/it/test/GcpCatalogFederationIntegrationTest.java: ########## @@ -0,0 +1,206 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.it.test; + +import static java.lang.String.format; +import static org.apache.polaris.service.it.env.PolarisClient.polarisClient; +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.List; +import java.util.UUID; +import org.apache.polaris.core.admin.model.AuthenticationParameters; +import org.apache.polaris.core.admin.model.Catalog; +import org.apache.polaris.core.admin.model.CatalogGrant; +import org.apache.polaris.core.admin.model.CatalogPrivilege; +import org.apache.polaris.core.admin.model.CatalogProperties; +import org.apache.polaris.core.admin.model.CatalogRole; +import org.apache.polaris.core.admin.model.ConnectionConfigInfo; +import org.apache.polaris.core.admin.model.ExternalCatalog; +import org.apache.polaris.core.admin.model.GcpAuthenticationParameters; +import org.apache.polaris.core.admin.model.GcpStorageConfigInfo; +import org.apache.polaris.core.admin.model.GrantResource; +import org.apache.polaris.core.admin.model.IcebergRestConnectionConfigInfo; +import org.apache.polaris.core.admin.model.PrincipalWithCredentials; +import org.apache.polaris.core.admin.model.StorageConfigInfo; +import org.apache.polaris.service.it.env.ClientCredentials; +import org.apache.polaris.service.it.env.ManagementApi; +import org.apache.polaris.service.it.env.PolarisApiEndpoints; +import org.apache.polaris.service.it.env.PolarisClient; +import org.apache.polaris.service.it.ext.PolarisIntegrationTestExtension; +import org.apache.polaris.service.it.ext.SparkSessionBuilder; +import org.apache.spark.sql.Dataset; +import org.apache.spark.sql.Row; +import org.apache.spark.sql.SparkSession; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.io.TempDir; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@ExtendWith(PolarisIntegrationTestExtension.class) +public class GcpCatalogFederationIntegrationTest { + + private static final Logger logger = + LoggerFactory.getLogger(GcpCatalogFederationIntegrationTest.class); + public static final String BIG_LAKE_REST_URI = + "https://biglake.googleapis.com/iceberg/v1/restcatalog"; + + static { + String googleCredentials = System.getenv("GOOGLE_APPLICATION_CREDENTIALS"); + if (googleCredentials == null) { + logger.warn("GOOGLE_APPLICATION_CREDENTIALS environment variable is not set"); + } else { + logger.info("GOOGLE_APPLICATION_CREDENTIALS = {}", googleCredentials); Review Comment: I'd suggest to avoid logging credentials. Developers can use a debugger to explore this, if necessary. ########## integration-tests/src/main/java/org/apache/polaris/service/it/test/GcpCatalogFederationIntegrationTest.java: ########## @@ -0,0 +1,206 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.it.test; + +import static java.lang.String.format; +import static org.apache.polaris.service.it.env.PolarisClient.polarisClient; +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.List; +import java.util.UUID; +import org.apache.polaris.core.admin.model.AuthenticationParameters; +import org.apache.polaris.core.admin.model.Catalog; +import org.apache.polaris.core.admin.model.CatalogGrant; +import org.apache.polaris.core.admin.model.CatalogPrivilege; +import org.apache.polaris.core.admin.model.CatalogProperties; +import org.apache.polaris.core.admin.model.CatalogRole; +import org.apache.polaris.core.admin.model.ConnectionConfigInfo; +import org.apache.polaris.core.admin.model.ExternalCatalog; +import org.apache.polaris.core.admin.model.GcpAuthenticationParameters; +import org.apache.polaris.core.admin.model.GcpStorageConfigInfo; +import org.apache.polaris.core.admin.model.GrantResource; +import org.apache.polaris.core.admin.model.IcebergRestConnectionConfigInfo; +import org.apache.polaris.core.admin.model.PrincipalWithCredentials; +import org.apache.polaris.core.admin.model.StorageConfigInfo; +import org.apache.polaris.service.it.env.ClientCredentials; +import org.apache.polaris.service.it.env.ManagementApi; +import org.apache.polaris.service.it.env.PolarisApiEndpoints; +import org.apache.polaris.service.it.env.PolarisClient; +import org.apache.polaris.service.it.ext.PolarisIntegrationTestExtension; +import org.apache.polaris.service.it.ext.SparkSessionBuilder; +import org.apache.spark.sql.Dataset; +import org.apache.spark.sql.Row; +import org.apache.spark.sql.SparkSession; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.io.TempDir; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@ExtendWith(PolarisIntegrationTestExtension.class) +public class GcpCatalogFederationIntegrationTest { + + private static final Logger logger = + LoggerFactory.getLogger(GcpCatalogFederationIntegrationTest.class); + public static final String BIG_LAKE_REST_URI = + "https://biglake.googleapis.com/iceberg/v1/restcatalog"; + + static { + String googleCredentials = System.getenv("GOOGLE_APPLICATION_CREDENTIALS"); Review Comment: `PolarisIntegrationTestExtension` will not be necessary. Please use `@QuarkusIntegration` as existing examples in that source tree. ########## integration-tests/src/main/java/org/apache/polaris/service/it/test/GcpCatalogFederationIntegrationTest.java: ########## @@ -0,0 +1,206 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.it.test; + +import static java.lang.String.format; +import static org.apache.polaris.service.it.env.PolarisClient.polarisClient; +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.List; +import java.util.UUID; +import org.apache.polaris.core.admin.model.AuthenticationParameters; +import org.apache.polaris.core.admin.model.Catalog; +import org.apache.polaris.core.admin.model.CatalogGrant; +import org.apache.polaris.core.admin.model.CatalogPrivilege; +import org.apache.polaris.core.admin.model.CatalogProperties; +import org.apache.polaris.core.admin.model.CatalogRole; +import org.apache.polaris.core.admin.model.ConnectionConfigInfo; +import org.apache.polaris.core.admin.model.ExternalCatalog; +import org.apache.polaris.core.admin.model.GcpAuthenticationParameters; +import org.apache.polaris.core.admin.model.GcpStorageConfigInfo; +import org.apache.polaris.core.admin.model.GrantResource; +import org.apache.polaris.core.admin.model.IcebergRestConnectionConfigInfo; +import org.apache.polaris.core.admin.model.PrincipalWithCredentials; +import org.apache.polaris.core.admin.model.StorageConfigInfo; +import org.apache.polaris.service.it.env.ClientCredentials; +import org.apache.polaris.service.it.env.ManagementApi; +import org.apache.polaris.service.it.env.PolarisApiEndpoints; +import org.apache.polaris.service.it.env.PolarisClient; +import org.apache.polaris.service.it.ext.PolarisIntegrationTestExtension; +import org.apache.polaris.service.it.ext.SparkSessionBuilder; +import org.apache.spark.sql.Dataset; +import org.apache.spark.sql.Row; +import org.apache.spark.sql.SparkSession; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.io.TempDir; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@ExtendWith(PolarisIntegrationTestExtension.class) +public class GcpCatalogFederationIntegrationTest { + + private static final Logger logger = + LoggerFactory.getLogger(GcpCatalogFederationIntegrationTest.class); + public static final String BIG_LAKE_REST_URI = + "https://biglake.googleapis.com/iceberg/v1/restcatalog"; + + static { + String googleCredentials = System.getenv("GOOGLE_APPLICATION_CREDENTIALS"); Review Comment: Traditionally, tests like this are grouped under https://github.com/apache/polaris/tree/main/runtime/service/src/cloudTest Would you mind moving this test there? ########## integration-tests/src/main/java/org/apache/polaris/service/it/test/GcpCatalogFederationIntegrationTest.java: ########## @@ -0,0 +1,206 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.polaris.service.it.test; + +import static java.lang.String.format; +import static org.apache.polaris.service.it.env.PolarisClient.polarisClient; +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.List; +import java.util.UUID; +import org.apache.polaris.core.admin.model.AuthenticationParameters; +import org.apache.polaris.core.admin.model.Catalog; +import org.apache.polaris.core.admin.model.CatalogGrant; +import org.apache.polaris.core.admin.model.CatalogPrivilege; +import org.apache.polaris.core.admin.model.CatalogProperties; +import org.apache.polaris.core.admin.model.CatalogRole; +import org.apache.polaris.core.admin.model.ConnectionConfigInfo; +import org.apache.polaris.core.admin.model.ExternalCatalog; +import org.apache.polaris.core.admin.model.GcpAuthenticationParameters; +import org.apache.polaris.core.admin.model.GcpStorageConfigInfo; +import org.apache.polaris.core.admin.model.GrantResource; +import org.apache.polaris.core.admin.model.IcebergRestConnectionConfigInfo; +import org.apache.polaris.core.admin.model.PrincipalWithCredentials; +import org.apache.polaris.core.admin.model.StorageConfigInfo; +import org.apache.polaris.service.it.env.ClientCredentials; +import org.apache.polaris.service.it.env.ManagementApi; +import org.apache.polaris.service.it.env.PolarisApiEndpoints; +import org.apache.polaris.service.it.env.PolarisClient; +import org.apache.polaris.service.it.ext.PolarisIntegrationTestExtension; +import org.apache.polaris.service.it.ext.SparkSessionBuilder; +import org.apache.spark.sql.Dataset; +import org.apache.spark.sql.Row; +import org.apache.spark.sql.SparkSession; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.io.TempDir; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@ExtendWith(PolarisIntegrationTestExtension.class) +public class GcpCatalogFederationIntegrationTest { + + private static final Logger logger = + LoggerFactory.getLogger(GcpCatalogFederationIntegrationTest.class); + public static final String BIG_LAKE_REST_URI = + "https://biglake.googleapis.com/iceberg/v1/restcatalog"; + + static { + String googleCredentials = System.getenv("GOOGLE_APPLICATION_CREDENTIALS"); + if (googleCredentials == null) { + logger.warn("GOOGLE_APPLICATION_CREDENTIALS environment variable is not set"); + } else { + logger.info("GOOGLE_APPLICATION_CREDENTIALS = {}", googleCredentials); + } + } + + @TempDir static java.nio.file.Path warehouseDir; + + public static final String SERVICE_ACCOUNT = + System.getenv("INTEGRATION_TEST_GCS_SERVICE_ACCOUNT"); + public static final String FEDERATED_CATALOG = + System.getenv("INTEGRATION_TEST_GCS_FEDERATED_CATALOG"); + public static final String QUOTA_PROJECT = + System.getenv("INTEGRATION_TEST_GCS_FEDERATED_QUOTA_PROJECT"); + public static final String BASE_LOCATION = System.getenv("INTEGRATION_TEST_GCS_FEDERATED_PATH"); + + private static final String PRINCIPAL_NAME = "test-catalog-federation-user"; + private static final String PRINCIPAL_ROLE_NAME = "test-catalog-federation-user-role"; + private String localCatalogName; + + protected StorageConfigInfo getStorageConfigInfo() { + return GcpStorageConfigInfo.builder() + .setGcsServiceAccount(SERVICE_ACCOUNT) + .setStorageType(StorageConfigInfo.StorageTypeEnum.GCS) + .setAllowedLocations(List.of(BASE_LOCATION)) + .build(); + } + + private static final CatalogGrant defaultCatalogGrant = + CatalogGrant.builder() + .setType(GrantResource.TypeEnum.CATALOG) + .setPrivilege(CatalogPrivilege.CATALOG_MANAGE_CONTENT) + .build(); + + private static PolarisApiEndpoints endpoints; + private static PolarisClient client; + private static ManagementApi managementApi; + private SparkSession spark; + private PrincipalWithCredentials newUserCredentials; + + @BeforeAll + static void setup(PolarisApiEndpoints apiEndpoints, ClientCredentials credentials) { + endpoints = apiEndpoints; + client = polarisClient(endpoints); + String adminToken = client.obtainToken(credentials); + managementApi = client.managementApi(adminToken); + } + + @BeforeEach + void before() { + setupCatalogs(); + setupSpark(); + } + + private void setupSpark() { Review Comment: nit: Using Spark for this test is fine, but I suppose it could be done from a simpler java client... Cf. `RestCatalogMinIOSpecialIT`. The test code may be more verbose, but hopefully faster to run and easier to debug (if it comes to that). This is optional. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
