ayushtkn commented on a change in pull request #4028:
URL: https://github.com/apache/hadoop/pull/4028#discussion_r816704591
##########
File path:
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/qjournal/TestMiniJournalCluster.java
##########
@@ -52,4 +53,70 @@ public void testStartStop() throws IOException {
c.shutdown();
}
}
+
+ @Test
+ public void testStartStopWithPorts() throws IOException {
+ Configuration conf = new Configuration();
+
+ try {
+ new MiniJournalCluster.Builder(conf).setHttpPorts(8481).build();
+ fail("Should not reach here");
+ } catch (IllegalArgumentException e) {
+ assertEquals("Num of http ports (1) should match num of JournalNodes
(3)", e.getMessage());
+ }
+
+ try {
+ new MiniJournalCluster.Builder(conf).setRpcPorts(8481, 8482)
+ .build();
+ fail("Should not reach here");
+ } catch (IllegalArgumentException e) {
+ assertEquals("Num of rpc ports (2) should match num of JournalNodes
(3)", e.getMessage());
+ }
+
+ try {
+ new MiniJournalCluster.Builder(conf).setHttpPorts(800, 9000,
10000).setRpcPorts(8481)
+ .build();
+ fail("Should not reach here");
+ } catch (IllegalArgumentException e) {
+ assertEquals("Num of rpc ports (1) should match num of JournalNodes
(3)", e.getMessage());
+ }
+
+ try {
+ new MiniJournalCluster.Builder(conf).setHttpPorts(800, 9000, 1000, 2000)
+ .setRpcPorts(8481, 8482, 8483)
+ .build();
+ fail("Should not reach here");
+ } catch (IllegalArgumentException e) {
+ assertEquals("Num of http ports (4) should match num of JournalNodes
(3)", e.getMessage());
+ }
+
+ MiniJournalCluster miniJournalCluster =
+ new MiniJournalCluster.Builder(conf).setHttpPorts(8481, 8482, 8483)
+ .setRpcPorts(8491, 8492, 8493).build();
Review comment:
We can not rely completely on Jenkins, I remember seeing an issue with a
RBF test, where we had a port hard-coded, and for some organisation, there
internal build was failing for that test, because they had something running on
that port.
May be first finding some free ports, and then putting them into this conf
should do. Or if that isn't possible, second option is try some randomisation,
get a set of some random ports in a specified range, if they work great, if not
loop back find another set and so on for some specified amount of iterations.
If above two doesn't work, we can try some skipping mechanism, like ports
are occupied so skip the test or so, But this would be the last and the worst
thing to do.
And in Jenkins the tests run in parallel, so results might change depending
on what tests are running together & what ports they randomly choose.
My general experience so far, such controversial tests don't fail in the
actual PR, but in other folks PR. :-P
Better we play safe. :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]