Skip to content

Commit 8ec824f

Browse files
touchidaToshihiko Uchida
andauthored
HDFS-15762. TestMultipleNNPortQOP#testMultipleNNPortOverwriteDownStream fails intermittently (#2598)
Co-authored-by: Toshihiko Uchida <toshihiko.uchida@linecorp.com> Signed-off-by: Akira Ajisaka <aajisaka@apache.org>
1 parent 724edb0 commit 8ec824f

1 file changed

Lines changed: 19 additions & 42 deletions

File tree

hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestMultipleNNPortQOP.java

Lines changed: 19 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.apache.hadoop.fs.FileSystem;
2626
import org.apache.hadoop.fs.FileSystemTestHelper;
2727
import org.apache.hadoop.fs.Path;
28-
import org.apache.hadoop.hdfs.protocol.datatransfer.sasl.SaslDataTransferClient;
2928
import org.apache.hadoop.hdfs.protocol.datatransfer.sasl.SaslDataTransferServer;
3029
import org.apache.hadoop.hdfs.protocol.datatransfer.sasl.SaslDataTransferTestCase;
3130
import org.apache.hadoop.hdfs.security.token.block.BlockTokenIdentifier;
@@ -251,55 +250,33 @@ public void testMultipleNNPortOverwriteDownStream() throws Exception {
251250
clientConf.set(HADOOP_RPC_PROTECTION, "privacy");
252251
FileSystem fsPrivacy = FileSystem.get(uriPrivacyPort, clientConf);
253252
doTest(fsPrivacy, PATH1);
254-
for (int i = 0; i < 2; i++) {
255-
DataNode dn = dataNodes.get(i);
256-
SaslDataTransferClient saslClient = dn.getSaslClient();
257-
String qop = null;
258-
// It may take some time for the qop to populate
259-
// to all DNs, check in a loop.
260-
for (int trial = 0; trial < 10; trial++) {
261-
qop = saslClient.getTargetQOP();
262-
if (qop != null) {
263-
break;
264-
}
265-
Thread.sleep(100);
266-
}
267-
assertEquals("auth", qop);
268-
}
253+
long count = dataNodes.stream()
254+
.map(dn -> dn.getSaslClient().getTargetQOP())
255+
.filter("auth"::equals)
256+
.count();
257+
// For each datanode pipeline, targetQOPs of sasl clients in the first two
258+
// datanodes become equal to auth.
259+
// Note that it is not necessarily the case for all datanodes,
260+
// since a datanode may be always at the last position in pipelines.
261+
assertTrue("At least two qops should be auth", count >= 2);
269262

270263
clientConf.set(HADOOP_RPC_PROTECTION, "integrity");
271264
FileSystem fsIntegrity = FileSystem.get(uriIntegrityPort, clientConf);
272265
doTest(fsIntegrity, PATH2);
273-
for (int i = 0; i < 2; i++) {
274-
DataNode dn = dataNodes.get(i);
275-
SaslDataTransferClient saslClient = dn.getSaslClient();
276-
String qop = null;
277-
for (int trial = 0; trial < 10; trial++) {
278-
qop = saslClient.getTargetQOP();
279-
if (qop != null) {
280-
break;
281-
}
282-
Thread.sleep(100);
283-
}
284-
assertEquals("auth", qop);
285-
}
266+
count = dataNodes.stream()
267+
.map(dn -> dn.getSaslClient().getTargetQOP())
268+
.filter("auth"::equals)
269+
.count();
270+
assertTrue("At least two qops should be auth", count >= 2);
286271

287272
clientConf.set(HADOOP_RPC_PROTECTION, "authentication");
288273
FileSystem fsAuth = FileSystem.get(uriAuthPort, clientConf);
289274
doTest(fsAuth, PATH3);
290-
for (int i = 0; i < 3; i++) {
291-
DataNode dn = dataNodes.get(i);
292-
SaslDataTransferServer saslServer = dn.getSaslServer();
293-
String qop = null;
294-
for (int trial = 0; trial < 10; trial++) {
295-
qop = saslServer.getNegotiatedQOP();
296-
if (qop != null) {
297-
break;
298-
}
299-
Thread.sleep(100);
300-
}
301-
assertEquals("auth", qop);
302-
}
275+
count = dataNodes.stream()
276+
.map(dn -> dn.getSaslServer().getNegotiatedQOP())
277+
.filter("auth"::equals)
278+
.count();
279+
assertEquals("All qops should be auth", 3, count);
303280
} finally {
304281
if (cluster != null) {
305282
cluster.shutdown();

0 commit comments

Comments
 (0)