mchades commented on code in PR #13367: URL: https://github.com/apache/gravitino/pull/13367#discussion_r4059809278
########## core/src/test/java/org/apache/gravitino/TestGravitinoEnvMetadataComponents.java: ########## @@ -0,0 +1,161 @@ +/* + * 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; + +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.mockStatic; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.withSettings; + +import java.util.Collections; +import org.apache.commons.lang3.reflect.FieldUtils; +import org.apache.gravitino.lock.LockManager; +import org.apache.gravitino.stats.StatisticManager; +import org.apache.gravitino.stats.storage.MemoryPartitionStatsStorageFactory; +import org.junit.jupiter.api.Test; +import org.mockito.MockedStatic; + +class TestGravitinoEnvMetadataComponents { + + @Test + void testMetadataProfileProvidesCompleteMetadataAccessWithoutServerServices() throws Exception { + Config config = metadataConfig(false); + EntityStore entityStore = relationStore(); + TestGravitinoEnv env = new TestGravitinoEnv(); + Object originalLockManager = installSingletonLock(config); + + try (MockedStatic<EntityStoreFactory> entityStoreFactory = + mockStatic(EntityStoreFactory.class)) { + entityStoreFactory + .when(() -> EntityStoreFactory.createEntityStore(config)) + .thenReturn(entityStore); + + env.initializeMetadataComponents(config); + + assertSame(entityStore, env.entityStore()); + assertNotNull(env.catalogManager()); + assertNotNull(env.internalMetalakeDispatcher()); + assertNotNull(env.internalCatalogDispatcher()); + assertNotNull(env.internalFilesetDispatcher()); + assertNotNull(env.internalSchemaDispatcher()); + assertNotNull(env.internalTableDispatcher()); + assertNotNull(env.internalPartitionDispatcher()); + assertNotNull(env.internalTopicDispatcher()); + assertNotNull(env.internalModelDispatcher()); + assertNotNull(env.internalFunctionDispatcher()); + assertNotNull(env.internalViewDispatcher()); + assertNotNull(env.semanticModelDispatcher()); + assertNotNull(env.credentialOperationDispatcher()); + assertNotNull(env.secretPropertyOperationDispatcher()); + assertNotNull(env.internalTagDispatcher()); + assertNotNull(env.internalPolicyDispatcher()); + assertInstanceOf(StatisticManager.class, env.statisticDispatcher()); + assertNotNull(env.lockManager()); + assertNotNull(env.metricsSystem()); + assertNotNull(env.secretManager()); + + assertNull(env.auxServiceManager()); + assertNull(env.eventListenerManager()); + assertNull(env.metalakeDispatcher()); + assertNull(env.catalogDispatcher()); + assertNull(env.filesetDispatcher()); + assertNull(env.schemaDispatcher()); + assertNull(env.tableDispatcher()); + assertNull(env.partitionDispatcher()); + assertNull(env.topicDispatcher()); + assertNull(env.modelDispatcher()); + assertNull(env.functionDispatcher()); + assertNull(env.viewDispatcher()); + assertNull(env.tagDispatcher()); + assertNull(env.policyDispatcher()); + assertNull(env.internalAccessControlDispatcher()); + assertNull(env.internalOwnerDispatcher()); + assertNull(env.bulkManager()); + assertNull(env.futureGrantManager()); + assertThrows(IllegalArgumentException.class, env::eventBus); + assertThrows(IllegalArgumentException.class, env::jobOperationDispatcher); + assertThrows(IllegalArgumentException.class, env::internalJobOperationDispatcher); + + assertDoesNotThrow(env::start); Review Comment: Updated in `178321cea9`. The metadata-profile test now calls `internalMetalakeDispatcher().listMetalakes()` and verifies the resulting `EntityStore.list(...)` call. The authorization test now verifies `EntityStore.close()`. I also added a full-profile regression test for the fileset/schema/table/topic/model/function/view chains and for partition/statistic delegate reuse. -- 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]
