YARN-10460. Upgrading to JUnit 4.13 causes tests in TestNodeStatusUpdater to fail. Contributed by Peter Bacsko
(cherry picked from commit 31477a224f
)
This commit is contained in:
parent
49f6326a9f
commit
f7e382c62e
|
@ -29,6 +29,8 @@ import org.apache.hadoop.conf.Configuration;
|
|||
import org.apache.hadoop.io.ObjectWritable;
|
||||
import org.apache.hadoop.io.Writable;
|
||||
|
||||
import org.apache.hadoop.thirdparty.com.google.common.annotations.VisibleForTesting;
|
||||
|
||||
/* Cache a client using its socket factory as the hash key */
|
||||
@InterfaceAudience.LimitedPrivate({"HDFS", "MapReduce"})
|
||||
@InterfaceStability.Evolving
|
||||
|
@ -114,4 +116,10 @@ public class ClientCache {
|
|||
client.stop();
|
||||
}
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public void clearCache() {
|
||||
clients.values().forEach(c -> c.stop());
|
||||
clients.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -352,6 +352,11 @@ public class ProtobufRpcEngine2 implements RpcEngine {
|
|||
portRangeConfig, alignmentContext);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public static void clearClientCache() {
|
||||
CLIENTS.clearCache();
|
||||
}
|
||||
|
||||
public static class Server extends RPC.Server {
|
||||
|
||||
static final ThreadLocal<ProtobufRpcEngineCallback2> CURRENT_CALLBACK =
|
||||
|
|
|
@ -54,6 +54,7 @@ import org.apache.hadoop.io.DataOutputBuffer;
|
|||
import org.apache.hadoop.io.Text;
|
||||
import org.apache.hadoop.io.retry.RetryPolicy;
|
||||
import org.apache.hadoop.io.retry.RetryProxy;
|
||||
import org.apache.hadoop.ipc.ProtobufRpcEngine2;
|
||||
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
|
||||
import org.apache.hadoop.net.NetUtils;
|
||||
import org.apache.hadoop.net.ServerSocketUtil;
|
||||
|
@ -137,6 +138,12 @@ public class TestNodeStatusUpdater extends NodeManagerTestBase {
|
|||
private NodeManager nm;
|
||||
private AtomicBoolean assertionFailedInThread = new AtomicBoolean(false);
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
// to avoid threading issues with JUnit 4.13+
|
||||
ProtobufRpcEngine2.clearClientCache();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
this.registeredNodes.clear();
|
||||
|
|
Loading…
Reference in New Issue