YARN-4909. Fix intermittent failures of TestRMWebServices And TestRMWithCSRFFilter. Contributed by Bibin A Chundatt
This commit is contained in:
parent
55e19b7f0c
commit
fdbafbc9e5
@ -19,9 +19,10 @@
|
|||||||
package org.apache.hadoop.yarn.webapp;
|
package org.apache.hadoop.yarn.webapp;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import org.apache.hadoop.net.ServerSocketUtil;
|
import org.apache.hadoop.net.ServerSocketUtil;
|
||||||
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;
|
||||||
|
|
||||||
@ -30,9 +31,16 @@ public JerseyTestBase(WebAppDescriptor appDescriptor) {
|
|||||||
super(appDescriptor);
|
super(appDescriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Override
|
||||||
public void initializeJerseyPort() throws IOException {
|
protected int getPort(int port) {
|
||||||
int jerseyPort = ServerSocketUtil.getPort(9998, 10);
|
Random rand = new Random();
|
||||||
System.setProperty("jersey.test.port", Integer.toString(jerseyPort));
|
int jerseyPort = port + rand.nextInt(1000);
|
||||||
|
try {
|
||||||
|
jerseyPort = ServerSocketUtil.getPort(jerseyPort, 10);
|
||||||
|
} catch (IOException e) {
|
||||||
|
// Ignore exception even after 10 times free port is
|
||||||
|
// not received.
|
||||||
|
}
|
||||||
|
return super.getPort(jerseyPort);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user