[ https://issues.apache.org/jira/browse/HDFS-17731?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17930163#comment-17930163 ]
ASF GitHub Bot commented on HDFS-17731: --------------------------------------- hfutatzhanghb commented on code in PR #7409: URL: https://github.com/apache/hadoop/pull/7409#discussion_r1969254736 ########## hadoop-hdfs-project/hadoop-hdfs-rbf/src/test/java/org/apache/hadoop/hdfs/server/federation/router/async/TestAsyncRouterAdmin.java: ########## @@ -0,0 +1,119 @@ +/** + * 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.hadoop.hdfs.server.federation.router.async; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.ha.HAServiceProtocol; +import org.apache.hadoop.hdfs.protocol.HdfsFileStatus; +import org.apache.hadoop.hdfs.server.federation.RouterConfigBuilder; +import org.apache.hadoop.hdfs.server.federation.StateStoreDFSCluster; +import org.apache.hadoop.hdfs.server.federation.resolver.ActiveNamenodeResolver; +import org.apache.hadoop.hdfs.server.federation.resolver.RemoteLocation; +import org.apache.hadoop.hdfs.server.federation.router.RemoteMethod; +import org.apache.hadoop.hdfs.server.federation.router.Router; +import org.apache.hadoop.hdfs.server.federation.router.RouterRpcServer; +import org.apache.hadoop.hdfs.server.federation.router.TestRouterAdmin; +import org.apache.hadoop.hdfs.server.federation.router.async.utils.AsyncUtil; +import org.apache.hadoop.util.Lists; +import org.junit.BeforeClass; +import org.mockito.Mockito; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +import static org.apache.hadoop.hdfs.server.federation.FederationTestUtils.createNamenodeReport; +import static org.apache.hadoop.hdfs.server.federation.router.RBFConfigKeys.DFS_ROUTER_ADMIN_MOUNT_CHECK_ENABLE; +import static org.apache.hadoop.hdfs.server.federation.router.RBFConfigKeys.DFS_ROUTER_ASYNC_RPC_ENABLE_KEY; + +public class TestAsyncRouterAdmin extends TestRouterAdmin { + + @BeforeClass + public static void globalSetUp() throws Exception { + cluster = new StateStoreDFSCluster(false, 1); + // Build and start a router with State Store + admin + RPC + Configuration conf = new RouterConfigBuilder() + .stateStore() + .admin() + .rpc() + .build(); + conf.setBoolean(DFS_ROUTER_ADMIN_MOUNT_CHECK_ENABLE, true); + conf.setBoolean(DFS_ROUTER_ASYNC_RPC_ENABLE_KEY, true); + + cluster.addRouterOverrides(conf); + cluster.startRouters(); + routerContext = cluster.getRandomRouter(); + mockMountTable = cluster.generateMockMountTable(); + Router router = routerContext.getRouter(); + stateStore = router.getStateStore(); + + // Add two name services for testing disabling + ActiveNamenodeResolver membership = router.getNamenodeResolver(); + membership.registerNamenode( + createNamenodeReport("ns0", "nn1", HAServiceProtocol.HAServiceState.ACTIVE)); + membership.registerNamenode( + createNamenodeReport("ns1", "nn1", HAServiceProtocol.HAServiceState.ACTIVE)); + stateStore.refreshCaches(true); + + setUpMocks(); + } + + private static void setUpMocks() + throws IOException, NoSuchFieldException, IllegalAccessException { + RouterRpcServer spyRpcServer = + Mockito.spy(routerContext.getRouter().createRpcServer()); + //Used reflection to set the 'rpcServer field' Review Comment: Sir, thanks for reviewing, have fixed and also fix the same problems in TestRouterAdmin.java. > [ARR] Add unit test for async RouterAdminServer > ----------------------------------------------- > > Key: HDFS-17731 > URL: https://issues.apache.org/jira/browse/HDFS-17731 > Project: Hadoop HDFS > Issue Type: Sub-task > Components: rbf > Affects Versions: 3.4.1 > Reporter: farmmamba > Assignee: farmmamba > Priority: Major > Labels: pull-request-available > > Add unit test for async RouterAdminServer -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org