|
@@ -28,11 +28,11 @@ import static org.apache.hadoop.mapreduce.security.SecureShuffleUtils.HTTP_HEADE
|
|
|
import static org.apache.hadoop.test.MetricsAsserts.assertCounter;
|
|
|
import static org.apache.hadoop.test.MetricsAsserts.assertGauge;
|
|
|
import static org.apache.hadoop.test.MetricsAsserts.getMetrics;
|
|
|
-import static org.junit.Assert.assertNotEquals;
|
|
|
-import static org.junit.Assert.assertNotNull;
|
|
|
-import static org.junit.Assert.assertTrue;
|
|
|
-import static org.junit.Assert.assertEquals;
|
|
|
-import static org.junit.Assert.fail;
|
|
|
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
|
|
+import static org.junit.jupiter.api.Assertions.assertNotNull;
|
|
|
+import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
|
+import static org.junit.jupiter.api.Assertions.assertEquals;
|
|
|
+import static org.junit.jupiter.api.Assertions.fail;
|
|
|
import static org.junit.Assume.assumeTrue;
|
|
|
import static org.mockito.Mockito.mock;
|
|
|
import static org.mockito.Mockito.when;
|
|
@@ -79,7 +79,8 @@ import org.apache.hadoop.yarn.api.records.ApplicationId;
|
|
|
import org.apache.hadoop.yarn.server.api.ApplicationInitializationContext;
|
|
|
import org.apache.hadoop.yarn.server.api.ApplicationTerminationContext;
|
|
|
import org.apache.hadoop.yarn.server.records.Version;
|
|
|
-import org.junit.Test;
|
|
|
+import org.junit.jupiter.api.Test;
|
|
|
+import org.junit.jupiter.api.Timeout;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
@@ -97,7 +98,8 @@ public class TestShuffleHandler extends TestShuffleHandlerBase {
|
|
|
*
|
|
|
* @throws Exception exception
|
|
|
*/
|
|
|
- @Test(timeout = 10000)
|
|
|
+ @Test
|
|
|
+ @Timeout(value = 10)
|
|
|
public void testSerializeMeta() throws Exception {
|
|
|
assertEquals(1, ShuffleHandler.deserializeMetaData(
|
|
|
ShuffleHandler.serializeMetaData(1)));
|
|
@@ -112,7 +114,8 @@ public class TestShuffleHandler extends TestShuffleHandlerBase {
|
|
|
*
|
|
|
* @throws Exception exception
|
|
|
*/
|
|
|
- @Test(timeout = 10000)
|
|
|
+ @Test
|
|
|
+ @Timeout(value = 10)
|
|
|
public void testShuffleMetrics() throws Exception {
|
|
|
MetricsSystem ms = new MetricsSystemImpl();
|
|
|
ShuffleHandler sh = new ShuffleHandler(ms);
|
|
@@ -135,7 +138,7 @@ public class TestShuffleHandler extends TestShuffleHandlerBase {
|
|
|
}
|
|
|
|
|
|
static void checkShuffleMetrics(MetricsSystem ms, long bytes, int failed,
|
|
|
- int succeeded, int connections) {
|
|
|
+ int succeeded, int connections) {
|
|
|
MetricsSource source = ms.getSource("ShuffleMetrics");
|
|
|
MetricsRecordBuilder rb = getMetrics(source);
|
|
|
assertCounter("ShuffleOutputBytes", bytes, rb);
|
|
@@ -149,7 +152,8 @@ public class TestShuffleHandler extends TestShuffleHandlerBase {
|
|
|
*
|
|
|
* @throws Exception exception
|
|
|
*/
|
|
|
- @Test(timeout = 10000)
|
|
|
+ @Test
|
|
|
+ @Timeout(value = 10)
|
|
|
public void testMaxConnections() throws Exception {
|
|
|
final int maxAllowedConnections = 3;
|
|
|
final int notAcceptedConnections = 1;
|
|
@@ -195,34 +199,33 @@ public class TestShuffleHandler extends TestShuffleHandlerBase {
|
|
|
connectionList.add(conn);
|
|
|
}
|
|
|
|
|
|
- assertEquals(String.format("Expected only %s and %s response",
|
|
|
- OK_STATUS, ShuffleHandler.TOO_MANY_REQ_STATUS),
|
|
|
+ assertEquals(
|
|
|
Sets.newHashSet(
|
|
|
HttpURLConnection.HTTP_OK,
|
|
|
ShuffleHandler.TOO_MANY_REQ_STATUS.code()),
|
|
|
- mapOfConnections.keySet());
|
|
|
+ mapOfConnections.keySet(), String.format("Expected only %s and %s response",
|
|
|
+ OK_STATUS, ShuffleHandler.TOO_MANY_REQ_STATUS));
|
|
|
|
|
|
List<HttpURLConnection> successfulConnections =
|
|
|
mapOfConnections.get(HttpURLConnection.HTTP_OK);
|
|
|
- assertEquals(String.format("Expected exactly %d requests " +
|
|
|
- "with %s response", maxAllowedConnections, OK_STATUS),
|
|
|
- maxAllowedConnections, successfulConnections.size());
|
|
|
+ assertEquals(maxAllowedConnections, successfulConnections.size(),
|
|
|
+ String.format("Expected exactly %d requests " +
|
|
|
+ "with %s response", maxAllowedConnections, OK_STATUS));
|
|
|
|
|
|
//Ensure exactly one connection is HTTP 429 (TOO MANY REQUESTS)
|
|
|
List<HttpURLConnection> closedConnections =
|
|
|
mapOfConnections.get(ShuffleHandler.TOO_MANY_REQ_STATUS.code());
|
|
|
- assertEquals(String.format("Expected exactly %d %s response",
|
|
|
- notAcceptedConnections, ShuffleHandler.TOO_MANY_REQ_STATUS),
|
|
|
- notAcceptedConnections, closedConnections.size());
|
|
|
+ assertEquals(notAcceptedConnections, closedConnections.size(),
|
|
|
+ String.format("Expected exactly %d %s response",
|
|
|
+ notAcceptedConnections, ShuffleHandler.TOO_MANY_REQ_STATUS));
|
|
|
|
|
|
// This connection should be closed because it is above the maximum limit
|
|
|
HttpURLConnection conn = closedConnections.get(0);
|
|
|
- assertEquals(String.format("Expected a %s response",
|
|
|
- ShuffleHandler.TOO_MANY_REQ_STATUS),
|
|
|
- ShuffleHandler.TOO_MANY_REQ_STATUS.code(), conn.getResponseCode());
|
|
|
+ assertEquals(ShuffleHandler.TOO_MANY_REQ_STATUS.code(), conn.getResponseCode(),
|
|
|
+ String.format("Expected a %s response", ShuffleHandler.TOO_MANY_REQ_STATUS));
|
|
|
long backoff = Long.parseLong(
|
|
|
conn.getHeaderField(ShuffleHandler.RETRY_AFTER_HEADER));
|
|
|
- assertTrue("The backoff value cannot be negative.", backoff > 0);
|
|
|
+ assertTrue(backoff > 0, "The backoff value cannot be negative.");
|
|
|
|
|
|
shuffleHandler.stop();
|
|
|
}
|
|
@@ -232,7 +235,8 @@ public class TestShuffleHandler extends TestShuffleHandlerBase {
|
|
|
*
|
|
|
* @throws Exception exception
|
|
|
*/
|
|
|
- @Test(timeout = 10000)
|
|
|
+ @Test
|
|
|
+ @Timeout(value = 10)
|
|
|
public void testKeepAlive() throws Exception {
|
|
|
Configuration conf = new Configuration();
|
|
|
ShuffleHandlerMock shuffleHandler = new ShuffleHandlerMock();
|
|
@@ -262,8 +266,8 @@ public class TestShuffleHandler extends TestShuffleHandlerBase {
|
|
|
shuffleHandler.stop();
|
|
|
|
|
|
List<String> actual = matchLogs("connections=\\d+");
|
|
|
- assertEquals("only one connection was used",
|
|
|
- Arrays.asList("connections=1", "connections=0"), actual);
|
|
|
+ assertEquals(Arrays.asList("connections=1", "connections=0"), actual,
|
|
|
+ "only one connection was used");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -272,7 +276,8 @@ public class TestShuffleHandler extends TestShuffleHandlerBase {
|
|
|
*
|
|
|
* @throws IOException exception
|
|
|
*/
|
|
|
- @Test(timeout = 100000)
|
|
|
+ @Test
|
|
|
+ @Timeout(value = 100)
|
|
|
public void testMapFileAccess() throws IOException {
|
|
|
// This will run only in NativeIO is enabled as SecureIOUtils need it
|
|
|
assumeTrue(NativeIO.isAvailable());
|
|
@@ -326,9 +331,9 @@ public class TestShuffleHandler extends TestShuffleHandlerBase {
|
|
|
String message =
|
|
|
"Owner '" + owner + "' for path " + indexFilePath
|
|
|
+ " did not match expected owner '" + randomUser + "'";
|
|
|
- assertTrue(String.format("Received string '%s' should contain " +
|
|
|
- "message '%s'", receivedString, message),
|
|
|
- receivedString.contains(message));
|
|
|
+ assertTrue(receivedString.contains(message),
|
|
|
+ String.format("Received string '%s' should contain message '%s'",
|
|
|
+ receivedString, message));
|
|
|
assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, conn.getResponseCode());
|
|
|
LOG.info("received: " + receivedString);
|
|
|
assertNotEquals("", receivedString);
|
|
@@ -454,8 +459,8 @@ public class TestShuffleHandler extends TestShuffleHandlerBase {
|
|
|
shuffle.start();
|
|
|
fail("Incompatible version, should expect fail here.");
|
|
|
} catch (ServiceStateException e) {
|
|
|
- assertTrue("Exception message mismatch",
|
|
|
- e.getMessage().contains("Incompatible version for state DB schema:"));
|
|
|
+ assertTrue(e.getMessage().contains("Incompatible version for state DB schema:"),
|
|
|
+ "Exception message mismatch");
|
|
|
}
|
|
|
|
|
|
} finally {
|