jerryshao commented on code in PR #14812: URL: https://github.com/apache/gravitino/pull/14812#discussion_r4522261178
########## iceberg/iceberg-common/src/test/java/org/apache/gravitino/iceberg/common/ops/TestKerberosAwareIcebergCatalogProxy.java: ########## @@ -0,0 +1,125 @@ +/* + * 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.gravitino.iceberg.common.ops; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; +import org.apache.gravitino.iceberg.common.IcebergConfig; +import org.apache.gravitino.iceberg.common.authentication.SupportsKerberos; +import org.apache.iceberg.catalog.Catalog; +import org.apache.iceberg.inmemory.InMemoryCatalog; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class TestKerberosAwareIcebergCatalogProxy { + + private static final AtomicInteger WRAPPER_CONSTRUCTIONS = new AtomicInteger(); + private static final AtomicInteger CATALOG_CONSTRUCTIONS = new AtomicInteger(); + private static final AtomicInteger CATALOG_CLOSES = new AtomicInteger(); + private static final AtomicInteger KERBEROS_OPERATIONS = new AtomicInteger(); + + /** A catalog that counts how often it is created, closed and used under Kerberos. */ + public static class CountingKerberosCatalog extends InMemoryCatalog implements SupportsKerberos { + public CountingKerberosCatalog() { + CATALOG_CONSTRUCTIONS.incrementAndGet(); + } + + @Override + public <R> R doKerberosOperations(Executable<R> executable) throws Throwable { + KERBEROS_OPERATIONS.incrementAndGet(); + return executable.execute(); + } + + @Override + public void close() { + CATALOG_CLOSES.incrementAndGet(); + } + } + + /** A wrapper that creates one {@link CountingKerberosCatalog} per constructed instance. */ + public static class CountingWrapper extends IcebergCatalogWrapper { + private final Catalog countingCatalog = new CountingKerberosCatalog(); Review Comment: Added `TestKerberosAwareCatalogWrapperForREST` in iceberg-rest-server (proxies a real `CatalogWrapperForREST`, asserts the constructor runs once and the proxy has no credential manager of its own), and made the iceberg-common test wrapper load its catalog lazily. _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_ -- 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]
