HDFS-15952. TestRouterRpcMultiDestination#testProxyGetTransactionID and testProxyVersionRequest are flaky. (#2970)
(cherry picked from commit 7c561e2a02
)
This commit is contained in:
parent
43fac739bb
commit
25244c4eec
@ -26,6 +26,7 @@
|
||||
import static org.apache.hadoop.hdfs.server.federation.FederationTestUtils.verifyFileExists;
|
||||
import static org.apache.hadoop.hdfs.server.federation.MiniRouterDFSCluster.TEST_STRING;
|
||||
import static org.apache.hadoop.test.GenericTestUtils.assertExceptionContains;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@ -179,6 +180,7 @@ public int compare(
|
||||
private NamenodeProtocol routerNamenodeProtocol;
|
||||
/** NameNodeProtocol interface to the Namenode. */
|
||||
private NamenodeProtocol nnNamenodeProtocol;
|
||||
private NamenodeProtocol nnNamenodeProtocol1;
|
||||
|
||||
/** Filesystem interface to the Router. */
|
||||
private FileSystem routerFS;
|
||||
@ -348,6 +350,11 @@ protected void setNamenode(NamenodeContext nn)
|
||||
NamenodeContext nn0 = cluster.getNamenode(ns0, null);
|
||||
this.nnNamenodeProtocol = NameNodeProxies.createProxy(nn0.getConf(),
|
||||
nn0.getFileSystem().getUri(), NamenodeProtocol.class).getProxy();
|
||||
// Namenode from the other namespace
|
||||
String ns1 = cluster.getNameservices().get(1);
|
||||
NamenodeContext nn1 = cluster.getNamenode(ns1, null);
|
||||
this.nnNamenodeProtocol1 = NameNodeProxies.createProxy(nn1.getConf(),
|
||||
nn1.getFileSystem().getUri(), NamenodeProtocol.class).getProxy();
|
||||
}
|
||||
|
||||
protected String getNs() {
|
||||
@ -1271,11 +1278,14 @@ public void testProxyVersionRequest() throws Exception {
|
||||
// Check with default namespace specified.
|
||||
NamespaceInfo rVersion = routerNamenodeProtocol.versionRequest();
|
||||
NamespaceInfo nnVersion = nnNamenodeProtocol.versionRequest();
|
||||
NamespaceInfo nnVersion1 = nnNamenodeProtocol1.versionRequest();
|
||||
compareVersion(rVersion, nnVersion);
|
||||
// Check with default namespace unspecified.
|
||||
resolver.setDisableNamespace(true);
|
||||
rVersion = routerNamenodeProtocol.versionRequest();
|
||||
compareVersion(rVersion, nnVersion);
|
||||
// Verify the NamespaceInfo is of nn0 or nn1
|
||||
boolean isNN0 =
|
||||
rVersion.getBlockPoolID().equals(nnVersion.getBlockPoolID());
|
||||
compareVersion(rVersion, isNN0 ? nnVersion : nnVersion1);
|
||||
} finally {
|
||||
resolver.setDisableNamespace(false);
|
||||
}
|
||||
@ -1344,11 +1354,13 @@ public void testProxyGetTransactionID() throws IOException {
|
||||
// Check with default namespace specified.
|
||||
long routerTransactionID = routerNamenodeProtocol.getTransactionID();
|
||||
long nnTransactionID = nnNamenodeProtocol.getTransactionID();
|
||||
long nnTransactionID1 = nnNamenodeProtocol1.getTransactionID();
|
||||
assertEquals(nnTransactionID, routerTransactionID);
|
||||
// Check with default namespace unspecified.
|
||||
resolver.setDisableNamespace(true);
|
||||
// Verify the transaction ID is of nn0 or nn1
|
||||
routerTransactionID = routerNamenodeProtocol.getTransactionID();
|
||||
assertEquals(nnTransactionID, routerTransactionID);
|
||||
assertThat(routerTransactionID).isIn(nnTransactionID, nnTransactionID1);
|
||||
} finally {
|
||||
resolver.setDisableNamespace(false);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user