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.FederationTestUtils.verifyFileExists;
|
||||||
import static org.apache.hadoop.hdfs.server.federation.MiniRouterDFSCluster.TEST_STRING;
|
import static org.apache.hadoop.hdfs.server.federation.MiniRouterDFSCluster.TEST_STRING;
|
||||||
import static org.apache.hadoop.test.GenericTestUtils.assertExceptionContains;
|
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.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
@ -179,6 +180,7 @@ public int compare(
|
|||||||
private NamenodeProtocol routerNamenodeProtocol;
|
private NamenodeProtocol routerNamenodeProtocol;
|
||||||
/** NameNodeProtocol interface to the Namenode. */
|
/** NameNodeProtocol interface to the Namenode. */
|
||||||
private NamenodeProtocol nnNamenodeProtocol;
|
private NamenodeProtocol nnNamenodeProtocol;
|
||||||
|
private NamenodeProtocol nnNamenodeProtocol1;
|
||||||
|
|
||||||
/** Filesystem interface to the Router. */
|
/** Filesystem interface to the Router. */
|
||||||
private FileSystem routerFS;
|
private FileSystem routerFS;
|
||||||
@ -348,6 +350,11 @@ protected void setNamenode(NamenodeContext nn)
|
|||||||
NamenodeContext nn0 = cluster.getNamenode(ns0, null);
|
NamenodeContext nn0 = cluster.getNamenode(ns0, null);
|
||||||
this.nnNamenodeProtocol = NameNodeProxies.createProxy(nn0.getConf(),
|
this.nnNamenodeProtocol = NameNodeProxies.createProxy(nn0.getConf(),
|
||||||
nn0.getFileSystem().getUri(), NamenodeProtocol.class).getProxy();
|
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() {
|
protected String getNs() {
|
||||||
@ -1271,11 +1278,14 @@ public void testProxyVersionRequest() throws Exception {
|
|||||||
// Check with default namespace specified.
|
// Check with default namespace specified.
|
||||||
NamespaceInfo rVersion = routerNamenodeProtocol.versionRequest();
|
NamespaceInfo rVersion = routerNamenodeProtocol.versionRequest();
|
||||||
NamespaceInfo nnVersion = nnNamenodeProtocol.versionRequest();
|
NamespaceInfo nnVersion = nnNamenodeProtocol.versionRequest();
|
||||||
|
NamespaceInfo nnVersion1 = nnNamenodeProtocol1.versionRequest();
|
||||||
compareVersion(rVersion, nnVersion);
|
compareVersion(rVersion, nnVersion);
|
||||||
// Check with default namespace unspecified.
|
// Check with default namespace unspecified.
|
||||||
resolver.setDisableNamespace(true);
|
resolver.setDisableNamespace(true);
|
||||||
rVersion = routerNamenodeProtocol.versionRequest();
|
// Verify the NamespaceInfo is of nn0 or nn1
|
||||||
compareVersion(rVersion, nnVersion);
|
boolean isNN0 =
|
||||||
|
rVersion.getBlockPoolID().equals(nnVersion.getBlockPoolID());
|
||||||
|
compareVersion(rVersion, isNN0 ? nnVersion : nnVersion1);
|
||||||
} finally {
|
} finally {
|
||||||
resolver.setDisableNamespace(false);
|
resolver.setDisableNamespace(false);
|
||||||
}
|
}
|
||||||
@ -1344,11 +1354,13 @@ public void testProxyGetTransactionID() throws IOException {
|
|||||||
// Check with default namespace specified.
|
// Check with default namespace specified.
|
||||||
long routerTransactionID = routerNamenodeProtocol.getTransactionID();
|
long routerTransactionID = routerNamenodeProtocol.getTransactionID();
|
||||||
long nnTransactionID = nnNamenodeProtocol.getTransactionID();
|
long nnTransactionID = nnNamenodeProtocol.getTransactionID();
|
||||||
|
long nnTransactionID1 = nnNamenodeProtocol1.getTransactionID();
|
||||||
assertEquals(nnTransactionID, routerTransactionID);
|
assertEquals(nnTransactionID, routerTransactionID);
|
||||||
// Check with default namespace unspecified.
|
// Check with default namespace unspecified.
|
||||||
resolver.setDisableNamespace(true);
|
resolver.setDisableNamespace(true);
|
||||||
|
// Verify the transaction ID is of nn0 or nn1
|
||||||
routerTransactionID = routerNamenodeProtocol.getTransactionID();
|
routerTransactionID = routerNamenodeProtocol.getTransactionID();
|
||||||
assertEquals(nnTransactionID, routerTransactionID);
|
assertThat(routerTransactionID).isIn(nnTransactionID, nnTransactionID1);
|
||||||
} finally {
|
} finally {
|
||||||
resolver.setDisableNamespace(false);
|
resolver.setDisableNamespace(false);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user