HDFS-15952. TestRouterRpcMultiDestination#testProxyGetTransactionID and testProxyVersionRequest are flaky. (#2970)

This commit is contained in:
Akira Ajisaka 2021-05-04 00:25:29 +09:00 committed by GitHub
parent 6e525ab81c
commit 7c561e2a02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 3 deletions

View File

@ -26,6 +26,7 @@ import static org.apache.hadoop.hdfs.server.federation.FederationTestUtils.getFi
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;
@ -185,6 +186,7 @@ public class TestRouterRpc {
private NamenodeProtocol routerNamenodeProtocol;
/** NameNodeProtocol interface to the Namenode. */
private NamenodeProtocol nnNamenodeProtocol;
private NamenodeProtocol nnNamenodeProtocol1;
/** Filesystem interface to the Router. */
private FileSystem routerFS;
@ -366,6 +368,11 @@ public class TestRouterRpc {
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() {
@ -1302,11 +1309,14 @@ public class TestRouterRpc {
// 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);
}
@ -1375,11 +1385,13 @@ public class TestRouterRpc {
// 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);
}