YARN-3433. Jersey tests failing with Port in Use -again. (Brahma Reddy Battula)

This commit is contained in:
Steve Loughran 2015-09-16 10:30:49 +01:00
parent 08024d1b0b
commit bf2f2b4fc4
2 changed files with 8 additions and 9 deletions

View File

@ -928,6 +928,9 @@ Release 2.7.2 - UNRELEASED
YARN-4158. Remove duplicate close for LogWriter in YARN-4158. Remove duplicate close for LogWriter in
AppLogAggregatorImpl#uploadLogsForContainers (Zhihai Xu via jlowe) AppLogAggregatorImpl#uploadLogsForContainers (Zhihai Xu via jlowe)
YARN-3433. Jersey tests failing with Port in Use -again.
(Brahma Reddy Battula)
Release 2.7.1 - 2015-07-06 Release 2.7.1 - 2015-07-06
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -18,6 +18,9 @@
package org.apache.hadoop.yarn.webapp; package org.apache.hadoop.yarn.webapp;
import java.io.IOException;
import org.apache.hadoop.net.ServerSocketUtil;
import org.junit.Before; import org.junit.Before;
import com.sun.jersey.test.framework.JerseyTest; import com.sun.jersey.test.framework.JerseyTest;
import com.sun.jersey.test.framework.WebAppDescriptor; import com.sun.jersey.test.framework.WebAppDescriptor;
@ -28,15 +31,8 @@ public JerseyTestBase(WebAppDescriptor appDescriptor) {
} }
@Before @Before
public void initializeJerseyPort() { public void initializeJerseyPort() throws IOException {
int jerseyPort = 9998; int jerseyPort = ServerSocketUtil.getPort(9998, 10);
String port = System.getProperty("jersey.test.port");
if(null != port) {
jerseyPort = Integer.parseInt(port) + 10;
if(jerseyPort > 65535) {
jerseyPort = 9998;
}
}
System.setProperty("jersey.test.port", Integer.toString(jerseyPort)); System.setProperty("jersey.test.port", Integer.toString(jerseyPort));
} }
} }