-
Notifications
You must be signed in to change notification settings - Fork 9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HDFS-17751. [ARR] Add unit tests using asynchronous router rpc for al…
…l in org.apache.hadoop.hdfs.server.federation.router
- Loading branch information
1 parent
d552bb0
commit 713d92f
Showing
2 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
...va/org/apache/hadoop/hdfs/server/federation/router/async/TestSafeModeWithRouterAsync.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/** | ||
* 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 static org.apache.hadoop.hdfs.server.federation.FederationTestUtils.NAMENODES; | ||
|
||
import java.io.IOException; | ||
|
||
import org.apache.hadoop.conf.Configuration; | ||
import org.apache.hadoop.hdfs.protocol.ClientProtocol; | ||
import org.apache.hadoop.hdfs.protocol.HdfsConstants.SafeModeAction; | ||
import org.apache.hadoop.hdfs.server.federation.MiniRouterDFSCluster; | ||
import org.apache.hadoop.hdfs.server.federation.MiniRouterDFSCluster.RouterContext; | ||
import org.apache.hadoop.hdfs.server.federation.RouterConfigBuilder; | ||
import org.apache.hadoop.hdfs.server.federation.router.RBFConfigKeys; | ||
import org.apache.hadoop.hdfs.server.federation.router.TestSafeMode; | ||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
/** | ||
* Test the SafeMode using async router rpc. | ||
*/ | ||
public class TestSafeModeWithRouterAsync extends TestSafeMode { | ||
|
||
@Before | ||
public void setup() throws Exception { | ||
cluster = new MiniRouterDFSCluster(true, 2); | ||
Configuration routerConf = new RouterConfigBuilder().rpc().build(); | ||
routerConf.setBoolean(RBFConfigKeys.DFS_ROUTER_ASYNC_RPC_ENABLE_KEY, true); | ||
cluster.addRouterOverrides(routerConf); | ||
|
||
// Start NNs and DNs and wait until ready. | ||
cluster.startCluster(); | ||
|
||
// Start routers with only an RPC service. | ||
cluster.startRouters(); | ||
|
||
// Register and verify all NNs with all routers. | ||
cluster.registerNamenodes(); | ||
cluster.waitNamenodeRegistration(); | ||
|
||
// Setup the mount table. | ||
cluster.installMockLocations(); | ||
|
||
// Making one Namenodes active per nameservice. | ||
if (cluster.isHighAvailability()) { | ||
for (String ns : cluster.getNameservices()) { | ||
cluster.switchToActive(ns, NAMENODES[0]); | ||
cluster.switchToStandby(ns, NAMENODES[1]); | ||
} | ||
} | ||
cluster.waitActiveNamespaces(); | ||
} | ||
|
||
@After | ||
public void teardown() throws IOException { | ||
if (cluster != null) { | ||
cluster.shutdown(); | ||
cluster = null; | ||
} | ||
} | ||
|
||
@Test | ||
public void testProxySetSafemode() throws Exception { | ||
RouterContext routerContext = cluster.getRandomRouter(); | ||
ClientProtocol routerProtocol = routerContext.getClient().getNamenode(); | ||
routerProtocol.setSafeMode(SafeModeAction.SAFEMODE_GET, true); | ||
routerProtocol.setSafeMode(SafeModeAction.SAFEMODE_GET, false); | ||
} | ||
} |