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

View File

@ -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;
@ -185,6 +186,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;
@ -366,6 +368,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() {
@ -1302,11 +1309,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);
} }
@ -1375,11 +1385,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);
} }