bharos commented on code in PR #10652:
URL: https://github.com/apache/gravitino/pull/10652#discussion_r3024803584
##########
iceberg/iceberg-rest-server/src/test/java/org/apache/gravitino/iceberg/service/rest/TestIcebergConfig.java:
##########
@@ -104,12 +117,62 @@ public void testConfigWithNonExistentWarehouses(String
warehouse) {
Assertions.assertEquals(404, resp.getStatus());
}
+ @Test
+ public void testConfigWithPrefixReturnsCatalogConfig() {
+ // When prefix is specified, the config endpoint should return catalog
properties
+ // for the catalog that the prefix represents
+ setUrlPathWithPrefix(IcebergRestTestUtil.PREFIX);
+ Response resp = getConfigClientBuilder().get();
+ Assertions.assertEquals(Response.Status.OK.getStatusCode(),
resp.getStatus());
+ Assertions.assertEquals(MediaType.APPLICATION_JSON_TYPE,
resp.getMediaType());
+
+ ConfigResponse response = resp.readEntity(ConfigResponse.class);
+ Map<String, String> expectedConfig =
+ ImmutableMap.of(
+ "prefix",
+ IcebergRestTestUtil.PREFIX,
+ IcebergConstants.IO_IMPL,
+ "org.apache.iceberg.aws.s3.S3FileIO",
+ IcebergConstants.ICEBERG_S3_ENDPOINT,
+ "https://s3-endpoint.example.com",
+ IcebergConstants.AWS_S3_REGION,
+ "us-west-2",
+ IcebergConstants.ICEBERG_OSS_ENDPOINT,
+ "https://oss-endpoint.example.com",
+ IcebergConstants.ICEBERG_S3_PATH_STYLE_ACCESS,
+ "true");
+ Assertions.assertEquals(expectedConfig, response.defaults());
+ Assertions.assertEquals(0, response.overrides().size());
+ }
+
+ @Test
+ public void testConfigWithPrefixAndWarehouse() {
+ // When both prefix and warehouse are specified, prefix takes precedence
+ // for catalog resolution, warehouse is used for the prefix default
+ setUrlPathWithPrefix(IcebergRestTestUtil.PREFIX);
Review Comment:
The test sets both prefix and warehouse to IcebergRestTestUtil.PREFIX (same
value)
The assertion response.defaults().get("prefix") == PREFIX passes regardless
of which branch wins.
Use distinct values to actually test the priority ?
##########
iceberg/iceberg-rest-server/src/main/java/org/apache/gravitino/iceberg/service/rest/IcebergConfigOperations.java:
##########
@@ -98,13 +99,19 @@ public IcebergConfigOperations(IcebergCatalogWrapperManager
catalogWrapperManage
@Produces(MediaType.APPLICATION_JSON)
@Timed(name = "config." + MetricNames.HTTP_PROCESS_DURATION, absolute = true)
@ResponseMetered(name = "config", absolute = true)
- public Response getConfig(@DefaultValue("") @QueryParam("warehouse") String
warehouse) {
- String catalogName = getCatalogName(warehouse);
+ public Response getConfig(
+ @DefaultValue("") @PathParam("prefix") String prefix,
Review Comment:
@DefaultValue on a @PathParam is unusual — a path param derived from a regex
like ([^/]*/)? already captures an empty string when the segment is absent.
It's harmless but maybe we can remove it for clarity. The other endpoints
(e.g., IcebergTableOperations) don't annotate their prefix path param with
@DefaultValue
--
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]