|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | +package org.apache.polaris.service.quarkus.catalog; |
| 20 | + |
| 21 | +import static jakarta.ws.rs.core.Response.Status.CREATED; |
| 22 | +import static org.assertj.core.api.Assertions.assertThat; |
| 23 | + |
| 24 | +import io.quarkus.test.junit.QuarkusTest; |
| 25 | +import jakarta.ws.rs.core.Response; |
| 26 | +import java.util.List; |
| 27 | +import java.util.Map; |
| 28 | +import java.util.UUID; |
| 29 | +import org.apache.iceberg.rest.responses.ConfigResponse; |
| 30 | +import org.apache.polaris.core.admin.model.*; |
| 31 | +import org.apache.polaris.core.rest.PolarisEndpoints; |
| 32 | +import org.apache.polaris.service.TestServices; |
| 33 | +import org.junit.jupiter.params.ParameterizedTest; |
| 34 | +import org.junit.jupiter.params.provider.ValueSource; |
| 35 | + |
| 36 | +@QuarkusTest |
| 37 | +public class GetConfigTest { |
| 38 | + @ParameterizedTest |
| 39 | + @ValueSource(booleans = {true, false}) |
| 40 | + public void testGetConfig(boolean enableGenericTable) { |
| 41 | + TestServices services = |
| 42 | + TestServices.builder().config(Map.of("ENABLE_GENERIC_TABLES", enableGenericTable)).build(); |
| 43 | + |
| 44 | + FileStorageConfigInfo fileStorage = |
| 45 | + FileStorageConfigInfo.builder(StorageConfigInfo.StorageTypeEnum.FILE) |
| 46 | + .setAllowedLocations(List.of("file://")) |
| 47 | + .build(); |
| 48 | + String catalogName = "test-catalog-" + UUID.randomUUID(); |
| 49 | + Catalog catalog = |
| 50 | + PolarisCatalog.builder() |
| 51 | + .setType(Catalog.TypeEnum.INTERNAL) |
| 52 | + .setName(catalogName) |
| 53 | + .setProperties(new CatalogProperties("file:///tmp/path/to/data")) |
| 54 | + .setStorageConfigInfo(fileStorage) |
| 55 | + .build(); |
| 56 | + |
| 57 | + Response response = |
| 58 | + services |
| 59 | + .catalogsApi() |
| 60 | + .createCatalog( |
| 61 | + new CreateCatalogRequest(catalog), |
| 62 | + services.realmContext(), |
| 63 | + services.securityContext()); |
| 64 | + assertThat(response.getStatus()).isEqualTo(CREATED.getStatusCode()); |
| 65 | + |
| 66 | + response = |
| 67 | + services |
| 68 | + .restConfigurationApi() |
| 69 | + .getConfig(catalogName, services.realmContext(), services.securityContext()); |
| 70 | + ConfigResponse configResponse = response.readEntity(ConfigResponse.class); |
| 71 | + assertThat(configResponse.overrides()).contains(Map.entry("prefix", catalogName)); |
| 72 | + if (enableGenericTable) { |
| 73 | + assertThat(configResponse.endpoints()).contains(PolarisEndpoints.V1_CREATE_GENERIC_TABLE); |
| 74 | + assertThat(configResponse.endpoints()).contains(PolarisEndpoints.V1_DELETE_GENERIC_TABLE); |
| 75 | + assertThat(configResponse.endpoints()).contains(PolarisEndpoints.V1_LIST_GENERIC_TABLES); |
| 76 | + assertThat(configResponse.endpoints()).contains(PolarisEndpoints.V1_LOAD_GENERIC_TABLE); |
| 77 | + } else { |
| 78 | + assertThat(configResponse.endpoints()) |
| 79 | + .doesNotContain(PolarisEndpoints.V1_CREATE_GENERIC_TABLE); |
| 80 | + assertThat(configResponse.endpoints()) |
| 81 | + .doesNotContain(PolarisEndpoints.V1_DELETE_GENERIC_TABLE); |
| 82 | + assertThat(configResponse.endpoints()) |
| 83 | + .doesNotContain(PolarisEndpoints.V1_LIST_GENERIC_TABLES); |
| 84 | + assertThat(configResponse.endpoints()).doesNotContain(PolarisEndpoints.V1_LOAD_GENERIC_TABLE); |
| 85 | + } |
| 86 | + } |
| 87 | +} |
0 commit comments