Revert "YARN-11404. Add junit5 dependency to hadoop-mapreduce-client-app to fix few unit test failure. Contributed by Susheel Gupta"
This reverts commit 8eda456d37
.
This commit is contained in:
parent
4e6e2f318c
commit
fe5bb49ad9
|
@ -100,39 +100,6 @@
|
|||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-params</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-junit-jupiter</artifactId>
|
||||
<version>4.11.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>uk.org.webcompere</groupId>
|
||||
<artifactId>system-stubs-core</artifactId>
|
||||
<version>1.1.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>uk.org.webcompere</groupId>
|
||||
<artifactId>system-stubs-jupiter</artifactId>
|
||||
<version>1.1.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
|
|
|
@ -53,11 +53,10 @@ import org.apache.hadoop.yarn.api.records.Container;
|
|||
import org.apache.hadoop.yarn.api.records.NodeId;
|
||||
import org.apache.hadoop.yarn.event.Event;
|
||||
import org.apache.hadoop.yarn.event.EventHandler;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Timeout;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.mockito.invocation.InvocationOnMock;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -76,7 +75,7 @@ public class TestLocalContainerLauncher {
|
|||
fs.delete(p, true);
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
@BeforeClass
|
||||
public static void setupTestDirs() throws IOException {
|
||||
testWorkDir = new File("target",
|
||||
TestLocalContainerLauncher.class.getCanonicalName());
|
||||
|
@ -90,7 +89,7 @@ public class TestLocalContainerLauncher {
|
|||
}
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
@AfterClass
|
||||
public static void cleanupTestDirs() throws IOException {
|
||||
if (testWorkDir != null) {
|
||||
delete(testWorkDir);
|
||||
|
@ -98,8 +97,7 @@ public class TestLocalContainerLauncher {
|
|||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Test
|
||||
@Timeout(10000)
|
||||
@Test(timeout=10000)
|
||||
public void testKillJob() throws Exception {
|
||||
JobConf conf = new JobConf();
|
||||
AppContext context = mock(AppContext.class);
|
||||
|
@ -200,8 +198,8 @@ public class TestLocalContainerLauncher {
|
|||
final Path mapOut = mrOutputFiles.getOutputFileForWrite(1);
|
||||
conf.set(MRConfig.LOCAL_DIR, localDirs[1].toString());
|
||||
final Path mapOutIdx = mrOutputFiles.getOutputIndexFileForWrite(1);
|
||||
Assertions.assertNotEquals(mapOut.getParent(), mapOutIdx.getParent(),
|
||||
"Paths must be different!");
|
||||
Assert.assertNotEquals("Paths must be different!",
|
||||
mapOut.getParent(), mapOutIdx.getParent());
|
||||
|
||||
// make both dirs part of LOCAL_DIR
|
||||
conf.setStrings(MRConfig.LOCAL_DIR, localDirs);
|
||||
|
|
|
@ -37,8 +37,8 @@ import org.apache.hadoop.yarn.event.Event;
|
|||
import org.apache.hadoop.yarn.event.EventHandler;
|
||||
import org.apache.hadoop.yarn.util.SystemClock;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
@ -87,7 +87,7 @@ public class TestTaskAttemptFinishingMonitor {
|
|||
}
|
||||
taskAttemptFinishingMonitor.stop();
|
||||
|
||||
assertTrue(eventHandler.timedOut, "Finishing attempt didn't time out.");
|
||||
assertTrue("Finishing attempt didn't time out.", eventHandler.timedOut);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -19,18 +19,19 @@ package org.apache.hadoop.mapred;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Timeout;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.Path;
|
||||
|
@ -66,15 +67,14 @@ import org.apache.hadoop.yarn.factories.RecordFactory;
|
|||
import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
|
||||
import org.apache.hadoop.yarn.util.ControlledClock;
|
||||
import org.apache.hadoop.yarn.util.SystemClock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.eq;
|
||||
|
@ -87,7 +87,7 @@ import static org.mockito.Mockito.when;
|
|||
/**
|
||||
* Tests the behavior of TaskAttemptListenerImpl.
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class TestTaskAttemptListenerImpl {
|
||||
private static final String ATTEMPT1_ID =
|
||||
"attempt_123456789012_0001_m_000001_0";
|
||||
|
@ -172,7 +172,7 @@ public class TestTaskAttemptListenerImpl {
|
|||
}
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
@After
|
||||
public void after() throws IOException {
|
||||
if (listener != null) {
|
||||
listener.close();
|
||||
|
@ -180,8 +180,7 @@ public class TestTaskAttemptListenerImpl {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(5000)
|
||||
@Test (timeout=5000)
|
||||
public void testGetTask() throws IOException {
|
||||
configureMocks();
|
||||
startListener(false);
|
||||
|
@ -190,12 +189,12 @@ public class TestTaskAttemptListenerImpl {
|
|||
//The JVM ID has not been registered yet so we should kill it.
|
||||
JvmContext context = new JvmContext();
|
||||
|
||||
context.jvmId = id;
|
||||
context.jvmId = id;
|
||||
JvmTask result = listener.getTask(context);
|
||||
assertNotNull(result);
|
||||
assertTrue(result.shouldDie);
|
||||
|
||||
// Verify ask after registration but before launch.
|
||||
// Verify ask after registration but before launch.
|
||||
// Don't kill, should be null.
|
||||
//Now put a task with the ID
|
||||
listener.registerPendingTask(task, wid);
|
||||
|
@ -239,8 +238,7 @@ public class TestTaskAttemptListenerImpl {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(5000)
|
||||
@Test (timeout=5000)
|
||||
public void testJVMId() {
|
||||
|
||||
JVMId jvmid = new JVMId("test", 1, true, 2);
|
||||
|
@ -249,8 +247,7 @@ public class TestTaskAttemptListenerImpl {
|
|||
assertEquals(0, jvmid.compareTo(jvmid1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(10000)
|
||||
@Test (timeout=10000)
|
||||
public void testGetMapCompletionEvents() throws IOException {
|
||||
TaskAttemptCompletionEvent[] empty = {};
|
||||
TaskAttemptCompletionEvent[] taskEvents = {
|
||||
|
@ -260,6 +257,12 @@ public class TestTaskAttemptListenerImpl {
|
|||
createTce(3, false, TaskAttemptCompletionEventStatus.FAILED) };
|
||||
TaskAttemptCompletionEvent[] mapEvents = { taskEvents[0], taskEvents[2] };
|
||||
Job mockJob = mock(Job.class);
|
||||
when(mockJob.getTaskAttemptCompletionEvents(0, 100))
|
||||
.thenReturn(taskEvents);
|
||||
when(mockJob.getTaskAttemptCompletionEvents(0, 2))
|
||||
.thenReturn(Arrays.copyOfRange(taskEvents, 0, 2));
|
||||
when(mockJob.getTaskAttemptCompletionEvents(2, 100))
|
||||
.thenReturn(Arrays.copyOfRange(taskEvents, 2, 4));
|
||||
when(mockJob.getMapAttemptCompletionEvents(0, 100)).thenReturn(
|
||||
TypeConverter.fromYarn(mapEvents));
|
||||
when(mockJob.getMapAttemptCompletionEvents(0, 2)).thenReturn(
|
||||
|
@ -309,8 +312,7 @@ public class TestTaskAttemptListenerImpl {
|
|||
return tce;
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(10000)
|
||||
@Test (timeout=10000)
|
||||
public void testCommitWindow() throws IOException {
|
||||
SystemClock clock = SystemClock.getInstance();
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ import java.io.IOException;
|
|||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.ClusterStorageCapacityExceededException;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
|
@ -36,7 +36,7 @@ public class TestYarnChild {
|
|||
final static private String KILL_LIMIT_EXCEED_CONF_NAME =
|
||||
"mapreduce.job.dfs.storage.capacity.kill-limit-exceed";
|
||||
|
||||
@BeforeEach
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
task = mock(Task.class);
|
||||
umbilical = mock(TaskUmbilicalProtocol.class);
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
package org.apache.hadoop.mapreduce.jobhistory;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
@ -40,8 +40,7 @@ import org.apache.hadoop.mapreduce.TaskType;
|
|||
import org.apache.hadoop.mapreduce.v2.app.job.impl.JobImpl;
|
||||
import org.apache.hadoop.yarn.api.records.timelineservice.TimelineEvent;
|
||||
import org.apache.hadoop.yarn.api.records.timelineservice.TimelineMetric;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Timeout;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestEvents {
|
||||
|
||||
|
@ -51,9 +50,9 @@ public class TestEvents {
|
|||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
@Timeout(10000)
|
||||
@Test(timeout = 10000)
|
||||
public void testTaskAttemptFinishedEvent() throws Exception {
|
||||
|
||||
JobID jid = new JobID("001", 1);
|
||||
TaskID tid = new TaskID(jid, TaskType.REDUCE, 2);
|
||||
TaskAttemptID taskAttemptId = new TaskAttemptID(tid, 3);
|
||||
|
@ -80,18 +79,17 @@ public class TestEvents {
|
|||
* @throws Exception
|
||||
*/
|
||||
|
||||
@Test
|
||||
@Timeout(10000)
|
||||
@Test(timeout = 10000)
|
||||
public void testJobPriorityChange() throws Exception {
|
||||
org.apache.hadoop.mapreduce.JobID jid = new JobID("001", 1);
|
||||
JobPriorityChangeEvent test = new JobPriorityChangeEvent(jid,
|
||||
JobPriority.LOW);
|
||||
assertThat(test.getJobId().toString()).isEqualTo(jid.toString());
|
||||
assertThat(test.getPriority()).isEqualTo(JobPriority.LOW);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(10000)
|
||||
}
|
||||
|
||||
@Test(timeout = 10000)
|
||||
public void testJobQueueChange() throws Exception {
|
||||
org.apache.hadoop.mapreduce.JobID jid = new JobID("001", 1);
|
||||
JobQueueChangeEvent test = new JobQueueChangeEvent(jid,
|
||||
|
@ -105,14 +103,14 @@ public class TestEvents {
|
|||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
@Test
|
||||
@Timeout(10000)
|
||||
@Test(timeout = 10000)
|
||||
public void testTaskUpdated() throws Exception {
|
||||
JobID jid = new JobID("001", 1);
|
||||
TaskID tid = new TaskID(jid, TaskType.REDUCE, 2);
|
||||
TaskUpdatedEvent test = new TaskUpdatedEvent(tid, 1234L);
|
||||
assertThat(test.getTaskId().toString()).isEqualTo(tid.toString());
|
||||
assertThat(test.getFinishTime()).isEqualTo(1234L);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -120,9 +118,9 @@ public class TestEvents {
|
|||
* instance of HistoryEvent Different HistoryEvent should have a different
|
||||
* datum.
|
||||
*/
|
||||
@Test
|
||||
@Timeout(10000)
|
||||
@Test(timeout = 10000)
|
||||
public void testEvents() throws Exception {
|
||||
|
||||
EventReader reader = new EventReader(new DataInputStream(
|
||||
new ByteArrayInputStream(getEvents())));
|
||||
HistoryEvent e = reader.getNextEvent();
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
package org.apache.hadoop.mapreduce.jobhistory;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
|
@ -81,12 +81,11 @@ import org.apache.hadoop.yarn.event.DrainDispatcher;
|
|||
import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
|
||||
import org.apache.hadoop.yarn.server.MiniYARNCluster;
|
||||
import org.apache.hadoop.yarn.server.timeline.TimelineStore;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Timeout;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
@ -102,7 +101,7 @@ public class TestJobHistoryEventHandler {
|
|||
private static MiniDFSCluster dfsCluster = null;
|
||||
private static String coreSitePath;
|
||||
|
||||
@BeforeAll
|
||||
@BeforeClass
|
||||
public static void setUpClass() throws Exception {
|
||||
coreSitePath = "." + File.separator + "target" + File.separator +
|
||||
"test-classes" + File.separator + "core-site.xml";
|
||||
|
@ -110,18 +109,17 @@ public class TestJobHistoryEventHandler {
|
|||
dfsCluster = new MiniDFSCluster.Builder(conf).build();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
@AfterClass
|
||||
public static void cleanUpClass() throws Exception {
|
||||
dfsCluster.shutdown();
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
@After
|
||||
public void cleanTest() throws Exception {
|
||||
new File(coreSitePath).delete();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(50000)
|
||||
@Test (timeout=50000)
|
||||
public void testFirstFlushOnCompletionEvent() throws Exception {
|
||||
TestParams t = new TestParams();
|
||||
Configuration conf = new Configuration();
|
||||
|
@ -164,8 +162,7 @@ public class TestJobHistoryEventHandler {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(50000)
|
||||
@Test (timeout=50000)
|
||||
public void testMaxUnflushedCompletionEvents() throws Exception {
|
||||
TestParams t = new TestParams();
|
||||
Configuration conf = new Configuration();
|
||||
|
@ -210,8 +207,7 @@ public class TestJobHistoryEventHandler {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(50000)
|
||||
@Test (timeout=50000)
|
||||
public void testUnflushedTimer() throws Exception {
|
||||
TestParams t = new TestParams();
|
||||
Configuration conf = new Configuration();
|
||||
|
@ -236,26 +232,25 @@ public class TestJobHistoryEventHandler {
|
|||
mockWriter = jheh.getEventWriter();
|
||||
verify(mockWriter).write(any(HistoryEvent.class));
|
||||
|
||||
for (int i = 0; i < 100; i++) {
|
||||
for (int i = 0 ; i < 100 ; i++) {
|
||||
queueEvent(jheh, new JobHistoryEvent(t.jobId, new TaskFinishedEvent(
|
||||
t.taskID, t.taskAttemptID, 0, TaskType.MAP, "", null, 0)));
|
||||
}
|
||||
|
||||
handleNextNEvents(jheh, 9);
|
||||
Assertions.assertTrue(jheh.getFlushTimerStatus());
|
||||
Assert.assertTrue(jheh.getFlushTimerStatus());
|
||||
verify(mockWriter, times(0)).flush();
|
||||
|
||||
Thread.sleep(2 * 4 * 1000l); // 4 seconds should be enough. Just be safe.
|
||||
verify(mockWriter).flush();
|
||||
Assertions.assertFalse(jheh.getFlushTimerStatus());
|
||||
Assert.assertFalse(jheh.getFlushTimerStatus());
|
||||
} finally {
|
||||
jheh.stop();
|
||||
verify(mockWriter).close();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(50000)
|
||||
@Test (timeout=50000)
|
||||
public void testBatchedFlushJobEndMultiplier() throws Exception {
|
||||
TestParams t = new TestParams();
|
||||
Configuration conf = new Configuration();
|
||||
|
@ -300,8 +295,7 @@ public class TestJobHistoryEventHandler {
|
|||
}
|
||||
|
||||
// In case of all types of events, process Done files if it's last AM retry
|
||||
@Test
|
||||
@Timeout(50000)
|
||||
@Test (timeout=50000)
|
||||
public void testProcessDoneFilesOnLastAMRetry() throws Exception {
|
||||
TestParams t = new TestParams(true);
|
||||
Configuration conf = new Configuration();
|
||||
|
@ -315,12 +309,12 @@ public class TestJobHistoryEventHandler {
|
|||
try {
|
||||
jheh.start();
|
||||
handleEvent(jheh, new JobHistoryEvent(t.jobId, new AMStartedEvent(
|
||||
t.appAttemptId, 200, t.containerId, "nmhost", 3000, 4000, -1)));
|
||||
t.appAttemptId, 200, t.containerId, "nmhost", 3000, 4000, -1)));
|
||||
verify(jheh, times(0)).processDoneFiles(any(JobId.class));
|
||||
|
||||
handleEvent(jheh, new JobHistoryEvent(t.jobId,
|
||||
new JobUnsuccessfulCompletionEvent(TypeConverter.fromYarn(t.jobId), 0,
|
||||
0, 0, 0, 0, 0, 0, JobStateInternal.ERROR.toString())));
|
||||
new JobUnsuccessfulCompletionEvent(TypeConverter.fromYarn(t.jobId), 0,
|
||||
0, 0, 0, 0, 0, 0, JobStateInternal.ERROR.toString())));
|
||||
verify(jheh, times(1)).processDoneFiles(any(JobId.class));
|
||||
|
||||
handleEvent(jheh, new JobHistoryEvent(t.jobId, new JobFinishedEvent(
|
||||
|
@ -329,13 +323,13 @@ public class TestJobHistoryEventHandler {
|
|||
verify(jheh, times(2)).processDoneFiles(any(JobId.class));
|
||||
|
||||
handleEvent(jheh, new JobHistoryEvent(t.jobId,
|
||||
new JobUnsuccessfulCompletionEvent(TypeConverter.fromYarn(t.jobId), 0,
|
||||
0, 0, 0, 0, 0, 0, JobStateInternal.FAILED.toString())));
|
||||
new JobUnsuccessfulCompletionEvent(TypeConverter.fromYarn(t.jobId), 0,
|
||||
0, 0, 0, 0, 0, 0, JobStateInternal.FAILED.toString())));
|
||||
verify(jheh, times(3)).processDoneFiles(any(JobId.class));
|
||||
|
||||
handleEvent(jheh, new JobHistoryEvent(t.jobId,
|
||||
new JobUnsuccessfulCompletionEvent(TypeConverter.fromYarn(t.jobId), 0,
|
||||
0, 0, 0, 0, 0, 0, JobStateInternal.KILLED.toString())));
|
||||
new JobUnsuccessfulCompletionEvent(TypeConverter.fromYarn(t.jobId), 0,
|
||||
0, 0, 0, 0, 0, 0, JobStateInternal.KILLED.toString())));
|
||||
verify(jheh, times(4)).processDoneFiles(any(JobId.class));
|
||||
|
||||
mockWriter = jheh.getEventWriter();
|
||||
|
@ -347,8 +341,7 @@ public class TestJobHistoryEventHandler {
|
|||
}
|
||||
|
||||
// Skip processing Done files in case of ERROR, if it's not last AM retry
|
||||
@Test
|
||||
@Timeout(50000)
|
||||
@Test (timeout=50000)
|
||||
public void testProcessDoneFilesNotLastAMRetry() throws Exception {
|
||||
TestParams t = new TestParams(false);
|
||||
Configuration conf = new Configuration();
|
||||
|
@ -361,13 +354,13 @@ public class TestJobHistoryEventHandler {
|
|||
try {
|
||||
jheh.start();
|
||||
handleEvent(jheh, new JobHistoryEvent(t.jobId, new AMStartedEvent(
|
||||
t.appAttemptId, 200, t.containerId, "nmhost", 3000, 4000, -1)));
|
||||
t.appAttemptId, 200, t.containerId, "nmhost", 3000, 4000, -1)));
|
||||
verify(jheh, times(0)).processDoneFiles(t.jobId);
|
||||
|
||||
// skip processing done files
|
||||
handleEvent(jheh, new JobHistoryEvent(t.jobId,
|
||||
new JobUnsuccessfulCompletionEvent(TypeConverter.fromYarn(t.jobId), 0,
|
||||
0, 0, 0, 0, 0, 0, JobStateInternal.ERROR.toString())));
|
||||
new JobUnsuccessfulCompletionEvent(TypeConverter.fromYarn(t.jobId), 0,
|
||||
0, 0, 0, 0, 0, 0, JobStateInternal.ERROR.toString())));
|
||||
verify(jheh, times(0)).processDoneFiles(t.jobId);
|
||||
|
||||
handleEvent(jheh, new JobHistoryEvent(t.jobId, new JobFinishedEvent(
|
||||
|
@ -376,13 +369,13 @@ public class TestJobHistoryEventHandler {
|
|||
verify(jheh, times(1)).processDoneFiles(t.jobId);
|
||||
|
||||
handleEvent(jheh, new JobHistoryEvent(t.jobId,
|
||||
new JobUnsuccessfulCompletionEvent(TypeConverter.fromYarn(t.jobId), 0,
|
||||
0, 0, 0, 0, 0, 0, JobStateInternal.FAILED.toString())));
|
||||
new JobUnsuccessfulCompletionEvent(TypeConverter.fromYarn(t.jobId), 0,
|
||||
0, 0, 0, 0, 0, 0, JobStateInternal.FAILED.toString())));
|
||||
verify(jheh, times(2)).processDoneFiles(t.jobId);
|
||||
|
||||
handleEvent(jheh, new JobHistoryEvent(t.jobId,
|
||||
new JobUnsuccessfulCompletionEvent(TypeConverter.fromYarn(t.jobId), 0,
|
||||
0, 0, 0, 0, 0, 0, JobStateInternal.KILLED.toString())));
|
||||
new JobUnsuccessfulCompletionEvent(TypeConverter.fromYarn(t.jobId), 0,
|
||||
0, 0, 0, 0, 0, 0, JobStateInternal.KILLED.toString())));
|
||||
verify(jheh, times(3)).processDoneFiles(t.jobId);
|
||||
|
||||
mockWriter = jheh.getEventWriter();
|
||||
|
@ -428,15 +421,16 @@ public class TestJobHistoryEventHandler {
|
|||
|
||||
// load the job_conf.xml in JHS directory and verify property redaction.
|
||||
Path jhsJobConfFile = getJobConfInIntermediateDoneDir(conf, params.jobId);
|
||||
Assertions.assertTrue(FileContext.getFileContext(conf).util().exists(jhsJobConfFile),
|
||||
"The job_conf.xml file is not in the JHS directory");
|
||||
Assert.assertTrue("The job_conf.xml file is not in the JHS directory",
|
||||
FileContext.getFileContext(conf).util().exists(jhsJobConfFile));
|
||||
Configuration jhsJobConf = new Configuration();
|
||||
|
||||
try (InputStream input = FileSystem.get(conf).open(jhsJobConfFile)) {
|
||||
jhsJobConf.addResource(input);
|
||||
Assertions.assertEquals(MRJobConfUtil.REDACTION_REPLACEMENT_VAL,
|
||||
jhsJobConf.get(sensitivePropertyName),
|
||||
sensitivePropertyName + " is not redacted in HDFS.");
|
||||
Assert.assertEquals(
|
||||
sensitivePropertyName + " is not redacted in HDFS.",
|
||||
MRJobConfUtil.REDACTION_REPLACEMENT_VAL,
|
||||
jhsJobConf.get(sensitivePropertyName));
|
||||
}
|
||||
} finally {
|
||||
jheh.stop();
|
||||
|
@ -462,20 +456,19 @@ public class TestJobHistoryEventHandler {
|
|||
fs.delete(new Path(intermDoneDirPrefix), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(50000)
|
||||
@Test (timeout=50000)
|
||||
public void testDefaultFsIsUsedForHistory() throws Exception {
|
||||
// Create default configuration pointing to the minicluster
|
||||
Configuration conf = new Configuration();
|
||||
conf.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY,
|
||||
dfsCluster.getURI().toString());
|
||||
dfsCluster.getURI().toString());
|
||||
FileOutputStream os = new FileOutputStream(coreSitePath);
|
||||
conf.writeXml(os);
|
||||
os.close();
|
||||
|
||||
// simulate execution under a non-default namenode
|
||||
conf.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY,
|
||||
"file:///");
|
||||
"file:///");
|
||||
|
||||
TestParams t = new TestParams();
|
||||
conf.set(MRJobConfig.MR_AM_STAGING_DIR, t.dfsWorkDir);
|
||||
|
@ -497,11 +490,11 @@ public class TestJobHistoryEventHandler {
|
|||
// If we got here then event handler worked but we don't know with which
|
||||
// file system. Now we check that history stuff was written to minicluster
|
||||
FileSystem dfsFileSystem = dfsCluster.getFileSystem();
|
||||
assertTrue(dfsFileSystem.globStatus(new Path(t.dfsWorkDir + "/*")).length != 0,
|
||||
"Minicluster contains some history files");
|
||||
assertTrue("Minicluster contains some history files",
|
||||
dfsFileSystem.globStatus(new Path(t.dfsWorkDir + "/*")).length != 0);
|
||||
FileSystem localFileSystem = LocalFileSystem.get(conf);
|
||||
assertFalse(localFileSystem.exists(new Path(t.dfsWorkDir)),
|
||||
"No history directory on non-default file system");
|
||||
assertFalse("No history directory on non-default file system",
|
||||
localFileSystem.exists(new Path(t.dfsWorkDir)));
|
||||
} finally {
|
||||
jheh.stop();
|
||||
purgeHdfsHistoryIntermediateDoneDirectory(conf);
|
||||
|
@ -516,7 +509,7 @@ public class TestJobHistoryEventHandler {
|
|||
"/mapred/history/done_intermediate");
|
||||
conf.set(MRJobConfig.USER_NAME, System.getProperty("user.name"));
|
||||
String pathStr = JobHistoryUtils.getHistoryIntermediateDoneDirForUser(conf);
|
||||
Assertions.assertEquals("/mapred/history/done_intermediate/" +
|
||||
Assert.assertEquals("/mapred/history/done_intermediate/" +
|
||||
System.getProperty("user.name"), pathStr);
|
||||
|
||||
// Test fully qualified path
|
||||
|
@ -530,14 +523,13 @@ public class TestJobHistoryEventHandler {
|
|||
conf.set(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY,
|
||||
"file:///");
|
||||
pathStr = JobHistoryUtils.getHistoryIntermediateDoneDirForUser(conf);
|
||||
Assertions.assertEquals(dfsCluster.getURI().toString() +
|
||||
Assert.assertEquals(dfsCluster.getURI().toString() +
|
||||
"/mapred/history/done_intermediate/" + System.getProperty("user.name"),
|
||||
pathStr);
|
||||
}
|
||||
|
||||
// test AMStartedEvent for submitTime and startTime
|
||||
@Test
|
||||
@Timeout(50000)
|
||||
@Test (timeout=50000)
|
||||
public void testAMStartedEvent() throws Exception {
|
||||
TestParams t = new TestParams();
|
||||
Configuration conf = new Configuration();
|
||||
|
@ -579,8 +571,7 @@ public class TestJobHistoryEventHandler {
|
|||
|
||||
// Have JobHistoryEventHandler handle some events and make sure they get
|
||||
// stored to the Timeline store
|
||||
@Test
|
||||
@Timeout(50000)
|
||||
@Test (timeout=50000)
|
||||
public void testTimelineEventHandling() throws Exception {
|
||||
TestParams t = new TestParams(RunningAppContext.class, false);
|
||||
Configuration conf = new YarnConfiguration();
|
||||
|
@ -607,13 +598,13 @@ public class TestJobHistoryEventHandler {
|
|||
jheh.getDispatcher().await();
|
||||
TimelineEntities entities = ts.getEntities("MAPREDUCE_JOB", null, null,
|
||||
null, null, null, null, null, null, null);
|
||||
Assertions.assertEquals(1, entities.getEntities().size());
|
||||
Assert.assertEquals(1, entities.getEntities().size());
|
||||
TimelineEntity tEntity = entities.getEntities().get(0);
|
||||
Assertions.assertEquals(t.jobId.toString(), tEntity.getEntityId());
|
||||
Assertions.assertEquals(1, tEntity.getEvents().size());
|
||||
Assertions.assertEquals(EventType.AM_STARTED.toString(),
|
||||
Assert.assertEquals(t.jobId.toString(), tEntity.getEntityId());
|
||||
Assert.assertEquals(1, tEntity.getEvents().size());
|
||||
Assert.assertEquals(EventType.AM_STARTED.toString(),
|
||||
tEntity.getEvents().get(0).getEventType());
|
||||
Assertions.assertEquals(currentTime - 10,
|
||||
Assert.assertEquals(currentTime - 10,
|
||||
tEntity.getEvents().get(0).getTimestamp());
|
||||
|
||||
handleEvent(jheh, new JobHistoryEvent(t.jobId,
|
||||
|
@ -624,17 +615,17 @@ public class TestJobHistoryEventHandler {
|
|||
jheh.getDispatcher().await();
|
||||
entities = ts.getEntities("MAPREDUCE_JOB", null, null, null,
|
||||
null, null, null, null, null, null);
|
||||
Assertions.assertEquals(1, entities.getEntities().size());
|
||||
Assert.assertEquals(1, entities.getEntities().size());
|
||||
tEntity = entities.getEntities().get(0);
|
||||
Assertions.assertEquals(t.jobId.toString(), tEntity.getEntityId());
|
||||
Assertions.assertEquals(2, tEntity.getEvents().size());
|
||||
Assertions.assertEquals(EventType.JOB_SUBMITTED.toString(),
|
||||
Assert.assertEquals(t.jobId.toString(), tEntity.getEntityId());
|
||||
Assert.assertEquals(2, tEntity.getEvents().size());
|
||||
Assert.assertEquals(EventType.JOB_SUBMITTED.toString(),
|
||||
tEntity.getEvents().get(0).getEventType());
|
||||
Assertions.assertEquals(EventType.AM_STARTED.toString(),
|
||||
Assert.assertEquals(EventType.AM_STARTED.toString(),
|
||||
tEntity.getEvents().get(1).getEventType());
|
||||
Assertions.assertEquals(currentTime + 10,
|
||||
Assert.assertEquals(currentTime + 10,
|
||||
tEntity.getEvents().get(0).getTimestamp());
|
||||
Assertions.assertEquals(currentTime - 10,
|
||||
Assert.assertEquals(currentTime - 10,
|
||||
tEntity.getEvents().get(1).getTimestamp());
|
||||
|
||||
handleEvent(jheh, new JobHistoryEvent(t.jobId,
|
||||
|
@ -643,80 +634,80 @@ public class TestJobHistoryEventHandler {
|
|||
jheh.getDispatcher().await();
|
||||
entities = ts.getEntities("MAPREDUCE_JOB", null, null, null,
|
||||
null, null, null, null, null, null);
|
||||
Assertions.assertEquals(1, entities.getEntities().size());
|
||||
Assert.assertEquals(1, entities.getEntities().size());
|
||||
tEntity = entities.getEntities().get(0);
|
||||
Assertions.assertEquals(t.jobId.toString(), tEntity.getEntityId());
|
||||
Assertions.assertEquals(3, tEntity.getEvents().size());
|
||||
Assertions.assertEquals(EventType.JOB_SUBMITTED.toString(),
|
||||
Assert.assertEquals(t.jobId.toString(), tEntity.getEntityId());
|
||||
Assert.assertEquals(3, tEntity.getEvents().size());
|
||||
Assert.assertEquals(EventType.JOB_SUBMITTED.toString(),
|
||||
tEntity.getEvents().get(0).getEventType());
|
||||
Assertions.assertEquals(EventType.AM_STARTED.toString(),
|
||||
Assert.assertEquals(EventType.AM_STARTED.toString(),
|
||||
tEntity.getEvents().get(1).getEventType());
|
||||
Assertions.assertEquals(EventType.JOB_QUEUE_CHANGED.toString(),
|
||||
Assert.assertEquals(EventType.JOB_QUEUE_CHANGED.toString(),
|
||||
tEntity.getEvents().get(2).getEventType());
|
||||
Assertions.assertEquals(currentTime + 10,
|
||||
Assert.assertEquals(currentTime + 10,
|
||||
tEntity.getEvents().get(0).getTimestamp());
|
||||
Assertions.assertEquals(currentTime - 10,
|
||||
Assert.assertEquals(currentTime - 10,
|
||||
tEntity.getEvents().get(1).getTimestamp());
|
||||
Assertions.assertEquals(currentTime - 20,
|
||||
Assert.assertEquals(currentTime - 20,
|
||||
tEntity.getEvents().get(2).getTimestamp());
|
||||
|
||||
handleEvent(jheh, new JobHistoryEvent(t.jobId,
|
||||
new JobFinishedEvent(TypeConverter.fromYarn(t.jobId), 0, 0, 0, 0,
|
||||
new JobFinishedEvent(TypeConverter.fromYarn(t.jobId), 0, 0, 0, 0,
|
||||
0, 0, 0, new Counters(), new Counters(), new Counters()), currentTime));
|
||||
jheh.getDispatcher().await();
|
||||
entities = ts.getEntities("MAPREDUCE_JOB", null, null, null,
|
||||
null, null, null, null, null, null);
|
||||
Assertions.assertEquals(1, entities.getEntities().size());
|
||||
null, null, null, null, null, null);
|
||||
Assert.assertEquals(1, entities.getEntities().size());
|
||||
tEntity = entities.getEntities().get(0);
|
||||
Assertions.assertEquals(t.jobId.toString(), tEntity.getEntityId());
|
||||
Assertions.assertEquals(4, tEntity.getEvents().size());
|
||||
Assertions.assertEquals(EventType.JOB_SUBMITTED.toString(),
|
||||
Assert.assertEquals(t.jobId.toString(), tEntity.getEntityId());
|
||||
Assert.assertEquals(4, tEntity.getEvents().size());
|
||||
Assert.assertEquals(EventType.JOB_SUBMITTED.toString(),
|
||||
tEntity.getEvents().get(0).getEventType());
|
||||
Assertions.assertEquals(EventType.JOB_FINISHED.toString(),
|
||||
Assert.assertEquals(EventType.JOB_FINISHED.toString(),
|
||||
tEntity.getEvents().get(1).getEventType());
|
||||
Assertions.assertEquals(EventType.AM_STARTED.toString(),
|
||||
Assert.assertEquals(EventType.AM_STARTED.toString(),
|
||||
tEntity.getEvents().get(2).getEventType());
|
||||
Assertions.assertEquals(EventType.JOB_QUEUE_CHANGED.toString(),
|
||||
Assert.assertEquals(EventType.JOB_QUEUE_CHANGED.toString(),
|
||||
tEntity.getEvents().get(3).getEventType());
|
||||
Assertions.assertEquals(currentTime + 10,
|
||||
Assert.assertEquals(currentTime + 10,
|
||||
tEntity.getEvents().get(0).getTimestamp());
|
||||
Assertions.assertEquals(currentTime,
|
||||
Assert.assertEquals(currentTime,
|
||||
tEntity.getEvents().get(1).getTimestamp());
|
||||
Assertions.assertEquals(currentTime - 10,
|
||||
Assert.assertEquals(currentTime - 10,
|
||||
tEntity.getEvents().get(2).getTimestamp());
|
||||
Assertions.assertEquals(currentTime - 20,
|
||||
Assert.assertEquals(currentTime - 20,
|
||||
tEntity.getEvents().get(3).getTimestamp());
|
||||
|
||||
handleEvent(jheh, new JobHistoryEvent(t.jobId,
|
||||
new JobUnsuccessfulCompletionEvent(TypeConverter.fromYarn(t.jobId),
|
||||
0, 0, 0, 0, 0, 0, 0, JobStateInternal.KILLED.toString()),
|
||||
currentTime + 20));
|
||||
currentTime + 20));
|
||||
jheh.getDispatcher().await();
|
||||
entities = ts.getEntities("MAPREDUCE_JOB", null, null, null,
|
||||
null, null, null, null, null, null);
|
||||
Assertions.assertEquals(1, entities.getEntities().size());
|
||||
Assert.assertEquals(1, entities.getEntities().size());
|
||||
tEntity = entities.getEntities().get(0);
|
||||
Assertions.assertEquals(t.jobId.toString(), tEntity.getEntityId());
|
||||
Assertions.assertEquals(5, tEntity.getEvents().size());
|
||||
Assertions.assertEquals(EventType.JOB_KILLED.toString(),
|
||||
Assert.assertEquals(t.jobId.toString(), tEntity.getEntityId());
|
||||
Assert.assertEquals(5, tEntity.getEvents().size());
|
||||
Assert.assertEquals(EventType.JOB_KILLED.toString(),
|
||||
tEntity.getEvents().get(0).getEventType());
|
||||
Assertions.assertEquals(EventType.JOB_SUBMITTED.toString(),
|
||||
Assert.assertEquals(EventType.JOB_SUBMITTED.toString(),
|
||||
tEntity.getEvents().get(1).getEventType());
|
||||
Assertions.assertEquals(EventType.JOB_FINISHED.toString(),
|
||||
Assert.assertEquals(EventType.JOB_FINISHED.toString(),
|
||||
tEntity.getEvents().get(2).getEventType());
|
||||
Assertions.assertEquals(EventType.AM_STARTED.toString(),
|
||||
Assert.assertEquals(EventType.AM_STARTED.toString(),
|
||||
tEntity.getEvents().get(3).getEventType());
|
||||
Assertions.assertEquals(EventType.JOB_QUEUE_CHANGED.toString(),
|
||||
Assert.assertEquals(EventType.JOB_QUEUE_CHANGED.toString(),
|
||||
tEntity.getEvents().get(4).getEventType());
|
||||
Assertions.assertEquals(currentTime + 20,
|
||||
Assert.assertEquals(currentTime + 20,
|
||||
tEntity.getEvents().get(0).getTimestamp());
|
||||
Assertions.assertEquals(currentTime + 10,
|
||||
Assert.assertEquals(currentTime + 10,
|
||||
tEntity.getEvents().get(1).getTimestamp());
|
||||
Assertions.assertEquals(currentTime,
|
||||
Assert.assertEquals(currentTime,
|
||||
tEntity.getEvents().get(2).getTimestamp());
|
||||
Assertions.assertEquals(currentTime - 10,
|
||||
Assert.assertEquals(currentTime - 10,
|
||||
tEntity.getEvents().get(3).getTimestamp());
|
||||
Assertions.assertEquals(currentTime - 20,
|
||||
Assert.assertEquals(currentTime - 20,
|
||||
tEntity.getEvents().get(4).getTimestamp());
|
||||
|
||||
handleEvent(jheh, new JobHistoryEvent(t.jobId,
|
||||
|
@ -724,13 +715,13 @@ public class TestJobHistoryEventHandler {
|
|||
jheh.getDispatcher().await();
|
||||
entities = ts.getEntities("MAPREDUCE_TASK", null, null, null,
|
||||
null, null, null, null, null, null);
|
||||
Assertions.assertEquals(1, entities.getEntities().size());
|
||||
Assert.assertEquals(1, entities.getEntities().size());
|
||||
tEntity = entities.getEntities().get(0);
|
||||
Assertions.assertEquals(t.taskID.toString(), tEntity.getEntityId());
|
||||
Assertions.assertEquals(1, tEntity.getEvents().size());
|
||||
Assertions.assertEquals(EventType.TASK_STARTED.toString(),
|
||||
Assert.assertEquals(t.taskID.toString(), tEntity.getEntityId());
|
||||
Assert.assertEquals(1, tEntity.getEvents().size());
|
||||
Assert.assertEquals(EventType.TASK_STARTED.toString(),
|
||||
tEntity.getEvents().get(0).getEventType());
|
||||
Assertions.assertEquals(TaskType.MAP.toString(),
|
||||
Assert.assertEquals(TaskType.MAP.toString(),
|
||||
tEntity.getEvents().get(0).getEventInfo().get("TASK_TYPE"));
|
||||
|
||||
handleEvent(jheh, new JobHistoryEvent(t.jobId,
|
||||
|
@ -738,31 +729,30 @@ public class TestJobHistoryEventHandler {
|
|||
jheh.getDispatcher().await();
|
||||
entities = ts.getEntities("MAPREDUCE_TASK", null, null, null,
|
||||
null, null, null, null, null, null);
|
||||
Assertions.assertEquals(1, entities.getEntities().size());
|
||||
Assert.assertEquals(1, entities.getEntities().size());
|
||||
tEntity = entities.getEntities().get(0);
|
||||
Assertions.assertEquals(t.taskID.toString(), tEntity.getEntityId());
|
||||
Assertions.assertEquals(2, tEntity.getEvents().size());
|
||||
Assertions.assertEquals(EventType.TASK_STARTED.toString(),
|
||||
Assert.assertEquals(t.taskID.toString(), tEntity.getEntityId());
|
||||
Assert.assertEquals(2, tEntity.getEvents().size());
|
||||
Assert.assertEquals(EventType.TASK_STARTED.toString(),
|
||||
tEntity.getEvents().get(1).getEventType());
|
||||
Assertions.assertEquals(TaskType.REDUCE.toString(),
|
||||
Assert.assertEquals(TaskType.REDUCE.toString(),
|
||||
tEntity.getEvents().get(0).getEventInfo().get("TASK_TYPE"));
|
||||
Assertions.assertEquals(TaskType.MAP.toString(),
|
||||
Assert.assertEquals(TaskType.MAP.toString(),
|
||||
tEntity.getEvents().get(1).getEventInfo().get("TASK_TYPE"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(50000)
|
||||
@Test (timeout=50000)
|
||||
public void testCountersToJSON() throws Exception {
|
||||
JobHistoryEventHandler jheh = new JobHistoryEventHandler(null, 0);
|
||||
Counters counters = new Counters();
|
||||
CounterGroup group1 = counters.addGroup("DOCTORS",
|
||||
"Incarnations of the Doctor");
|
||||
"Incarnations of the Doctor");
|
||||
group1.addCounter("PETER_CAPALDI", "Peter Capaldi", 12);
|
||||
group1.addCounter("MATT_SMITH", "Matt Smith", 11);
|
||||
group1.addCounter("DAVID_TENNANT", "David Tennant", 10);
|
||||
CounterGroup group2 = counters.addGroup("COMPANIONS",
|
||||
"Companions of the Doctor");
|
||||
"Companions of the Doctor");
|
||||
group2.addCounter("CLARA_OSWALD", "Clara Oswald", 6);
|
||||
group2.addCounter("RORY_WILLIAMS", "Rory Williams", 5);
|
||||
group2.addCounter("AMY_POND", "Amy Pond", 4);
|
||||
|
@ -785,31 +775,30 @@ public class TestJobHistoryEventHandler {
|
|||
+ "{\"NAME\":\"MATT_SMITH\",\"DISPLAY_NAME\":\"Matt Smith\",\"VALUE\":"
|
||||
+ "11},{\"NAME\":\"PETER_CAPALDI\",\"DISPLAY_NAME\":\"Peter Capaldi\","
|
||||
+ "\"VALUE\":12}]}]";
|
||||
Assertions.assertEquals(expected, jsonStr);
|
||||
Assert.assertEquals(expected, jsonStr);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(50000)
|
||||
@Test (timeout=50000)
|
||||
public void testCountersToJSONEmpty() throws Exception {
|
||||
JobHistoryEventHandler jheh = new JobHistoryEventHandler(null, 0);
|
||||
Counters counters = null;
|
||||
JsonNode jsonNode = JobHistoryEventUtils.countersToJSON(counters);
|
||||
String jsonStr = new ObjectMapper().writeValueAsString(jsonNode);
|
||||
String expected = "[]";
|
||||
Assertions.assertEquals(expected, jsonStr);
|
||||
Assert.assertEquals(expected, jsonStr);
|
||||
|
||||
counters = new Counters();
|
||||
jsonNode = JobHistoryEventUtils.countersToJSON(counters);
|
||||
jsonStr = new ObjectMapper().writeValueAsString(jsonNode);
|
||||
expected = "[]";
|
||||
Assertions.assertEquals(expected, jsonStr);
|
||||
Assert.assertEquals(expected, jsonStr);
|
||||
|
||||
counters.addGroup("DOCTORS", "Incarnations of the Doctor");
|
||||
jsonNode = JobHistoryEventUtils.countersToJSON(counters);
|
||||
jsonStr = new ObjectMapper().writeValueAsString(jsonNode);
|
||||
expected = "[{\"NAME\":\"DOCTORS\",\"DISPLAY_NAME\":\"Incarnations of the "
|
||||
+ "Doctor\",\"COUNTERS\":[]}]";
|
||||
Assertions.assertEquals(expected, jsonStr);
|
||||
Assert.assertEquals(expected, jsonStr);
|
||||
}
|
||||
|
||||
private void queueEvent(JHEvenHandlerForTest jheh, JobHistoryEvent event) {
|
||||
|
@ -923,9 +912,8 @@ public class TestJobHistoryEventHandler {
|
|||
}
|
||||
jheh.stop();
|
||||
//Make sure events were handled
|
||||
assertTrue(jheh.eventsHandled == 4,
|
||||
"handleEvent should've been called only 4 times but was "
|
||||
+ jheh.eventsHandled);
|
||||
assertTrue("handleEvent should've been called only 4 times but was "
|
||||
+ jheh.eventsHandled, jheh.eventsHandled == 4);
|
||||
|
||||
//Create a new jheh because the last stop closed the eventWriter etc.
|
||||
jheh = new JHEventHandlerForSigtermTest(mockedContext, 0);
|
||||
|
@ -946,15 +934,14 @@ public class TestJobHistoryEventHandler {
|
|||
}
|
||||
jheh.stop();
|
||||
//Make sure events were handled, 4 + 1 finish event
|
||||
assertTrue(jheh.eventsHandled == 5, "handleEvent should've been called only 5 times but was "
|
||||
+ jheh.eventsHandled);
|
||||
assertTrue(jheh.lastEventHandled.getHistoryEvent()
|
||||
instanceof JobUnsuccessfulCompletionEvent,
|
||||
"Last event handled wasn't JobUnsuccessfulCompletionEvent");
|
||||
assertTrue("handleEvent should've been called only 5 times but was "
|
||||
+ jheh.eventsHandled, jheh.eventsHandled == 5);
|
||||
assertTrue("Last event handled wasn't JobUnsuccessfulCompletionEvent",
|
||||
jheh.lastEventHandled.getHistoryEvent()
|
||||
instanceof JobUnsuccessfulCompletionEvent);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(50000)
|
||||
@Test (timeout=50000)
|
||||
public void testSetTrackingURLAfterHistoryIsWritten() throws Exception {
|
||||
TestParams t = new TestParams(true);
|
||||
Configuration conf = new Configuration();
|
||||
|
@ -985,8 +972,7 @@ public class TestJobHistoryEventHandler {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(50000)
|
||||
@Test (timeout=50000)
|
||||
public void testDontSetTrackingURLIfHistoryWriteFailed() throws Exception {
|
||||
TestParams t = new TestParams(true);
|
||||
Configuration conf = new Configuration();
|
||||
|
@ -1017,8 +1003,7 @@ public class TestJobHistoryEventHandler {
|
|||
jheh.stop();
|
||||
}
|
||||
}
|
||||
@Test
|
||||
@Timeout(50000)
|
||||
@Test (timeout=50000)
|
||||
public void testDontSetTrackingURLIfHistoryWriteThrows() throws Exception {
|
||||
TestParams t = new TestParams(true);
|
||||
Configuration conf = new Configuration();
|
||||
|
@ -1054,8 +1039,7 @@ public class TestJobHistoryEventHandler {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(50000)
|
||||
@Test(timeout = 50000)
|
||||
public void testJobHistoryFilePermissions() throws Exception {
|
||||
TestParams t = new TestParams(true);
|
||||
Configuration conf = new Configuration();
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
package org.apache.hadoop.mapreduce.jobhistory;
|
||||
|
||||
import org.apache.hadoop.mapreduce.v2.api.records.JobId;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class TestJobSummary {
|
|||
LoggerFactory.getLogger(TestJobSummary.class);
|
||||
private JobSummary summary = new JobSummary();
|
||||
|
||||
@BeforeEach
|
||||
@Before
|
||||
public void before() {
|
||||
JobId mockJobId = mock(JobId.class);
|
||||
when(mockJobId.toString()).thenReturn("testJobId");
|
||||
|
@ -64,8 +64,8 @@ public class TestJobSummary {
|
|||
summary.setJobName("aa\rbb\ncc\r\ndd");
|
||||
String out = summary.getJobSummaryString();
|
||||
LOG.info("summary: " + out);
|
||||
Assertions.assertFalse(out.contains("\r"));
|
||||
Assertions.assertFalse(out.contains("\n"));
|
||||
Assertions.assertTrue(out.contains("aa\\rbb\\ncc\\r\\ndd"));
|
||||
Assert.assertFalse(out.contains("\r"));
|
||||
Assert.assertFalse(out.contains("\n"));
|
||||
Assert.assertTrue(out.contains("aa\\rbb\\ncc\\r\\ndd"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,12 +24,12 @@ import org.apache.hadoop.mapreduce.v2.app.MockJobs;
|
|||
import org.apache.hadoop.mapreduce.v2.proto.MRProtos;
|
||||
import org.apache.hadoop.yarn.util.Records;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class TestTaskAttemptReport {
|
||||
|
||||
|
|
|
@ -24,12 +24,12 @@ import org.apache.hadoop.mapreduce.v2.app.MockJobs;
|
|||
import org.apache.hadoop.mapreduce.v2.proto.MRProtos;
|
||||
import org.apache.hadoop.yarn.util.Records;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class TestTaskReport {
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ import org.apache.hadoop.yarn.state.StateMachine;
|
|||
import org.apache.hadoop.yarn.state.StateMachineFactory;
|
||||
import org.apache.hadoop.yarn.util.Clock;
|
||||
import org.apache.hadoop.yarn.util.SystemClock;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.Assert;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -326,8 +326,8 @@ public class MRApp extends MRAppMaster {
|
|||
iState = job.getInternalState();
|
||||
}
|
||||
LOG.info("Job {} Internal State is : {}", job.getID(), iState);
|
||||
Assertions.assertEquals(finalState, iState,
|
||||
"Task Internal state is not correct (timedout)");
|
||||
Assert.assertEquals("Task Internal state is not correct (timedout)",
|
||||
finalState, iState);
|
||||
}
|
||||
|
||||
public void waitForInternalState(TaskImpl task,
|
||||
|
@ -339,8 +339,8 @@ public class MRApp extends MRAppMaster {
|
|||
iState = task.getInternalState();
|
||||
}
|
||||
LOG.info("Task {} Internal State is : {}", task.getID(), iState);
|
||||
Assertions.assertEquals(finalState, iState,
|
||||
"Task Internal state is not correct (timedout)");
|
||||
Assert.assertEquals("Task Internal state is not correct (timedout)",
|
||||
finalState, iState);
|
||||
}
|
||||
|
||||
public void waitForInternalState(TaskAttemptImpl attempt,
|
||||
|
@ -352,8 +352,8 @@ public class MRApp extends MRAppMaster {
|
|||
iState = attempt.getInternalState();
|
||||
}
|
||||
LOG.info("TaskAttempt {} Internal State is : {}", attempt.getID(), iState);
|
||||
Assertions.assertEquals(finalState, iState,
|
||||
"TaskAttempt Internal state is not correct (timedout)");
|
||||
Assert.assertEquals("TaskAttempt Internal state is not correct (timedout)",
|
||||
finalState, iState);
|
||||
}
|
||||
|
||||
public void waitForState(TaskAttempt attempt,
|
||||
|
@ -367,8 +367,9 @@ public class MRApp extends MRAppMaster {
|
|||
}
|
||||
LOG.info("TaskAttempt {} State is : {}", attempt.getID(),
|
||||
report.getTaskAttemptState());
|
||||
Assertions.assertEquals(finalState, report.getTaskAttemptState(),
|
||||
"TaskAttempt state is not correct (timedout)");
|
||||
Assert.assertEquals("TaskAttempt state is not correct (timedout)",
|
||||
finalState,
|
||||
report.getTaskAttemptState());
|
||||
}
|
||||
|
||||
public void waitForState(Task task, TaskState finalState) throws Exception {
|
||||
|
@ -380,8 +381,8 @@ public class MRApp extends MRAppMaster {
|
|||
report = task.getReport();
|
||||
}
|
||||
LOG.info("Task {} State is : {}", task.getID(), report.getTaskState());
|
||||
Assertions.assertEquals(finalState, report.getTaskState(),
|
||||
"Task state is not correct (timedout)");
|
||||
Assert.assertEquals("Task state is not correct (timedout)", finalState,
|
||||
report.getTaskState());
|
||||
}
|
||||
|
||||
public void waitForState(Job job, JobState finalState) throws Exception {
|
||||
|
@ -393,14 +394,14 @@ public class MRApp extends MRAppMaster {
|
|||
Thread.sleep(WAIT_FOR_STATE_INTERVAL);
|
||||
}
|
||||
LOG.info("Job {} State is : {}", job.getID(), report.getJobState());
|
||||
Assertions.assertEquals(finalState, job.getState(),
|
||||
"Job state is not correct (timedout)");
|
||||
Assert.assertEquals("Job state is not correct (timedout)", finalState,
|
||||
job.getState());
|
||||
}
|
||||
|
||||
public void waitForState(Service.STATE finalState) throws Exception {
|
||||
if (finalState == Service.STATE.STOPPED) {
|
||||
Assertions.assertTrue(waitForServiceToStop(20 * 1000),
|
||||
"Timeout while waiting for MRApp to stop");
|
||||
Assert.assertTrue("Timeout while waiting for MRApp to stop",
|
||||
waitForServiceToStop(20 * 1000));
|
||||
} else {
|
||||
int timeoutSecs = 0;
|
||||
while (!finalState.equals(getServiceState())
|
||||
|
@ -408,8 +409,8 @@ public class MRApp extends MRAppMaster {
|
|||
Thread.sleep(WAIT_FOR_STATE_INTERVAL);
|
||||
}
|
||||
LOG.info("MRApp State is : {}", getServiceState());
|
||||
Assertions.assertEquals(finalState, getServiceState(),
|
||||
"MRApp state is not correct (timedout)");
|
||||
Assert.assertEquals("MRApp state is not correct (timedout)", finalState,
|
||||
getServiceState());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -418,23 +419,22 @@ public class MRApp extends MRAppMaster {
|
|||
JobReport jobReport = job.getReport();
|
||||
LOG.info("Job start time :{}", jobReport.getStartTime());
|
||||
LOG.info("Job finish time :", jobReport.getFinishTime());
|
||||
Assertions.assertTrue(jobReport.getStartTime() <= jobReport.getFinishTime(),
|
||||
"Job start time is not less than finish time");
|
||||
Assertions.assertTrue(jobReport.getFinishTime() <= System.currentTimeMillis(),
|
||||
"Job finish time is in future");
|
||||
Assert.assertTrue("Job start time is not less than finish time",
|
||||
jobReport.getStartTime() <= jobReport.getFinishTime());
|
||||
Assert.assertTrue("Job finish time is in future",
|
||||
jobReport.getFinishTime() <= System.currentTimeMillis());
|
||||
for (Task task : job.getTasks().values()) {
|
||||
TaskReport taskReport = task.getReport();
|
||||
LOG.info("Task {} start time : {}", task.getID(),
|
||||
taskReport.getStartTime());
|
||||
LOG.info("Task {} finish time : {}", task.getID(),
|
||||
taskReport.getFinishTime());
|
||||
Assertions.assertTrue(taskReport.getStartTime() <= taskReport.getFinishTime(),
|
||||
"Task start time is not less than finish time");
|
||||
Assert.assertTrue("Task start time is not less than finish time",
|
||||
taskReport.getStartTime() <= taskReport.getFinishTime());
|
||||
for (TaskAttempt attempt : task.getAttempts().values()) {
|
||||
TaskAttemptReport attemptReport = attempt.getReport();
|
||||
Assertions.assertTrue(attemptReport.getStartTime() <=
|
||||
attemptReport.getFinishTime(),
|
||||
"Attempt start time is not less than finish time");
|
||||
Assert.assertTrue("Attempt start time is not less than finish time",
|
||||
attemptReport.getStartTime() <= attemptReport.getFinishTime());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,8 +56,7 @@ import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
|
|||
import org.apache.hadoop.yarn.factories.RecordFactory;
|
||||
import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
|
||||
import org.apache.hadoop.yarn.util.Records;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Timeout;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.event.Level;
|
||||
|
||||
public class MRAppBenchmark {
|
||||
|
@ -197,8 +196,7 @@ public class MRAppBenchmark {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(60000)
|
||||
@Test(timeout = 60000)
|
||||
public void benchmark1() throws Exception {
|
||||
int maps = 100; // Adjust for benchmarking. Start with thousands.
|
||||
int reduces = 0;
|
||||
|
@ -277,8 +275,7 @@ public class MRAppBenchmark {
|
|||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(60000)
|
||||
@Test(timeout = 60000)
|
||||
public void benchmark2() throws Exception {
|
||||
int maps = 100; // Adjust for benchmarking, start with a couple of thousands
|
||||
int reduces = 50;
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.apache.hadoop.mapreduce.v2.app;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.Assert;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.mapreduce.MRJobConfig;
|
||||
|
@ -33,7 +33,7 @@ import org.apache.hadoop.mapreduce.v2.app.TestRecovery.MRAppWithHistory;
|
|||
import org.apache.hadoop.mapreduce.v2.app.job.Job;
|
||||
import org.apache.hadoop.mapreduce.v2.app.job.Task;
|
||||
import org.apache.hadoop.mapreduce.v2.app.job.TaskAttempt;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestAMInfos {
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class TestAMInfos {
|
|||
|
||||
long am1StartTime = app.getAllAMInfos().get(0).getStartTime();
|
||||
|
||||
Assertions.assertEquals(1, job.getTasks().size(), "No of tasks not correct");
|
||||
Assert.assertEquals("No of tasks not correct", 1, job.getTasks().size());
|
||||
Iterator<Task> it = job.getTasks().values().iterator();
|
||||
Task mapTask = it.next();
|
||||
app.waitForState(mapTask, TaskState.RUNNING);
|
||||
|
@ -71,14 +71,14 @@ public class TestAMInfos {
|
|||
conf.setBoolean(MRJobConfig.JOB_UBERTASK_ENABLE, false);
|
||||
job = app.submit(conf);
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
Assertions.assertEquals(1, job.getTasks().size(), "No of tasks not correct");
|
||||
Assert.assertEquals("No of tasks not correct", 1, job.getTasks().size());
|
||||
it = job.getTasks().values().iterator();
|
||||
mapTask = it.next();
|
||||
// There should be two AMInfos
|
||||
List<AMInfo> amInfos = app.getAllAMInfos();
|
||||
Assertions.assertEquals(2, amInfos.size());
|
||||
Assert.assertEquals(2, amInfos.size());
|
||||
AMInfo amInfoOne = amInfos.get(0);
|
||||
Assertions.assertEquals(am1StartTime, amInfoOne.getStartTime());
|
||||
Assert.assertEquals(am1StartTime, amInfoOne.getStartTime());
|
||||
app.stop();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.apache.hadoop.yarn.api.records.PreemptionMessage;
|
|||
import org.apache.hadoop.yarn.api.records.Priority;
|
||||
import org.apache.hadoop.yarn.util.resource.Resources;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -58,8 +58,8 @@ import org.apache.hadoop.yarn.event.EventHandler;
|
|||
import org.apache.hadoop.yarn.factories.RecordFactory;
|
||||
import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
|
||||
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Allocation;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestCheckpointPreemptionPolicy {
|
||||
|
||||
|
@ -77,7 +77,7 @@ public class TestCheckpointPreemptionPolicy {
|
|||
|
||||
private int minAlloc = 1024;
|
||||
|
||||
@BeforeEach
|
||||
@Before
|
||||
@SuppressWarnings("rawtypes") // mocked generics
|
||||
public void setup() {
|
||||
ApplicationId appId = ApplicationId.newInstance(200, 1);
|
||||
|
|
|
@ -24,7 +24,7 @@ import java.util.Iterator;
|
|||
import java.util.Map;
|
||||
|
||||
import org.apache.hadoop.mapreduce.v2.app.job.event.TaskAttemptFailEvent;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.Assert;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.mapred.TaskAttemptListenerImpl;
|
||||
|
@ -48,7 +48,7 @@ import org.apache.hadoop.mapreduce.v2.app.rm.preemption.AMPreemptionPolicy;
|
|||
import org.apache.hadoop.net.NetUtils;
|
||||
import org.apache.hadoop.yarn.api.records.ContainerId;
|
||||
import org.apache.hadoop.yarn.client.api.impl.ContainerManagementProtocolProxy.ContainerManagementProtocolProxyData;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests the state machine with respect to Job/Task/TaskAttempt failure
|
||||
|
@ -68,20 +68,20 @@ public class TestFail {
|
|||
Job job = app.submit(conf);
|
||||
app.waitForState(job, JobState.SUCCEEDED);
|
||||
Map<TaskId,Task> tasks = job.getTasks();
|
||||
Assertions.assertEquals(1, tasks.size(), "Num tasks is not correct");
|
||||
Assert.assertEquals("Num tasks is not correct", 1, tasks.size());
|
||||
Task task = tasks.values().iterator().next();
|
||||
Assertions.assertEquals(TaskState.SUCCEEDED, task.getReport().getTaskState(),
|
||||
"Task state not correct");
|
||||
Assert.assertEquals("Task state not correct", TaskState.SUCCEEDED,
|
||||
task.getReport().getTaskState());
|
||||
Map<TaskAttemptId, TaskAttempt> attempts =
|
||||
tasks.values().iterator().next().getAttempts();
|
||||
Assertions.assertEquals(2, attempts.size(), "Num attempts is not correct");
|
||||
Assert.assertEquals("Num attempts is not correct", 2, attempts.size());
|
||||
//one attempt must be failed
|
||||
//and another must have succeeded
|
||||
Iterator<TaskAttempt> it = attempts.values().iterator();
|
||||
Assertions.assertEquals(TaskAttemptState.FAILED,
|
||||
it.next().getReport().getTaskAttemptState(), "Attempt state not correct");
|
||||
Assertions.assertEquals(TaskAttemptState.SUCCEEDED,
|
||||
it.next().getReport().getTaskAttemptState(), "Attempt state not correct");
|
||||
Assert.assertEquals("Attempt state not correct", TaskAttemptState.FAILED,
|
||||
it.next().getReport().getTaskAttemptState());
|
||||
Assert.assertEquals("Attempt state not correct", TaskAttemptState.SUCCEEDED,
|
||||
it.next().getReport().getTaskAttemptState());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -159,17 +159,17 @@ public class TestFail {
|
|||
Job job = app.submit(conf);
|
||||
app.waitForState(job, JobState.FAILED);
|
||||
Map<TaskId,Task> tasks = job.getTasks();
|
||||
Assertions.assertEquals(1, tasks.size(), "Num tasks is not correct");
|
||||
Assert.assertEquals("Num tasks is not correct", 1, tasks.size());
|
||||
Task task = tasks.values().iterator().next();
|
||||
Assertions.assertEquals(TaskState.FAILED,
|
||||
task.getReport().getTaskState(), "Task state not correct");
|
||||
Assert.assertEquals("Task state not correct", TaskState.FAILED,
|
||||
task.getReport().getTaskState());
|
||||
Map<TaskAttemptId, TaskAttempt> attempts =
|
||||
tasks.values().iterator().next().getAttempts();
|
||||
Assertions.assertEquals(maxAttempts,
|
||||
attempts.size(), "Num attempts is not correct");
|
||||
Assert.assertEquals("Num attempts is not correct", maxAttempts,
|
||||
attempts.size());
|
||||
for (TaskAttempt attempt : attempts.values()) {
|
||||
Assertions.assertEquals(TaskAttemptState.FAILED,
|
||||
attempt.getReport().getTaskAttemptState(), "Attempt state not correct");
|
||||
Assert.assertEquals("Attempt state not correct", TaskAttemptState.FAILED,
|
||||
attempt.getReport().getTaskAttemptState());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -185,14 +185,13 @@ public class TestFail {
|
|||
Job job = app.submit(conf);
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
Map<TaskId, Task> tasks = job.getTasks();
|
||||
Assertions.assertEquals(1, tasks.size(),
|
||||
"Num tasks is not correct");
|
||||
Assert.assertEquals("Num tasks is not correct", 1, tasks.size());
|
||||
Task task = tasks.values().iterator().next();
|
||||
app.waitForState(task, TaskState.SCHEDULED);
|
||||
Map<TaskAttemptId, TaskAttempt> attempts = tasks.values().iterator()
|
||||
.next().getAttempts();
|
||||
Assertions.assertEquals(maxAttempts, attempts.size(),
|
||||
"Num attempts is not correct");
|
||||
Assert.assertEquals("Num attempts is not correct", maxAttempts, attempts
|
||||
.size());
|
||||
TaskAttempt attempt = attempts.values().iterator().next();
|
||||
app.waitForInternalState((TaskAttemptImpl) attempt,
|
||||
TaskAttemptStateInternal.ASSIGNED);
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package org.apache.hadoop.mapreduce.v2.app;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -50,8 +50,8 @@ import org.apache.hadoop.mapreduce.v2.app.job.event.TaskAttemptEventType;
|
|||
import org.apache.hadoop.mapreduce.v2.app.job.event.TaskAttemptStatusUpdateEvent;
|
||||
import org.apache.hadoop.test.GenericTestUtils;
|
||||
import org.apache.hadoop.yarn.event.EventHandler;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestFetchFailure {
|
||||
|
||||
|
@ -65,8 +65,8 @@ public class TestFetchFailure {
|
|||
Job job = app.submit(conf);
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
//all maps would be running
|
||||
Assertions.assertEquals(2, job.getTasks().size(),
|
||||
"Num tasks not correct");
|
||||
Assert.assertEquals("Num tasks not correct",
|
||||
2, job.getTasks().size());
|
||||
Iterator<Task> it = job.getTasks().values().iterator();
|
||||
Task mapTask = it.next();
|
||||
Task reduceTask = it.next();
|
||||
|
@ -97,10 +97,10 @@ public class TestFetchFailure {
|
|||
|
||||
TaskAttemptCompletionEvent[] events =
|
||||
job.getTaskAttemptCompletionEvents(0, 100);
|
||||
Assertions.assertEquals(1, events.length,
|
||||
"Num completion events not correct");
|
||||
Assertions.assertEquals(TaskAttemptCompletionEventStatus.SUCCEEDED,
|
||||
events[0].getStatus(), "Event status not correct");
|
||||
Assert.assertEquals("Num completion events not correct",
|
||||
1, events.length);
|
||||
Assert.assertEquals("Event status not correct",
|
||||
TaskAttemptCompletionEventStatus.SUCCEEDED, events[0].getStatus());
|
||||
|
||||
// wait for reduce to start running
|
||||
app.waitForState(reduceTask, TaskState.RUNNING);
|
||||
|
@ -117,11 +117,11 @@ public class TestFetchFailure {
|
|||
app.waitForState(mapTask, TaskState.RUNNING);
|
||||
|
||||
//map attempt must have become FAILED
|
||||
Assertions.assertEquals(TaskAttemptState.FAILED, mapAttempt1.getState(),
|
||||
"Map TaskAttempt state not correct");
|
||||
Assert.assertEquals("Map TaskAttempt state not correct",
|
||||
TaskAttemptState.FAILED, mapAttempt1.getState());
|
||||
|
||||
Assertions.assertEquals(2, mapTask.getAttempts().size(),
|
||||
"Num attempts in Map Task not correct");
|
||||
Assert.assertEquals("Num attempts in Map Task not correct",
|
||||
2, mapTask.getAttempts().size());
|
||||
|
||||
Iterator<TaskAttempt> atIt = mapTask.getAttempts().values().iterator();
|
||||
atIt.next();
|
||||
|
@ -144,41 +144,39 @@ public class TestFetchFailure {
|
|||
app.waitForState(job, JobState.SUCCEEDED);
|
||||
|
||||
//previous completion event now becomes obsolete
|
||||
Assertions.assertEquals(TaskAttemptCompletionEventStatus.OBSOLETE,
|
||||
events[0].getStatus(), "Event status not correct");
|
||||
Assert.assertEquals("Event status not correct",
|
||||
TaskAttemptCompletionEventStatus.OBSOLETE, events[0].getStatus());
|
||||
|
||||
events = job.getTaskAttemptCompletionEvents(0, 100);
|
||||
Assertions.assertEquals(4, events.length,
|
||||
"Num completion events not correct");
|
||||
Assertions.assertEquals(mapAttempt1.getID(), events[0].getAttemptId(),
|
||||
"Event map attempt id not correct");
|
||||
Assertions.assertEquals(mapAttempt1.getID(), events[1].getAttemptId(),
|
||||
"Event map attempt id not correct");
|
||||
Assertions.assertEquals(mapAttempt2.getID(), events[2].getAttemptId(),
|
||||
"Event map attempt id not correct");
|
||||
Assertions.assertEquals(reduceAttempt.getID(), events[3].getAttemptId(),
|
||||
"Event redude attempt id not correct");
|
||||
Assertions.assertEquals(TaskAttemptCompletionEventStatus.OBSOLETE,
|
||||
events[0].getStatus(), "Event status not correct for map attempt1");
|
||||
Assertions.assertEquals(TaskAttemptCompletionEventStatus.FAILED,
|
||||
events[1].getStatus(), "Event status not correct for map attempt1");
|
||||
Assertions.assertEquals(TaskAttemptCompletionEventStatus.SUCCEEDED,
|
||||
events[2].getStatus(), "Event status not correct for map attempt2");
|
||||
Assertions.assertEquals(TaskAttemptCompletionEventStatus.SUCCEEDED,
|
||||
events[3].getStatus(), "Event status not correct for reduce attempt1");
|
||||
Assert.assertEquals("Num completion events not correct",
|
||||
4, events.length);
|
||||
Assert.assertEquals("Event map attempt id not correct",
|
||||
mapAttempt1.getID(), events[0].getAttemptId());
|
||||
Assert.assertEquals("Event map attempt id not correct",
|
||||
mapAttempt1.getID(), events[1].getAttemptId());
|
||||
Assert.assertEquals("Event map attempt id not correct",
|
||||
mapAttempt2.getID(), events[2].getAttemptId());
|
||||
Assert.assertEquals("Event redude attempt id not correct",
|
||||
reduceAttempt.getID(), events[3].getAttemptId());
|
||||
Assert.assertEquals("Event status not correct for map attempt1",
|
||||
TaskAttemptCompletionEventStatus.OBSOLETE, events[0].getStatus());
|
||||
Assert.assertEquals("Event status not correct for map attempt1",
|
||||
TaskAttemptCompletionEventStatus.FAILED, events[1].getStatus());
|
||||
Assert.assertEquals("Event status not correct for map attempt2",
|
||||
TaskAttemptCompletionEventStatus.SUCCEEDED, events[2].getStatus());
|
||||
Assert.assertEquals("Event status not correct for reduce attempt1",
|
||||
TaskAttemptCompletionEventStatus.SUCCEEDED, events[3].getStatus());
|
||||
|
||||
TaskCompletionEvent mapEvents[] =
|
||||
job.getMapAttemptCompletionEvents(0, 2);
|
||||
TaskCompletionEvent convertedEvents[] = TypeConverter.fromYarn(events);
|
||||
Assertions.assertEquals(2, mapEvents.length,
|
||||
"Incorrect number of map events");
|
||||
Assertions.assertArrayEquals(Arrays.copyOfRange(convertedEvents, 0, 2),
|
||||
mapEvents, "Unexpected map events");
|
||||
Assert.assertEquals("Incorrect number of map events", 2, mapEvents.length);
|
||||
Assert.assertArrayEquals("Unexpected map events",
|
||||
Arrays.copyOfRange(convertedEvents, 0, 2), mapEvents);
|
||||
mapEvents = job.getMapAttemptCompletionEvents(2, 200);
|
||||
Assertions.assertEquals(1, mapEvents.length,
|
||||
"Incorrect number of map events");
|
||||
Assertions.assertEquals(convertedEvents[2], mapEvents[0],
|
||||
"Unexpected map event");
|
||||
Assert.assertEquals("Incorrect number of map events", 1, mapEvents.length);
|
||||
Assert.assertEquals("Unexpected map event", convertedEvents[2],
|
||||
mapEvents[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -199,8 +197,8 @@ public class TestFetchFailure {
|
|||
Job job = app.submit(conf);
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
//all maps would be running
|
||||
Assertions.assertEquals(2, job.getTasks().size(),
|
||||
"Num tasks not correct");
|
||||
Assert.assertEquals("Num tasks not correct",
|
||||
2, job.getTasks().size());
|
||||
Iterator<Task> it = job.getTasks().values().iterator();
|
||||
Task mapTask = it.next();
|
||||
Task reduceTask = it.next();
|
||||
|
@ -220,10 +218,10 @@ public class TestFetchFailure {
|
|||
|
||||
TaskAttemptCompletionEvent[] events =
|
||||
job.getTaskAttemptCompletionEvents(0, 100);
|
||||
Assertions.assertEquals(1, events.length,
|
||||
"Num completion events not correct");
|
||||
Assertions.assertEquals(TaskAttemptCompletionEventStatus.SUCCEEDED,
|
||||
events[0].getStatus(), "Event status not correct");
|
||||
Assert.assertEquals("Num completion events not correct",
|
||||
1, events.length);
|
||||
Assert.assertEquals("Event status not correct",
|
||||
TaskAttemptCompletionEventStatus.SUCCEEDED, events[0].getStatus());
|
||||
|
||||
// wait for reduce to start running
|
||||
app.waitForState(reduceTask, TaskState.RUNNING);
|
||||
|
@ -252,8 +250,8 @@ public class TestFetchFailure {
|
|||
job = app.submit(conf);
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
//all maps would be running
|
||||
Assertions.assertEquals(2, job.getTasks().size(),
|
||||
"Num tasks not correct");
|
||||
Assert.assertEquals("Num tasks not correct",
|
||||
2, job.getTasks().size());
|
||||
it = job.getTasks().values().iterator();
|
||||
mapTask = it.next();
|
||||
reduceTask = it.next();
|
||||
|
@ -279,8 +277,7 @@ public class TestFetchFailure {
|
|||
|
||||
app.waitForState(job, JobState.SUCCEEDED);
|
||||
events = job.getTaskAttemptCompletionEvents(0, 100);
|
||||
Assertions.assertEquals(2, events.length,
|
||||
"Num completion events not correct");
|
||||
Assert.assertEquals("Num completion events not correct", 2, events.length);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -293,8 +290,8 @@ public class TestFetchFailure {
|
|||
Job job = app.submit(conf);
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
//all maps would be running
|
||||
Assertions.assertEquals(4, job.getTasks().size(),
|
||||
"Num tasks not correct");
|
||||
Assert.assertEquals("Num tasks not correct",
|
||||
4, job.getTasks().size());
|
||||
Iterator<Task> it = job.getTasks().values().iterator();
|
||||
Task mapTask = it.next();
|
||||
Task reduceTask = it.next();
|
||||
|
@ -316,10 +313,10 @@ public class TestFetchFailure {
|
|||
|
||||
TaskAttemptCompletionEvent[] events =
|
||||
job.getTaskAttemptCompletionEvents(0, 100);
|
||||
Assertions.assertEquals(1, events.length,
|
||||
"Num completion events not correct");
|
||||
Assertions.assertEquals(TaskAttemptCompletionEventStatus.SUCCEEDED, events[0].getStatus(),
|
||||
"Event status not correct");
|
||||
Assert.assertEquals("Num completion events not correct",
|
||||
1, events.length);
|
||||
Assert.assertEquals("Event status not correct",
|
||||
TaskAttemptCompletionEventStatus.SUCCEEDED, events[0].getStatus());
|
||||
|
||||
// wait for reduce to start running
|
||||
app.waitForState(reduceTask, TaskState.RUNNING);
|
||||
|
@ -357,16 +354,16 @@ public class TestFetchFailure {
|
|||
app.waitForState(mapTask, TaskState.RUNNING);
|
||||
|
||||
//map attempt must have become FAILED
|
||||
Assertions.assertEquals(TaskAttemptState.FAILED, mapAttempt1.getState(),
|
||||
"Map TaskAttempt state not correct");
|
||||
Assert.assertEquals("Map TaskAttempt state not correct",
|
||||
TaskAttemptState.FAILED, mapAttempt1.getState());
|
||||
|
||||
assertThat(mapAttempt1.getDiagnostics().get(0))
|
||||
.isEqualTo("Too many fetch failures. Failing the attempt. "
|
||||
+ "Last failure reported by "
|
||||
+ reduceAttempt3.getID().toString() + " from host host3");
|
||||
|
||||
Assertions.assertEquals(2, mapTask.getAttempts().size(),
|
||||
"Num attempts in Map Task not correct");
|
||||
Assert.assertEquals("Num attempts in Map Task not correct",
|
||||
2, mapTask.getAttempts().size());
|
||||
|
||||
Iterator<TaskAttempt> atIt = mapTask.getAttempts().values().iterator();
|
||||
atIt.next();
|
||||
|
@ -399,40 +396,39 @@ public class TestFetchFailure {
|
|||
app.waitForState(job, JobState.SUCCEEDED);
|
||||
|
||||
//previous completion event now becomes obsolete
|
||||
Assertions.assertEquals(TaskAttemptCompletionEventStatus.OBSOLETE, events[0].getStatus(),
|
||||
"Event status not correct");
|
||||
Assert.assertEquals("Event status not correct",
|
||||
TaskAttemptCompletionEventStatus.OBSOLETE, events[0].getStatus());
|
||||
|
||||
events = job.getTaskAttemptCompletionEvents(0, 100);
|
||||
Assertions.assertEquals(6, events.length,
|
||||
"Num completion events not correct");
|
||||
Assertions.assertEquals(mapAttempt1.getID(), events[0].getAttemptId(),
|
||||
"Event map attempt id not correct");
|
||||
Assertions.assertEquals(mapAttempt1.getID(), events[1].getAttemptId(),
|
||||
"Event map attempt id not correct");
|
||||
Assertions.assertEquals(mapAttempt2.getID(), events[2].getAttemptId(),
|
||||
"Event map attempt id not correct");
|
||||
Assertions.assertEquals(reduceAttempt.getID(), events[3].getAttemptId(),
|
||||
"Event reduce attempt id not correct");
|
||||
Assertions.assertEquals(TaskAttemptCompletionEventStatus.OBSOLETE,
|
||||
events[0].getStatus(), "Event status not correct for map attempt1");
|
||||
Assertions.assertEquals(TaskAttemptCompletionEventStatus.FAILED,
|
||||
events[1].getStatus(), "Event status not correct for map attempt1");
|
||||
Assertions.assertEquals(TaskAttemptCompletionEventStatus.SUCCEEDED,
|
||||
events[2].getStatus(), "Event status not correct for map attempt2");
|
||||
Assertions.assertEquals(TaskAttemptCompletionEventStatus.SUCCEEDED,
|
||||
events[3].getStatus(), "Event status not correct for reduce attempt1");
|
||||
Assert.assertEquals("Num completion events not correct",
|
||||
6, events.length);
|
||||
Assert.assertEquals("Event map attempt id not correct",
|
||||
mapAttempt1.getID(), events[0].getAttemptId());
|
||||
Assert.assertEquals("Event map attempt id not correct",
|
||||
mapAttempt1.getID(), events[1].getAttemptId());
|
||||
Assert.assertEquals("Event map attempt id not correct",
|
||||
mapAttempt2.getID(), events[2].getAttemptId());
|
||||
Assert.assertEquals("Event reduce attempt id not correct",
|
||||
reduceAttempt.getID(), events[3].getAttemptId());
|
||||
Assert.assertEquals("Event status not correct for map attempt1",
|
||||
TaskAttemptCompletionEventStatus.OBSOLETE, events[0].getStatus());
|
||||
Assert.assertEquals("Event status not correct for map attempt1",
|
||||
TaskAttemptCompletionEventStatus.FAILED, events[1].getStatus());
|
||||
Assert.assertEquals("Event status not correct for map attempt2",
|
||||
TaskAttemptCompletionEventStatus.SUCCEEDED, events[2].getStatus());
|
||||
Assert.assertEquals("Event status not correct for reduce attempt1",
|
||||
TaskAttemptCompletionEventStatus.SUCCEEDED, events[3].getStatus());
|
||||
|
||||
TaskCompletionEvent mapEvents[] =
|
||||
job.getMapAttemptCompletionEvents(0, 2);
|
||||
TaskCompletionEvent convertedEvents[] = TypeConverter.fromYarn(events);
|
||||
Assertions.assertEquals(2, mapEvents.length,
|
||||
"Incorrect number of map events");
|
||||
Assertions.assertArrayEquals(Arrays.copyOfRange(convertedEvents, 0, 2),
|
||||
mapEvents, "Unexpected map events");
|
||||
Assert.assertEquals("Incorrect number of map events", 2, mapEvents.length);
|
||||
Assert.assertArrayEquals("Unexpected map events",
|
||||
Arrays.copyOfRange(convertedEvents, 0, 2), mapEvents);
|
||||
mapEvents = job.getMapAttemptCompletionEvents(2, 200);
|
||||
Assertions.assertEquals(1, mapEvents.length, "Incorrect number of map events");
|
||||
Assertions.assertEquals(convertedEvents[2], mapEvents[0],
|
||||
"Unexpected map event");
|
||||
Assert.assertEquals("Incorrect number of map events", 1, mapEvents.length);
|
||||
Assert.assertEquals("Unexpected map event", convertedEvents[2],
|
||||
mapEvents[0]);
|
||||
}
|
||||
|
||||
private void updateStatus(MRApp app, TaskAttempt attempt, Phase phase) {
|
||||
|
|
|
@ -59,8 +59,8 @@ import org.apache.hadoop.mapreduce.v2.app.rm.RMCommunicator;
|
|||
import org.apache.hadoop.mapreduce.v2.app.rm.RMHeartbeatHandler;
|
||||
import org.apache.hadoop.yarn.exceptions.YarnException;
|
||||
import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests job end notification
|
||||
|
@ -74,18 +74,18 @@ public class TestJobEndNotifier extends JobEndNotifier {
|
|||
conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_MAX_ATTEMPTS, "0");
|
||||
conf.set(MRJobConfig.MR_JOB_END_RETRY_ATTEMPTS, "10");
|
||||
setConf(conf);
|
||||
Assertions.assertTrue(numTries == 0,
|
||||
"Expected numTries to be 0, but was " + numTries);
|
||||
Assert.assertTrue("Expected numTries to be 0, but was " + numTries,
|
||||
numTries == 0 );
|
||||
|
||||
conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_MAX_ATTEMPTS, "1");
|
||||
setConf(conf);
|
||||
Assertions.assertTrue(numTries == 1,
|
||||
"Expected numTries to be 1, but was " + numTries);
|
||||
Assert.assertTrue("Expected numTries to be 1, but was " + numTries,
|
||||
numTries == 1 );
|
||||
|
||||
conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_MAX_ATTEMPTS, "20");
|
||||
setConf(conf);
|
||||
Assertions.assertTrue(numTries == 11 , "Expected numTries to be 11, but was "
|
||||
+ numTries); //11 because number of _retries_ is 10
|
||||
Assert.assertTrue("Expected numTries to be 11, but was " + numTries,
|
||||
numTries == 11 ); //11 because number of _retries_ is 10
|
||||
}
|
||||
|
||||
//Test maximum retry interval is capped by
|
||||
|
@ -94,53 +94,53 @@ public class TestJobEndNotifier extends JobEndNotifier {
|
|||
conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_MAX_RETRY_INTERVAL, "5000");
|
||||
conf.set(MRJobConfig.MR_JOB_END_RETRY_INTERVAL, "1000");
|
||||
setConf(conf);
|
||||
Assertions.assertTrue(waitInterval == 1000,
|
||||
"Expected waitInterval to be 1000, but was " + waitInterval);
|
||||
Assert.assertTrue("Expected waitInterval to be 1000, but was "
|
||||
+ waitInterval, waitInterval == 1000);
|
||||
|
||||
conf.set(MRJobConfig.MR_JOB_END_RETRY_INTERVAL, "10000");
|
||||
setConf(conf);
|
||||
Assertions.assertTrue(waitInterval == 5000,
|
||||
"Expected waitInterval to be 5000, but was " + waitInterval);
|
||||
Assert.assertTrue("Expected waitInterval to be 5000, but was "
|
||||
+ waitInterval, waitInterval == 5000);
|
||||
|
||||
//Test negative numbers are set to default
|
||||
conf.set(MRJobConfig.MR_JOB_END_RETRY_INTERVAL, "-10");
|
||||
setConf(conf);
|
||||
Assertions.assertTrue(waitInterval == 5000,
|
||||
"Expected waitInterval to be 5000, but was " + waitInterval);
|
||||
Assert.assertTrue("Expected waitInterval to be 5000, but was "
|
||||
+ waitInterval, waitInterval == 5000);
|
||||
}
|
||||
|
||||
private void testTimeout(Configuration conf) {
|
||||
conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_TIMEOUT, "1000");
|
||||
setConf(conf);
|
||||
Assertions.assertTrue(timeout == 1000,
|
||||
"Expected timeout to be 1000, but was " + timeout);
|
||||
Assert.assertTrue("Expected timeout to be 1000, but was "
|
||||
+ timeout, timeout == 1000);
|
||||
}
|
||||
|
||||
private void testProxyConfiguration(Configuration conf) {
|
||||
conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_PROXY, "somehost");
|
||||
setConf(conf);
|
||||
Assertions.assertTrue(proxyToUse.type() == Proxy.Type.DIRECT,
|
||||
"Proxy shouldn't be set because port wasn't specified");
|
||||
Assert.assertTrue("Proxy shouldn't be set because port wasn't specified",
|
||||
proxyToUse.type() == Proxy.Type.DIRECT);
|
||||
conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_PROXY, "somehost:someport");
|
||||
setConf(conf);
|
||||
Assertions.assertTrue(proxyToUse.type() == Proxy.Type.DIRECT,
|
||||
"Proxy shouldn't be set because port wasn't numeric");
|
||||
Assert.assertTrue("Proxy shouldn't be set because port wasn't numeric",
|
||||
proxyToUse.type() == Proxy.Type.DIRECT);
|
||||
conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_PROXY, "somehost:1000");
|
||||
setConf(conf);
|
||||
Assertions.assertEquals("HTTP @ somehost:1000", proxyToUse.toString(),
|
||||
"Proxy should have been set but wasn't ");
|
||||
Assert.assertEquals("Proxy should have been set but wasn't ",
|
||||
"HTTP @ somehost:1000", proxyToUse.toString());
|
||||
conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_PROXY, "socks@somehost:1000");
|
||||
setConf(conf);
|
||||
Assertions.assertEquals("SOCKS @ somehost:1000", proxyToUse.toString(),
|
||||
"Proxy should have been socks but wasn't ");
|
||||
Assert.assertEquals("Proxy should have been socks but wasn't ",
|
||||
"SOCKS @ somehost:1000", proxyToUse.toString());
|
||||
conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_PROXY, "SOCKS@somehost:1000");
|
||||
setConf(conf);
|
||||
Assertions.assertEquals("SOCKS @ somehost:1000", proxyToUse.toString(),
|
||||
"Proxy should have been socks but wasn't ");
|
||||
Assert.assertEquals("Proxy should have been socks but wasn't ",
|
||||
"SOCKS @ somehost:1000", proxyToUse.toString());
|
||||
conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_PROXY, "sfafn@somehost:1000");
|
||||
setConf(conf);
|
||||
Assertions.assertEquals("HTTP @ somehost:1000", proxyToUse.toString(),
|
||||
"Proxy should have been http but wasn't ");
|
||||
Assert.assertEquals("Proxy should have been http but wasn't ",
|
||||
"HTTP @ somehost:1000", proxyToUse.toString());
|
||||
|
||||
}
|
||||
|
||||
|
@ -181,10 +181,10 @@ public class TestJobEndNotifier extends JobEndNotifier {
|
|||
this.setConf(conf);
|
||||
this.notify(jobReport);
|
||||
long endTime = System.currentTimeMillis();
|
||||
Assertions.assertEquals(1, this.notificationCount,
|
||||
"Only 1 try was expected but was : " + this.notificationCount);
|
||||
Assertions.assertTrue(endTime - startTime > 5000,
|
||||
"Should have taken more than 5 seconds it took " + (endTime - startTime));
|
||||
Assert.assertEquals("Only 1 try was expected but was : "
|
||||
+ this.notificationCount, 1, this.notificationCount);
|
||||
Assert.assertTrue("Should have taken more than 5 seconds it took "
|
||||
+ (endTime - startTime), endTime - startTime > 5000);
|
||||
|
||||
conf.set(MRJobConfig.MR_JOB_END_NOTIFICATION_MAX_ATTEMPTS, "3");
|
||||
conf.set(MRJobConfig.MR_JOB_END_RETRY_ATTEMPTS, "3");
|
||||
|
@ -196,10 +196,10 @@ public class TestJobEndNotifier extends JobEndNotifier {
|
|||
this.setConf(conf);
|
||||
this.notify(jobReport);
|
||||
endTime = System.currentTimeMillis();
|
||||
Assertions.assertEquals(3, this.notificationCount,
|
||||
"Only 3 retries were expected but was : " + this.notificationCount);
|
||||
Assertions.assertTrue(endTime - startTime > 9000,
|
||||
"Should have taken more than 9 seconds it took " + (endTime - startTime));
|
||||
Assert.assertEquals("Only 3 retries were expected but was : "
|
||||
+ this.notificationCount, 3, this.notificationCount);
|
||||
Assert.assertTrue("Should have taken more than 9 seconds it took "
|
||||
+ (endTime - startTime), endTime - startTime > 9000);
|
||||
|
||||
}
|
||||
|
||||
|
@ -222,11 +222,11 @@ public class TestJobEndNotifier extends JobEndNotifier {
|
|||
doThrow(runtimeException).when(app).stop();
|
||||
}
|
||||
app.shutDownJob();
|
||||
Assertions.assertTrue(app.isLastAMRetry());
|
||||
Assertions.assertEquals(1, JobEndServlet.calledTimes);
|
||||
Assertions.assertEquals("jobid=" + job.getID() + "&status=SUCCEEDED",
|
||||
Assert.assertTrue(app.isLastAMRetry());
|
||||
Assert.assertEquals(1, JobEndServlet.calledTimes);
|
||||
Assert.assertEquals("jobid=" + job.getID() + "&status=SUCCEEDED",
|
||||
JobEndServlet.requestUri.getQuery());
|
||||
Assertions.assertEquals(JobState.SUCCEEDED.toString(),
|
||||
Assert.assertEquals(JobState.SUCCEEDED.toString(),
|
||||
JobEndServlet.foundJobState);
|
||||
server.stop();
|
||||
}
|
||||
|
@ -262,10 +262,10 @@ public class TestJobEndNotifier extends JobEndNotifier {
|
|||
app.shutDownJob();
|
||||
// Not the last AM attempt. So user should that the job is still running.
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
Assertions.assertFalse(app.isLastAMRetry());
|
||||
Assertions.assertEquals(0, JobEndServlet.calledTimes);
|
||||
Assertions.assertNull(JobEndServlet.requestUri);
|
||||
Assertions.assertNull(JobEndServlet.foundJobState);
|
||||
Assert.assertFalse(app.isLastAMRetry());
|
||||
Assert.assertEquals(0, JobEndServlet.calledTimes);
|
||||
Assert.assertNull(JobEndServlet.requestUri);
|
||||
Assert.assertNull(JobEndServlet.foundJobState);
|
||||
server.stop();
|
||||
}
|
||||
|
||||
|
@ -294,11 +294,11 @@ public class TestJobEndNotifier extends JobEndNotifier {
|
|||
// Unregistration fails: isLastAMRetry is recalculated, this is
|
||||
///reboot will stop service internally, we don't need to shutdown twice
|
||||
app.waitForServiceToStop(10000);
|
||||
Assertions.assertFalse(app.isLastAMRetry());
|
||||
Assert.assertFalse(app.isLastAMRetry());
|
||||
// Since it's not last retry, JobEndServlet didn't called
|
||||
Assertions.assertEquals(0, JobEndServlet.calledTimes);
|
||||
Assertions.assertNull(JobEndServlet.requestUri);
|
||||
Assertions.assertNull(JobEndServlet.foundJobState);
|
||||
Assert.assertEquals(0, JobEndServlet.calledTimes);
|
||||
Assert.assertNull(JobEndServlet.requestUri);
|
||||
Assert.assertNull(JobEndServlet.foundJobState);
|
||||
server.stop();
|
||||
}
|
||||
|
||||
|
@ -321,7 +321,7 @@ public class TestJobEndNotifier extends JobEndNotifier {
|
|||
this.notify(jobReport);
|
||||
final URL urlToNotify = CustomNotifier.urlToNotify;
|
||||
|
||||
Assertions.assertEquals("http://example.com?jobId=mock-Id&jobStatus=SUCCEEDED",
|
||||
Assert.assertEquals("http://example.com?jobId=mock-Id&jobStatus=SUCCEEDED",
|
||||
urlToNotify.toString());
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.Map;
|
|||
import java.util.concurrent.CountDownLatch;
|
||||
|
||||
import org.apache.hadoop.service.Service;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.Assert;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.mapreduce.v2.api.records.JobId;
|
||||
|
@ -48,7 +48,7 @@ import org.apache.hadoop.mapreduce.v2.app.job.impl.JobImpl;
|
|||
import org.apache.hadoop.yarn.event.AsyncDispatcher;
|
||||
import org.apache.hadoop.yarn.event.Dispatcher;
|
||||
import org.apache.hadoop.yarn.event.Event;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Tests the state machine with respect to Job/Task/TaskAttempt kill scenarios.
|
||||
|
@ -83,17 +83,18 @@ public class TestKill {
|
|||
app.waitForState(Service.STATE.STOPPED);
|
||||
|
||||
Map<TaskId,Task> tasks = job.getTasks();
|
||||
Assertions.assertEquals(1, tasks.size(),
|
||||
"No of tasks is not correct");
|
||||
Assert.assertEquals("No of tasks is not correct", 1,
|
||||
tasks.size());
|
||||
Task task = tasks.values().iterator().next();
|
||||
Assertions.assertEquals(TaskState.KILLED,
|
||||
task.getReport().getTaskState(), "Task state not correct");
|
||||
Assert.assertEquals("Task state not correct", TaskState.KILLED,
|
||||
task.getReport().getTaskState());
|
||||
Map<TaskAttemptId, TaskAttempt> attempts =
|
||||
tasks.values().iterator().next().getAttempts();
|
||||
Assertions.assertEquals(1, attempts.size(), "No of attempts is not correct");
|
||||
Assert.assertEquals("No of attempts is not correct", 1,
|
||||
attempts.size());
|
||||
Iterator<TaskAttempt> it = attempts.values().iterator();
|
||||
Assertions.assertEquals(TaskAttemptState.KILLED,
|
||||
it.next().getReport().getTaskAttemptState(), "Attempt state not correct");
|
||||
Assert.assertEquals("Attempt state not correct", TaskAttemptState.KILLED,
|
||||
it.next().getReport().getTaskAttemptState());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -106,8 +107,8 @@ public class TestKill {
|
|||
//wait and vailidate for Job to become RUNNING
|
||||
app.waitForInternalState((JobImpl) job, JobStateInternal.RUNNING);
|
||||
Map<TaskId,Task> tasks = job.getTasks();
|
||||
Assertions.assertEquals(2, tasks.size(),
|
||||
"No of tasks is not correct");
|
||||
Assert.assertEquals("No of tasks is not correct", 2,
|
||||
tasks.size());
|
||||
Iterator<Task> it = tasks.values().iterator();
|
||||
Task task1 = it.next();
|
||||
Task task2 = it.next();
|
||||
|
@ -124,24 +125,24 @@ public class TestKill {
|
|||
|
||||
//first Task is killed and second is Succeeded
|
||||
//Job is succeeded
|
||||
|
||||
Assertions.assertEquals(TaskState.KILLED, task1.getReport().getTaskState(),
|
||||
"Task state not correct");
|
||||
Assertions.assertEquals(TaskState.SUCCEEDED, task2.getReport().getTaskState(),
|
||||
"Task state not correct");
|
||||
|
||||
Assert.assertEquals("Task state not correct", TaskState.KILLED,
|
||||
task1.getReport().getTaskState());
|
||||
Assert.assertEquals("Task state not correct", TaskState.SUCCEEDED,
|
||||
task2.getReport().getTaskState());
|
||||
Map<TaskAttemptId, TaskAttempt> attempts = task1.getAttempts();
|
||||
Assertions.assertEquals(1, attempts.size(),
|
||||
"No of attempts is not correct");
|
||||
Assert.assertEquals("No of attempts is not correct", 1,
|
||||
attempts.size());
|
||||
Iterator<TaskAttempt> iter = attempts.values().iterator();
|
||||
Assertions.assertEquals(TaskAttemptState.KILLED,
|
||||
iter.next().getReport().getTaskAttemptState(), "Attempt state not correct");
|
||||
Assert.assertEquals("Attempt state not correct", TaskAttemptState.KILLED,
|
||||
iter.next().getReport().getTaskAttemptState());
|
||||
|
||||
attempts = task2.getAttempts();
|
||||
Assertions.assertEquals(1, attempts.size(),
|
||||
"No of attempts is not correct");
|
||||
Assert.assertEquals("No of attempts is not correct", 1,
|
||||
attempts.size());
|
||||
iter = attempts.values().iterator();
|
||||
Assertions.assertEquals(TaskAttemptState.SUCCEEDED,
|
||||
iter.next().getReport().getTaskAttemptState(), "Attempt state not correct");
|
||||
Assert.assertEquals("Attempt state not correct", TaskAttemptState.SUCCEEDED,
|
||||
iter.next().getReport().getTaskAttemptState());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -193,8 +194,7 @@ public class TestKill {
|
|||
Job job = app.submit(new Configuration());
|
||||
JobId jobId = app.getJobId();
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
Assertions.assertEquals(2, job.getTasks().size(),
|
||||
"Num tasks not correct");
|
||||
Assert.assertEquals("Num tasks not correct", 2, job.getTasks().size());
|
||||
Iterator<Task> it = job.getTasks().values().iterator();
|
||||
Task mapTask = it.next();
|
||||
Task reduceTask = it.next();
|
||||
|
@ -232,8 +232,7 @@ public class TestKill {
|
|||
Job job = app.submit(new Configuration());
|
||||
JobId jobId = app.getJobId();
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
Assertions.assertEquals(2, job.getTasks().size(),
|
||||
"Num tasks not correct");
|
||||
Assert.assertEquals("Num tasks not correct", 2, job.getTasks().size());
|
||||
Iterator<Task> it = job.getTasks().values().iterator();
|
||||
Task mapTask = it.next();
|
||||
Task reduceTask = it.next();
|
||||
|
@ -281,8 +280,7 @@ public class TestKill {
|
|||
Job job = app.submit(new Configuration());
|
||||
JobId jobId = app.getJobId();
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
Assertions.assertEquals(2, job.getTasks().size(),
|
||||
"Num tasks not correct");
|
||||
Assert.assertEquals("Num tasks not correct", 2, job.getTasks().size());
|
||||
Iterator<Task> it = job.getTasks().values().iterator();
|
||||
Task mapTask = it.next();
|
||||
Task reduceTask = it.next();
|
||||
|
@ -372,8 +370,8 @@ public class TestKill {
|
|||
//wait and vailidate for Job to become RUNNING
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
Map<TaskId,Task> tasks = job.getTasks();
|
||||
Assertions.assertEquals(2, tasks.size(),
|
||||
"No of tasks is not correct");
|
||||
Assert.assertEquals("No of tasks is not correct", 2,
|
||||
tasks.size());
|
||||
Iterator<Task> it = tasks.values().iterator();
|
||||
Task task1 = it.next();
|
||||
Task task2 = it.next();
|
||||
|
@ -396,26 +394,26 @@ public class TestKill {
|
|||
|
||||
//first Task will have two attempts 1st is killed, 2nd Succeeds
|
||||
//both Tasks and Job succeeds
|
||||
Assertions.assertEquals(TaskState.SUCCEEDED,
|
||||
task1.getReport().getTaskState(), "Task state not correct");
|
||||
Assertions.assertEquals(TaskState.SUCCEEDED,
|
||||
task2.getReport().getTaskState(), "Task state not correct");
|
||||
Assert.assertEquals("Task state not correct", TaskState.SUCCEEDED,
|
||||
task1.getReport().getTaskState());
|
||||
Assert.assertEquals("Task state not correct", TaskState.SUCCEEDED,
|
||||
task2.getReport().getTaskState());
|
||||
|
||||
Map<TaskAttemptId, TaskAttempt> attempts = task1.getAttempts();
|
||||
Assertions.assertEquals(2, attempts.size(),
|
||||
"No of attempts is not correct");
|
||||
Assert.assertEquals("No of attempts is not correct", 2,
|
||||
attempts.size());
|
||||
Iterator<TaskAttempt> iter = attempts.values().iterator();
|
||||
Assertions.assertEquals(TaskAttemptState.KILLED,
|
||||
iter.next().getReport().getTaskAttemptState(), "Attempt state not correct");
|
||||
Assertions.assertEquals(TaskAttemptState.SUCCEEDED,
|
||||
iter.next().getReport().getTaskAttemptState(), "Attempt state not correct");
|
||||
Assert.assertEquals("Attempt state not correct", TaskAttemptState.KILLED,
|
||||
iter.next().getReport().getTaskAttemptState());
|
||||
Assert.assertEquals("Attempt state not correct", TaskAttemptState.SUCCEEDED,
|
||||
iter.next().getReport().getTaskAttemptState());
|
||||
|
||||
attempts = task2.getAttempts();
|
||||
Assertions.assertEquals(1, attempts.size(),
|
||||
"No of attempts is not correct");
|
||||
Assert.assertEquals("No of attempts is not correct", 1,
|
||||
attempts.size());
|
||||
iter = attempts.values().iterator();
|
||||
Assertions.assertEquals(TaskAttemptState.SUCCEEDED,
|
||||
iter.next().getReport().getTaskAttemptState(), "Attempt state not correct");
|
||||
Assert.assertEquals("Attempt state not correct", TaskAttemptState.SUCCEEDED,
|
||||
iter.next().getReport().getTaskAttemptState());
|
||||
}
|
||||
|
||||
static class BlockingMRApp extends MRApp {
|
||||
|
|
|
@ -47,7 +47,7 @@ import org.apache.hadoop.yarn.event.Event;
|
|||
import org.apache.hadoop.yarn.event.EventHandler;
|
||||
import org.apache.hadoop.yarn.factories.RecordFactory;
|
||||
import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestKillAMPreemptionPolicy {
|
||||
private final RecordFactory recordFactory = RecordFactoryProvider
|
||||
|
|
|
@ -30,7 +30,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
|
||||
import java.util.function.Supplier;
|
||||
import org.apache.hadoop.test.GenericTestUtils;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.Assert;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.mapreduce.MRJobConfig;
|
||||
|
@ -68,7 +68,7 @@ import org.apache.hadoop.yarn.event.AsyncDispatcher;
|
|||
import org.apache.hadoop.yarn.event.Dispatcher;
|
||||
import org.apache.hadoop.yarn.event.EventHandler;
|
||||
import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
/**
|
||||
|
@ -83,7 +83,7 @@ public class TestMRApp {
|
|||
Job job = app.submit(new Configuration());
|
||||
app.waitForState(job, JobState.SUCCEEDED);
|
||||
app.verifyCompleted();
|
||||
Assertions.assertEquals(System.getProperty("user.name"),job.getUserName());
|
||||
Assert.assertEquals(System.getProperty("user.name"),job.getUserName());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -106,7 +106,7 @@ public class TestMRApp {
|
|||
MRApp app = new MRApp(1, 0, false, this.getClass().getName(), true);
|
||||
Job job = app.submit(new Configuration());
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
Assertions.assertEquals(1, job.getTasks().size(), "Num tasks not correct");
|
||||
Assert.assertEquals("Num tasks not correct", 1, job.getTasks().size());
|
||||
Iterator<Task> it = job.getTasks().values().iterator();
|
||||
Task task = it.next();
|
||||
app.waitForState(task, TaskState.RUNNING);
|
||||
|
@ -151,7 +151,7 @@ public class TestMRApp {
|
|||
Job job = app.submit(conf);
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
//all maps would be running
|
||||
Assertions.assertEquals(3, job.getTasks().size(), "Num tasks not correct");
|
||||
Assert.assertEquals("Num tasks not correct", 3, job.getTasks().size());
|
||||
Iterator<Task> it = job.getTasks().values().iterator();
|
||||
Task mapTask1 = it.next();
|
||||
Task mapTask2 = it.next();
|
||||
|
@ -170,8 +170,8 @@ public class TestMRApp {
|
|||
app.waitForState(task2Attempt, TaskAttemptState.RUNNING);
|
||||
|
||||
// reduces must be in NEW state
|
||||
Assertions.assertEquals(TaskState.NEW,
|
||||
reduceTask.getReport().getTaskState(), "Reduce Task state not correct");
|
||||
Assert.assertEquals("Reduce Task state not correct",
|
||||
TaskState.NEW, reduceTask.getReport().getTaskState());
|
||||
|
||||
//send the done signal to the 1st map task
|
||||
app.getContext().getEventHandler().handle(
|
||||
|
@ -224,8 +224,7 @@ public class TestMRApp {
|
|||
|
||||
final Job job1 = app.submit(conf);
|
||||
app.waitForState(job1, JobState.RUNNING);
|
||||
Assertions.assertEquals(4, job1.getTasks().size(),
|
||||
"Num tasks not correct");
|
||||
Assert.assertEquals("Num tasks not correct", 4, job1.getTasks().size());
|
||||
Iterator<Task> it = job1.getTasks().values().iterator();
|
||||
Task mapTask1 = it.next();
|
||||
Task mapTask2 = it.next();
|
||||
|
@ -240,7 +239,7 @@ public class TestMRApp {
|
|||
.next();
|
||||
NodeId node1 = task1Attempt.getNodeId();
|
||||
NodeId node2 = task2Attempt.getNodeId();
|
||||
Assertions.assertEquals(node1, node2);
|
||||
Assert.assertEquals(node1, node2);
|
||||
|
||||
// send the done signal to the task
|
||||
app.getContext()
|
||||
|
@ -272,8 +271,8 @@ public class TestMRApp {
|
|||
|
||||
TaskAttemptCompletionEvent[] events = job1.getTaskAttemptCompletionEvents
|
||||
(0, 100);
|
||||
Assertions.assertEquals(2, events.length,
|
||||
"Expecting 2 completion events for success");
|
||||
Assert.assertEquals("Expecting 2 completion events for success", 2,
|
||||
events.length);
|
||||
|
||||
// send updated nodes info
|
||||
ArrayList<NodeReport> updatedNodes = new ArrayList<NodeReport>();
|
||||
|
@ -298,8 +297,8 @@ public class TestMRApp {
|
|||
}, checkIntervalMillis, waitForMillis);
|
||||
|
||||
events = job1.getTaskAttemptCompletionEvents(0, 100);
|
||||
Assertions.assertEquals(4, events.length,
|
||||
"Expecting 2 more completion events for killed");
|
||||
Assert.assertEquals("Expecting 2 more completion events for killed", 4,
|
||||
events.length);
|
||||
// 2 map task attempts which were killed above should be requested from
|
||||
// container allocator with the previous map task marked as failed. If
|
||||
// this happens allocator will request the container for this mapper from
|
||||
|
@ -336,8 +335,8 @@ public class TestMRApp {
|
|||
}, checkIntervalMillis, waitForMillis);
|
||||
|
||||
events = job1.getTaskAttemptCompletionEvents(0, 100);
|
||||
Assertions.assertEquals(5, events.length,
|
||||
"Expecting 1 more completion events for success");
|
||||
Assert.assertEquals("Expecting 1 more completion events for success", 5,
|
||||
events.length);
|
||||
|
||||
// Crash the app again.
|
||||
app.stop();
|
||||
|
@ -352,8 +351,7 @@ public class TestMRApp {
|
|||
|
||||
final Job job2 = app.submit(conf);
|
||||
app.waitForState(job2, JobState.RUNNING);
|
||||
Assertions.assertEquals(4, job2.getTasks().size(),
|
||||
"No of tasks not correct");
|
||||
Assert.assertEquals("No of tasks not correct", 4, job2.getTasks().size());
|
||||
it = job2.getTasks().values().iterator();
|
||||
mapTask1 = it.next();
|
||||
mapTask2 = it.next();
|
||||
|
@ -374,8 +372,9 @@ public class TestMRApp {
|
|||
}, checkIntervalMillis, waitForMillis);
|
||||
|
||||
events = job2.getTaskAttemptCompletionEvents(0, 100);
|
||||
Assertions.assertEquals(2, events.length,
|
||||
"Expecting 2 completion events for killed & success of map1");
|
||||
Assert.assertEquals(
|
||||
"Expecting 2 completion events for killed & success of map1", 2,
|
||||
events.length);
|
||||
|
||||
task2Attempt = mapTask2.getAttempts().values().iterator().next();
|
||||
app.getContext()
|
||||
|
@ -395,8 +394,8 @@ public class TestMRApp {
|
|||
}, checkIntervalMillis, waitForMillis);
|
||||
|
||||
events = job2.getTaskAttemptCompletionEvents(0, 100);
|
||||
Assertions.assertEquals(3, events.length,
|
||||
"Expecting 1 more completion events for success");
|
||||
Assert.assertEquals("Expecting 1 more completion events for success", 3,
|
||||
events.length);
|
||||
|
||||
app.waitForState(reduceTask1, TaskState.RUNNING);
|
||||
app.waitForState(reduceTask2, TaskState.RUNNING);
|
||||
|
@ -434,8 +433,8 @@ public class TestMRApp {
|
|||
}
|
||||
}, checkIntervalMillis, waitForMillis);
|
||||
events = job2.getTaskAttemptCompletionEvents(0, 100);
|
||||
Assertions.assertEquals(5, events.length,
|
||||
"Expecting 2 more completion events for reduce success");
|
||||
Assert.assertEquals("Expecting 2 more completion events for reduce success",
|
||||
5, events.length);
|
||||
|
||||
// job succeeds
|
||||
app.waitForState(job2, JobState.SUCCEEDED);
|
||||
|
@ -473,8 +472,7 @@ public class TestMRApp {
|
|||
MRApp app = new MRApp(1, 0, false, this.getClass().getName(), true);
|
||||
Job job = app.submit(new Configuration());
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
Assertions.assertEquals(1, job.getTasks().size(),
|
||||
"Num tasks not correct");
|
||||
Assert.assertEquals("Num tasks not correct", 1, job.getTasks().size());
|
||||
Iterator<Task> it = job.getTasks().values().iterator();
|
||||
Task task = it.next();
|
||||
app.waitForState(task, TaskState.RUNNING);
|
||||
|
@ -495,7 +493,7 @@ public class TestMRApp {
|
|||
JobImpl job = (JobImpl) app.submit(new Configuration());
|
||||
app.waitForInternalState(job, JobStateInternal.SUCCEEDED);
|
||||
// AM is not unregistered
|
||||
Assertions.assertEquals(JobState.RUNNING, job.getState());
|
||||
Assert.assertEquals(JobState.RUNNING, job.getState());
|
||||
// imitate that AM is unregistered
|
||||
app.successfullyUnregistered.set(true);
|
||||
app.waitForState(job, JobState.SUCCEEDED);
|
||||
|
@ -507,8 +505,7 @@ public class TestMRApp {
|
|||
MRApp app = new MRApp(1, 0, false, this.getClass().getName(), true);
|
||||
Job job = app.submit(new Configuration());
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
Assertions.assertEquals(1, job.getTasks().size(),
|
||||
"Num tasks not correct");
|
||||
Assert.assertEquals("Num tasks not correct", 1, job.getTasks().size());
|
||||
Iterator<Task> it = job.getTasks().values().iterator();
|
||||
Task task = it.next();
|
||||
app.waitForState(task, TaskState.RUNNING);
|
||||
|
@ -533,8 +530,7 @@ public class TestMRApp {
|
|||
Configuration conf = new Configuration();
|
||||
Job job = app.submit(conf);
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
Assertions.assertEquals(1, job.getTasks().size(),
|
||||
"Num tasks not correct");
|
||||
Assert.assertEquals("Num tasks not correct", 1, job.getTasks().size());
|
||||
Iterator<Task> it = job.getTasks().values().iterator();
|
||||
Task task = it.next();
|
||||
app.waitForState(task, TaskState.RUNNING);
|
||||
|
@ -628,7 +624,7 @@ public class TestMRApp {
|
|||
(TaskAttemptImpl) taskAttempts.iterator().next();
|
||||
// Container from RM should pass through to the launcher. Container object
|
||||
// should be the same.
|
||||
Assertions.assertTrue(taskAttempt.container
|
||||
Assert.assertTrue(taskAttempt.container
|
||||
== containerObtainedByContainerLauncher);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.hadoop.mapreduce.v2.app;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.Assert;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.mapreduce.jobhistory.JobHistoryEvent;
|
||||
|
@ -35,13 +35,11 @@ import org.apache.hadoop.mapreduce.v2.app.job.impl.JobImpl;
|
|||
import org.apache.hadoop.security.UserGroupInformation;
|
||||
import org.apache.hadoop.yarn.event.EventHandler;
|
||||
import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Timeout;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestMRAppComponentDependencies {
|
||||
|
||||
@Test
|
||||
@Timeout(20000)
|
||||
@Test(timeout = 20000)
|
||||
public void testComponentStopOrder() throws Exception {
|
||||
@SuppressWarnings("resource")
|
||||
TestMRApp app = new TestMRApp(1, 1, true, this.getClass().getName(), true);
|
||||
|
@ -56,8 +54,8 @@ public class TestMRAppComponentDependencies {
|
|||
}
|
||||
|
||||
// assert JobHistoryEventHandlerStopped and then clientServiceStopped
|
||||
Assertions.assertEquals(1, app.JobHistoryEventHandlerStopped);
|
||||
Assertions.assertEquals(2, app.clientServiceStopped);
|
||||
Assert.assertEquals(1, app.JobHistoryEventHandlerStopped);
|
||||
Assert.assertEquals(2, app.clientServiceStopped);
|
||||
}
|
||||
|
||||
private final class TestMRApp extends MRApp {
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
package org.apache.hadoop.mapreduce.v2.app;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
|
@ -40,7 +40,7 @@ import java.util.concurrent.atomic.AtomicLong;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.Assert;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.FileContext;
|
||||
|
@ -84,11 +84,10 @@ import org.apache.hadoop.yarn.api.records.ContainerId;
|
|||
import org.apache.hadoop.yarn.event.EventHandler;
|
||||
import org.apache.hadoop.yarn.security.AMRMTokenIdentifier;
|
||||
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Timeout;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mockito;
|
||||
import org.slf4j.event.Level;
|
||||
|
@ -105,7 +104,7 @@ public class TestMRAppMaster {
|
|||
static String stagingDir = new Path(testDir, "staging").toString();
|
||||
private static FileContext localFS = null;
|
||||
|
||||
@BeforeAll
|
||||
@BeforeClass
|
||||
public static void setup() throws AccessControlException,
|
||||
FileNotFoundException, IllegalArgumentException, IOException {
|
||||
//Do not error out if metrics are inited multiple times
|
||||
|
@ -117,7 +116,7 @@ public class TestMRAppMaster {
|
|||
new File(testDir.toString()).mkdir();
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
@Before
|
||||
public void prepare() throws IOException {
|
||||
File dir = new File(stagingDir);
|
||||
if(dir.exists()) {
|
||||
|
@ -126,7 +125,7 @@ public class TestMRAppMaster {
|
|||
dir.mkdirs();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
@AfterClass
|
||||
public static void cleanup() throws IOException {
|
||||
localFS.delete(testDir, true);
|
||||
}
|
||||
|
@ -227,8 +226,8 @@ public class TestMRAppMaster {
|
|||
"host", -1, -1, System.currentTimeMillis());
|
||||
MRAppMaster.initAndStartAppMaster(appMaster, conf, userName);
|
||||
appMaster.stop();
|
||||
assertTrue(appMaster.jobLaunchTime.get() >= 0,
|
||||
"Job launch time should not be negative.");
|
||||
assertTrue("Job launch time should not be negative.",
|
||||
appMaster.jobLaunchTime.get() >= 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -344,8 +343,7 @@ public class TestMRAppMaster {
|
|||
appMaster.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(30000)
|
||||
@Test (timeout = 30000)
|
||||
public void testMRAppMasterMaxAppAttempts() throws IOException,
|
||||
InterruptedException {
|
||||
// No matter what's the maxAppAttempt or attempt id, the isLastRetry always
|
||||
|
@ -370,8 +368,8 @@ public class TestMRAppMaster {
|
|||
new MRAppMasterTest(applicationAttemptId, containerId, "host", -1, -1,
|
||||
System.currentTimeMillis(), false, true);
|
||||
MRAppMaster.initAndStartAppMaster(appMaster, conf, userName);
|
||||
assertEquals(expectedBools[i], appMaster.isLastAMRetry(),
|
||||
"isLastAMRetry is correctly computed.");
|
||||
assertEquals("isLastAMRetry is correctly computed.", expectedBools[i],
|
||||
appMaster.isLastAMRetry());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -467,37 +465,37 @@ public class TestMRAppMaster {
|
|||
|
||||
// Now validate the task credentials
|
||||
Credentials appMasterCreds = appMaster.getCredentials();
|
||||
Assertions.assertNotNull(appMasterCreds);
|
||||
Assertions.assertEquals(1, appMasterCreds.numberOfSecretKeys());
|
||||
Assertions.assertEquals(1, appMasterCreds.numberOfTokens());
|
||||
Assert.assertNotNull(appMasterCreds);
|
||||
Assert.assertEquals(1, appMasterCreds.numberOfSecretKeys());
|
||||
Assert.assertEquals(1, appMasterCreds.numberOfTokens());
|
||||
|
||||
// Validate the tokens - app token should not be present
|
||||
Token<? extends TokenIdentifier> usedToken =
|
||||
appMasterCreds.getToken(tokenAlias);
|
||||
Assertions.assertNotNull(usedToken);
|
||||
Assertions.assertEquals(storedToken, usedToken);
|
||||
Assert.assertNotNull(usedToken);
|
||||
Assert.assertEquals(storedToken, usedToken);
|
||||
|
||||
// Validate the keys
|
||||
byte[] usedKey = appMasterCreds.getSecretKey(keyAlias);
|
||||
Assertions.assertNotNull(usedKey);
|
||||
Assertions.assertEquals("mySecretKey", new String(usedKey));
|
||||
Assert.assertNotNull(usedKey);
|
||||
Assert.assertEquals("mySecretKey", new String(usedKey));
|
||||
|
||||
// The credentials should also be added to conf so that OuputCommitter can
|
||||
// access it - app token should not be present
|
||||
Credentials confCredentials = conf.getCredentials();
|
||||
Assertions.assertEquals(1, confCredentials.numberOfSecretKeys());
|
||||
Assertions.assertEquals(1, confCredentials.numberOfTokens());
|
||||
Assertions.assertEquals(storedToken, confCredentials.getToken(tokenAlias));
|
||||
Assertions.assertEquals("mySecretKey",
|
||||
Assert.assertEquals(1, confCredentials.numberOfSecretKeys());
|
||||
Assert.assertEquals(1, confCredentials.numberOfTokens());
|
||||
Assert.assertEquals(storedToken, confCredentials.getToken(tokenAlias));
|
||||
Assert.assertEquals("mySecretKey",
|
||||
new String(confCredentials.getSecretKey(keyAlias)));
|
||||
|
||||
// Verify the AM's ugi - app token should be present
|
||||
Credentials ugiCredentials = appMaster.getUgi().getCredentials();
|
||||
Assertions.assertEquals(1, ugiCredentials.numberOfSecretKeys());
|
||||
Assertions.assertEquals(2, ugiCredentials.numberOfTokens());
|
||||
Assertions.assertEquals(storedToken, ugiCredentials.getToken(tokenAlias));
|
||||
Assertions.assertEquals(appToken, ugiCredentials.getToken(appTokenService));
|
||||
Assertions.assertEquals("mySecretKey",
|
||||
Assert.assertEquals(1, ugiCredentials.numberOfSecretKeys());
|
||||
Assert.assertEquals(2, ugiCredentials.numberOfTokens());
|
||||
Assert.assertEquals(storedToken, ugiCredentials.getToken(tokenAlias));
|
||||
Assert.assertEquals(appToken, ugiCredentials.getToken(appTokenService));
|
||||
Assert.assertEquals("mySecretKey",
|
||||
new String(ugiCredentials.getSecretKey(keyAlias)));
|
||||
|
||||
|
||||
|
@ -527,10 +525,10 @@ public class TestMRAppMaster {
|
|||
doNothing().when(appMaster).serviceStop();
|
||||
// Test normal shutdown.
|
||||
appMaster.shutDownJob();
|
||||
Assertions.assertTrue(ExitUtil.terminateCalled(),
|
||||
"Expected shutDownJob to terminate.");
|
||||
Assertions.assertEquals(0, ExitUtil.getFirstExitException().status,
|
||||
"Expected shutDownJob to exit with status code of 0.");
|
||||
Assert.assertTrue("Expected shutDownJob to terminate.",
|
||||
ExitUtil.terminateCalled());
|
||||
Assert.assertEquals("Expected shutDownJob to exit with status code of 0.",
|
||||
0, ExitUtil.getFirstExitException().status);
|
||||
|
||||
// Test shutdown with exception.
|
||||
ExitUtil.resetFirstExitException();
|
||||
|
@ -538,10 +536,10 @@ public class TestMRAppMaster {
|
|||
doThrow(new RuntimeException(msg))
|
||||
.when(appMaster).notifyIsLastAMRetry(anyBoolean());
|
||||
appMaster.shutDownJob();
|
||||
assertTrue(ExitUtil.getFirstExitException().getMessage().contains(msg),
|
||||
"Expected message from ExitUtil.ExitException to be " + msg);
|
||||
Assertions.assertEquals(1, ExitUtil.getFirstExitException().status,
|
||||
"Expected shutDownJob to exit with status code of 1.");
|
||||
assertTrue("Expected message from ExitUtil.ExitException to be " + msg,
|
||||
ExitUtil.getFirstExitException().getMessage().contains(msg));
|
||||
Assert.assertEquals("Expected shutDownJob to exit with status code of 1.",
|
||||
1, ExitUtil.getFirstExitException().status);
|
||||
}
|
||||
|
||||
private void verifyFailedStatus(MRAppMasterTest appMaster,
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
package org.apache.hadoop.mapreduce.v2.app;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
|
@ -26,7 +26,7 @@ import java.util.Iterator;
|
|||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.Assert;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.mapreduce.JobACL;
|
||||
|
@ -70,7 +70,7 @@ import org.apache.hadoop.security.UserGroupInformation;
|
|||
import org.apache.hadoop.yarn.factories.RecordFactory;
|
||||
import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
|
||||
import org.apache.hadoop.yarn.ipc.YarnRPC;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestMRClientService {
|
||||
|
||||
|
@ -82,8 +82,7 @@ public class TestMRClientService {
|
|||
Configuration conf = new Configuration();
|
||||
Job job = app.submit(conf);
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
Assertions.assertEquals(1, job.getTasks().size(),
|
||||
"Num tasks not correct");
|
||||
Assert.assertEquals("Num tasks not correct", 1, job.getTasks().size());
|
||||
Iterator<Task> it = job.getTasks().values().iterator();
|
||||
Task task = it.next();
|
||||
app.waitForState(task, TaskState.RUNNING);
|
||||
|
@ -117,8 +116,8 @@ public class TestMRClientService {
|
|||
GetCountersRequest gcRequest =
|
||||
recordFactory.newRecordInstance(GetCountersRequest.class);
|
||||
gcRequest.setJobId(job.getID());
|
||||
Assertions.assertNotNull(proxy.getCounters(gcRequest).getCounters(),
|
||||
"Counters is null");
|
||||
Assert.assertNotNull("Counters is null",
|
||||
proxy.getCounters(gcRequest).getCounters());
|
||||
|
||||
GetJobReportRequest gjrRequest =
|
||||
recordFactory.newRecordInstance(GetJobReportRequest.class);
|
||||
|
@ -132,14 +131,14 @@ public class TestMRClientService {
|
|||
gtaceRequest.setJobId(job.getID());
|
||||
gtaceRequest.setFromEventId(0);
|
||||
gtaceRequest.setMaxEvents(10);
|
||||
Assertions.assertNotNull(proxy.getTaskAttemptCompletionEvents(gtaceRequest).
|
||||
getCompletionEventList(), "TaskCompletionEvents is null");
|
||||
Assert.assertNotNull("TaskCompletionEvents is null",
|
||||
proxy.getTaskAttemptCompletionEvents(gtaceRequest).getCompletionEventList());
|
||||
|
||||
GetDiagnosticsRequest gdRequest =
|
||||
recordFactory.newRecordInstance(GetDiagnosticsRequest.class);
|
||||
gdRequest.setTaskAttemptId(attempt.getID());
|
||||
Assertions.assertNotNull(proxy.getDiagnostics(gdRequest).
|
||||
getDiagnosticsList(), "Diagnostics is null");
|
||||
Assert.assertNotNull("Diagnostics is null",
|
||||
proxy.getDiagnostics(gdRequest).getDiagnosticsList());
|
||||
|
||||
GetTaskAttemptReportRequest gtarRequest =
|
||||
recordFactory.newRecordInstance(GetTaskAttemptReportRequest.class);
|
||||
|
@ -152,32 +151,31 @@ public class TestMRClientService {
|
|||
GetTaskReportRequest gtrRequest =
|
||||
recordFactory.newRecordInstance(GetTaskReportRequest.class);
|
||||
gtrRequest.setTaskId(task.getID());
|
||||
Assertions.assertNotNull(proxy.getTaskReport(gtrRequest).getTaskReport(),
|
||||
"TaskReport is null");
|
||||
Assert.assertNotNull("TaskReport is null",
|
||||
proxy.getTaskReport(gtrRequest).getTaskReport());
|
||||
|
||||
GetTaskReportsRequest gtreportsRequest =
|
||||
recordFactory.newRecordInstance(GetTaskReportsRequest.class);
|
||||
gtreportsRequest.setJobId(job.getID());
|
||||
gtreportsRequest.setTaskType(TaskType.MAP);
|
||||
Assertions.assertNotNull(proxy.getTaskReports(gtreportsRequest)
|
||||
.getTaskReportList(), "TaskReports for map is null");
|
||||
Assert.assertNotNull("TaskReports for map is null",
|
||||
proxy.getTaskReports(gtreportsRequest).getTaskReportList());
|
||||
|
||||
gtreportsRequest =
|
||||
recordFactory.newRecordInstance(GetTaskReportsRequest.class);
|
||||
gtreportsRequest.setJobId(job.getID());
|
||||
gtreportsRequest.setTaskType(TaskType.REDUCE);
|
||||
Assertions.assertNotNull(proxy.getTaskReports(gtreportsRequest).getTaskReportList(),
|
||||
"TaskReports for reduce is null");
|
||||
Assert.assertNotNull("TaskReports for reduce is null",
|
||||
proxy.getTaskReports(gtreportsRequest).getTaskReportList());
|
||||
|
||||
List<String> diag = proxy.getDiagnostics(gdRequest).getDiagnosticsList();
|
||||
Assertions.assertEquals(1 , diag.size(),
|
||||
"Num diagnostics not correct");
|
||||
Assertions.assertEquals(diagnostic1, diag.get(0).toString(),
|
||||
"Diag 1 not correct");
|
||||
Assert.assertEquals("Num diagnostics not correct", 1 , diag.size());
|
||||
Assert.assertEquals("Diag 1 not correct",
|
||||
diagnostic1, diag.get(0).toString());
|
||||
|
||||
TaskReport taskReport = proxy.getTaskReport(gtrRequest).getTaskReport();
|
||||
Assertions.assertEquals(1, taskReport.getDiagnosticsCount(),
|
||||
"Num diagnostics not correct");
|
||||
Assert.assertEquals("Num diagnostics not correct", 1,
|
||||
taskReport.getDiagnosticsCount());
|
||||
|
||||
//send the done signal to the task
|
||||
app.getContext().getEventHandler().handle(
|
||||
|
@ -209,8 +207,7 @@ public class TestMRClientService {
|
|||
conf.set(MRJobConfig.JOB_ACL_VIEW_JOB, "viewonlyuser");
|
||||
Job job = app.submit(conf);
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
Assertions.assertEquals(1, job.getTasks().size(),
|
||||
"Num tasks not correct");
|
||||
Assert.assertEquals("Num tasks not correct", 1, job.getTasks().size());
|
||||
Iterator<Task> it = job.getTasks().values().iterator();
|
||||
Task task = it.next();
|
||||
app.waitForState(task, TaskState.RUNNING);
|
||||
|
@ -220,10 +217,10 @@ public class TestMRClientService {
|
|||
UserGroupInformation viewOnlyUser =
|
||||
UserGroupInformation.createUserForTesting(
|
||||
"viewonlyuser", new String[] {});
|
||||
Assertions.assertTrue(job.checkAccess(viewOnlyUser, JobACL.VIEW_JOB),
|
||||
"viewonlyuser cannot view job");
|
||||
Assertions.assertFalse(job.checkAccess(viewOnlyUser, JobACL.MODIFY_JOB),
|
||||
"viewonlyuser can modify job");
|
||||
Assert.assertTrue("viewonlyuser cannot view job",
|
||||
job.checkAccess(viewOnlyUser, JobACL.VIEW_JOB));
|
||||
Assert.assertFalse("viewonlyuser can modify job",
|
||||
job.checkAccess(viewOnlyUser, JobACL.MODIFY_JOB));
|
||||
MRClientProtocol client = viewOnlyUser.doAs(
|
||||
new PrivilegedExceptionAction<MRClientProtocol>() {
|
||||
@Override
|
||||
|
@ -276,28 +273,28 @@ public class TestMRClientService {
|
|||
}
|
||||
|
||||
private void verifyJobReport(JobReport jr) {
|
||||
Assertions.assertNotNull(jr, "JobReport is null");
|
||||
Assert.assertNotNull("JobReport is null", jr);
|
||||
List<AMInfo> amInfos = jr.getAMInfos();
|
||||
Assertions.assertEquals(1, amInfos.size());
|
||||
Assertions.assertEquals(JobState.RUNNING, jr.getJobState());
|
||||
Assert.assertEquals(1, amInfos.size());
|
||||
Assert.assertEquals(JobState.RUNNING, jr.getJobState());
|
||||
AMInfo amInfo = amInfos.get(0);
|
||||
Assertions.assertEquals(MRApp.NM_HOST, amInfo.getNodeManagerHost());
|
||||
Assertions.assertEquals(MRApp.NM_PORT, amInfo.getNodeManagerPort());
|
||||
Assertions.assertEquals(MRApp.NM_HTTP_PORT, amInfo.getNodeManagerHttpPort());
|
||||
Assertions.assertEquals(1, amInfo.getAppAttemptId().getAttemptId());
|
||||
Assertions.assertEquals(1, amInfo.getContainerId().getApplicationAttemptId()
|
||||
Assert.assertEquals(MRApp.NM_HOST, amInfo.getNodeManagerHost());
|
||||
Assert.assertEquals(MRApp.NM_PORT, amInfo.getNodeManagerPort());
|
||||
Assert.assertEquals(MRApp.NM_HTTP_PORT, amInfo.getNodeManagerHttpPort());
|
||||
Assert.assertEquals(1, amInfo.getAppAttemptId().getAttemptId());
|
||||
Assert.assertEquals(1, amInfo.getContainerId().getApplicationAttemptId()
|
||||
.getAttemptId());
|
||||
Assertions.assertTrue(amInfo.getStartTime() > 0);
|
||||
Assertions.assertFalse(jr.isUber());
|
||||
Assert.assertTrue(amInfo.getStartTime() > 0);
|
||||
Assert.assertFalse(jr.isUber());
|
||||
}
|
||||
|
||||
private void verifyTaskAttemptReport(TaskAttemptReport tar) {
|
||||
Assertions.assertEquals(TaskAttemptState.RUNNING, tar.getTaskAttemptState());
|
||||
Assertions.assertNotNull(tar, "TaskAttemptReport is null");
|
||||
Assertions.assertEquals(MRApp.NM_HOST, tar.getNodeManagerHost());
|
||||
Assertions.assertEquals(MRApp.NM_PORT, tar.getNodeManagerPort());
|
||||
Assertions.assertEquals(MRApp.NM_HTTP_PORT, tar.getNodeManagerHttpPort());
|
||||
Assertions.assertEquals(1, tar.getContainerId().getApplicationAttemptId()
|
||||
Assert.assertEquals(TaskAttemptState.RUNNING, tar.getTaskAttemptState());
|
||||
Assert.assertNotNull("TaskAttemptReport is null", tar);
|
||||
Assert.assertEquals(MRApp.NM_HOST, tar.getNodeManagerHost());
|
||||
Assert.assertEquals(MRApp.NM_PORT, tar.getNodeManagerPort());
|
||||
Assert.assertEquals(MRApp.NM_HTTP_PORT, tar.getNodeManagerHttpPort());
|
||||
Assert.assertEquals(1, tar.getContainerId().getApplicationAttemptId()
|
||||
.getAttemptId());
|
||||
}
|
||||
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
package org.apache.hadoop.mapreduce.v2.app;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.atLeast;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
|
@ -42,7 +42,7 @@ import java.util.concurrent.TimeoutException;
|
|||
|
||||
import org.apache.hadoop.mapreduce.util.MRJobConfUtil;
|
||||
import org.apache.hadoop.mapreduce.v2.app.job.event.TaskAttemptFailEvent;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.Assert;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.Path;
|
||||
|
@ -107,9 +107,8 @@ import org.apache.hadoop.test.GenericTestUtils;
|
|||
import org.apache.hadoop.yarn.util.Clock;
|
||||
import org.apache.hadoop.yarn.util.SystemClock;
|
||||
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Timeout;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -127,7 +126,7 @@ public class TestRecovery {
|
|||
private Text val1 = new Text("val1");
|
||||
private Text val2 = new Text("val2");
|
||||
|
||||
@BeforeAll
|
||||
@BeforeClass
|
||||
public static void setupClass() throws Exception {
|
||||
// setup the test root directory
|
||||
testRootDir =
|
||||
|
@ -159,8 +158,8 @@ public class TestRecovery {
|
|||
app.waitForState(job, JobState.RUNNING);
|
||||
long jobStartTime = job.getReport().getStartTime();
|
||||
//all maps would be running
|
||||
Assertions.assertEquals(3, job.getTasks().size(),
|
||||
"No of tasks not correct");
|
||||
Assert.assertEquals("No of tasks not correct",
|
||||
3, job.getTasks().size());
|
||||
Iterator<Task> it = job.getTasks().values().iterator();
|
||||
Task mapTask1 = it.next();
|
||||
Task mapTask2 = it.next();
|
||||
|
@ -193,7 +192,7 @@ public class TestRecovery {
|
|||
Thread.sleep(2000);
|
||||
LOG.info("Waiting for next attempt to start");
|
||||
}
|
||||
Assertions.assertEquals(2, mapTask1.getAttempts().size());
|
||||
Assert.assertEquals(2, mapTask1.getAttempts().size());
|
||||
Iterator<TaskAttempt> itr = mapTask1.getAttempts().values().iterator();
|
||||
itr.next();
|
||||
TaskAttempt task1Attempt2 = itr.next();
|
||||
|
@ -214,7 +213,7 @@ public class TestRecovery {
|
|||
Thread.sleep(2000);
|
||||
LOG.info("Waiting for next attempt to start");
|
||||
}
|
||||
Assertions.assertEquals(3, mapTask1.getAttempts().size());
|
||||
Assert.assertEquals(3, mapTask1.getAttempts().size());
|
||||
itr = mapTask1.getAttempts().values().iterator();
|
||||
itr.next();
|
||||
itr.next();
|
||||
|
@ -235,7 +234,7 @@ public class TestRecovery {
|
|||
Thread.sleep(2000);
|
||||
LOG.info("Waiting for next attempt to start");
|
||||
}
|
||||
Assertions.assertEquals(4, mapTask1.getAttempts().size());
|
||||
Assert.assertEquals(4, mapTask1.getAttempts().size());
|
||||
itr = mapTask1.getAttempts().values().iterator();
|
||||
itr.next();
|
||||
itr.next();
|
||||
|
@ -273,8 +272,8 @@ public class TestRecovery {
|
|||
job = app.submit(conf);
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
//all maps would be running
|
||||
Assertions.assertEquals(3, job.getTasks().size(),
|
||||
"No of tasks not correct");
|
||||
Assert.assertEquals("No of tasks not correct",
|
||||
3, job.getTasks().size());
|
||||
it = job.getTasks().values().iterator();
|
||||
mapTask1 = it.next();
|
||||
mapTask2 = it.next();
|
||||
|
@ -309,29 +308,29 @@ public class TestRecovery {
|
|||
|
||||
app.waitForState(job, JobState.SUCCEEDED);
|
||||
app.verifyCompleted();
|
||||
Assertions.assertEquals(jobStartTime, job.getReport().getStartTime(),
|
||||
"Job Start time not correct");
|
||||
Assertions.assertEquals(task1StartTime, mapTask1.getReport().getStartTime(),
|
||||
"Task Start time not correct");
|
||||
Assertions.assertEquals(task1FinishTime, mapTask1.getReport().getFinishTime(),
|
||||
"Task Finish time not correct");
|
||||
Assertions.assertEquals(2, job.getAMInfos().size());
|
||||
Assert.assertEquals("Job Start time not correct",
|
||||
jobStartTime, job.getReport().getStartTime());
|
||||
Assert.assertEquals("Task Start time not correct",
|
||||
task1StartTime, mapTask1.getReport().getStartTime());
|
||||
Assert.assertEquals("Task Finish time not correct",
|
||||
task1FinishTime, mapTask1.getReport().getFinishTime());
|
||||
Assert.assertEquals(2, job.getAMInfos().size());
|
||||
int attemptNum = 1;
|
||||
// Verify AMInfo
|
||||
for (AMInfo amInfo : job.getAMInfos()) {
|
||||
Assertions.assertEquals(attemptNum++, amInfo.getAppAttemptId()
|
||||
Assert.assertEquals(attemptNum++, amInfo.getAppAttemptId()
|
||||
.getAttemptId());
|
||||
Assertions.assertEquals(amInfo.getAppAttemptId(), amInfo.getContainerId()
|
||||
Assert.assertEquals(amInfo.getAppAttemptId(), amInfo.getContainerId()
|
||||
.getApplicationAttemptId());
|
||||
Assertions.assertEquals(MRApp.NM_HOST, amInfo.getNodeManagerHost());
|
||||
Assertions.assertEquals(MRApp.NM_PORT, amInfo.getNodeManagerPort());
|
||||
Assertions.assertEquals(MRApp.NM_HTTP_PORT, amInfo.getNodeManagerHttpPort());
|
||||
Assert.assertEquals(MRApp.NM_HOST, amInfo.getNodeManagerHost());
|
||||
Assert.assertEquals(MRApp.NM_PORT, amInfo.getNodeManagerPort());
|
||||
Assert.assertEquals(MRApp.NM_HTTP_PORT, amInfo.getNodeManagerHttpPort());
|
||||
}
|
||||
long am1StartTimeReal = job.getAMInfos().get(0).getStartTime();
|
||||
long am2StartTimeReal = job.getAMInfos().get(1).getStartTime();
|
||||
Assertions.assertTrue(am1StartTimeReal >= am1StartTimeEst
|
||||
Assert.assertTrue(am1StartTimeReal >= am1StartTimeEst
|
||||
&& am1StartTimeReal <= am2StartTimeEst);
|
||||
Assertions.assertTrue(am2StartTimeReal >= am2StartTimeEst
|
||||
Assert.assertTrue(am2StartTimeReal >= am2StartTimeEst
|
||||
&& am2StartTimeReal <= System.currentTimeMillis());
|
||||
// TODO Add verification of additional data from jobHistory - whatever was
|
||||
// available in the failed attempt should be available here
|
||||
|
@ -372,7 +371,7 @@ public class TestRecovery {
|
|||
app.waitForState(job, JobState.RUNNING);
|
||||
|
||||
// all maps would be running
|
||||
Assertions.assertEquals(3, job.getTasks().size(), "No of tasks not correct");
|
||||
Assert.assertEquals("No of tasks not correct", 3, job.getTasks().size());
|
||||
Iterator<Task> it = job.getTasks().values().iterator();
|
||||
Task mapTask1 = it.next();
|
||||
Task mapTask2 = it.next();
|
||||
|
@ -430,7 +429,7 @@ public class TestRecovery {
|
|||
job = app.submit(conf);
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
|
||||
Assertions.assertEquals(3, job.getTasks().size(), "No of tasks not correct");
|
||||
Assert.assertEquals("No of tasks not correct", 3, job.getTasks().size());
|
||||
it = job.getTasks().values().iterator();
|
||||
mapTask1 = it.next();
|
||||
mapTask2 = it.next();
|
||||
|
@ -517,7 +516,7 @@ public class TestRecovery {
|
|||
app.waitForState(job, JobState.RUNNING);
|
||||
|
||||
// all maps would be running
|
||||
Assertions.assertEquals(3, job.getTasks().size(), "No of tasks not correct");
|
||||
Assert.assertEquals("No of tasks not correct", 3, job.getTasks().size());
|
||||
Iterator<Task> it = job.getTasks().values().iterator();
|
||||
Task mapTask1 = it.next();
|
||||
Task mapTask2 = it.next();
|
||||
|
@ -576,7 +575,7 @@ public class TestRecovery {
|
|||
job = app.submit(conf);
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
|
||||
Assertions.assertEquals(3, job.getTasks().size(), "No of tasks not correct");
|
||||
Assert.assertEquals("No of tasks not correct", 3, job.getTasks().size());
|
||||
it = job.getTasks().values().iterator();
|
||||
mapTask1 = it.next();
|
||||
mapTask2 = it.next();
|
||||
|
@ -642,9 +641,8 @@ public class TestRecovery {
|
|||
app = new MRAppWithHistory(1, 1, false, this.getClass().getName(), false,
|
||||
++runCount);
|
||||
Job jobAttempt2 = app.submit(conf);
|
||||
Assertions.assertTrue(!app.recovered(),
|
||||
"Recovery from previous job attempt is processed even " +
|
||||
"though intermediate data encryption is enabled.");
|
||||
Assert.assertTrue("Recovery from previous job attempt is processed even " +
|
||||
"though intermediate data encryption is enabled.", !app.recovered());
|
||||
|
||||
// The map task succeeded from previous job attempt will not be recovered
|
||||
// because the data spill encryption is enabled.
|
||||
|
@ -696,7 +694,7 @@ public class TestRecovery {
|
|||
app.waitForState(job, JobState.RUNNING);
|
||||
|
||||
// all maps would be running
|
||||
Assertions.assertEquals(3, job.getTasks().size(), "No of tasks not correct");
|
||||
Assert.assertEquals("No of tasks not correct", 3, job.getTasks().size());
|
||||
Iterator<Task> it = job.getTasks().values().iterator();
|
||||
Task mapTask1 = it.next();
|
||||
Task mapTask2 = it.next();
|
||||
|
@ -755,7 +753,7 @@ public class TestRecovery {
|
|||
job = app.submit(conf);
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
|
||||
Assertions.assertEquals(3, job.getTasks().size(), "No of tasks not correct");
|
||||
Assert.assertEquals("No of tasks not correct", 3, job.getTasks().size());
|
||||
it = job.getTasks().values().iterator();
|
||||
mapTask1 = it.next();
|
||||
mapTask2 = it.next();
|
||||
|
@ -815,8 +813,8 @@ public class TestRecovery {
|
|||
Job job = app.submit(conf);
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
//all maps would be running
|
||||
Assertions.assertEquals(3, job.getTasks().size(),
|
||||
"No of tasks not correct");
|
||||
Assert.assertEquals("No of tasks not correct",
|
||||
3, job.getTasks().size());
|
||||
Iterator<Task> it = job.getTasks().values().iterator();
|
||||
Task mapTask1 = it.next();
|
||||
Task mapTask2 = it.next();
|
||||
|
@ -835,8 +833,8 @@ public class TestRecovery {
|
|||
app.waitForState(task2Attempt, TaskAttemptState.RUNNING);
|
||||
|
||||
// reduces must be in NEW state
|
||||
Assertions.assertEquals(TaskState.RUNNING, reduceTask.getReport().getTaskState(),
|
||||
"Reduce Task state not correct");
|
||||
Assert.assertEquals("Reduce Task state not correct",
|
||||
TaskState.RUNNING, reduceTask.getReport().getTaskState());
|
||||
|
||||
//send the done signal to the 1st map
|
||||
app.getContext().getEventHandler().handle(
|
||||
|
@ -864,8 +862,8 @@ public class TestRecovery {
|
|||
job = app.submit(conf);
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
//all maps would be running
|
||||
Assertions.assertEquals(3, job.getTasks().size(),
|
||||
"No of tasks not correct");
|
||||
Assert.assertEquals("No of tasks not correct",
|
||||
3, job.getTasks().size());
|
||||
it = job.getTasks().values().iterator();
|
||||
mapTask1 = it.next();
|
||||
mapTask2 = it.next();
|
||||
|
@ -907,8 +905,8 @@ public class TestRecovery {
|
|||
job = app.submit(conf);
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
//all maps would be running
|
||||
Assertions.assertEquals(3, job.getTasks().size(),
|
||||
"No of tasks not correct");
|
||||
Assert.assertEquals("No of tasks not correct",
|
||||
3, job.getTasks().size());
|
||||
it = job.getTasks().values().iterator();
|
||||
mapTask1 = it.next();
|
||||
mapTask2 = it.next();
|
||||
|
@ -942,8 +940,8 @@ public class TestRecovery {
|
|||
conf.set(FileOutputFormat.OUTDIR, outputDir.toString());
|
||||
Job job = app.submit(conf);
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
Assertions.assertEquals(3, job.getTasks().size(),
|
||||
"No of tasks not correct");
|
||||
Assert.assertEquals("No of tasks not correct",
|
||||
3, job.getTasks().size());
|
||||
Iterator<Task> it = job.getTasks().values().iterator();
|
||||
Task mapTask1 = it.next();
|
||||
Task reduceTask1 = it.next();
|
||||
|
@ -968,7 +966,7 @@ public class TestRecovery {
|
|||
app.waitForState(mapTask1, TaskState.SUCCEEDED);
|
||||
|
||||
// Verify the shuffle-port
|
||||
Assertions.assertEquals(5467, task1Attempt1.getShufflePort());
|
||||
Assert.assertEquals(5467, task1Attempt1.getShufflePort());
|
||||
|
||||
app.waitForState(reduceTask1, TaskState.RUNNING);
|
||||
TaskAttempt reduce1Attempt1 = reduceTask1.getAttempts().values().iterator().next();
|
||||
|
@ -1000,8 +998,8 @@ public class TestRecovery {
|
|||
conf.setBoolean(MRJobConfig.JOB_UBERTASK_ENABLE, false);
|
||||
job = app.submit(conf);
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
Assertions.assertEquals(3, job.getTasks().size(),
|
||||
"No of tasks not correct");
|
||||
Assert.assertEquals("No of tasks not correct",
|
||||
3, job.getTasks().size());
|
||||
it = job.getTasks().values().iterator();
|
||||
mapTask1 = it.next();
|
||||
reduceTask1 = it.next();
|
||||
|
@ -1012,7 +1010,7 @@ public class TestRecovery {
|
|||
|
||||
// Verify the shuffle-port after recovery
|
||||
task1Attempt1 = mapTask1.getAttempts().values().iterator().next();
|
||||
Assertions.assertEquals(5467, task1Attempt1.getShufflePort());
|
||||
Assert.assertEquals(5467, task1Attempt1.getShufflePort());
|
||||
|
||||
// first reduce will be recovered, no need to send done
|
||||
app.waitForState(reduceTask1, TaskState.SUCCEEDED);
|
||||
|
@ -1053,7 +1051,7 @@ public class TestRecovery {
|
|||
conf.set(FileOutputFormat.OUTDIR, outputDir.toString());
|
||||
Job job = app.submit(conf);
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
Assertions.assertEquals(3, job.getTasks().size(), "No of tasks not correct");
|
||||
Assert.assertEquals("No of tasks not correct", 3, job.getTasks().size());
|
||||
//stop the app before the job completes.
|
||||
app.stop();
|
||||
app.close();
|
||||
|
@ -1063,11 +1061,11 @@ public class TestRecovery {
|
|||
++runCount);
|
||||
job = app.submit(conf);
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
Assertions.assertEquals(3, job.getTasks().size(), "No of tasks not correct");
|
||||
Assert.assertEquals("No of tasks not correct", 3, job.getTasks().size());
|
||||
TestFileOutputCommitter committer = (
|
||||
TestFileOutputCommitter) app.getCommitter();
|
||||
assertTrue(committer.isAbortJobCalled(),
|
||||
"commiter.abortJob() has not been called");
|
||||
assertTrue("commiter.abortJob() has not been called",
|
||||
committer.isAbortJobCalled());
|
||||
app.close();
|
||||
}
|
||||
|
||||
|
@ -1088,8 +1086,7 @@ public class TestRecovery {
|
|||
conf.set(FileOutputFormat.OUTDIR, outputDir.toString());
|
||||
Job job = app.submit(conf);
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
Assertions.assertEquals(3, job.getTasks().size(),
|
||||
"No of tasks not correct");
|
||||
Assert.assertEquals("No of tasks not correct", 3, job.getTasks().size());
|
||||
//stop the app before the job completes.
|
||||
app.stop();
|
||||
app.close();
|
||||
|
@ -1099,12 +1096,11 @@ public class TestRecovery {
|
|||
++runCount);
|
||||
job = app.submit(conf);
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
Assertions.assertEquals(3, job.getTasks().size(),
|
||||
"No of tasks not correct");
|
||||
Assert.assertEquals("No of tasks not correct", 3, job.getTasks().size());
|
||||
TestFileOutputCommitter committer = (
|
||||
TestFileOutputCommitter) app.getCommitter();
|
||||
assertFalse(committer.isAbortJobCalled(),
|
||||
"commiter.abortJob() has been called");
|
||||
assertFalse("commiter.abortJob() has been called",
|
||||
committer.isAbortJobCalled());
|
||||
app.close();
|
||||
}
|
||||
|
||||
|
@ -1120,8 +1116,8 @@ public class TestRecovery {
|
|||
conf.set(FileOutputFormat.OUTDIR, outputDir.toString());
|
||||
Job job = app.submit(conf);
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
Assertions.assertEquals(3, job.getTasks().size(),
|
||||
"No of tasks not correct");
|
||||
Assert.assertEquals("No of tasks not correct",
|
||||
3, job.getTasks().size());
|
||||
Iterator<Task> it = job.getTasks().values().iterator();
|
||||
Task mapTask1 = it.next();
|
||||
Task mapTask2 = it.next();
|
||||
|
@ -1151,7 +1147,7 @@ public class TestRecovery {
|
|||
app.waitForState(mapTask1, TaskState.SUCCEEDED);
|
||||
|
||||
// Verify the shuffle-port
|
||||
Assertions.assertEquals(5467, task1Attempt1.getShufflePort());
|
||||
Assert.assertEquals(5467, task1Attempt1.getShufflePort());
|
||||
|
||||
//stop the app before the job completes.
|
||||
app.stop();
|
||||
|
@ -1168,8 +1164,8 @@ public class TestRecovery {
|
|||
conf.setBoolean(MRJobConfig.JOB_UBERTASK_ENABLE, false);
|
||||
job = app.submit(conf);
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
Assertions.assertEquals(3, job.getTasks().size(),
|
||||
"No of tasks not correct");
|
||||
Assert.assertEquals("No of tasks not correct",
|
||||
3, job.getTasks().size());
|
||||
it = job.getTasks().values().iterator();
|
||||
mapTask1 = it.next();
|
||||
mapTask2 = it.next();
|
||||
|
@ -1180,7 +1176,7 @@ public class TestRecovery {
|
|||
|
||||
// Verify the shuffle-port after recovery
|
||||
task1Attempt1 = mapTask1.getAttempts().values().iterator().next();
|
||||
Assertions.assertEquals(5467, task1Attempt1.getShufflePort());
|
||||
Assert.assertEquals(5467, task1Attempt1.getShufflePort());
|
||||
|
||||
app.waitForState(mapTask2, TaskState.RUNNING);
|
||||
|
||||
|
@ -1201,7 +1197,7 @@ public class TestRecovery {
|
|||
app.waitForState(mapTask2, TaskState.SUCCEEDED);
|
||||
|
||||
// Verify the shuffle-port
|
||||
Assertions.assertEquals(5467, task2Attempt1.getShufflePort());
|
||||
Assert.assertEquals(5467, task2Attempt1.getShufflePort());
|
||||
|
||||
app.waitForState(reduceTask1, TaskState.RUNNING);
|
||||
TaskAttempt reduce1Attempt1 = reduceTask1.getAttempts().values().iterator().next();
|
||||
|
@ -1235,8 +1231,8 @@ public class TestRecovery {
|
|||
conf.set(FileOutputFormat.OUTDIR, outputDir.toString());
|
||||
Job job = app.submit(conf);
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
Assertions.assertEquals(3, job.getTasks().size(),
|
||||
"No of tasks not correct");
|
||||
Assert.assertEquals("No of tasks not correct",
|
||||
3, job.getTasks().size());
|
||||
Iterator<Task> it = job.getTasks().values().iterator();
|
||||
Task mapTask1 = it.next();
|
||||
Task reduceTask1 = it.next();
|
||||
|
@ -1261,7 +1257,7 @@ public class TestRecovery {
|
|||
app.waitForState(mapTask1, TaskState.SUCCEEDED);
|
||||
|
||||
// Verify the shuffle-port
|
||||
Assertions.assertEquals(5467, task1Attempt1.getShufflePort());
|
||||
Assert.assertEquals(5467, task1Attempt1.getShufflePort());
|
||||
|
||||
app.waitForState(reduceTask1, TaskState.RUNNING);
|
||||
TaskAttempt reduce1Attempt1 = reduceTask1.getAttempts().values().iterator().next();
|
||||
|
@ -1293,8 +1289,8 @@ public class TestRecovery {
|
|||
conf.setBoolean(MRJobConfig.JOB_UBERTASK_ENABLE, false);
|
||||
job = app.submit(conf);
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
Assertions.assertEquals(3, job.getTasks().size(),
|
||||
"No of tasks not correct");
|
||||
Assert.assertEquals("No of tasks not correct",
|
||||
3, job.getTasks().size());
|
||||
it = job.getTasks().values().iterator();
|
||||
mapTask1 = it.next();
|
||||
reduceTask1 = it.next();
|
||||
|
@ -1305,7 +1301,7 @@ public class TestRecovery {
|
|||
|
||||
// Verify the shuffle-port after recovery
|
||||
task1Attempt1 = mapTask1.getAttempts().values().iterator().next();
|
||||
Assertions.assertEquals(5467, task1Attempt1.getShufflePort());
|
||||
Assert.assertEquals(5467, task1Attempt1.getShufflePort());
|
||||
|
||||
// first reduce will be recovered, no need to send done
|
||||
app.waitForState(reduceTask1, TaskState.SUCCEEDED);
|
||||
|
@ -1355,8 +1351,8 @@ public class TestRecovery {
|
|||
app.waitForState(job, JobState.RUNNING);
|
||||
long jobStartTime = job.getReport().getStartTime();
|
||||
//all maps would be running
|
||||
Assertions.assertEquals(3, job.getTasks().size(),
|
||||
"No of tasks not correct");
|
||||
Assert.assertEquals("No of tasks not correct",
|
||||
3, job.getTasks().size());
|
||||
|
||||
Iterator<Task> it = job.getTasks().values().iterator();
|
||||
Task mapTask1 = it.next();
|
||||
|
@ -1429,8 +1425,8 @@ public class TestRecovery {
|
|||
job = app.submit(conf);
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
//all maps would be running
|
||||
Assertions.assertEquals(3, job.getTasks().size(),
|
||||
"No of tasks not correct");
|
||||
Assert.assertEquals("No of tasks not correct",
|
||||
3, job.getTasks().size());
|
||||
it = job.getTasks().values().iterator();
|
||||
mapTask1 = it.next();
|
||||
mapTask2 = it.next();
|
||||
|
@ -1466,36 +1462,36 @@ public class TestRecovery {
|
|||
|
||||
app.waitForState(job, JobState.SUCCEEDED);
|
||||
app.verifyCompleted();
|
||||
Assertions.assertEquals(jobStartTime, job.getReport().getStartTime(),
|
||||
"Job Start time not correct");
|
||||
Assertions.assertEquals(task1StartTime, mapTask1.getReport().getStartTime(),
|
||||
"Task Start time not correct");
|
||||
Assertions.assertEquals(task1FinishTime, mapTask1.getReport().getFinishTime(),
|
||||
"Task Finish time not correct");
|
||||
Assertions.assertEquals(2, job.getAMInfos().size());
|
||||
Assert.assertEquals("Job Start time not correct",
|
||||
jobStartTime, job.getReport().getStartTime());
|
||||
Assert.assertEquals("Task Start time not correct",
|
||||
task1StartTime, mapTask1.getReport().getStartTime());
|
||||
Assert.assertEquals("Task Finish time not correct",
|
||||
task1FinishTime, mapTask1.getReport().getFinishTime());
|
||||
Assert.assertEquals(2, job.getAMInfos().size());
|
||||
int attemptNum = 1;
|
||||
// Verify AMInfo
|
||||
for (AMInfo amInfo : job.getAMInfos()) {
|
||||
Assertions.assertEquals(attemptNum++, amInfo.getAppAttemptId()
|
||||
Assert.assertEquals(attemptNum++, amInfo.getAppAttemptId()
|
||||
.getAttemptId());
|
||||
Assertions.assertEquals(amInfo.getAppAttemptId(), amInfo.getContainerId()
|
||||
Assert.assertEquals(amInfo.getAppAttemptId(), amInfo.getContainerId()
|
||||
.getApplicationAttemptId());
|
||||
Assertions.assertEquals(MRApp.NM_HOST, amInfo.getNodeManagerHost());
|
||||
Assertions.assertEquals(MRApp.NM_PORT, amInfo.getNodeManagerPort());
|
||||
Assertions.assertEquals(MRApp.NM_HTTP_PORT, amInfo.getNodeManagerHttpPort());
|
||||
Assert.assertEquals(MRApp.NM_HOST, amInfo.getNodeManagerHost());
|
||||
Assert.assertEquals(MRApp.NM_PORT, amInfo.getNodeManagerPort());
|
||||
Assert.assertEquals(MRApp.NM_HTTP_PORT, amInfo.getNodeManagerHttpPort());
|
||||
}
|
||||
long am1StartTimeReal = job.getAMInfos().get(0).getStartTime();
|
||||
long am2StartTimeReal = job.getAMInfos().get(1).getStartTime();
|
||||
Assertions.assertTrue(am1StartTimeReal >= am1StartTimeEst
|
||||
Assert.assertTrue(am1StartTimeReal >= am1StartTimeEst
|
||||
&& am1StartTimeReal <= am2StartTimeEst);
|
||||
Assertions.assertTrue(am2StartTimeReal >= am2StartTimeEst
|
||||
Assert.assertTrue(am2StartTimeReal >= am2StartTimeEst
|
||||
&& am2StartTimeReal <= System.currentTimeMillis());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(30000)
|
||||
@Test(timeout=30000)
|
||||
public void testRecoveryWithoutShuffleSecret() throws Exception {
|
||||
|
||||
int runCount = 0;
|
||||
MRApp app = new MRAppNoShuffleSecret(2, 1, false,
|
||||
this.getClass().getName(), true, ++runCount);
|
||||
|
@ -1507,8 +1503,8 @@ public class TestRecovery {
|
|||
Job job = app.submit(conf);
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
//all maps would be running
|
||||
Assertions.assertEquals(3, job.getTasks().size(),
|
||||
"No of tasks not correct");
|
||||
Assert.assertEquals("No of tasks not correct",
|
||||
3, job.getTasks().size());
|
||||
Iterator<Task> it = job.getTasks().values().iterator();
|
||||
Task mapTask1 = it.next();
|
||||
Task mapTask2 = it.next();
|
||||
|
@ -1554,8 +1550,8 @@ public class TestRecovery {
|
|||
job = app.submit(conf);
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
//all maps would be running
|
||||
Assertions.assertEquals(3, job.getTasks().size(),
|
||||
"No of tasks not correct");
|
||||
Assert.assertEquals("No of tasks not correct",
|
||||
3, job.getTasks().size());
|
||||
it = job.getTasks().values().iterator();
|
||||
mapTask1 = it.next();
|
||||
mapTask2 = it.next();
|
||||
|
@ -1894,16 +1890,16 @@ public class TestRecovery {
|
|||
ArgumentCaptor<Event> arg, List<EventType> expectedJobHistoryEvents,
|
||||
long expectedMapLaunches, long expectedFailedMaps) {
|
||||
|
||||
assertEquals(finalState, checkTask.getState(), "Final State of Task");
|
||||
assertEquals("Final State of Task", finalState, checkTask.getState());
|
||||
|
||||
Map<TaskAttemptId, TaskAttempt> recoveredAttempts =
|
||||
checkTask.getAttempts();
|
||||
assertEquals(finalAttemptStates.size(), recoveredAttempts.size(),
|
||||
"Expected Number of Task Attempts");
|
||||
assertEquals("Expected Number of Task Attempts",
|
||||
finalAttemptStates.size(), recoveredAttempts.size());
|
||||
for (TaskAttemptID taID : finalAttemptStates.keySet()) {
|
||||
assertEquals(finalAttemptStates.get(taID),
|
||||
recoveredAttempts.get(TypeConverter.toYarn(taID)).getState(),
|
||||
"Expected Task Attempt State");
|
||||
assertEquals("Expected Task Attempt State",
|
||||
finalAttemptStates.get(taID),
|
||||
recoveredAttempts.get(TypeConverter.toYarn(taID)).getState());
|
||||
}
|
||||
|
||||
Iterator<Event> ie = arg.getAllValues().iterator();
|
||||
|
@ -1951,12 +1947,12 @@ public class TestRecovery {
|
|||
}
|
||||
}
|
||||
assertTrue(jobTaskEventReceived || (finalState == TaskState.RUNNING));
|
||||
assertEquals(0, expectedJobHistoryEvents.size(),
|
||||
"Did not process all expected JobHistoryEvents");
|
||||
assertEquals(expectedMapLaunches, totalLaunchedMaps,
|
||||
"Expected Map Launches");
|
||||
assertEquals(expectedFailedMaps, totalFailedMaps,
|
||||
"Expected Failed Maps");
|
||||
assertEquals("Did not process all expected JobHistoryEvents",
|
||||
0, expectedJobHistoryEvents.size());
|
||||
assertEquals("Expected Map Launches",
|
||||
expectedMapLaunches, totalLaunchedMaps);
|
||||
assertEquals("Expected Failed Maps",
|
||||
expectedFailedMaps, totalFailedMaps);
|
||||
}
|
||||
|
||||
private MapTaskImpl getMockMapTask(long clusterTimestamp, EventHandler eh) {
|
||||
|
|
|
@ -78,8 +78,8 @@ import org.apache.hadoop.yarn.security.client.ClientToAMTokenSecretManager;
|
|||
import org.apache.hadoop.yarn.util.Clock;
|
||||
import org.apache.hadoop.yarn.util.ControlledClock;
|
||||
import org.apache.hadoop.yarn.util.SystemClock;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -152,16 +152,16 @@ public class TestRuntimeEstimators {
|
|||
conf.setDouble(MRJobConfig.SPECULATIVECAP_TOTAL_TASKS, 0.001);
|
||||
conf.setInt(MRJobConfig.SPECULATIVE_MINIMUM_ALLOWED_TASKS, 5);
|
||||
speculator = new DefaultSpeculator(conf, myAppContext, estimator, clock);
|
||||
Assertions.assertEquals(500L, speculator.getSoonestRetryAfterNoSpeculate(),
|
||||
"wrong SPECULATIVE_RETRY_AFTER_NO_SPECULATE value");
|
||||
Assertions.assertEquals(5000L, speculator.getSoonestRetryAfterSpeculate(),
|
||||
"wrong SPECULATIVE_RETRY_AFTER_SPECULATE value");
|
||||
Assert.assertEquals("wrong SPECULATIVE_RETRY_AFTER_NO_SPECULATE value",
|
||||
500L, speculator.getSoonestRetryAfterNoSpeculate());
|
||||
Assert.assertEquals("wrong SPECULATIVE_RETRY_AFTER_SPECULATE value",
|
||||
5000L, speculator.getSoonestRetryAfterSpeculate());
|
||||
assertThat(speculator.getProportionRunningTasksSpeculatable())
|
||||
.isCloseTo(0.1, offset(0.00001));
|
||||
assertThat(speculator.getProportionTotalTasksSpeculatable())
|
||||
.isCloseTo(0.001, offset(0.00001));
|
||||
Assertions.assertEquals(5, speculator.getMinimumAllowedSpeculativeTasks(),
|
||||
"wrong SPECULATIVE_MINIMUM_ALLOWED_TASKS value");
|
||||
Assert.assertEquals("wrong SPECULATIVE_MINIMUM_ALLOWED_TASKS value",
|
||||
5, speculator.getMinimumAllowedSpeculativeTasks());
|
||||
|
||||
dispatcher.register(Speculator.EventType.class, speculator);
|
||||
|
||||
|
@ -244,8 +244,8 @@ public class TestRuntimeEstimators {
|
|||
}
|
||||
}
|
||||
|
||||
Assertions.assertEquals(expectedSpeculations, successfulSpeculations.get(),
|
||||
"We got the wrong number of successful speculations.");
|
||||
Assert.assertEquals("We got the wrong number of successful speculations.",
|
||||
expectedSpeculations, successfulSpeculations.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -279,8 +279,8 @@ public class TestRuntimeEstimators {
|
|||
TaskId taskID = event.getTaskID();
|
||||
Task task = myJob.getTask(taskID);
|
||||
|
||||
Assertions.assertEquals
|
||||
(TaskEventType.T_ADD_SPEC_ATTEMPT, event.getType(), "Wrong type event");
|
||||
Assert.assertEquals
|
||||
("Wrong type event", TaskEventType.T_ADD_SPEC_ATTEMPT, event.getType());
|
||||
|
||||
System.out.println("SpeculationRequestEventHandler.handle adds a speculation task for " + taskID);
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
|
||||
package org.apache.hadoop.mapreduce.v2.app;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
@ -61,10 +61,9 @@ import org.apache.hadoop.yarn.exceptions.YarnException;
|
|||
import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
|
||||
import org.apache.hadoop.yarn.factories.RecordFactory;
|
||||
import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Timeout;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -79,7 +78,7 @@ import org.junit.jupiter.api.Timeout;
|
|||
private final static RecordFactory recordFactory = RecordFactoryProvider.
|
||||
getRecordFactory(null);
|
||||
|
||||
@AfterEach
|
||||
@After
|
||||
public void tearDown() {
|
||||
conf.setBoolean(MRJobConfig.PRESERVE_FAILED_TASK_FILES, false);
|
||||
}
|
||||
|
@ -136,7 +135,7 @@ import org.junit.jupiter.api.Timeout;
|
|||
JobId jobid = recordFactory.newRecordInstance(JobId.class);
|
||||
jobid.setAppId(appId);
|
||||
ContainerAllocator mockAlloc = mock(ContainerAllocator.class);
|
||||
Assertions.assertTrue(MRJobConfig.DEFAULT_MR_AM_MAX_ATTEMPTS > 1);
|
||||
Assert.assertTrue(MRJobConfig.DEFAULT_MR_AM_MAX_ATTEMPTS > 1);
|
||||
MRAppMaster appMaster = new TestMRApp(attemptId, mockAlloc,
|
||||
JobStateInternal.RUNNING, MRJobConfig.DEFAULT_MR_AM_MAX_ATTEMPTS);
|
||||
appMaster.init(conf);
|
||||
|
@ -147,8 +146,7 @@ import org.junit.jupiter.api.Timeout;
|
|||
verify(fs).delete(stagingJobPath, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(30000)
|
||||
@Test (timeout = 30000)
|
||||
public void testNoDeletionofStagingOnReboot() throws IOException {
|
||||
conf.set(MRJobConfig.MAPREDUCE_JOB_DIR, stagingJobDir);
|
||||
fs = mock(FileSystem.class);
|
||||
|
@ -160,7 +158,7 @@ import org.junit.jupiter.api.Timeout;
|
|||
0);
|
||||
ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance(appId, 1);
|
||||
ContainerAllocator mockAlloc = mock(ContainerAllocator.class);
|
||||
Assertions.assertTrue(MRJobConfig.DEFAULT_MR_AM_MAX_ATTEMPTS > 1);
|
||||
Assert.assertTrue(MRJobConfig.DEFAULT_MR_AM_MAX_ATTEMPTS > 1);
|
||||
MRAppMaster appMaster = new TestMRApp(attemptId, mockAlloc,
|
||||
JobStateInternal.REBOOT, MRJobConfig.DEFAULT_MR_AM_MAX_ATTEMPTS);
|
||||
appMaster.init(conf);
|
||||
|
@ -199,8 +197,7 @@ import org.junit.jupiter.api.Timeout;
|
|||
verify(fs).delete(stagingJobPath, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(30000)
|
||||
@Test (timeout = 30000)
|
||||
public void testDeletionofStagingOnKill() throws IOException {
|
||||
conf.set(MRJobConfig.MAPREDUCE_JOB_DIR, stagingJobDir);
|
||||
fs = mock(FileSystem.class);
|
||||
|
@ -218,7 +215,7 @@ import org.junit.jupiter.api.Timeout;
|
|||
MRAppMaster appMaster = new TestMRApp(attemptId, mockAlloc);
|
||||
appMaster.init(conf);
|
||||
//simulate the process being killed
|
||||
MRAppMaster.MRAppMasterShutdownHook hook =
|
||||
MRAppMaster.MRAppMasterShutdownHook hook =
|
||||
new MRAppMaster.MRAppMasterShutdownHook(appMaster);
|
||||
hook.run();
|
||||
verify(fs, times(0)).delete(stagingJobPath, true);
|
||||
|
@ -245,14 +242,13 @@ import org.junit.jupiter.api.Timeout;
|
|||
ContainerAllocator mockAlloc = mock(ContainerAllocator.class);
|
||||
MRAppMaster appMaster = new TestMRApp(attemptId, mockAlloc); //no retry
|
||||
appMaster.init(conf);
|
||||
assertTrue(appMaster.isLastAMRetry(),
|
||||
"appMaster.isLastAMRetry() is false");
|
||||
assertTrue("appMaster.isLastAMRetry() is false", appMaster.isLastAMRetry());
|
||||
//simulate the process being killed
|
||||
MRAppMaster.MRAppMasterShutdownHook hook =
|
||||
new MRAppMaster.MRAppMasterShutdownHook(appMaster);
|
||||
hook.run();
|
||||
assertTrue(appMaster.isInState(Service.STATE.STOPPED),
|
||||
"MRAppMaster isn't stopped");
|
||||
assertTrue("MRAppMaster isn't stopped",
|
||||
appMaster.isInState(Service.STATE.STOPPED));
|
||||
verify(fs).delete(stagingJobPath, true);
|
||||
}
|
||||
|
||||
|
@ -274,7 +270,7 @@ import org.junit.jupiter.api.Timeout;
|
|||
JobId jobid = recordFactory.newRecordInstance(JobId.class);
|
||||
jobid.setAppId(appId);
|
||||
ContainerAllocator mockAlloc = mock(ContainerAllocator.class);
|
||||
Assertions.assertTrue(MRJobConfig.DEFAULT_MR_AM_MAX_ATTEMPTS > 1);
|
||||
Assert.assertTrue(MRJobConfig.DEFAULT_MR_AM_MAX_ATTEMPTS > 1);
|
||||
MRAppMaster appMaster = new TestMRApp(attemptId, mockAlloc,
|
||||
JobStateInternal.FAILED, MRJobConfig.DEFAULT_MR_AM_MAX_ATTEMPTS);
|
||||
appMaster.init(conf);
|
||||
|
@ -302,7 +298,7 @@ import org.junit.jupiter.api.Timeout;
|
|||
JobId jobid = recordFactory.newRecordInstance(JobId.class);
|
||||
jobid.setAppId(appId);
|
||||
ContainerAllocator mockAlloc = mock(ContainerAllocator.class);
|
||||
Assertions.assertTrue(MRJobConfig.DEFAULT_MR_AM_MAX_ATTEMPTS > 1);
|
||||
Assert.assertTrue(MRJobConfig.DEFAULT_MR_AM_MAX_ATTEMPTS > 1);
|
||||
MRAppMaster appMaster = new TestMRApp(attemptId, mockAlloc,
|
||||
JobStateInternal.RUNNING, MRJobConfig.DEFAULT_MR_AM_MAX_ATTEMPTS);
|
||||
appMaster.init(conf);
|
||||
|
@ -328,7 +324,7 @@ import org.junit.jupiter.api.Timeout;
|
|||
JobId jobid = recordFactory.newRecordInstance(JobId.class);
|
||||
jobid.setAppId(appId);
|
||||
ContainerAllocator mockAlloc = mock(ContainerAllocator.class);
|
||||
Assertions.assertTrue(MRJobConfig.DEFAULT_MR_AM_MAX_ATTEMPTS > 1);
|
||||
Assert.assertTrue(MRJobConfig.DEFAULT_MR_AM_MAX_ATTEMPTS > 1);
|
||||
MRAppMaster appMaster = new TestMRApp(attemptId, mockAlloc,
|
||||
JobStateInternal.RUNNING, MRJobConfig.DEFAULT_MR_AM_MAX_ATTEMPTS);
|
||||
appMaster.init(conf);
|
||||
|
@ -359,7 +355,7 @@ import org.junit.jupiter.api.Timeout;
|
|||
JobId jobid = recordFactory.newRecordInstance(JobId.class);
|
||||
jobid.setAppId(appId);
|
||||
ContainerAllocator mockAlloc = mock(ContainerAllocator.class);
|
||||
Assertions.assertTrue(MRJobConfig.DEFAULT_MR_AM_MAX_ATTEMPTS > 1);
|
||||
Assert.assertTrue(MRJobConfig.DEFAULT_MR_AM_MAX_ATTEMPTS > 1);
|
||||
MRAppMaster appMaster = new TestMRApp(attemptId, mockAlloc,
|
||||
JobStateInternal.RUNNING, MRJobConfig.DEFAULT_MR_AM_MAX_ATTEMPTS);
|
||||
appMaster.init(conf);
|
||||
|
@ -587,8 +583,7 @@ import org.junit.jupiter.api.Timeout;
|
|||
};
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(20000)
|
||||
@Test(timeout=20000)
|
||||
public void testStagingCleanupOrder() throws Exception {
|
||||
MRAppTestCleanup app = new MRAppTestCleanup(1, 1, true,
|
||||
this.getClass().getName(), true);
|
||||
|
@ -603,7 +598,7 @@ import org.junit.jupiter.api.Timeout;
|
|||
}
|
||||
|
||||
// assert ContainerAllocatorStopped and then tagingDirCleanedup
|
||||
Assertions.assertEquals(1, app.ContainerAllocatorStopped);
|
||||
Assertions.assertEquals(2, app.stagingDirCleanedup);
|
||||
Assert.assertEquals(1, app.ContainerAllocatorStopped);
|
||||
Assert.assertEquals(2, app.stagingDirCleanedup);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
package org.apache.hadoop.mapreduce.v2.app;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
|
@ -40,8 +40,8 @@ import org.apache.hadoop.yarn.event.EventHandler;
|
|||
import org.apache.hadoop.yarn.util.Clock;
|
||||
import org.apache.hadoop.yarn.util.ControlledClock;
|
||||
import org.apache.hadoop.yarn.util.SystemClock;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
@ -214,11 +214,11 @@ public class TestTaskHeartbeatHandler {
|
|||
JobId jobId = MRBuilderUtils.newJobId(appId, 4);
|
||||
TaskId tid = MRBuilderUtils.newTaskId(jobId, 3, TaskType.MAP);
|
||||
final TaskAttemptId taid = MRBuilderUtils.newTaskAttemptId(tid, 2);
|
||||
Assertions.assertFalse(hb.hasRecentlyUnregistered(taid));
|
||||
Assert.assertFalse(hb.hasRecentlyUnregistered(taid));
|
||||
hb.register(taid);
|
||||
Assertions.assertFalse(hb.hasRecentlyUnregistered(taid));
|
||||
Assert.assertFalse(hb.hasRecentlyUnregistered(taid));
|
||||
hb.unregister(taid);
|
||||
Assertions.assertTrue(hb.hasRecentlyUnregistered(taid));
|
||||
Assert.assertTrue(hb.hasRecentlyUnregistered(taid));
|
||||
long unregisterTimeout = conf.getLong(MRJobConfig.TASK_EXIT_TIMEOUT,
|
||||
MRJobConfig.TASK_EXIT_TIMEOUT_DEFAULT);
|
||||
clock.setTime(unregisterTimeout + 1);
|
||||
|
@ -260,7 +260,7 @@ public class TestTaskHeartbeatHandler {
|
|||
new TaskHeartbeatHandler(null, SystemClock.getInstance(), 1);
|
||||
hb.init(conf);
|
||||
|
||||
Assertions.assertTrue(hb.getTaskTimeOut() == expectedTimeout,
|
||||
"The value of the task timeout is incorrect.");
|
||||
Assert.assertTrue("The value of the task timeout is incorrect.",
|
||||
hb.getTaskTimeOut() == expectedTimeout);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ import static org.mockito.Mockito.when;
|
|||
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.Assert;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.mapreduce.JobContext;
|
||||
|
@ -39,7 +39,7 @@ import org.apache.hadoop.mapreduce.v2.app.rm.RMHeartbeatHandler;
|
|||
import org.apache.hadoop.yarn.event.AsyncDispatcher;
|
||||
import org.apache.hadoop.yarn.event.EventHandler;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.junit.Assert.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -62,9 +62,9 @@ import org.apache.hadoop.yarn.event.Event;
|
|||
import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
|
||||
import org.apache.hadoop.yarn.util.Clock;
|
||||
import org.apache.hadoop.yarn.util.SystemClock;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestCommitterEventHandler {
|
||||
public static class WaitForItHandler implements EventHandler<Event> {
|
||||
|
@ -95,13 +95,13 @@ public class TestCommitterEventHandler {
|
|||
|
||||
static String stagingDir = "target/test-staging/";
|
||||
|
||||
@BeforeAll
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
File dir = new File(stagingDir);
|
||||
stagingDir = dir.getAbsolutePath();
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
@Before
|
||||
public void cleanup() throws IOException {
|
||||
File dir = new File(stagingDir);
|
||||
if(dir.exists()) {
|
||||
|
@ -146,11 +146,11 @@ public class TestCommitterEventHandler {
|
|||
Thread.sleep(10);
|
||||
timeToWaitMs -= 10;
|
||||
}
|
||||
Assertions.assertEquals(1, rmhh.getNumCallbacks(),
|
||||
"committer did not register a heartbeat callback");
|
||||
Assert.assertEquals("committer did not register a heartbeat callback",
|
||||
1, rmhh.getNumCallbacks());
|
||||
verify(committer, never()).commitJob(any(JobContext.class));
|
||||
Assertions.assertEquals(0, jeh.numCommitCompletedEvents,
|
||||
"committer should not have committed");
|
||||
Assert.assertEquals("committer should not have committed",
|
||||
0, jeh.numCommitCompletedEvents);
|
||||
|
||||
// set a fresh heartbeat and verify commit completes
|
||||
rmhh.setLastHeartbeatTime(clock.getTime());
|
||||
|
@ -159,8 +159,8 @@ public class TestCommitterEventHandler {
|
|||
Thread.sleep(10);
|
||||
timeToWaitMs -= 10;
|
||||
}
|
||||
Assertions.assertEquals(1, jeh.numCommitCompletedEvents,
|
||||
"committer did not complete commit after RM hearbeat");
|
||||
Assert.assertEquals("committer did not complete commit after RM hearbeat",
|
||||
1, jeh.numCommitCompletedEvents);
|
||||
verify(committer, times(1)).commitJob(any());
|
||||
|
||||
//Clean up so we can try to commit again (Don't do this at home)
|
||||
|
@ -174,8 +174,8 @@ public class TestCommitterEventHandler {
|
|||
Thread.sleep(10);
|
||||
timeToWaitMs -= 10;
|
||||
}
|
||||
Assertions.assertEquals(2, jeh.numCommitCompletedEvents,
|
||||
"committer did not commit");
|
||||
Assert.assertEquals("committer did not commit",
|
||||
2, jeh.numCommitCompletedEvents);
|
||||
verify(committer, times(2)).commitJob(any());
|
||||
|
||||
ceh.stop();
|
||||
|
@ -262,9 +262,9 @@ public class TestCommitterEventHandler {
|
|||
assertNotNull(e);
|
||||
assertTrue(e instanceof JobCommitCompletedEvent);
|
||||
FileSystem fs = FileSystem.get(conf);
|
||||
assertTrue(fs.exists(startCommitFile), startCommitFile.toString());
|
||||
assertTrue(fs.exists(endCommitSuccessFile), endCommitSuccessFile.toString());
|
||||
assertFalse(fs.exists(endCommitFailureFile), endCommitFailureFile.toString());
|
||||
assertTrue(startCommitFile.toString(), fs.exists(startCommitFile));
|
||||
assertTrue(endCommitSuccessFile.toString(), fs.exists(endCommitSuccessFile));
|
||||
assertFalse(endCommitFailureFile.toString(), fs.exists(endCommitFailureFile));
|
||||
verify(mockCommitter).commitJob(any(JobContext.class));
|
||||
} finally {
|
||||
handler.stop();
|
||||
|
|
|
@ -105,11 +105,10 @@ import org.apache.hadoop.yarn.state.StateMachine;
|
|||
import org.apache.hadoop.yarn.state.StateMachineFactory;
|
||||
import org.apache.hadoop.yarn.util.Records;
|
||||
import org.apache.hadoop.yarn.util.SystemClock;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Timeout;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
|
||||
|
@ -121,13 +120,13 @@ public class TestJobImpl {
|
|||
|
||||
static String stagingDir = "target/test-staging/";
|
||||
|
||||
@BeforeAll
|
||||
@BeforeClass
|
||||
public static void setup() {
|
||||
File dir = new File(stagingDir);
|
||||
stagingDir = dir.getAbsolutePath();
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
@Before
|
||||
public void cleanup() throws IOException {
|
||||
File dir = new File(stagingDir);
|
||||
if(dir.exists()) {
|
||||
|
@ -170,14 +169,13 @@ public class TestJobImpl {
|
|||
dispatcher.stop();
|
||||
commitHandler.stop();
|
||||
try {
|
||||
Assertions.assertTrue(jseHandler.getAssertValue());
|
||||
Assert.assertTrue(jseHandler.getAssertValue());
|
||||
} catch (InterruptedException e) {
|
||||
Assertions.fail("Workflow related attributes are not tested properly");
|
||||
Assert.fail("Workflow related attributes are not tested properly");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(20000)
|
||||
@Test(timeout=20000)
|
||||
public void testCommitJobFailsJob() throws Exception {
|
||||
Configuration conf = new Configuration();
|
||||
conf.set(MRJobConfig.MR_AM_STAGING_DIR, stagingDir);
|
||||
|
@ -202,8 +200,7 @@ public class TestJobImpl {
|
|||
commitHandler.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(20000)
|
||||
@Test(timeout=20000)
|
||||
public void testCheckJobCompleteSuccess() throws Exception {
|
||||
Configuration conf = new Configuration();
|
||||
conf.set(MRJobConfig.MR_AM_STAGING_DIR, stagingDir);
|
||||
|
@ -242,7 +239,7 @@ public class TestJobImpl {
|
|||
JobEventType.JOB_TASK_ATTEMPT_COMPLETED));
|
||||
assertJobState(job, JobStateInternal.SUCCEEDED);
|
||||
|
||||
job.handle(new JobEvent(job.getID(),
|
||||
job.handle(new JobEvent(job.getID(),
|
||||
JobEventType.JOB_MAP_TASK_RESCHEDULED));
|
||||
assertJobState(job, JobStateInternal.SUCCEEDED);
|
||||
|
||||
|
@ -250,14 +247,13 @@ public class TestJobImpl {
|
|||
JobEventType.JOB_TASK_COMPLETED));
|
||||
dispatcher.await();
|
||||
assertJobState(job, JobStateInternal.SUCCEEDED);
|
||||
|
||||
|
||||
dispatcher.stop();
|
||||
commitHandler.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(20000)
|
||||
public void testRebootedDuringSetup() throws Exception {
|
||||
@Test(timeout=20000)
|
||||
public void testRebootedDuringSetup() throws Exception{
|
||||
Configuration conf = new Configuration();
|
||||
conf.set(MRJobConfig.MR_AM_STAGING_DIR, stagingDir);
|
||||
AsyncDispatcher dispatcher = new AsyncDispatcher();
|
||||
|
@ -293,14 +289,13 @@ public class TestJobImpl {
|
|||
assertJobState(job, JobStateInternal.REBOOT);
|
||||
// return the external state as RUNNING since otherwise JobClient will
|
||||
// exit when it polls the AM for job state
|
||||
Assertions.assertEquals(JobState.RUNNING, job.getState());
|
||||
Assert.assertEquals(JobState.RUNNING, job.getState());
|
||||
|
||||
dispatcher.stop();
|
||||
commitHandler.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(20000)
|
||||
@Test(timeout=20000)
|
||||
public void testRebootedDuringCommit() throws Exception {
|
||||
Configuration conf = new Configuration();
|
||||
conf.set(MRJobConfig.MR_AM_STAGING_DIR, stagingDir);
|
||||
|
@ -326,16 +321,15 @@ public class TestJobImpl {
|
|||
job.handle(new JobEvent(job.getID(), JobEventType.JOB_AM_REBOOT));
|
||||
assertJobState(job, JobStateInternal.REBOOT);
|
||||
// return the external state as ERROR since this is last retry.
|
||||
Assertions.assertEquals(JobState.RUNNING, job.getState());
|
||||
Assert.assertEquals(JobState.RUNNING, job.getState());
|
||||
when(mockContext.hasSuccessfullyUnregistered()).thenReturn(true);
|
||||
Assertions.assertEquals(JobState.ERROR, job.getState());
|
||||
Assert.assertEquals(JobState.ERROR, job.getState());
|
||||
|
||||
dispatcher.stop();
|
||||
commitHandler.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(20000)
|
||||
@Test(timeout=20000)
|
||||
public void testKilledDuringSetup() throws Exception {
|
||||
Configuration conf = new Configuration();
|
||||
conf.set(MRJobConfig.MR_AM_STAGING_DIR, stagingDir);
|
||||
|
@ -372,8 +366,7 @@ public class TestJobImpl {
|
|||
commitHandler.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(20000)
|
||||
@Test(timeout=20000)
|
||||
public void testKilledDuringCommit() throws Exception {
|
||||
Configuration conf = new Configuration();
|
||||
conf.set(MRJobConfig.MR_AM_STAGING_DIR, stagingDir);
|
||||
|
@ -430,8 +423,7 @@ public class TestJobImpl {
|
|||
dispatcher.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(10000)
|
||||
@Test (timeout=10000)
|
||||
public void testFailAbortDoesntHang() throws IOException {
|
||||
Configuration conf = new Configuration();
|
||||
conf.set(MRJobConfig.MR_AM_STAGING_DIR, stagingDir);
|
||||
|
@ -469,8 +461,7 @@ public class TestJobImpl {
|
|||
dispatcher.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(20000)
|
||||
@Test(timeout=20000)
|
||||
public void testKilledDuringFailAbort() throws Exception {
|
||||
Configuration conf = new Configuration();
|
||||
conf.set(MRJobConfig.MR_AM_STAGING_DIR, stagingDir);
|
||||
|
@ -512,8 +503,7 @@ public class TestJobImpl {
|
|||
commitHandler.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(20000)
|
||||
@Test(timeout=20000)
|
||||
public void testKilledDuringKillAbort() throws Exception {
|
||||
Configuration conf = new Configuration();
|
||||
conf.set(MRJobConfig.MR_AM_STAGING_DIR, stagingDir);
|
||||
|
@ -556,8 +546,7 @@ public class TestJobImpl {
|
|||
commitHandler.stop();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(20000)
|
||||
@Test(timeout=20000)
|
||||
public void testUnusableNodeTransition() throws Exception {
|
||||
Configuration conf = new Configuration();
|
||||
conf.set(MRJobConfig.MR_AM_STAGING_DIR, stagingDir);
|
||||
|
@ -610,7 +599,7 @@ public class TestJobImpl {
|
|||
job.handle(new JobTaskAttemptCompletedEvent(tce));
|
||||
// complete the task itself
|
||||
job.handle(new JobTaskEvent(taskId, TaskState.SUCCEEDED));
|
||||
Assertions.assertEquals(JobState.RUNNING, job.getState());
|
||||
Assert.assertEquals(JobState.RUNNING, job.getState());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -710,13 +699,13 @@ public class TestJobImpl {
|
|||
* much value. Instead, we validate the T_KILL events.
|
||||
*/
|
||||
if (killMappers) {
|
||||
Assertions.assertEquals(2, killedEvents.size(), "Number of killed events");
|
||||
Assertions.assertEquals("task_1234567890000_0001_m_000000",
|
||||
killedEvents.get(0).getTaskID().toString(), "AttemptID");
|
||||
Assertions.assertEquals("task_1234567890000_0001_m_000001",
|
||||
killedEvents.get(1).getTaskID().toString(), "AttemptID");
|
||||
Assert.assertEquals("Number of killed events", 2, killedEvents.size());
|
||||
Assert.assertEquals("AttemptID", "task_1234567890000_0001_m_000000",
|
||||
killedEvents.get(0).getTaskID().toString());
|
||||
Assert.assertEquals("AttemptID", "task_1234567890000_0001_m_000001",
|
||||
killedEvents.get(1).getTaskID().toString());
|
||||
} else {
|
||||
Assertions.assertEquals(0, killedEvents.size(), "Number of killed events");
|
||||
Assert.assertEquals("Number of killed events", 0, killedEvents.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -749,8 +738,8 @@ public class TestJobImpl {
|
|||
// Verify access
|
||||
JobImpl job1 = new JobImpl(jobId, null, conf1, null, null, null, null, null,
|
||||
null, null, null, true, user1, 0, null, null, null, null);
|
||||
Assertions.assertTrue(job1.checkAccess(ugi1, JobACL.VIEW_JOB));
|
||||
Assertions.assertFalse(job1.checkAccess(ugi2, JobACL.VIEW_JOB));
|
||||
Assert.assertTrue(job1.checkAccess(ugi1, JobACL.VIEW_JOB));
|
||||
Assert.assertFalse(job1.checkAccess(ugi2, JobACL.VIEW_JOB));
|
||||
|
||||
// Setup configuration access to the user1 (owner) and user2
|
||||
Configuration conf2 = new Configuration();
|
||||
|
@ -760,8 +749,8 @@ public class TestJobImpl {
|
|||
// Verify access
|
||||
JobImpl job2 = new JobImpl(jobId, null, conf2, null, null, null, null, null,
|
||||
null, null, null, true, user1, 0, null, null, null, null);
|
||||
Assertions.assertTrue(job2.checkAccess(ugi1, JobACL.VIEW_JOB));
|
||||
Assertions.assertTrue(job2.checkAccess(ugi2, JobACL.VIEW_JOB));
|
||||
Assert.assertTrue(job2.checkAccess(ugi1, JobACL.VIEW_JOB));
|
||||
Assert.assertTrue(job2.checkAccess(ugi2, JobACL.VIEW_JOB));
|
||||
|
||||
// Setup configuration access with security enabled and access to all
|
||||
Configuration conf3 = new Configuration();
|
||||
|
@ -771,8 +760,8 @@ public class TestJobImpl {
|
|||
// Verify access
|
||||
JobImpl job3 = new JobImpl(jobId, null, conf3, null, null, null, null, null,
|
||||
null, null, null, true, user1, 0, null, null, null, null);
|
||||
Assertions.assertTrue(job3.checkAccess(ugi1, JobACL.VIEW_JOB));
|
||||
Assertions.assertTrue(job3.checkAccess(ugi2, JobACL.VIEW_JOB));
|
||||
Assert.assertTrue(job3.checkAccess(ugi1, JobACL.VIEW_JOB));
|
||||
Assert.assertTrue(job3.checkAccess(ugi2, JobACL.VIEW_JOB));
|
||||
|
||||
// Setup configuration access without security enabled
|
||||
Configuration conf4 = new Configuration();
|
||||
|
@ -782,8 +771,8 @@ public class TestJobImpl {
|
|||
// Verify access
|
||||
JobImpl job4 = new JobImpl(jobId, null, conf4, null, null, null, null, null,
|
||||
null, null, null, true, user1, 0, null, null, null, null);
|
||||
Assertions.assertTrue(job4.checkAccess(ugi1, JobACL.VIEW_JOB));
|
||||
Assertions.assertTrue(job4.checkAccess(ugi2, JobACL.VIEW_JOB));
|
||||
Assert.assertTrue(job4.checkAccess(ugi1, JobACL.VIEW_JOB));
|
||||
Assert.assertTrue(job4.checkAccess(ugi2, JobACL.VIEW_JOB));
|
||||
|
||||
// Setup configuration access without security enabled
|
||||
Configuration conf5 = new Configuration();
|
||||
|
@ -793,8 +782,8 @@ public class TestJobImpl {
|
|||
// Verify access
|
||||
JobImpl job5 = new JobImpl(jobId, null, conf5, null, null, null, null, null,
|
||||
null, null, null, true, user1, 0, null, null, null, null);
|
||||
Assertions.assertTrue(job5.checkAccess(ugi1, null));
|
||||
Assertions.assertTrue(job5.checkAccess(ugi2, null));
|
||||
Assert.assertTrue(job5.checkAccess(ugi1, null));
|
||||
Assert.assertTrue(job5.checkAccess(ugi2, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -815,8 +804,8 @@ public class TestJobImpl {
|
|||
mrAppMetrics, null, true, null, 0, null, mockContext, null, null);
|
||||
job.handle(diagUpdateEvent);
|
||||
String diagnostics = job.getReport().getDiagnostics();
|
||||
Assertions.assertNotNull(diagnostics);
|
||||
Assertions.assertTrue(diagnostics.contains(diagMsg));
|
||||
Assert.assertNotNull(diagnostics);
|
||||
Assert.assertTrue(diagnostics.contains(diagMsg));
|
||||
|
||||
job = new JobImpl(jobId, Records
|
||||
.newRecord(ApplicationAttemptId.class), new Configuration(),
|
||||
|
@ -827,8 +816,8 @@ public class TestJobImpl {
|
|||
job.handle(new JobEvent(jobId, JobEventType.JOB_KILL));
|
||||
job.handle(diagUpdateEvent);
|
||||
diagnostics = job.getReport().getDiagnostics();
|
||||
Assertions.assertNotNull(diagnostics);
|
||||
Assertions.assertTrue(diagnostics.contains(diagMsg));
|
||||
Assert.assertNotNull(diagnostics);
|
||||
Assert.assertTrue(diagnostics.contains(diagMsg));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -837,13 +826,13 @@ public class TestJobImpl {
|
|||
// with default values, no of maps is 2
|
||||
Configuration conf = new Configuration();
|
||||
boolean isUber = testUberDecision(conf);
|
||||
Assertions.assertFalse(isUber);
|
||||
Assert.assertFalse(isUber);
|
||||
|
||||
// enable uber mode, no of maps is 2
|
||||
conf = new Configuration();
|
||||
conf.setBoolean(MRJobConfig.JOB_UBERTASK_ENABLE, true);
|
||||
isUber = testUberDecision(conf);
|
||||
Assertions.assertTrue(isUber);
|
||||
Assert.assertTrue(isUber);
|
||||
|
||||
// enable uber mode, no of maps is 2, no of reduces is 1 and uber task max
|
||||
// reduces is 0
|
||||
|
@ -852,7 +841,7 @@ public class TestJobImpl {
|
|||
conf.setInt(MRJobConfig.JOB_UBERTASK_MAXREDUCES, 0);
|
||||
conf.setInt(MRJobConfig.NUM_REDUCES, 1);
|
||||
isUber = testUberDecision(conf);
|
||||
Assertions.assertFalse(isUber);
|
||||
Assert.assertFalse(isUber);
|
||||
|
||||
// enable uber mode, no of maps is 2, no of reduces is 1 and uber task max
|
||||
// reduces is 1
|
||||
|
@ -861,14 +850,14 @@ public class TestJobImpl {
|
|||
conf.setInt(MRJobConfig.JOB_UBERTASK_MAXREDUCES, 1);
|
||||
conf.setInt(MRJobConfig.NUM_REDUCES, 1);
|
||||
isUber = testUberDecision(conf);
|
||||
Assertions.assertTrue(isUber);
|
||||
Assert.assertTrue(isUber);
|
||||
|
||||
// enable uber mode, no of maps is 2 and uber task max maps is 0
|
||||
conf = new Configuration();
|
||||
conf.setBoolean(MRJobConfig.JOB_UBERTASK_ENABLE, true);
|
||||
conf.setInt(MRJobConfig.JOB_UBERTASK_MAXMAPS, 1);
|
||||
isUber = testUberDecision(conf);
|
||||
Assertions.assertFalse(isUber);
|
||||
Assert.assertFalse(isUber);
|
||||
|
||||
// enable uber mode of 0 reducer no matter how much memory assigned to reducer
|
||||
conf = new Configuration();
|
||||
|
@ -877,7 +866,7 @@ public class TestJobImpl {
|
|||
conf.setInt(MRJobConfig.REDUCE_MEMORY_MB, 2048);
|
||||
conf.setInt(MRJobConfig.REDUCE_CPU_VCORES, 10);
|
||||
isUber = testUberDecision(conf);
|
||||
Assertions.assertTrue(isUber);
|
||||
Assert.assertTrue(isUber);
|
||||
}
|
||||
|
||||
private boolean testUberDecision(Configuration conf) {
|
||||
|
@ -942,9 +931,9 @@ public class TestJobImpl {
|
|||
assertJobState(job, JobStateInternal.FAILED);
|
||||
job.handle(new JobEvent(jobId, JobEventType.JOB_TASK_ATTEMPT_FETCH_FAILURE));
|
||||
assertJobState(job, JobStateInternal.FAILED);
|
||||
Assertions.assertEquals(JobState.RUNNING, job.getState());
|
||||
Assert.assertEquals(JobState.RUNNING, job.getState());
|
||||
when(mockContext.hasSuccessfullyUnregistered()).thenReturn(true);
|
||||
Assertions.assertEquals(JobState.FAILED, job.getState());
|
||||
Assert.assertEquals(JobState.FAILED, job.getState());
|
||||
|
||||
dispatcher.stop();
|
||||
commitHandler.stop();
|
||||
|
@ -971,12 +960,12 @@ public class TestJobImpl {
|
|||
JobEvent mockJobEvent = mock(JobEvent.class);
|
||||
|
||||
JobStateInternal jobSI = initTransition.transition(job, mockJobEvent);
|
||||
Assertions.assertTrue(jobSI.equals(JobStateInternal.NEW),
|
||||
"When init fails, return value from InitTransition.transition should equal NEW.");
|
||||
Assertions.assertTrue(job.getDiagnostics().toString().contains("YarnRuntimeException"),
|
||||
"Job diagnostics should contain YarnRuntimeException");
|
||||
Assertions.assertTrue(job.getDiagnostics().toString().contains(EXCEPTIONMSG),
|
||||
"Job diagnostics should contain " + EXCEPTIONMSG);
|
||||
Assert.assertTrue("When init fails, return value from InitTransition.transition should equal NEW.",
|
||||
jobSI.equals(JobStateInternal.NEW));
|
||||
Assert.assertTrue("Job diagnostics should contain YarnRuntimeException",
|
||||
job.getDiagnostics().toString().contains("YarnRuntimeException"));
|
||||
Assert.assertTrue("Job diagnostics should contain " + EXCEPTIONMSG,
|
||||
job.getDiagnostics().toString().contains(EXCEPTIONMSG));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -997,7 +986,7 @@ public class TestJobImpl {
|
|||
assertJobState(job, JobStateInternal.SETUP);
|
||||
// Update priority of job to 5, and it will be updated
|
||||
job.setJobPriority(submittedPriority);
|
||||
Assertions.assertEquals(submittedPriority, job.getReport().getJobPriority());
|
||||
Assert.assertEquals(submittedPriority, job.getReport().getJobPriority());
|
||||
|
||||
job.handle(new JobSetupCompletedEvent(jobId));
|
||||
assertJobState(job, JobStateInternal.RUNNING);
|
||||
|
@ -1007,10 +996,10 @@ public class TestJobImpl {
|
|||
job.setJobPriority(updatedPriority);
|
||||
assertJobState(job, JobStateInternal.RUNNING);
|
||||
Priority jobPriority = job.getReport().getJobPriority();
|
||||
Assertions.assertNotNull(jobPriority);
|
||||
Assert.assertNotNull(jobPriority);
|
||||
|
||||
// Verify whether changed priority is same as what is set in Job.
|
||||
Assertions.assertEquals(updatedPriority, jobPriority);
|
||||
Assert.assertEquals(updatedPriority, jobPriority);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1024,14 +1013,14 @@ public class TestJobImpl {
|
|||
filePolicies.put("file1", true);
|
||||
filePolicies.put("jar1", true);
|
||||
Job.setFileSharedCacheUploadPolicies(config, filePolicies);
|
||||
Assertions.assertEquals(
|
||||
Assert.assertEquals(
|
||||
2, Job.getArchiveSharedCacheUploadPolicies(config).size());
|
||||
Assertions.assertEquals(
|
||||
Assert.assertEquals(
|
||||
2, Job.getFileSharedCacheUploadPolicies(config).size());
|
||||
JobImpl.cleanupSharedCacheUploadPolicies(config);
|
||||
Assertions.assertEquals(
|
||||
Assert.assertEquals(
|
||||
0, Job.getArchiveSharedCacheUploadPolicies(config).size());
|
||||
Assertions.assertEquals(
|
||||
Assert.assertEquals(
|
||||
0, Job.getFileSharedCacheUploadPolicies(config).size());
|
||||
}
|
||||
|
||||
|
@ -1099,14 +1088,14 @@ public class TestJobImpl {
|
|||
job.handle(new JobTaskEvent(
|
||||
MRBuilderUtils.newTaskId(job.getID(), 1, TaskType.MAP),
|
||||
TaskState.SUCCEEDED));
|
||||
Assertions.assertEquals(JobState.RUNNING, job.getState());
|
||||
Assert.assertEquals(JobState.RUNNING, job.getState());
|
||||
}
|
||||
int numReduces = job.getTotalReduces();
|
||||
for (int i = 0; i < numReduces; ++i) {
|
||||
job.handle(new JobTaskEvent(
|
||||
MRBuilderUtils.newTaskId(job.getID(), 1, TaskType.MAP),
|
||||
TaskState.SUCCEEDED));
|
||||
Assertions.assertEquals(JobState.RUNNING, job.getState());
|
||||
Assert.assertEquals(JobState.RUNNING, job.getState());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1120,7 +1109,7 @@ public class TestJobImpl {
|
|||
break;
|
||||
}
|
||||
}
|
||||
Assertions.assertEquals(state, job.getInternalState());
|
||||
Assert.assertEquals(state, job.getInternalState());
|
||||
}
|
||||
|
||||
private void createSpiedMapTasks(Map<NodeReport, TaskId>
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.ArrayList;
|
|||
import java.util.Map;
|
||||
|
||||
import org.apache.hadoop.mapreduce.TaskType;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.Assert;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.mapred.JobConf;
|
||||
|
@ -37,8 +37,7 @@ import org.apache.hadoop.mapreduce.v2.app.launcher.ContainerLauncherEvent;
|
|||
import org.apache.hadoop.mapreduce.v2.app.launcher.ContainerRemoteLaunchEvent;
|
||||
import org.apache.hadoop.mapreduce.v2.util.MRApps;
|
||||
import org.apache.hadoop.yarn.api.records.ContainerLaunchContext;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Timeout;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -47,9 +46,9 @@ public class TestMapReduceChildJVM {
|
|||
private static final Logger LOG =
|
||||
LoggerFactory.getLogger(TestMapReduceChildJVM.class);
|
||||
|
||||
@Test
|
||||
@Timeout(30000)
|
||||
@Test (timeout = 30000)
|
||||
public void testCommandLine() throws Exception {
|
||||
|
||||
MyMRApp app = new MyMRApp(1, 0, true, this.getClass().getName(), true);
|
||||
Configuration conf = new Configuration();
|
||||
conf.setBoolean(MRConfig.MAPREDUCE_APP_SUBMISSION_CROSS_PLATFORM, true);
|
||||
|
@ -57,7 +56,7 @@ public class TestMapReduceChildJVM {
|
|||
app.waitForState(job, JobState.SUCCEEDED);
|
||||
app.verifyCompleted();
|
||||
|
||||
Assertions.assertEquals(
|
||||
Assert.assertEquals(
|
||||
"[" + MRApps.crossPlatformify("JAVA_HOME") + "/bin/java" +
|
||||
" -Djava.net.preferIPv4Stack=true" +
|
||||
" -Dhadoop.metrics.log.level=WARN " +
|
||||
|
@ -72,26 +71,24 @@ public class TestMapReduceChildJVM {
|
|||
" 0" +
|
||||
" 1><LOG_DIR>/stdout" +
|
||||
" 2><LOG_DIR>/stderr ]", app.launchCmdList.get(0));
|
||||
|
||||
Assertions.assertTrue(app.cmdEnvironment.containsKey("HADOOP_ROOT_LOGGER"),
|
||||
"HADOOP_ROOT_LOGGER not set for job");
|
||||
Assertions.assertEquals("INFO,console",
|
||||
|
||||
Assert.assertTrue("HADOOP_ROOT_LOGGER not set for job",
|
||||
app.cmdEnvironment.containsKey("HADOOP_ROOT_LOGGER"));
|
||||
Assert.assertEquals("INFO,console",
|
||||
app.cmdEnvironment.get("HADOOP_ROOT_LOGGER"));
|
||||
Assertions.assertTrue(app.cmdEnvironment.containsKey("HADOOP_CLIENT_OPTS"),
|
||||
"HADOOP_CLIENT_OPTS not set for job");
|
||||
Assertions.assertEquals("", app.cmdEnvironment.get("HADOOP_CLIENT_OPTS"));
|
||||
Assert.assertTrue("HADOOP_CLIENT_OPTS not set for job",
|
||||
app.cmdEnvironment.containsKey("HADOOP_CLIENT_OPTS"));
|
||||
Assert.assertEquals("", app.cmdEnvironment.get("HADOOP_CLIENT_OPTS"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(30000)
|
||||
@Test (timeout = 30000)
|
||||
public void testReduceCommandLineWithSeparateShuffle() throws Exception {
|
||||
final Configuration conf = new Configuration();
|
||||
conf.setBoolean(MRJobConfig.REDUCE_SEPARATE_SHUFFLE_LOG, true);
|
||||
testReduceCommandLine(conf);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(30000)
|
||||
@Test (timeout = 30000)
|
||||
public void testReduceCommandLineWithSeparateCRLAShuffle() throws Exception {
|
||||
final Configuration conf = new Configuration();
|
||||
conf.setBoolean(MRJobConfig.REDUCE_SEPARATE_SHUFFLE_LOG, true);
|
||||
|
@ -100,8 +97,7 @@ public class TestMapReduceChildJVM {
|
|||
testReduceCommandLine(conf);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(30000)
|
||||
@Test (timeout = 30000)
|
||||
public void testReduceCommandLine() throws Exception {
|
||||
final Configuration conf = new Configuration();
|
||||
testReduceCommandLine(conf);
|
||||
|
@ -123,7 +119,7 @@ public class TestMapReduceChildJVM {
|
|||
? "shuffleCRLA"
|
||||
: "shuffleCLA";
|
||||
|
||||
Assertions.assertEquals(
|
||||
Assert.assertEquals(
|
||||
"[" + MRApps.crossPlatformify("JAVA_HOME") + "/bin/java" +
|
||||
" -Djava.net.preferIPv4Stack=true" +
|
||||
" -Dhadoop.metrics.log.level=WARN " +
|
||||
|
@ -143,17 +139,16 @@ public class TestMapReduceChildJVM {
|
|||
" 1><LOG_DIR>/stdout" +
|
||||
" 2><LOG_DIR>/stderr ]", app.launchCmdList.get(0));
|
||||
|
||||
Assertions.assertTrue(app.cmdEnvironment.containsKey("HADOOP_ROOT_LOGGER"),
|
||||
"HADOOP_ROOT_LOGGER not set for job");
|
||||
Assertions.assertEquals("INFO,console",
|
||||
Assert.assertTrue("HADOOP_ROOT_LOGGER not set for job",
|
||||
app.cmdEnvironment.containsKey("HADOOP_ROOT_LOGGER"));
|
||||
Assert.assertEquals("INFO,console",
|
||||
app.cmdEnvironment.get("HADOOP_ROOT_LOGGER"));
|
||||
Assertions.assertTrue(app.cmdEnvironment.containsKey("HADOOP_CLIENT_OPTS"),
|
||||
"HADOOP_CLIENT_OPTS not set for job");
|
||||
Assertions.assertEquals("", app.cmdEnvironment.get("HADOOP_CLIENT_OPTS"));
|
||||
Assert.assertTrue("HADOOP_CLIENT_OPTS not set for job",
|
||||
app.cmdEnvironment.containsKey("HADOOP_CLIENT_OPTS"));
|
||||
Assert.assertEquals("", app.cmdEnvironment.get("HADOOP_CLIENT_OPTS"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(30000)
|
||||
@Test (timeout = 30000)
|
||||
public void testCommandLineWithLog4JConifg() throws Exception {
|
||||
|
||||
MyMRApp app = new MyMRApp(1, 0, true, this.getClass().getName(), true);
|
||||
|
@ -166,7 +161,7 @@ public class TestMapReduceChildJVM {
|
|||
app.waitForState(job, JobState.SUCCEEDED);
|
||||
app.verifyCompleted();
|
||||
|
||||
Assertions.assertEquals(
|
||||
Assert.assertEquals(
|
||||
"[" + MRApps.crossPlatformify("JAVA_HOME") + "/bin/java" +
|
||||
" -Djava.net.preferIPv4Stack=true" +
|
||||
" -Dhadoop.metrics.log.level=WARN " +
|
||||
|
@ -208,10 +203,10 @@ public class TestMapReduceChildJVM {
|
|||
MRJobConfig.DEFAULT_HEAP_MEMORY_MB_RATIO);
|
||||
|
||||
// Verify map and reduce java opts are not set by default
|
||||
Assertions.assertNull(conf.get(MRJobConfig.MAP_JAVA_OPTS),
|
||||
"Default map java opts!");
|
||||
Assertions.assertNull(conf.get(MRJobConfig.REDUCE_JAVA_OPTS),
|
||||
"Default reduce java opts!");
|
||||
Assert.assertNull("Default map java opts!",
|
||||
conf.get(MRJobConfig.MAP_JAVA_OPTS));
|
||||
Assert.assertNull("Default reduce java opts!",
|
||||
conf.get(MRJobConfig.REDUCE_JAVA_OPTS));
|
||||
// Set the memory-mbs and java-opts
|
||||
if (mapMb > 0) {
|
||||
conf.setInt(MRJobConfig.MAP_MEMORY_MB, mapMb);
|
||||
|
@ -247,8 +242,8 @@ public class TestMapReduceChildJVM {
|
|||
: MRJobConfig.REDUCE_JAVA_OPTS);
|
||||
heapMb = JobConf.parseMaximumHeapSizeMB(javaOpts);
|
||||
}
|
||||
Assertions.assertEquals(heapMb, JobConf.parseMaximumHeapSizeMB(cmd),
|
||||
"Incorrect heapsize in the command opts");
|
||||
Assert.assertEquals("Incorrect heapsize in the command opts",
|
||||
heapMb, JobConf.parseMaximumHeapSizeMB(cmd));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -293,13 +288,13 @@ public class TestMapReduceChildJVM {
|
|||
app.waitForState(job, JobState.SUCCEEDED);
|
||||
app.verifyCompleted();
|
||||
|
||||
Assertions.assertTrue(app.cmdEnvironment.containsKey("HADOOP_ROOT_LOGGER"),
|
||||
"HADOOP_ROOT_LOGGER not set for job");
|
||||
Assertions.assertEquals("WARN,console",
|
||||
Assert.assertTrue("HADOOP_ROOT_LOGGER not set for job",
|
||||
app.cmdEnvironment.containsKey("HADOOP_ROOT_LOGGER"));
|
||||
Assert.assertEquals("WARN,console",
|
||||
app.cmdEnvironment.get("HADOOP_ROOT_LOGGER"));
|
||||
Assertions.assertTrue(app.cmdEnvironment.containsKey("HADOOP_CLIENT_OPTS"),
|
||||
"HADOOP_CLIENT_OPTS not set for job");
|
||||
Assertions.assertEquals("test", app.cmdEnvironment.get("HADOOP_CLIENT_OPTS"));
|
||||
Assert.assertTrue("HADOOP_CLIENT_OPTS not set for job",
|
||||
app.cmdEnvironment.containsKey("HADOOP_CLIENT_OPTS"));
|
||||
Assert.assertEquals("test", app.cmdEnvironment.get("HADOOP_CLIENT_OPTS"));
|
||||
|
||||
// Try one more.
|
||||
app = new MyMRApp(1, 0, true, this.getClass().getName(), true);
|
||||
|
@ -309,9 +304,9 @@ public class TestMapReduceChildJVM {
|
|||
app.waitForState(job, JobState.SUCCEEDED);
|
||||
app.verifyCompleted();
|
||||
|
||||
Assertions.assertTrue(app.cmdEnvironment.containsKey("HADOOP_ROOT_LOGGER"),
|
||||
"HADOOP_ROOT_LOGGER not set for job");
|
||||
Assertions.assertEquals("trace",
|
||||
Assert.assertTrue("HADOOP_ROOT_LOGGER not set for job",
|
||||
app.cmdEnvironment.containsKey("HADOOP_ROOT_LOGGER"));
|
||||
Assert.assertEquals("trace",
|
||||
app.cmdEnvironment.get("HADOOP_ROOT_LOGGER"));
|
||||
|
||||
// Try one using the mapreduce.task.env.var=value syntax
|
||||
|
@ -323,9 +318,9 @@ public class TestMapReduceChildJVM {
|
|||
app.waitForState(job, JobState.SUCCEEDED);
|
||||
app.verifyCompleted();
|
||||
|
||||
Assertions.assertTrue(app.cmdEnvironment.containsKey("HADOOP_ROOT_LOGGER"),
|
||||
"HADOOP_ROOT_LOGGER not set for job");
|
||||
Assertions.assertEquals("DEBUG,console",
|
||||
Assert.assertTrue("HADOOP_ROOT_LOGGER not set for job",
|
||||
app.cmdEnvironment.containsKey("HADOOP_ROOT_LOGGER"));
|
||||
Assert.assertEquals("DEBUG,console",
|
||||
app.cmdEnvironment.get("HADOOP_ROOT_LOGGER"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,8 +53,8 @@ import org.apache.hadoop.yarn.server.api.AuxiliaryService;
|
|||
import org.apache.hadoop.yarn.server.api.ApplicationInitializationContext;
|
||||
import org.apache.hadoop.yarn.server.api.ApplicationTerminationContext;
|
||||
import org.apache.hadoop.yarn.conf.YarnConfiguration;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.Test;
|
||||
import org.junit.Assert;
|
||||
|
||||
public class TestShuffleProvider {
|
||||
|
||||
|
@ -110,12 +110,9 @@ public class TestShuffleProvider {
|
|||
credentials);
|
||||
|
||||
Map<String, ByteBuffer> serviceDataMap = launchCtx.getServiceData();
|
||||
Assertions.assertNotNull(serviceDataMap.get(TestShuffleHandler1.MAPREDUCE_TEST_SHUFFLE_SERVICEID),
|
||||
"TestShuffleHandler1 is missing");
|
||||
Assertions.assertNotNull(serviceDataMap.get(TestShuffleHandler2.MAPREDUCE_TEST_SHUFFLE_SERVICEID),
|
||||
"TestShuffleHandler2 is missing");
|
||||
Assertions.assertTrue(serviceDataMap.size() == 3,
|
||||
"mismatch number of services in map"); // 2 that we entered + 1 for the built-in shuffle-provider
|
||||
Assert.assertNotNull("TestShuffleHandler1 is missing", serviceDataMap.get(TestShuffleHandler1.MAPREDUCE_TEST_SHUFFLE_SERVICEID));
|
||||
Assert.assertNotNull("TestShuffleHandler2 is missing", serviceDataMap.get(TestShuffleHandler2.MAPREDUCE_TEST_SHUFFLE_SERVICEID));
|
||||
Assert.assertTrue("mismatch number of services in map", serviceDataMap.size() == 3); // 2 that we entered + 1 for the built-in shuffle-provider
|
||||
}
|
||||
|
||||
static public class StubbedFS extends RawLocalFileSystem {
|
||||
|
|
|
@ -20,10 +20,9 @@ package org.apache.hadoop.mapreduce.v2.app.job.impl;
|
|||
|
||||
import static org.apache.hadoop.test.GenericTestUtils.waitFor;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.times;
|
||||
|
@ -42,10 +41,10 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
|||
import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableMap;
|
||||
import org.apache.hadoop.mapreduce.v2.app.job.event.TaskAttemptFailEvent;
|
||||
import org.apache.hadoop.yarn.util.resource.CustomResourceTypesConfigurationProvider;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.FileStatus;
|
||||
import org.apache.hadoop.fs.FileSystem;
|
||||
|
@ -112,7 +111,7 @@ import org.apache.log4j.AppenderSkeleton;
|
|||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.spi.LoggingEvent;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
import org.apache.hadoop.thirdparty.com.google.common.collect.ImmutableList;
|
||||
|
@ -152,17 +151,17 @@ public class TestTaskAttempt{
|
|||
}
|
||||
}
|
||||
|
||||
@BeforeAll
|
||||
@BeforeClass
|
||||
public static void setupBeforeClass() {
|
||||
ResourceUtils.resetResourceTypes(new Configuration());
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
@Before
|
||||
public void before() {
|
||||
TaskAttemptImpl.RESOURCE_REQUEST_CACHE.clear();
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
@After
|
||||
public void tearDown() {
|
||||
ResourceUtils.resetResourceTypes(new Configuration());
|
||||
}
|
||||
|
@ -290,7 +289,7 @@ public class TestTaskAttempt{
|
|||
ArgumentCaptor<Event> arg = ArgumentCaptor.forClass(Event.class);
|
||||
verify(eventHandler, times(2)).handle(arg.capture());
|
||||
if (!(arg.getAllValues().get(1) instanceof ContainerRequestEvent)) {
|
||||
Assertions.fail("Second Event not of type ContainerRequestEvent");
|
||||
Assert.fail("Second Event not of type ContainerRequestEvent");
|
||||
}
|
||||
ContainerRequestEvent cre =
|
||||
(ContainerRequestEvent) arg.getAllValues().get(1);
|
||||
|
@ -324,7 +323,7 @@ public class TestTaskAttempt{
|
|||
ArgumentCaptor<Event> arg = ArgumentCaptor.forClass(Event.class);
|
||||
verify(eventHandler, times(2)).handle(arg.capture());
|
||||
if (!(arg.getAllValues().get(1) instanceof ContainerRequestEvent)) {
|
||||
Assertions.fail("Second Event not of type ContainerRequestEvent");
|
||||
Assert.fail("Second Event not of type ContainerRequestEvent");
|
||||
}
|
||||
Map<String, Boolean> expected = new HashMap<String, Boolean>();
|
||||
expected.put("host1", true);
|
||||
|
@ -362,16 +361,16 @@ public class TestTaskAttempt{
|
|||
Job job = app.submit(conf);
|
||||
app.waitForState(job, JobState.RUNNING);
|
||||
Map<TaskId, Task> tasks = job.getTasks();
|
||||
Assertions.assertEquals(2, tasks.size(), "Num tasks is not correct");
|
||||
Assert.assertEquals("Num tasks is not correct", 2, tasks.size());
|
||||
Iterator<Task> taskIter = tasks.values().iterator();
|
||||
Task mTask = taskIter.next();
|
||||
app.waitForState(mTask, TaskState.RUNNING);
|
||||
Task rTask = taskIter.next();
|
||||
app.waitForState(rTask, TaskState.RUNNING);
|
||||
Map<TaskAttemptId, TaskAttempt> mAttempts = mTask.getAttempts();
|
||||
Assertions.assertEquals(1, mAttempts.size(), "Num attempts is not correct");
|
||||
Assert.assertEquals("Num attempts is not correct", 1, mAttempts.size());
|
||||
Map<TaskAttemptId, TaskAttempt> rAttempts = rTask.getAttempts();
|
||||
Assertions.assertEquals(1, rAttempts.size(), "Num attempts is not correct");
|
||||
Assert.assertEquals("Num attempts is not correct", 1, rAttempts.size());
|
||||
TaskAttempt mta = mAttempts.values().iterator().next();
|
||||
TaskAttempt rta = rAttempts.values().iterator().next();
|
||||
app.waitForState(mta, TaskAttemptState.RUNNING);
|
||||
|
@ -393,21 +392,21 @@ public class TestTaskAttempt{
|
|||
|
||||
int memoryMb = (int) containerResource.getMemorySize();
|
||||
int vcores = containerResource.getVirtualCores();
|
||||
Assertions.assertEquals((int) Math.ceil((float) memoryMb / minContainerSize),
|
||||
Assert.assertEquals((int) Math.ceil((float) memoryMb / minContainerSize),
|
||||
counters.findCounter(JobCounter.SLOTS_MILLIS_MAPS).getValue());
|
||||
Assertions.assertEquals((int) Math.ceil((float) memoryMb / minContainerSize),
|
||||
Assert.assertEquals((int) Math.ceil((float) memoryMb / minContainerSize),
|
||||
counters.findCounter(JobCounter.SLOTS_MILLIS_REDUCES).getValue());
|
||||
Assertions.assertEquals(1,
|
||||
Assert.assertEquals(1,
|
||||
counters.findCounter(JobCounter.MILLIS_MAPS).getValue());
|
||||
Assertions.assertEquals(1,
|
||||
Assert.assertEquals(1,
|
||||
counters.findCounter(JobCounter.MILLIS_REDUCES).getValue());
|
||||
Assertions.assertEquals(memoryMb,
|
||||
Assert.assertEquals(memoryMb,
|
||||
counters.findCounter(JobCounter.MB_MILLIS_MAPS).getValue());
|
||||
Assertions.assertEquals(memoryMb,
|
||||
Assert.assertEquals(memoryMb,
|
||||
counters.findCounter(JobCounter.MB_MILLIS_REDUCES).getValue());
|
||||
Assertions.assertEquals(vcores,
|
||||
Assert.assertEquals(vcores,
|
||||
counters.findCounter(JobCounter.VCORES_MILLIS_MAPS).getValue());
|
||||
Assertions.assertEquals(vcores,
|
||||
Assert.assertEquals(vcores,
|
||||
counters.findCounter(JobCounter.VCORES_MILLIS_REDUCES).getValue());
|
||||
}
|
||||
|
||||
|
@ -453,25 +452,23 @@ public class TestTaskAttempt{
|
|||
app.waitForState(job, JobState.FAILED);
|
||||
Map<TaskId, Task> tasks = job.getTasks();
|
||||
|
||||
Assertions.assertEquals(1, tasks.size(),
|
||||
"Num tasks is not correct");
|
||||
Assert.assertEquals("Num tasks is not correct", 1, tasks.size());
|
||||
Task task = tasks.values().iterator().next();
|
||||
Assertions.assertEquals(TaskState.FAILED, task.getReport().getTaskState(),
|
||||
"Task state not correct");
|
||||
Assert.assertEquals("Task state not correct", TaskState.FAILED, task
|
||||
.getReport().getTaskState());
|
||||
Map<TaskAttemptId, TaskAttempt> attempts = tasks.values().iterator().next()
|
||||
.getAttempts();
|
||||
Assertions.assertEquals(4, attempts.size(),
|
||||
"Num attempts is not correct");
|
||||
Assert.assertEquals("Num attempts is not correct", 4, attempts.size());
|
||||
|
||||
Iterator<TaskAttempt> it = attempts.values().iterator();
|
||||
TaskAttemptReport report = it.next().getReport();
|
||||
Assertions.assertEquals(TaskAttemptState.FAILED, report.getTaskAttemptState(),
|
||||
"Attempt state not correct");
|
||||
Assertions.assertEquals("Test Diagnostic Event", report.getDiagnosticInfo(),
|
||||
"Diagnostic Information is not Correct");
|
||||
Assert.assertEquals("Attempt state not correct", TaskAttemptState.FAILED,
|
||||
report.getTaskAttemptState());
|
||||
Assert.assertEquals("Diagnostic Information is not Correct",
|
||||
"Test Diagnostic Event", report.getDiagnosticInfo());
|
||||
report = it.next().getReport();
|
||||
Assertions.assertEquals(TaskAttemptState.FAILED, report.getTaskAttemptState(),
|
||||
"Attempt state not correct ");
|
||||
Assert.assertEquals("Attempt state not correct", TaskAttemptState.FAILED,
|
||||
report.getTaskAttemptState());
|
||||
}
|
||||
|
||||
private void testTaskAttemptAssignedFailHistory
|
||||
|
@ -480,8 +477,8 @@ public class TestTaskAttempt{
|
|||
Job job = app.submit(conf);
|
||||
app.waitForState(job, JobState.FAILED);
|
||||
Map<TaskId, Task> tasks = job.getTasks();
|
||||
Assertions.assertTrue(app.getTaStartJHEvent(), "No Ta Started JH Event");
|
||||
Assertions.assertTrue(app.getTaFailedJHEvent(), "No Ta Failed JH Event");
|
||||
Assert.assertTrue("No Ta Started JH Event", app.getTaStartJHEvent());
|
||||
Assert.assertTrue("No Ta Failed JH Event", app.getTaFailedJHEvent());
|
||||
}
|
||||
|
||||
private void testTaskAttemptAssignedKilledHistory
|
||||
|
@ -521,8 +518,8 @@ public class TestTaskAttempt{
|
|||
if (event.getType() == org.apache.hadoop.mapreduce.jobhistory.EventType.MAP_ATTEMPT_FAILED) {
|
||||
TaskAttemptUnsuccessfulCompletion datum = (TaskAttemptUnsuccessfulCompletion) event
|
||||
.getHistoryEvent().getDatum();
|
||||
Assertions.assertEquals("Test Diagnostic Event", datum.get(8).toString(),
|
||||
"Diagnostic Information is not Correct");
|
||||
Assert.assertEquals("Diagnostic Information is not Correct",
|
||||
"Test Diagnostic Event", datum.get(8).toString());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -641,8 +638,8 @@ public class TestTaskAttempt{
|
|||
taImpl.handle(new TaskAttemptEvent(attemptId,
|
||||
TaskAttemptEventType.TA_CONTAINER_LAUNCH_FAILED));
|
||||
assertFalse(eventHandler.internalError);
|
||||
assertEquals(Locality.NODE_LOCAL, taImpl.getLocality(),
|
||||
"Task attempt is not assigned on the local node");
|
||||
assertEquals("Task attempt is not assigned on the local node",
|
||||
Locality.NODE_LOCAL, taImpl.getLocality());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -698,10 +695,10 @@ public class TestTaskAttempt{
|
|||
.isEqualTo(TaskAttemptState.RUNNING);
|
||||
taImpl.handle(new TaskAttemptEvent(attemptId,
|
||||
TaskAttemptEventType.TA_CONTAINER_CLEANED));
|
||||
assertFalse(eventHandler.internalError,
|
||||
"InternalError occurred trying to handle TA_CONTAINER_CLEANED");
|
||||
assertEquals(Locality.RACK_LOCAL, taImpl.getLocality(),
|
||||
"Task attempt is not assigned on the local rack");
|
||||
assertFalse("InternalError occurred trying to handle TA_CONTAINER_CLEANED",
|
||||
eventHandler.internalError);
|
||||
assertEquals("Task attempt is not assigned on the local rack",
|
||||
Locality.RACK_LOCAL, taImpl.getLocality());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -760,10 +757,10 @@ public class TestTaskAttempt{
|
|||
.isEqualTo(TaskAttemptState.COMMIT_PENDING);
|
||||
taImpl.handle(new TaskAttemptEvent(attemptId,
|
||||
TaskAttemptEventType.TA_CONTAINER_CLEANED));
|
||||
assertFalse(eventHandler.internalError,
|
||||
"InternalError occurred trying to handle TA_CONTAINER_CLEANED");
|
||||
assertEquals(Locality.OFF_SWITCH,taImpl.getLocality(),
|
||||
"Task attempt is assigned locally");
|
||||
assertFalse("InternalError occurred trying to handle TA_CONTAINER_CLEANED",
|
||||
eventHandler.internalError);
|
||||
assertEquals("Task attempt is assigned locally", Locality.OFF_SWITCH,
|
||||
taImpl.getLocality());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -835,8 +832,8 @@ public class TestTaskAttempt{
|
|||
assertThat(taImpl.getState())
|
||||
.withFailMessage("Task attempt is not in FAILED state, still")
|
||||
.isEqualTo(TaskAttemptState.FAILED);
|
||||
assertFalse(eventHandler.internalError,
|
||||
"InternalError occurred trying to handle TA_CONTAINER_CLEANED");
|
||||
assertFalse("InternalError occurred trying to handle TA_CONTAINER_CLEANED",
|
||||
eventHandler.internalError);
|
||||
}
|
||||
|
||||
|
||||
|
@ -886,15 +883,16 @@ public class TestTaskAttempt{
|
|||
TaskAttemptEventType.TA_SCHEDULE));
|
||||
taImpl.handle(new TaskAttemptDiagnosticsUpdateEvent(attemptId,
|
||||
"Task got killed"));
|
||||
assertFalse(eventHandler.internalError,
|
||||
"InternalError occurred trying to handle TA_DIAGNOSTICS_UPDATE on assigned task");
|
||||
assertFalse(
|
||||
"InternalError occurred trying to handle TA_DIAGNOSTICS_UPDATE on assigned task",
|
||||
eventHandler.internalError);
|
||||
try {
|
||||
taImpl.handle(new TaskAttemptEvent(attemptId,
|
||||
TaskAttemptEventType.TA_KILL));
|
||||
Assertions.assertTrue(true, "No exception on UNASSIGNED STATE KILL event");
|
||||
Assert.assertTrue("No exception on UNASSIGNED STATE KILL event", true);
|
||||
} catch (Exception e) {
|
||||
Assertions.assertFalse(true,
|
||||
"Exception not expected for UNASSIGNED STATE KILL event");
|
||||
Assert.assertFalse(
|
||||
"Exception not expected for UNASSIGNED STATE KILL event", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -964,8 +962,8 @@ public class TestTaskAttempt{
|
|||
assertThat(taImpl.getState())
|
||||
.withFailMessage("Task attempt is not in KILLED state, still")
|
||||
.isEqualTo(TaskAttemptState.KILLED);
|
||||
assertFalse(eventHandler.internalError,
|
||||
"InternalError occurred trying to handle TA_CONTAINER_CLEANED");
|
||||
assertFalse("InternalError occurred trying to handle TA_CONTAINER_CLEANED",
|
||||
eventHandler.internalError);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1011,8 +1009,9 @@ public class TestTaskAttempt{
|
|||
when(container.getNodeHttpAddress()).thenReturn("localhost:0");
|
||||
taImpl.handle(new TaskAttemptDiagnosticsUpdateEvent(attemptId,
|
||||
"Task got killed"));
|
||||
assertFalse(eventHandler.internalError,
|
||||
"InternalError occurred trying to handle TA_DIAGNOSTICS_UPDATE on assigned task");
|
||||
assertFalse(
|
||||
"InternalError occurred trying to handle TA_DIAGNOSTICS_UPDATE on assigned task",
|
||||
eventHandler.internalError);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1073,8 +1072,8 @@ public class TestTaskAttempt{
|
|||
.withFailMessage("Task attempt is not in SUCCEEDED state")
|
||||
.isEqualTo(TaskAttemptState.SUCCEEDED);
|
||||
|
||||
assertTrue(taImpl.getFinishTime() > 0,
|
||||
"Task Attempt finish time is not greater than 0");
|
||||
assertTrue("Task Attempt finish time is not greater than 0",
|
||||
taImpl.getFinishTime() > 0);
|
||||
|
||||
Long finishTime = taImpl.getFinishTime();
|
||||
Thread.sleep(5);
|
||||
|
@ -1085,9 +1084,9 @@ public class TestTaskAttempt{
|
|||
.withFailMessage("Task attempt is not in FAILED state")
|
||||
.isEqualTo(TaskAttemptState.FAILED);
|
||||
|
||||
assertEquals(finishTime, Long.valueOf(taImpl.getFinishTime()),
|
||||
"After TA_TOO_MANY_FETCH_FAILURE,"
|
||||
+ " Task attempt finish time is not the same ");
|
||||
assertEquals("After TA_TOO_MANY_FETCH_FAILURE,"
|
||||
+ " Task attempt finish time is not the same ",
|
||||
finishTime, Long.valueOf(taImpl.getFinishTime()));
|
||||
}
|
||||
|
||||
private void containerKillBeforeAssignment(boolean scheduleAttempt)
|
||||
|
@ -1115,7 +1114,7 @@ public class TestTaskAttempt{
|
|||
assertThat(taImpl.getInternalState())
|
||||
.withFailMessage("Task attempt's internal state is not KILLED")
|
||||
.isEqualTo(TaskAttemptStateInternal.KILLED);
|
||||
assertFalse(eventHandler.internalError, "InternalError occurred");
|
||||
assertFalse("InternalError occurred", eventHandler.internalError);
|
||||
TaskEvent event = eventHandler.lastTaskEvent;
|
||||
assertEquals(TaskEventType.T_ATTEMPT_KILLED, event.getType());
|
||||
// In NEW state, new map attempt should not be rescheduled.
|
||||
|
@ -1239,8 +1238,8 @@ public class TestTaskAttempt{
|
|||
.isEqualTo(TaskAttemptState.RUNNING);
|
||||
taImpl.handle(new TaskAttemptEvent(attemptId,
|
||||
TaskAttemptEventType.TA_KILL));
|
||||
assertFalse(eventHandler.internalError,
|
||||
"InternalError occurred trying to handle TA_KILL");
|
||||
assertFalse("InternalError occurred trying to handle TA_KILL",
|
||||
eventHandler.internalError);
|
||||
assertThat(taImpl.getInternalState())
|
||||
.withFailMessage("Task should be in KILL_CONTAINER_CLEANUP state")
|
||||
.isEqualTo(TaskAttemptStateInternal.KILL_CONTAINER_CLEANUP);
|
||||
|
@ -1302,8 +1301,8 @@ public class TestTaskAttempt{
|
|||
.isEqualTo(TaskAttemptStateInternal.COMMIT_PENDING);
|
||||
taImpl.handle(new TaskAttemptEvent(attemptId,
|
||||
TaskAttemptEventType.TA_KILL));
|
||||
assertFalse(eventHandler.internalError,
|
||||
"InternalError occurred trying to handle TA_KILL");
|
||||
assertFalse("InternalError occurred trying to handle TA_KILL",
|
||||
eventHandler.internalError);
|
||||
assertThat(taImpl.getInternalState())
|
||||
.withFailMessage("Task should be in KILL_CONTAINER_CLEANUP state")
|
||||
.isEqualTo(TaskAttemptStateInternal.KILL_CONTAINER_CLEANUP);
|
||||
|
@ -1349,7 +1348,7 @@ public class TestTaskAttempt{
|
|||
.withFailMessage("Task attempt is not in KILLED state")
|
||||
.isEqualTo(TaskAttemptState.KILLED);
|
||||
|
||||
assertFalse(eventHandler.internalError, "InternalError occurred");
|
||||
assertFalse("InternalError occurred", eventHandler.internalError);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1360,30 +1359,32 @@ public class TestTaskAttempt{
|
|||
taImpl.handle(new TaskAttemptEvent(taImpl.getID(),
|
||||
TaskAttemptEventType.TA_DONE));
|
||||
|
||||
assertEquals(TaskAttemptState.SUCCEEDED, taImpl.getState(),
|
||||
"Task attempt is not in SUCCEEDED state");
|
||||
assertEquals(TaskAttemptStateInternal.SUCCESS_FINISHING_CONTAINER,
|
||||
taImpl.getInternalState(), "Task attempt's internal state is not " +
|
||||
"SUCCESS_FINISHING_CONTAINER");
|
||||
assertEquals("Task attempt is not in SUCCEEDED state",
|
||||
TaskAttemptState.SUCCEEDED, taImpl.getState());
|
||||
assertEquals("Task attempt's internal state is not " +
|
||||
"SUCCESS_FINISHING_CONTAINER",
|
||||
TaskAttemptStateInternal.SUCCESS_FINISHING_CONTAINER,
|
||||
taImpl.getInternalState());
|
||||
|
||||
// If the map only task is killed when it is in SUCCESS_FINISHING_CONTAINER
|
||||
// state, the state will move to SUCCESS_CONTAINER_CLEANUP
|
||||
taImpl.handle(new TaskAttemptEvent(taImpl.getID(),
|
||||
TaskAttemptEventType.TA_KILL));
|
||||
assertEquals(TaskAttemptState.SUCCEEDED, taImpl.getState(),
|
||||
"Task attempt is not in SUCCEEDED state");
|
||||
assertEquals(TaskAttemptStateInternal.SUCCESS_CONTAINER_CLEANUP,
|
||||
taImpl.getInternalState(), "Task attempt's internal state is not " +
|
||||
"SUCCESS_CONTAINER_CLEANUP");
|
||||
assertEquals("Task attempt is not in SUCCEEDED state",
|
||||
TaskAttemptState.SUCCEEDED, taImpl.getState());
|
||||
assertEquals("Task attempt's internal state is not " +
|
||||
"SUCCESS_CONTAINER_CLEANUP",
|
||||
TaskAttemptStateInternal.SUCCESS_CONTAINER_CLEANUP,
|
||||
taImpl.getInternalState());
|
||||
|
||||
taImpl.handle(new TaskAttemptEvent(taImpl.getID(),
|
||||
TaskAttemptEventType.TA_CONTAINER_CLEANED));
|
||||
assertEquals(TaskAttemptState.SUCCEEDED, taImpl.getState(),
|
||||
"Task attempt is not in SUCCEEDED state");
|
||||
assertEquals(TaskAttemptStateInternal.SUCCEEDED, taImpl.getInternalState(),
|
||||
"Task attempt's internal state is not SUCCEEDED state");
|
||||
assertEquals("Task attempt is not in SUCCEEDED state",
|
||||
TaskAttemptState.SUCCEEDED, taImpl.getState());
|
||||
assertEquals("Task attempt's internal state is not SUCCEEDED state",
|
||||
TaskAttemptStateInternal.SUCCEEDED, taImpl.getInternalState());
|
||||
|
||||
assertFalse(eventHandler.internalError, "InternalError occurred");
|
||||
assertFalse("InternalError occurred", eventHandler.internalError);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1413,7 +1414,7 @@ public class TestTaskAttempt{
|
|||
assertThat(taImpl.getInternalState())
|
||||
.withFailMessage("Task attempt's internal state is not KILLED")
|
||||
.isEqualTo(TaskAttemptStateInternal.KILLED);
|
||||
assertFalse(eventHandler.internalError, "InternalError occurred");
|
||||
assertFalse("InternalError occurred", eventHandler.internalError);
|
||||
TaskEvent event = eventHandler.lastTaskEvent;
|
||||
assertEquals(TaskEventType.T_ATTEMPT_KILLED, event.getType());
|
||||
// Send an attempt killed event to TaskImpl forwarding the same reschedule
|
||||
|
@ -1429,21 +1430,22 @@ public class TestTaskAttempt{
|
|||
taImpl.handle(new TaskAttemptEvent(taImpl.getID(),
|
||||
TaskAttemptEventType.TA_DONE));
|
||||
|
||||
assertEquals(TaskAttemptState.SUCCEEDED, taImpl.getState(),
|
||||
"Task attempt is not in SUCCEEDED state");
|
||||
assertEquals(TaskAttemptStateInternal.SUCCESS_FINISHING_CONTAINER,
|
||||
taImpl.getInternalState(), "Task attempt's internal state is not " +
|
||||
"SUCCESS_FINISHING_CONTAINER");
|
||||
assertEquals("Task attempt is not in SUCCEEDED state",
|
||||
TaskAttemptState.SUCCEEDED, taImpl.getState());
|
||||
assertEquals("Task attempt's internal state is not " +
|
||||
"SUCCESS_FINISHING_CONTAINER",
|
||||
TaskAttemptStateInternal.SUCCESS_FINISHING_CONTAINER,
|
||||
taImpl.getInternalState());
|
||||
|
||||
taImpl.handle(new TaskAttemptEvent(taImpl.getID(),
|
||||
TaskAttemptEventType.TA_CONTAINER_CLEANED));
|
||||
// Succeeded
|
||||
taImpl.handle(new TaskAttemptKillEvent(taImpl.getID(),"", true));
|
||||
assertEquals(TaskAttemptState.SUCCEEDED, taImpl.getState(),
|
||||
"Task attempt is not in SUCCEEDED state");
|
||||
assertEquals(TaskAttemptStateInternal.SUCCEEDED, taImpl.getInternalState(),
|
||||
"Task attempt's internal state is not SUCCEEDED");
|
||||
assertFalse(eventHandler.internalError, "InternalError occurred");
|
||||
assertEquals("Task attempt is not in SUCCEEDED state",
|
||||
TaskAttemptState.SUCCEEDED, taImpl.getState());
|
||||
assertEquals("Task attempt's internal state is not SUCCEEDED",
|
||||
TaskAttemptStateInternal.SUCCEEDED, taImpl.getInternalState());
|
||||
assertFalse("InternalError occurred", eventHandler.internalError);
|
||||
TaskEvent event = eventHandler.lastTaskEvent;
|
||||
assertEquals(TaskEventType.T_ATTEMPT_SUCCEEDED, event.getType());
|
||||
}
|
||||
|
@ -1496,7 +1498,7 @@ public class TestTaskAttempt{
|
|||
.withFailMessage("Task attempt is not in FAILED state")
|
||||
.isEqualTo(TaskAttemptState.FAILED);
|
||||
|
||||
assertFalse(eventHandler.internalError, "InternalError occurred");
|
||||
assertFalse("InternalError occurred", eventHandler.internalError);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1529,7 +1531,7 @@ public class TestTaskAttempt{
|
|||
.withFailMessage("Task attempt is not in FAILED state")
|
||||
.isEqualTo(TaskAttemptState.FAILED);
|
||||
|
||||
assertFalse(eventHandler.internalError, "InternalError occurred");
|
||||
assertFalse("InternalError occurred", eventHandler.internalError);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1559,7 +1561,7 @@ public class TestTaskAttempt{
|
|||
"SUCCESS_FINISHING_CONTAINER")
|
||||
.isEqualTo(TaskAttemptStateInternal.SUCCESS_FINISHING_CONTAINER);
|
||||
|
||||
assertFalse(eventHandler.internalError, "InternalError occurred");
|
||||
assertFalse("InternalError occurred", eventHandler.internalError);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1590,7 +1592,7 @@ public class TestTaskAttempt{
|
|||
"SUCCESS_CONTAINER_CLEANUP")
|
||||
.isEqualTo(TaskAttemptStateInternal.SUCCESS_CONTAINER_CLEANUP);
|
||||
|
||||
assertFalse(eventHandler.internalError, "InternalError occurred");
|
||||
assertFalse("InternalError occurred", eventHandler.internalError);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1617,7 +1619,7 @@ public class TestTaskAttempt{
|
|||
"FAIL_CONTAINER_CLEANUP")
|
||||
.isEqualTo(TaskAttemptStateInternal.FAIL_CONTAINER_CLEANUP);
|
||||
|
||||
assertFalse(eventHandler.internalError, "InternalError occurred");
|
||||
assertFalse("InternalError occurred", eventHandler.internalError);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1634,8 +1636,8 @@ public class TestTaskAttempt{
|
|||
ResourceInformation resourceInfo =
|
||||
getResourceInfoFromContainerRequest(taImpl, eventHandler).
|
||||
getResourceInformation(CUSTOM_RESOURCE_NAME);
|
||||
assertEquals("G", resourceInfo.getUnits(),
|
||||
"Expecting the default unit (G)");
|
||||
assertEquals("Expecting the default unit (G)",
|
||||
"G", resourceInfo.getUnits());
|
||||
assertEquals(7L, resourceInfo.getValue());
|
||||
}
|
||||
|
||||
|
@ -1652,8 +1654,8 @@ public class TestTaskAttempt{
|
|||
ResourceInformation resourceInfo =
|
||||
getResourceInfoFromContainerRequest(taImpl, eventHandler).
|
||||
getResourceInformation(CUSTOM_RESOURCE_NAME);
|
||||
assertEquals("m", resourceInfo.getUnits(),
|
||||
"Expecting the specified unit (m)");
|
||||
assertEquals("Expecting the specified unit (m)",
|
||||
"m", resourceInfo.getUnits());
|
||||
assertEquals(3L, resourceInfo.getValue());
|
||||
}
|
||||
|
||||
|
@ -1750,20 +1752,18 @@ public class TestTaskAttempt{
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testReducerMemoryRequestMultipleName() {
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
EventHandler eventHandler = mock(EventHandler.class);
|
||||
Clock clock = SystemClock.getInstance();
|
||||
JobConf jobConf = new JobConf();
|
||||
for (String memoryName : ImmutableList.of(
|
||||
MRJobConfig.RESOURCE_TYPE_NAME_MEMORY,
|
||||
MRJobConfig.RESOURCE_TYPE_ALTERNATIVE_NAME_MEMORY)) {
|
||||
jobConf.set(MRJobConfig.REDUCE_RESOURCE_TYPE_PREFIX + memoryName,
|
||||
"3Gi");
|
||||
}
|
||||
createReduceTaskAttemptImplForTest(eventHandler, clock, jobConf);
|
||||
});
|
||||
EventHandler eventHandler = mock(EventHandler.class);
|
||||
Clock clock = SystemClock.getInstance();
|
||||
JobConf jobConf = new JobConf();
|
||||
for (String memoryName : ImmutableList.of(
|
||||
MRJobConfig.RESOURCE_TYPE_NAME_MEMORY,
|
||||
MRJobConfig.RESOURCE_TYPE_ALTERNATIVE_NAME_MEMORY)) {
|
||||
jobConf.set(MRJobConfig.REDUCE_RESOURCE_TYPE_PREFIX + memoryName,
|
||||
"3Gi");
|
||||
}
|
||||
createReduceTaskAttemptImplForTest(eventHandler, clock, jobConf);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1853,24 +1853,21 @@ public class TestTaskAttempt{
|
|||
containerRequestEvents.add((ContainerRequestEvent) e);
|
||||
}
|
||||
}
|
||||
assertEquals(1, containerRequestEvents.size(),
|
||||
"Expected one ContainerRequestEvent after scheduling "
|
||||
+ "task attempt");
|
||||
assertEquals("Expected one ContainerRequestEvent after scheduling "
|
||||
+ "task attempt", 1, containerRequestEvents.size());
|
||||
|
||||
return containerRequestEvents.get(0).getCapability();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testReducerCustomResourceTypeWithInvalidUnit() {
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
initResourceTypes();
|
||||
EventHandler eventHandler = mock(EventHandler.class);
|
||||
Clock clock = SystemClock.getInstance();
|
||||
JobConf jobConf = new JobConf();
|
||||
jobConf.set(MRJobConfig.REDUCE_RESOURCE_TYPE_PREFIX
|
||||
+ CUSTOM_RESOURCE_NAME, "3z");
|
||||
createReduceTaskAttemptImplForTest(eventHandler, clock, jobConf);
|
||||
});
|
||||
initResourceTypes();
|
||||
EventHandler eventHandler = mock(EventHandler.class);
|
||||
Clock clock = SystemClock.getInstance();
|
||||
JobConf jobConf = new JobConf();
|
||||
jobConf.set(MRJobConfig.REDUCE_RESOURCE_TYPE_PREFIX
|
||||
+ CUSTOM_RESOURCE_NAME, "3z");
|
||||
createReduceTaskAttemptImplForTest(eventHandler, clock, jobConf);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1885,19 +1882,22 @@ public class TestTaskAttempt{
|
|||
// move in two steps to the desired state (cannot get there directly)
|
||||
taImpl.handle(new TaskAttemptEvent(taImpl.getID(),
|
||||
TaskAttemptEventType.TA_DONE));
|
||||
assertEquals(TaskAttemptStateInternal.SUCCESS_FINISHING_CONTAINER,
|
||||
taImpl.getInternalState(), "Task attempt's internal state is not " +
|
||||
"SUCCESS_FINISHING_CONTAINER");
|
||||
assertEquals("Task attempt's internal state is not " +
|
||||
"SUCCESS_FINISHING_CONTAINER",
|
||||
TaskAttemptStateInternal.SUCCESS_FINISHING_CONTAINER,
|
||||
taImpl.getInternalState());
|
||||
|
||||
taImpl.handle(new TaskAttemptEvent(taImpl.getID(),
|
||||
TaskAttemptEventType.TA_TIMED_OUT));
|
||||
assertEquals(TaskAttemptStateInternal.SUCCESS_CONTAINER_CLEANUP,
|
||||
taImpl.getInternalState(), "Task attempt's internal state is not " +
|
||||
"SUCCESS_CONTAINER_CLEANUP");
|
||||
assertEquals("Task attempt's internal state is not " +
|
||||
"SUCCESS_CONTAINER_CLEANUP",
|
||||
TaskAttemptStateInternal.SUCCESS_CONTAINER_CLEANUP,
|
||||
taImpl.getInternalState());
|
||||
|
||||
taImpl.handle(new TaskAttemptKillEvent(mapTAId, "", true));
|
||||
assertEquals(TaskAttemptState.KILLED,
|
||||
taImpl.getState(), "Task attempt is not in KILLED state");
|
||||
assertEquals("Task attempt is not in KILLED state",
|
||||
TaskAttemptState.KILLED,
|
||||
taImpl.getState());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1912,21 +1912,24 @@ public class TestTaskAttempt{
|
|||
// move in two steps to the desired state (cannot get there directly)
|
||||
taImpl.handle(new TaskAttemptEvent(taImpl.getID(),
|
||||
TaskAttemptEventType.TA_DONE));
|
||||
assertEquals(TaskAttemptStateInternal.SUCCESS_FINISHING_CONTAINER,
|
||||
taImpl.getInternalState(), "Task attempt's internal state is not " +
|
||||
"SUCCESS_FINISHING_CONTAINER");
|
||||
assertEquals("Task attempt's internal state is not " +
|
||||
"SUCCESS_FINISHING_CONTAINER",
|
||||
TaskAttemptStateInternal.SUCCESS_FINISHING_CONTAINER,
|
||||
taImpl.getInternalState());
|
||||
|
||||
taImpl.handle(new TaskAttemptEvent(taImpl.getID(),
|
||||
TaskAttemptEventType.TA_TIMED_OUT));
|
||||
assertEquals(TaskAttemptStateInternal.SUCCESS_CONTAINER_CLEANUP,
|
||||
taImpl.getInternalState(), "Task attempt's internal state is not " +
|
||||
"SUCCESS_CONTAINER_CLEANUP");
|
||||
assertEquals("Task attempt's internal state is not " +
|
||||
"SUCCESS_CONTAINER_CLEANUP",
|
||||
TaskAttemptStateInternal.SUCCESS_CONTAINER_CLEANUP,
|
||||
taImpl.getInternalState());
|
||||
|
||||
taImpl.handle(new TaskAttemptTooManyFetchFailureEvent(taImpl.getID(),
|
||||
reduceTAId, "Host"));
|
||||
assertEquals(TaskAttemptState.FAILED,
|
||||
taImpl.getState(), "Task attempt is not in FAILED state");
|
||||
assertFalse(eventHandler.internalError, "InternalError occurred");
|
||||
assertEquals("Task attempt is not in FAILED state",
|
||||
TaskAttemptState.FAILED,
|
||||
taImpl.getState());
|
||||
assertFalse("InternalError occurred", eventHandler.internalError);
|
||||
}
|
||||
|
||||
private void initResourceTypes() {
|
||||
|
@ -1948,15 +1951,17 @@ public class TestTaskAttempt{
|
|||
taImpl.handle(new TaskAttemptEvent(taImpl.getID(),
|
||||
TaskAttemptEventType.TA_DONE));
|
||||
|
||||
assertEquals(TaskAttemptStateInternal.SUCCESS_FINISHING_CONTAINER,
|
||||
taImpl.getInternalState(), "Task attempt's internal state is not " +
|
||||
"SUCCESS_FINISHING_CONTAINER");
|
||||
assertEquals("Task attempt's internal state is not " +
|
||||
"SUCCESS_FINISHING_CONTAINER",
|
||||
TaskAttemptStateInternal.SUCCESS_FINISHING_CONTAINER,
|
||||
taImpl.getInternalState());
|
||||
|
||||
taImpl.handle(new TaskAttemptTooManyFetchFailureEvent(taImpl.getID(),
|
||||
reduceTAId, "Host"));
|
||||
assertEquals(TaskAttemptState.FAILED,
|
||||
taImpl.getState(), "Task attempt is not in FAILED state");
|
||||
assertFalse(eventHandler.internalError, "InternalError occurred");
|
||||
assertEquals("Task attempt is not in FAILED state",
|
||||
TaskAttemptState.FAILED,
|
||||
taImpl.getState());
|
||||
assertFalse("InternalError occurred", eventHandler.internalError);
|
||||
}
|
||||
|
||||
private void setupTaskAttemptFinishingMonitor(
|
||||
|
|
|
@ -27,8 +27,8 @@ import java.util.Arrays;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
|
||||
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
|
||||
import org.apache.hadoop.fs.FileStatus;
|
||||
|
@ -58,12 +58,12 @@ import org.apache.hadoop.yarn.api.records.ApplicationId;
|
|||
import org.apache.hadoop.yarn.api.records.ContainerLaunchContext;
|
||||
import org.apache.hadoop.yarn.event.EventHandler;
|
||||
import org.apache.hadoop.yarn.util.SystemClock;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.Test;
|
||||
|
||||
@SuppressWarnings({"rawtypes"})
|
||||
public class TestTaskAttemptContainerRequest {
|
||||
|
||||
@AfterEach
|
||||
@After
|
||||
public void cleanup() {
|
||||
UserGroupInformation.reset();
|
||||
}
|
||||
|
@ -114,8 +114,7 @@ public class TestTaskAttemptContainerRequest {
|
|||
mock(WrappedJvmID.class), taListener,
|
||||
credentials);
|
||||
|
||||
Assertions.assertEquals(acls, launchCtx.getApplicationACLs(),
|
||||
"ACLs mismatch");
|
||||
Assert.assertEquals("ACLs mismatch", acls, launchCtx.getApplicationACLs());
|
||||
Credentials launchCredentials = new Credentials();
|
||||
|
||||
DataInputByteBuffer dibb = new DataInputByteBuffer();
|
||||
|
@ -126,18 +125,17 @@ public class TestTaskAttemptContainerRequest {
|
|||
for (Token<? extends TokenIdentifier> token : credentials.getAllTokens()) {
|
||||
Token<? extends TokenIdentifier> launchToken =
|
||||
launchCredentials.getToken(token.getService());
|
||||
Assertions.assertNotNull(launchToken,
|
||||
"Token " + token.getService() + " is missing");
|
||||
Assertions.assertEquals(token, launchToken,
|
||||
"Token " + token.getService() + " mismatch");
|
||||
Assert.assertNotNull("Token " + token.getService() + " is missing",
|
||||
launchToken);
|
||||
Assert.assertEquals("Token " + token.getService() + " mismatch",
|
||||
token, launchToken);
|
||||
}
|
||||
|
||||
// verify the secret key is in the launch context
|
||||
Assertions.assertNotNull(launchCredentials.getSecretKey(SECRET_KEY_ALIAS),
|
||||
"Secret key missing");
|
||||
Assertions.assertTrue(Arrays.equals(SECRET_KEY,
|
||||
launchCredentials.getSecretKey(SECRET_KEY_ALIAS)),
|
||||
"Secret key mismatch");
|
||||
Assert.assertNotNull("Secret key missing",
|
||||
launchCredentials.getSecretKey(SECRET_KEY_ALIAS));
|
||||
Assert.assertTrue("Secret key mismatch", Arrays.equals(SECRET_KEY,
|
||||
launchCredentials.getSecretKey(SECRET_KEY_ALIAS)));
|
||||
}
|
||||
|
||||
static public class StubbedFS extends RawLocalFileSystem {
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
*/
|
||||
package org.apache.hadoop.mapreduce.v2.app.job.impl;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
|
@ -65,9 +65,9 @@ import org.apache.hadoop.yarn.event.InlineDispatcher;
|
|||
import org.apache.hadoop.yarn.util.Clock;
|
||||
import org.apache.hadoop.yarn.util.Records;
|
||||
import org.apache.hadoop.yarn.util.SystemClock;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -234,7 +234,7 @@ public class TestTaskImpl {
|
|||
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
@Before
|
||||
@SuppressWarnings("unchecked")
|
||||
public void setup() {
|
||||
dispatcher = new InlineDispatcher();
|
||||
|
@ -273,7 +273,7 @@ public class TestTaskImpl {
|
|||
startCount, metrics, appContext, taskType);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
@After
|
||||
public void teardown() {
|
||||
taskAttempts.clear();
|
||||
}
|
||||
|
@ -510,7 +510,7 @@ public class TestTaskImpl {
|
|||
assertTaskScheduledState();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test
|
||||
public void testTaskProgress() {
|
||||
LOG.info("--- START: testTaskProgress ---");
|
||||
mockTask = createMockTask(TaskType.MAP);
|
||||
|
@ -587,10 +587,10 @@ public class TestTaskImpl {
|
|||
mockTask.handle(new TaskTAttemptEvent(getLastAttempt().getAttemptId(),
|
||||
TaskEventType.T_ATTEMPT_SUCCEEDED));
|
||||
|
||||
assertFalse(mockTask.canCommit(taskAttempts.get(0).getAttemptId()),
|
||||
"First attempt should not commit");
|
||||
assertTrue(mockTask.canCommit(getLastAttempt().getAttemptId()),
|
||||
"Second attempt should commit");
|
||||
assertFalse("First attempt should not commit",
|
||||
mockTask.canCommit(taskAttempts.get(0).getAttemptId()));
|
||||
assertTrue("Second attempt should commit",
|
||||
mockTask.canCommit(getLastAttempt().getAttemptId()));
|
||||
|
||||
assertTaskSucceededState();
|
||||
}
|
||||
|
@ -879,8 +879,7 @@ public class TestTaskImpl {
|
|||
baseAttempt.setProgress(1.0f);
|
||||
|
||||
Counters taskCounters = mockTask.getCounters();
|
||||
assertEquals(specAttemptCounters, taskCounters,
|
||||
"wrong counters for task");
|
||||
assertEquals("wrong counters for task", specAttemptCounters, taskCounters);
|
||||
}
|
||||
|
||||
public static class MockTaskAttemptEventHandler implements EventHandler {
|
||||
|
|
|
@ -44,7 +44,7 @@ import org.apache.hadoop.yarn.api.protocolrecords.ResourceLocalizationRequest;
|
|||
import org.apache.hadoop.yarn.api.protocolrecords.ResourceLocalizationResponse;
|
||||
import org.apache.hadoop.yarn.api.protocolrecords.RestartContainerResponse;
|
||||
import org.apache.hadoop.yarn.api.protocolrecords.RollbackResponse;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.Assert;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
|
||||
import org.apache.hadoop.ipc.Server;
|
||||
|
@ -93,8 +93,7 @@ import org.apache.hadoop.yarn.security.ContainerTokenIdentifier;
|
|||
import org.apache.hadoop.yarn.server.api.records.MasterKey;
|
||||
import org.apache.hadoop.yarn.server.nodemanager.security.NMTokenSecretManagerInNM;
|
||||
import org.apache.hadoop.yarn.util.Records;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Timeout;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -108,9 +107,9 @@ public class TestContainerLauncher {
|
|||
static final Logger LOG =
|
||||
LoggerFactory.getLogger(TestContainerLauncher.class);
|
||||
|
||||
@Test
|
||||
@Timeout(10000)
|
||||
@Test (timeout = 10000)
|
||||
public void testPoolSize() throws InterruptedException {
|
||||
|
||||
ApplicationId appId = ApplicationId.newInstance(12345, 67);
|
||||
ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(
|
||||
appId, 3);
|
||||
|
@ -128,10 +127,10 @@ public class TestContainerLauncher {
|
|||
// No events yet
|
||||
assertThat(containerLauncher.initialPoolSize).isEqualTo(
|
||||
MRJobConfig.DEFAULT_MR_AM_CONTAINERLAUNCHER_THREADPOOL_INITIAL_SIZE);
|
||||
Assertions.assertEquals(0, threadPool.getPoolSize());
|
||||
Assertions.assertEquals(containerLauncher.initialPoolSize,
|
||||
Assert.assertEquals(0, threadPool.getPoolSize());
|
||||
Assert.assertEquals(containerLauncher.initialPoolSize,
|
||||
threadPool.getCorePoolSize());
|
||||
Assertions.assertNull(containerLauncher.foundErrors);
|
||||
Assert.assertNull(containerLauncher.foundErrors);
|
||||
|
||||
containerLauncher.expectedCorePoolSize = containerLauncher.initialPoolSize;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
|
@ -142,8 +141,8 @@ public class TestContainerLauncher {
|
|||
ContainerLauncher.EventType.CONTAINER_REMOTE_LAUNCH));
|
||||
}
|
||||
waitForEvents(containerLauncher, 10);
|
||||
Assertions.assertEquals(10, threadPool.getPoolSize());
|
||||
Assertions.assertNull(containerLauncher.foundErrors);
|
||||
Assert.assertEquals(10, threadPool.getPoolSize());
|
||||
Assert.assertNull(containerLauncher.foundErrors);
|
||||
|
||||
// Same set of hosts, so no change
|
||||
containerLauncher.finishEventHandling = true;
|
||||
|
@ -154,7 +153,7 @@ public class TestContainerLauncher {
|
|||
+ ". Timeout is " + timeOut);
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
Assertions.assertEquals(10, containerLauncher.numEventsProcessed.get());
|
||||
Assert.assertEquals(10, containerLauncher.numEventsProcessed.get());
|
||||
containerLauncher.finishEventHandling = false;
|
||||
for (int i = 0; i < 10; i++) {
|
||||
ContainerId containerId = ContainerId.newContainerId(appAttemptId,
|
||||
|
@ -166,8 +165,8 @@ public class TestContainerLauncher {
|
|||
ContainerLauncher.EventType.CONTAINER_REMOTE_LAUNCH));
|
||||
}
|
||||
waitForEvents(containerLauncher, 20);
|
||||
Assertions.assertEquals(10, threadPool.getPoolSize());
|
||||
Assertions.assertNull(containerLauncher.foundErrors);
|
||||
Assert.assertEquals(10, threadPool.getPoolSize());
|
||||
Assert.assertNull(containerLauncher.foundErrors);
|
||||
|
||||
// Different hosts, there should be an increase in core-thread-pool size to
|
||||
// 21(11hosts+10buffer)
|
||||
|
@ -180,8 +179,8 @@ public class TestContainerLauncher {
|
|||
containerId, "host11:1234", null,
|
||||
ContainerLauncher.EventType.CONTAINER_REMOTE_LAUNCH));
|
||||
waitForEvents(containerLauncher, 21);
|
||||
Assertions.assertEquals(11, threadPool.getPoolSize());
|
||||
Assertions.assertNull(containerLauncher.foundErrors);
|
||||
Assert.assertEquals(11, threadPool.getPoolSize());
|
||||
Assert.assertNull(containerLauncher.foundErrors);
|
||||
|
||||
containerLauncher.stop();
|
||||
|
||||
|
@ -195,8 +194,7 @@ public class TestContainerLauncher {
|
|||
assertThat(containerLauncher.initialPoolSize).isEqualTo(20);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(5000)
|
||||
@Test(timeout = 5000)
|
||||
public void testPoolLimits() throws InterruptedException {
|
||||
ApplicationId appId = ApplicationId.newInstance(12345, 67);
|
||||
ApplicationAttemptId appAttemptId = ApplicationAttemptId.newInstance(
|
||||
|
@ -224,8 +222,8 @@ public class TestContainerLauncher {
|
|||
ContainerLauncher.EventType.CONTAINER_REMOTE_LAUNCH));
|
||||
}
|
||||
waitForEvents(containerLauncher, 10);
|
||||
Assertions.assertEquals(10, threadPool.getPoolSize());
|
||||
Assertions.assertNull(containerLauncher.foundErrors);
|
||||
Assert.assertEquals(10, threadPool.getPoolSize());
|
||||
Assert.assertNull(containerLauncher.foundErrors);
|
||||
|
||||
// 4 more different hosts, but thread pool size should be capped at 12
|
||||
containerLauncher.expectedCorePoolSize = 12 ;
|
||||
|
@ -235,14 +233,14 @@ public class TestContainerLauncher {
|
|||
ContainerLauncher.EventType.CONTAINER_REMOTE_LAUNCH));
|
||||
}
|
||||
waitForEvents(containerLauncher, 12);
|
||||
Assertions.assertEquals(12, threadPool.getPoolSize());
|
||||
Assertions.assertNull(containerLauncher.foundErrors);
|
||||
Assert.assertEquals(12, threadPool.getPoolSize());
|
||||
Assert.assertNull(containerLauncher.foundErrors);
|
||||
|
||||
// Make some threads ideal so that remaining events are also done.
|
||||
containerLauncher.finishEventHandling = true;
|
||||
waitForEvents(containerLauncher, 14);
|
||||
Assertions.assertEquals(12, threadPool.getPoolSize());
|
||||
Assertions.assertNull(containerLauncher.foundErrors);
|
||||
Assert.assertEquals(12, threadPool.getPoolSize());
|
||||
Assert.assertNull(containerLauncher.foundErrors);
|
||||
|
||||
containerLauncher.stop();
|
||||
}
|
||||
|
@ -256,13 +254,13 @@ public class TestContainerLauncher {
|
|||
+ ". It is now " + containerLauncher.numEventsProcessing.get());
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
Assertions.assertEquals(expectedNumEvents,
|
||||
Assert.assertEquals(expectedNumEvents,
|
||||
containerLauncher.numEventsProcessing.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(15000)
|
||||
@Test(timeout = 15000)
|
||||
public void testSlowNM() throws Exception {
|
||||
|
||||
conf = new Configuration();
|
||||
int maxAttempts = 1;
|
||||
conf.setInt(MRJobConfig.MAP_MAX_ATTEMPTS, maxAttempts);
|
||||
|
@ -292,16 +290,15 @@ public class TestContainerLauncher {
|
|||
app.waitForState(job, JobState.RUNNING);
|
||||
|
||||
Map<TaskId, Task> tasks = job.getTasks();
|
||||
Assertions.assertEquals(1, tasks.size(),
|
||||
"Num tasks is not correct");
|
||||
Assert.assertEquals("Num tasks is not correct", 1, tasks.size());
|
||||
|
||||
Task task = tasks.values().iterator().next();
|
||||
app.waitForState(task, TaskState.SCHEDULED);
|
||||
|
||||
Map<TaskAttemptId, TaskAttempt> attempts = tasks.values().iterator()
|
||||
.next().getAttempts();
|
||||
Assertions.assertEquals(maxAttempts, attempts.size(),
|
||||
"Num attempts is not correct");
|
||||
Assert.assertEquals("Num attempts is not correct", maxAttempts,
|
||||
attempts.size());
|
||||
|
||||
TaskAttempt attempt = attempts.values().iterator().next();
|
||||
app.waitForInternalState((TaskAttemptImpl) attempt,
|
||||
|
@ -312,9 +309,9 @@ public class TestContainerLauncher {
|
|||
String diagnostics = attempt.getDiagnostics().toString();
|
||||
LOG.info("attempt.getDiagnostics: " + diagnostics);
|
||||
|
||||
Assertions.assertTrue(diagnostics.contains("Container launch failed for "
|
||||
Assert.assertTrue(diagnostics.contains("Container launch failed for "
|
||||
+ "container_0_0000_01_000000 : "));
|
||||
Assertions
|
||||
Assert
|
||||
.assertTrue(diagnostics
|
||||
.contains("java.net.SocketTimeoutException: 3000 millis timeout while waiting for channel"));
|
||||
|
||||
|
@ -443,7 +440,7 @@ public class TestContainerLauncher {
|
|||
MRApp.newContainerTokenIdentifier(request.getContainerToken());
|
||||
|
||||
// Validate that the container is what RM is giving.
|
||||
Assertions.assertEquals(MRApp.NM_HOST + ":" + MRApp.NM_PORT,
|
||||
Assert.assertEquals(MRApp.NM_HOST + ":" + MRApp.NM_PORT,
|
||||
containerTokenIdentifier.getNmHostAddress());
|
||||
|
||||
StartContainersResponse response = recordFactory
|
||||
|
|
|
@ -79,9 +79,8 @@ import org.apache.hadoop.yarn.exceptions.YarnException;
|
|||
import org.apache.hadoop.yarn.factories.RecordFactory;
|
||||
import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
|
||||
import org.apache.hadoop.yarn.security.ContainerTokenIdentifier;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Timeout;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -95,7 +94,7 @@ public class TestContainerLauncherImpl {
|
|||
private Map<String, ByteBuffer> serviceResponse =
|
||||
new HashMap<String, ByteBuffer>();
|
||||
|
||||
@BeforeEach
|
||||
@Before
|
||||
public void setup() throws IOException {
|
||||
serviceResponse.clear();
|
||||
serviceResponse.put(ShuffleHandler.MAPREDUCE_SHUFFLE_SERVICEID,
|
||||
|
@ -169,8 +168,7 @@ public class TestContainerLauncherImpl {
|
|||
return MRBuilderUtils.newTaskAttemptId(tID, id);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(5000)
|
||||
@Test(timeout = 5000)
|
||||
public void testHandle() throws Exception {
|
||||
LOG.info("STARTING testHandle");
|
||||
AppContext mockContext = mock(AppContext.class);
|
||||
|
@ -228,8 +226,7 @@ public class TestContainerLauncherImpl {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(5000)
|
||||
@Test(timeout = 5000)
|
||||
public void testOutOfOrder() throws Exception {
|
||||
LOG.info("STARTING testOutOfOrder");
|
||||
AppContext mockContext = mock(AppContext.class);
|
||||
|
@ -303,8 +300,7 @@ public class TestContainerLauncherImpl {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(5000)
|
||||
@Test(timeout = 5000)
|
||||
public void testMyShutdown() throws Exception {
|
||||
LOG.info("in test Shutdown");
|
||||
|
||||
|
@ -356,8 +352,7 @@ public class TestContainerLauncherImpl {
|
|||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@Test
|
||||
@Timeout(5000)
|
||||
@Test(timeout = 5000)
|
||||
public void testContainerCleaned() throws Exception {
|
||||
LOG.info("STARTING testContainerCleaned");
|
||||
|
||||
|
|
|
@ -69,8 +69,8 @@ import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
|
|||
import org.apache.hadoop.yarn.ipc.RPCUtil;
|
||||
import org.apache.hadoop.yarn.security.AMRMTokenIdentifier;
|
||||
import org.apache.hadoop.yarn.util.resource.Resources;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
public class TestLocalContainerAllocator {
|
||||
|
@ -90,7 +90,7 @@ public class TestLocalContainerAllocator {
|
|||
lca.start();
|
||||
try {
|
||||
lca.heartbeat();
|
||||
Assertions.fail("heartbeat was supposed to throw");
|
||||
Assert.fail("heartbeat was supposed to throw");
|
||||
} catch (YarnException e) {
|
||||
// YarnException is expected
|
||||
} finally {
|
||||
|
@ -104,7 +104,7 @@ public class TestLocalContainerAllocator {
|
|||
lca.start();
|
||||
try {
|
||||
lca.heartbeat();
|
||||
Assertions.fail("heartbeat was supposed to throw");
|
||||
Assert.fail("heartbeat was supposed to throw");
|
||||
} catch (YarnRuntimeException e) {
|
||||
// YarnRuntimeException is expected
|
||||
} finally {
|
||||
|
@ -172,13 +172,14 @@ public class TestLocalContainerAllocator {
|
|||
}
|
||||
}
|
||||
|
||||
Assertions.assertEquals(1, tokenCount, "too many AMRM tokens");
|
||||
Assertions.assertArrayEquals(newToken.getIdentifier(), ugiToken.getIdentifier(),
|
||||
"token identifier not updated");
|
||||
Assertions.assertArrayEquals(newToken.getPassword(), ugiToken.getPassword(),
|
||||
"token password not updated");
|
||||
Assertions.assertEquals(new Text(ClientRMProxy.getAMRMTokenService(conf)),
|
||||
ugiToken.getService(), "AMRM token service not updated");
|
||||
Assert.assertEquals("too many AMRM tokens", 1, tokenCount);
|
||||
Assert.assertArrayEquals("token identifier not updated",
|
||||
newToken.getIdentifier(), ugiToken.getIdentifier());
|
||||
Assert.assertArrayEquals("token password not updated",
|
||||
newToken.getPassword(), ugiToken.getPassword());
|
||||
Assert.assertEquals("AMRM token service not updated",
|
||||
new Text(ClientRMProxy.getAMRMTokenService(conf)),
|
||||
ugiToken.getService());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -201,7 +202,7 @@ public class TestLocalContainerAllocator {
|
|||
verify(eventHandler, times(1)).handle(containerAssignedCaptor.capture());
|
||||
Container container = containerAssignedCaptor.getValue().getContainer();
|
||||
Resource containerResource = container.getResource();
|
||||
Assertions.assertNotNull(containerResource);
|
||||
Assert.assertNotNull(containerResource);
|
||||
assertThat(containerResource.getMemorySize()).isEqualTo(0);
|
||||
assertThat(containerResource.getVirtualCores()).isEqualTo(0);
|
||||
}
|
||||
|
@ -281,8 +282,8 @@ public class TestLocalContainerAllocator {
|
|||
@Override
|
||||
public AllocateResponse allocate(AllocateRequest request)
|
||||
throws YarnException, IOException {
|
||||
Assertions.assertEquals(responseId, request.getResponseId(),
|
||||
"response ID mismatch");
|
||||
Assert.assertEquals("response ID mismatch",
|
||||
responseId, request.getResponseId());
|
||||
++responseId;
|
||||
org.apache.hadoop.yarn.api.records.Token yarnToken = null;
|
||||
if (amToken != null) {
|
||||
|
|
|
@ -25,20 +25,19 @@ import org.apache.hadoop.metrics2.MetricsRecordBuilder;
|
|||
import static org.apache.hadoop.test.MetricsAsserts.*;
|
||||
|
||||
import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
public class TestMRAppMetrics {
|
||||
|
||||
@AfterEach
|
||||
@After
|
||||
public void tearDown() {
|
||||
DefaultMetricsSystem.shutdown();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNames() {
|
||||
@Test public void testNames() {
|
||||
Job job = mock(Job.class);
|
||||
Task mapTask = mock(Task.class);
|
||||
when(mapTask.getType()).thenReturn(TaskType.MAP);
|
||||
|
|
|
@ -23,8 +23,7 @@ import org.apache.hadoop.mapreduce.v2.app.client.ClientService;
|
|||
import org.apache.hadoop.mapreduce.v2.app.rm.RMCommunicator.AllocatorRunnable;
|
||||
import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
|
||||
import org.apache.hadoop.yarn.util.Clock;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.Timeout;
|
||||
import org.junit.Test;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
|
@ -46,8 +45,7 @@ public class TestRMCommunicator {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(2000)
|
||||
@Test(timeout = 2000)
|
||||
public void testRMContainerAllocatorExceptionIsHandled() throws Exception {
|
||||
ClientService mockClientService = mock(ClientService.class);
|
||||
AppContext mockContext = mock(AppContext.class);
|
||||
|
@ -68,8 +66,7 @@ public class TestRMCommunicator {
|
|||
testRunnable.run();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Timeout(2000)
|
||||
@Test(timeout = 2000)
|
||||
public void testRMContainerAllocatorYarnRuntimeExceptionIsHandled()
|
||||
throws Exception {
|
||||
ClientService mockClientService = mock(ClientService.class);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -19,8 +19,8 @@
|
|||
package org.apache.hadoop.mapreduce.v2.app.rm;
|
||||
|
||||
import org.apache.hadoop.yarn.api.records.Resource;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
|
@ -59,17 +59,17 @@ public class TestResourceCalculatorUtils {
|
|||
Resource nonZeroResource, int expectedNumberOfContainersForMemoryOnly,
|
||||
int expectedNumberOfContainersOverall) {
|
||||
|
||||
Assertions.assertEquals(expectedNumberOfContainersForMemoryOnly,
|
||||
Assert.assertEquals("Incorrect number of available containers for Memory",
|
||||
expectedNumberOfContainersForMemoryOnly,
|
||||
ResourceCalculatorUtils.computeAvailableContainers(
|
||||
clusterAvailableResources, nonZeroResource,
|
||||
EnumSet.of(SchedulerResourceTypes.MEMORY)),
|
||||
"Incorrect number of available containers for Memory");
|
||||
EnumSet.of(SchedulerResourceTypes.MEMORY)));
|
||||
|
||||
Assertions.assertEquals(expectedNumberOfContainersOverall,
|
||||
Assert.assertEquals("Incorrect number of available containers overall",
|
||||
expectedNumberOfContainersOverall,
|
||||
ResourceCalculatorUtils.computeAvailableContainers(
|
||||
clusterAvailableResources, nonZeroResource,
|
||||
EnumSet.of(SchedulerResourceTypes.CPU,
|
||||
SchedulerResourceTypes.MEMORY)),
|
||||
"Incorrect number of available containers overall");
|
||||
SchedulerResourceTypes.MEMORY)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
|
||||
package org.apache.hadoop.mapreduce.v2.app.speculate;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TestDataStatistics {
|
||||
|
||||
|
@ -28,21 +28,21 @@ public class TestDataStatistics {
|
|||
@Test
|
||||
public void testEmptyDataStatistics() throws Exception {
|
||||
DataStatistics statistics = new DataStatistics();
|
||||
Assertions.assertEquals(0, statistics.count(), TOL);
|
||||
Assertions.assertEquals(0, statistics.mean(), TOL);
|
||||
Assertions.assertEquals(0, statistics.var(), TOL);
|
||||
Assertions.assertEquals(0, statistics.std(), TOL);
|
||||
Assertions.assertEquals(0, statistics.outlier(1.0f), TOL);
|
||||
Assert.assertEquals(0, statistics.count(), TOL);
|
||||
Assert.assertEquals(0, statistics.mean(), TOL);
|
||||
Assert.assertEquals(0, statistics.var(), TOL);
|
||||
Assert.assertEquals(0, statistics.std(), TOL);
|
||||
Assert.assertEquals(0, statistics.outlier(1.0f), TOL);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSingleEntryDataStatistics() throws Exception {
|
||||
DataStatistics statistics = new DataStatistics(17.29);
|
||||
Assertions.assertEquals(1, statistics.count(), TOL);
|
||||
Assertions.assertEquals(17.29, statistics.mean(), TOL);
|
||||
Assertions.assertEquals(0, statistics.var(), TOL);
|
||||
Assertions.assertEquals(0, statistics.std(), TOL);
|
||||
Assertions.assertEquals(17.29, statistics.outlier(1.0f), TOL);
|
||||
Assert.assertEquals(1, statistics.count(), TOL);
|
||||
Assert.assertEquals(17.29, statistics.mean(), TOL);
|
||||
Assert.assertEquals(0, statistics.var(), TOL);
|
||||
Assert.assertEquals(0, statistics.std(), TOL);
|
||||
Assert.assertEquals(17.29, statistics.outlier(1.0f), TOL);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -50,24 +50,24 @@ public class TestDataStatistics {
|
|||
DataStatistics statistics = new DataStatistics();
|
||||
statistics.add(17);
|
||||
statistics.add(29);
|
||||
Assertions.assertEquals(2, statistics.count(), TOL);
|
||||
Assertions.assertEquals(23.0, statistics.mean(), TOL);
|
||||
Assertions.assertEquals(36.0, statistics.var(), TOL);
|
||||
Assertions.assertEquals(6.0, statistics.std(), TOL);
|
||||
Assertions.assertEquals(29.0, statistics.outlier(1.0f), TOL);
|
||||
Assert.assertEquals(2, statistics.count(), TOL);
|
||||
Assert.assertEquals(23.0, statistics.mean(), TOL);
|
||||
Assert.assertEquals(36.0, statistics.var(), TOL);
|
||||
Assert.assertEquals(6.0, statistics.std(), TOL);
|
||||
Assert.assertEquals(29.0, statistics.outlier(1.0f), TOL);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpdateStatistics() throws Exception {
|
||||
DataStatistics statistics = new DataStatistics(17);
|
||||
statistics.add(29);
|
||||
Assertions.assertEquals(2, statistics.count(), TOL);
|
||||
Assertions.assertEquals(23.0, statistics.mean(), TOL);
|
||||
Assertions.assertEquals(36.0, statistics.var(), TOL);
|
||||
Assert.assertEquals(2, statistics.count(), TOL);
|
||||
Assert.assertEquals(23.0, statistics.mean(), TOL);
|
||||
Assert.assertEquals(36.0, statistics.var(), TOL);
|
||||
|
||||
statistics.updateStatistics(17, 29);
|
||||
Assertions.assertEquals(2, statistics.count(), TOL);
|
||||
Assertions.assertEquals(29.0, statistics.mean(), TOL);
|
||||
Assertions.assertEquals(0.0, statistics.var(), TOL);
|
||||
Assert.assertEquals(2, statistics.count(), TOL);
|
||||
Assert.assertEquals(29.0, statistics.mean(), TOL);
|
||||
Assert.assertEquals(0.0, statistics.var(), TOL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,13 +18,14 @@
|
|||
|
||||
package org.apache.hadoop.mapreduce.v2.app.speculate.forecast;
|
||||
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.apache.hadoop.yarn.util.ControlledClock;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Testing the statistical model of simple exponential estimator.
|
||||
*/
|
||||
|
@ -100,21 +101,21 @@ public class TestSimpleExponentialForecast {
|
|||
@Test
|
||||
public void testSimpleExponentialForecastLinearInc() throws Exception {
|
||||
int res = incTestSimpleExponentialForecast();
|
||||
Assertions.assertEquals(res, 0,
|
||||
"We got the wrong estimate from simple exponential.");
|
||||
Assert.assertEquals("We got the wrong estimate from simple exponential.",
|
||||
res, 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleExponentialForecastLinearDec() throws Exception {
|
||||
int res = decTestSimpleExponentialForecast();
|
||||
Assertions.assertEquals(res, 0,
|
||||
"We got the wrong estimate from simple exponential.");
|
||||
Assert.assertEquals("We got the wrong estimate from simple exponential.",
|
||||
res, 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleExponentialForecastZeros() throws Exception {
|
||||
int res = zeroTestSimpleExponentialForecast();
|
||||
Assertions.assertEquals(res, 0,
|
||||
"We got the wrong estimate from simple exponential.");
|
||||
Assert.assertEquals("We got the wrong estimate from simple exponential.",
|
||||
res, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
package org.apache.hadoop.mapreduce.v2.app.webapp;
|
||||
|
||||
import static org.apache.hadoop.mapreduce.v2.app.webapp.AMParams.APP_ID;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
|
@ -39,7 +39,7 @@ import javax.net.ssl.SSLException;
|
|||
|
||||
import org.apache.hadoop.mapreduce.MRJobConfig;
|
||||
import org.apache.hadoop.security.ssl.KeyStoreTestUtil;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.Assert;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.http.HttpConfig.Policy;
|
||||
|
@ -65,17 +65,14 @@ import org.apache.hadoop.yarn.webapp.WebApps;
|
|||
import org.apache.hadoop.yarn.webapp.test.WebAppTests;
|
||||
import org.apache.hadoop.yarn.webapp.util.WebAppUtils;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.After;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.apache.hadoop.thirdparty.com.google.common.net.HttpHeaders;
|
||||
import com.google.inject.Injector;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import uk.org.webcompere.systemstubs.environment.EnvironmentVariables;
|
||||
import uk.org.webcompere.systemstubs.jupiter.SystemStub;
|
||||
import uk.org.webcompere.systemstubs.jupiter.SystemStubsExtension;
|
||||
import org.junit.contrib.java.lang.system.EnvironmentVariables;
|
||||
|
||||
@ExtendWith(SystemStubsExtension.class)
|
||||
public class TestAMWebApp {
|
||||
|
||||
private static final File TEST_DIR = new File(
|
||||
|
@ -83,13 +80,12 @@ public class TestAMWebApp {
|
|||
System.getProperty("java.io.tmpdir")),
|
||||
TestAMWebApp.class.getName());
|
||||
|
||||
@AfterEach
|
||||
@After
|
||||
public void tearDown() {
|
||||
TEST_DIR.delete();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAppControllerIndex() {
|
||||
@Test public void testAppControllerIndex() {
|
||||
AppContext ctx = new MockAppContext(0, 1, 1, 1);
|
||||
Injector injector = WebAppTests.createMockInjector(AppContext.class, ctx);
|
||||
AppController controller = injector.getInstance(AppController.class);
|
||||
|
@ -97,29 +93,25 @@ public class TestAMWebApp {
|
|||
assertEquals(ctx.getApplicationID().toString(), controller.get(APP_ID,""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAppView() {
|
||||
@Test public void testAppView() {
|
||||
WebAppTests.testPage(AppView.class, AppContext.class, new MockAppContext(0, 1, 1, 1));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testJobView() {
|
||||
@Test public void testJobView() {
|
||||
AppContext appContext = new MockAppContext(0, 1, 1, 1);
|
||||
Map<String, String> params = getJobParams(appContext);
|
||||
WebAppTests.testPage(JobPage.class, AppContext.class, appContext, params);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTasksView() {
|
||||
@Test public void testTasksView() {
|
||||
AppContext appContext = new MockAppContext(0, 1, 1, 1);
|
||||
Map<String, String> params = getTaskParams(appContext);
|
||||
WebAppTests.testPage(TasksPage.class, AppContext.class, appContext, params);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTaskView() {
|
||||
@Test public void testTaskView() {
|
||||
AppContext appContext = new MockAppContext(0, 1, 1, 1);
|
||||
Map<String, String> params = getTaskParams(appContext);
|
||||
App app = new App(appContext);
|
||||
|
@ -146,22 +138,19 @@ public class TestAMWebApp {
|
|||
return params;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConfView() {
|
||||
@Test public void testConfView() {
|
||||
WebAppTests.testPage(JobConfPage.class, AppContext.class,
|
||||
new MockAppContext(0, 1, 1, 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCountersView() {
|
||||
@Test public void testCountersView() {
|
||||
AppContext appContext = new MockAppContext(0, 1, 1, 1);
|
||||
Map<String, String> params = getJobParams(appContext);
|
||||
WebAppTests.testPage(CountersPage.class, AppContext.class,
|
||||
appContext, params);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSingleCounterView() {
|
||||
@Test public void testSingleCounterView() {
|
||||
AppContext appContext = new MockAppContext(0, 1, 1, 1);
|
||||
Job job = appContext.getAllJobs().values().iterator().next();
|
||||
// add a failed task to the job without any counters
|
||||
|
@ -176,16 +165,14 @@ public class TestAMWebApp {
|
|||
appContext, params);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTaskCountersView() {
|
||||
@Test public void testTaskCountersView() {
|
||||
AppContext appContext = new MockAppContext(0, 1, 1, 1);
|
||||
Map<String, String> params = getTaskParams(appContext);
|
||||
WebAppTests.testPage(CountersPage.class, AppContext.class,
|
||||
appContext, params);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSingleTaskCounterView() {
|
||||
@Test public void testSingleTaskCounterView() {
|
||||
AppContext appContext = new MockAppContext(0, 1, 1, 2);
|
||||
Map<String, String> params = getTaskParams(appContext);
|
||||
params.put(AMParams.COUNTER_GROUP,
|
||||
|
@ -226,7 +213,7 @@ public class TestAMWebApp {
|
|||
InputStream in = conn.getInputStream();
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
IOUtils.copyBytes(in, out, 1024);
|
||||
Assertions.assertTrue(out.toString().contains("MapReduce Application"));
|
||||
Assert.assertTrue(out.toString().contains("MapReduce Application"));
|
||||
|
||||
// https:// is not accessible.
|
||||
URL httpsUrl = new URL("https://" + hostPort);
|
||||
|
@ -234,7 +221,7 @@ public class TestAMWebApp {
|
|||
HttpURLConnection httpsConn =
|
||||
(HttpURLConnection) httpsUrl.openConnection();
|
||||
httpsConn.getInputStream();
|
||||
Assertions.fail("https:// is not accessible, expected to fail");
|
||||
Assert.fail("https:// is not accessible, expected to fail");
|
||||
} catch (SSLException e) {
|
||||
// expected
|
||||
}
|
||||
|
@ -243,8 +230,9 @@ public class TestAMWebApp {
|
|||
app.verifyCompleted();
|
||||
}
|
||||
|
||||
@SystemStub
|
||||
public EnvironmentVariables environmentVariables;
|
||||
@Rule
|
||||
public final EnvironmentVariables environmentVariables
|
||||
= new EnvironmentVariables();
|
||||
|
||||
@Test
|
||||
public void testMRWebAppSSLEnabled() throws Exception {
|
||||
|
@ -282,7 +270,7 @@ public class TestAMWebApp {
|
|||
InputStream in = httpsConn.getInputStream();
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
IOUtils.copyBytes(in, out, 1024);
|
||||
Assertions.assertTrue(out.toString().contains("MapReduce Application"));
|
||||
Assert.assertTrue(out.toString().contains("MapReduce Application"));
|
||||
|
||||
// http:// is not accessible.
|
||||
URL httpUrl = new URL("http://" + hostPort);
|
||||
|
@ -290,7 +278,7 @@ public class TestAMWebApp {
|
|||
HttpURLConnection httpConn =
|
||||
(HttpURLConnection) httpUrl.openConnection();
|
||||
httpConn.getResponseCode();
|
||||
Assertions.fail("http:// is not accessible, expected to fail");
|
||||
Assert.fail("http:// is not accessible, expected to fail");
|
||||
} catch (SocketException e) {
|
||||
// expected
|
||||
}
|
||||
|
@ -349,7 +337,7 @@ public class TestAMWebApp {
|
|||
InputStream in = httpsConn.getInputStream();
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
IOUtils.copyBytes(in, out, 1024);
|
||||
Assertions.assertTrue(out.toString().contains("MapReduce Application"));
|
||||
Assert.assertTrue(out.toString().contains("MapReduce Application"));
|
||||
|
||||
// Try with wrong client cert
|
||||
KeyPair otherClientKeyPair = KeyStoreTestUtil.generateKeyPair("RSA");
|
||||
|
@ -361,7 +349,7 @@ public class TestAMWebApp {
|
|||
HttpURLConnection httpConn =
|
||||
(HttpURLConnection) httpsUrl.openConnection();
|
||||
httpConn.getResponseCode();
|
||||
Assertions.fail("Wrong client certificate, expected to fail");
|
||||
Assert.fail("Wrong client certificate, expected to fail");
|
||||
} catch (SSLException e) {
|
||||
// expected
|
||||
}
|
||||
|
@ -416,9 +404,9 @@ public class TestAMWebApp {
|
|||
String expectedURL = scheme + conf.get(YarnConfiguration.PROXY_ADDRESS)
|
||||
+ ProxyUriUtils.getPath(app.getAppID(), "/mapreduce", true);
|
||||
|
||||
Assertions.assertEquals(expectedURL,
|
||||
Assert.assertEquals(expectedURL,
|
||||
conn.getHeaderField(HttpHeaders.LOCATION));
|
||||
Assertions.assertEquals(HttpStatus.SC_MOVED_TEMPORARILY,
|
||||
Assert.assertEquals(HttpStatus.SC_MOVED_TEMPORARILY,
|
||||
conn.getResponseCode());
|
||||
app.waitForState(job, JobState.SUCCEEDED);
|
||||
app.verifyCompleted();
|
||||
|
|
|
@ -19,9 +19,9 @@
|
|||
package org.apache.hadoop.mapreduce.v2.app.webapp;
|
||||
|
||||
import static org.apache.hadoop.yarn.webapp.WebServicesTestUtils.assertResponseStatusCode;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.util.Set;
|
||||
|
@ -43,8 +43,8 @@ import org.apache.hadoop.yarn.webapp.WebServicesTestUtils;
|
|||
import org.codehaus.jettison.json.JSONArray;
|
||||
import org.codehaus.jettison.json.JSONException;
|
||||
import org.codehaus.jettison.json.JSONObject;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
@ -93,7 +93,7 @@ public class TestAMWebServices extends JerseyTestBase {
|
|||
Guice.createInjector(new WebServletModule()));
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
@Before
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
@ -117,7 +117,7 @@ public class TestAMWebServices extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
verifyAMInfo(json.getJSONObject("info"), appContext);
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ public class TestAMWebServices extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
verifyAMInfo(json.getJSONObject("info"), appContext);
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ public class TestAMWebServices extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
verifyAMInfo(json.getJSONObject("info"), appContext);
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ public class TestAMWebServices extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
verifyAMInfo(json.getJSONObject("info"), appContext);
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ public class TestAMWebServices extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
verifyAMInfo(json.getJSONObject("info"), appContext);
|
||||
}
|
||||
|
||||
|
@ -190,7 +190,7 @@ public class TestAMWebServices extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
verifyAMInfo(json.getJSONObject("info"), appContext);
|
||||
}
|
||||
|
||||
|
@ -264,7 +264,7 @@ public class TestAMWebServices extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
verifyBlacklistedNodesInfo(json, appContext);
|
||||
}
|
||||
|
||||
|
@ -282,7 +282,7 @@ public class TestAMWebServices extends JerseyTestBase {
|
|||
|
||||
public void verifyAMInfo(JSONObject info, AppContext ctx)
|
||||
throws JSONException {
|
||||
assertEquals(5, info.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 5, info.length());
|
||||
|
||||
verifyAMInfoGeneric(ctx, info.getString("appId"), info.getString("user"),
|
||||
info.getString("name"), info.getLong("startedOn"),
|
||||
|
@ -297,7 +297,7 @@ public class TestAMWebServices extends JerseyTestBase {
|
|||
is.setCharacterStream(new StringReader(xml));
|
||||
Document dom = db.parse(is);
|
||||
NodeList nodes = dom.getElementsByTagName("info");
|
||||
assertEquals(1, nodes.getLength(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, nodes.getLength());
|
||||
|
||||
for (int i = 0; i < nodes.getLength(); i++) {
|
||||
Element element = (Element) nodes.item(i);
|
||||
|
@ -320,8 +320,8 @@ public class TestAMWebServices extends JerseyTestBase {
|
|||
WebServicesTestUtils.checkStringMatch("name", ctx.getApplicationName(),
|
||||
name);
|
||||
|
||||
assertEquals(ctx.getStartTime(), startedOn, "startedOn incorrect");
|
||||
assertTrue((elapsedTime > 0), "elapsedTime not greater then 0");
|
||||
assertEquals("startedOn incorrect", ctx.getStartTime(), startedOn);
|
||||
assertTrue("elapsedTime not greater then 0", (elapsedTime > 0));
|
||||
|
||||
}
|
||||
|
||||
|
@ -342,11 +342,11 @@ public class TestAMWebServices extends JerseyTestBase {
|
|||
is.setCharacterStream(new StringReader(xml));
|
||||
Document dom = db.parse(is);
|
||||
NodeList infonodes = dom.getElementsByTagName("blacklistednodesinfo");
|
||||
assertEquals(1, infonodes.getLength(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, infonodes.getLength());
|
||||
NodeList nodes = dom.getElementsByTagName("blacklistedNodes");
|
||||
Set<String> blacklistedNodes = ctx.getBlacklistedNodes();
|
||||
assertEquals(blacklistedNodes.size(),
|
||||
nodes.getLength(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", blacklistedNodes.size(),
|
||||
nodes.getLength());
|
||||
for (int i = 0; i < nodes.getLength(); i++) {
|
||||
Element element = (Element) nodes.item(i);
|
||||
assertTrue(
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
|
||||
package org.apache.hadoop.mapreduce.v2.app.webapp;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.util.Enumeration;
|
||||
|
@ -50,8 +50,8 @@ import org.apache.hadoop.yarn.webapp.GuiceServletConfig;
|
|||
import org.apache.hadoop.yarn.webapp.JerseyTestBase;
|
||||
import org.apache.hadoop.yarn.webapp.WebServicesTestUtils;
|
||||
import org.codehaus.jettison.json.JSONObject;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
@ -118,7 +118,7 @@ public class TestAMWebServicesAttempt extends JerseyTestBase {
|
|||
Guice.createInjector(new WebServletModule()));
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
@Before
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
@ -157,7 +157,7 @@ public class TestAMWebServicesAttempt extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; "
|
||||
+ JettyUtils.UTF_8, response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
assertEquals(att.getState().toString(), json.get("state"));
|
||||
}
|
||||
}
|
||||
|
@ -226,8 +226,7 @@ public class TestAMWebServicesAttempt extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; "
|
||||
+ JettyUtils.UTF_8, response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(),
|
||||
"incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
assertEquals(TaskAttemptState.KILLED.toString(), json.get("state"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
package org.apache.hadoop.mapreduce.v2.app.webapp;
|
||||
|
||||
import static org.apache.hadoop.yarn.webapp.WebServicesTestUtils.assertResponseStatusCode;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.util.List;
|
||||
|
@ -52,8 +52,8 @@ import org.apache.hadoop.yarn.webapp.WebServicesTestUtils;
|
|||
import org.codehaus.jettison.json.JSONArray;
|
||||
import org.codehaus.jettison.json.JSONException;
|
||||
import org.codehaus.jettison.json.JSONObject;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
@ -101,7 +101,7 @@ public class TestAMWebServicesAttempts extends JerseyTestBase {
|
|||
Guice.createInjector(new WebServletModule()));
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
@Before
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
@ -199,7 +199,7 @@ public class TestAMWebServicesAttempts extends JerseyTestBase {
|
|||
is.setCharacterStream(new StringReader(xml));
|
||||
Document dom = db.parse(is);
|
||||
NodeList attempts = dom.getElementsByTagName("taskAttempts");
|
||||
assertEquals(1, attempts.getLength(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, attempts.getLength());
|
||||
|
||||
NodeList nodes = dom.getElementsByTagName("taskAttempt");
|
||||
verifyAMTaskAttemptsXML(nodes, task);
|
||||
|
@ -229,7 +229,7 @@ public class TestAMWebServicesAttempts extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; "
|
||||
+ JettyUtils.UTF_8, response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
JSONObject info = json.getJSONObject("taskAttempt");
|
||||
verifyAMTaskAttempt(info, att, task.getType());
|
||||
}
|
||||
|
@ -259,7 +259,7 @@ public class TestAMWebServicesAttempts extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; "
|
||||
+ JettyUtils.UTF_8, response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
JSONObject info = json.getJSONObject("taskAttempt");
|
||||
verifyAMTaskAttempt(info, att, task.getType());
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ public class TestAMWebServicesAttempts extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; "
|
||||
+ JettyUtils.UTF_8, response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
JSONObject info = json.getJSONObject("taskAttempt");
|
||||
verifyAMTaskAttempt(info, att, task.getType());
|
||||
}
|
||||
|
@ -391,7 +391,7 @@ public class TestAMWebServicesAttempts extends JerseyTestBase {
|
|||
+ JettyUtils.UTF_8, response.getType().toString());
|
||||
JSONObject msg = response.getEntity(JSONObject.class);
|
||||
JSONObject exception = msg.getJSONObject("RemoteException");
|
||||
assertEquals(3, exception.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 3, exception.length());
|
||||
String message = exception.getString("message");
|
||||
String type = exception.getString("exception");
|
||||
String classname = exception.getString("javaClassName");
|
||||
|
@ -434,9 +434,9 @@ public class TestAMWebServicesAttempts extends JerseyTestBase {
|
|||
public void verifyAMTaskAttempt(JSONObject info, TaskAttempt att,
|
||||
TaskType ttype) throws JSONException {
|
||||
if (ttype == TaskType.REDUCE) {
|
||||
assertEquals(17, info.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 17, info.length());
|
||||
} else {
|
||||
assertEquals(12, info.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 12, info.length());
|
||||
}
|
||||
|
||||
verifyTaskAttemptGeneric(att, ttype, info.getString("id"),
|
||||
|
@ -455,9 +455,9 @@ public class TestAMWebServicesAttempts extends JerseyTestBase {
|
|||
|
||||
public void verifyAMTaskAttempts(JSONObject json, Task task)
|
||||
throws JSONException {
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
JSONObject attempts = json.getJSONObject("taskAttempts");
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
JSONArray arr = attempts.getJSONArray("taskAttempt");
|
||||
for (TaskAttempt att : task.getAttempts().values()) {
|
||||
TaskAttemptId id = att.getID();
|
||||
|
@ -471,13 +471,13 @@ public class TestAMWebServicesAttempts extends JerseyTestBase {
|
|||
verifyAMTaskAttempt(info, att, task.getType());
|
||||
}
|
||||
}
|
||||
assertTrue(found, "task attempt with id: " + attid
|
||||
+ " not in web service output");
|
||||
assertTrue("task attempt with id: " + attid
|
||||
+ " not in web service output", found);
|
||||
}
|
||||
}
|
||||
|
||||
public void verifyAMTaskAttemptsXML(NodeList nodes, Task task) {
|
||||
assertEquals(1, nodes.getLength(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, nodes.getLength());
|
||||
|
||||
for (TaskAttempt att : task.getAttempts().values()) {
|
||||
TaskAttemptId id = att.getID();
|
||||
|
@ -485,14 +485,15 @@ public class TestAMWebServicesAttempts extends JerseyTestBase {
|
|||
Boolean found = false;
|
||||
for (int i = 0; i < nodes.getLength(); i++) {
|
||||
Element element = (Element) nodes.item(i);
|
||||
assertFalse(element.hasAttributes(), "task attempt should not contain any attributes, it can lead to incorrect JSON marshaling");
|
||||
assertFalse("task attempt should not contain any attributes, it can lead to incorrect JSON marshaling",
|
||||
element.hasAttributes());
|
||||
|
||||
if (attid.matches(WebServicesTestUtils.getXmlString(element, "id"))) {
|
||||
found = true;
|
||||
verifyAMTaskAttemptXML(element, att, task.getType());
|
||||
}
|
||||
}
|
||||
assertTrue(found, "task with id: " + attid + " not in web service output");
|
||||
assertTrue("task with id: " + attid + " not in web service output", found);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -527,26 +528,26 @@ public class TestAMWebServicesAttempts extends JerseyTestBase {
|
|||
ta.getAssignedContainerID().toString(),
|
||||
assignedContainerId);
|
||||
|
||||
assertEquals(ta.getLaunchTime(), startTime, "startTime wrong");
|
||||
assertEquals(ta.getFinishTime(), finishTime, "finishTime wrong");
|
||||
assertEquals(finishTime - startTime, elapsedTime, "elapsedTime wrong");
|
||||
assertEquals(ta.getProgress() * 100, progress, 1e-3f, "progress wrong");
|
||||
assertEquals("startTime wrong", ta.getLaunchTime(), startTime);
|
||||
assertEquals("finishTime wrong", ta.getFinishTime(), finishTime);
|
||||
assertEquals("elapsedTime wrong", finishTime - startTime, elapsedTime);
|
||||
assertEquals("progress wrong", ta.getProgress() * 100, progress, 1e-3f);
|
||||
}
|
||||
|
||||
public void verifyReduceTaskAttemptGeneric(TaskAttempt ta,
|
||||
long shuffleFinishTime, long mergeFinishTime, long elapsedShuffleTime,
|
||||
long elapsedMergeTime, long elapsedReduceTime) {
|
||||
|
||||
assertEquals(ta.getShuffleFinishTime(),
|
||||
shuffleFinishTime, "shuffleFinishTime wrong");
|
||||
assertEquals(ta.getSortFinishTime(),
|
||||
mergeFinishTime, "mergeFinishTime wrong");
|
||||
assertEquals(ta.getShuffleFinishTime() - ta.getLaunchTime(), elapsedShuffleTime,
|
||||
"elapsedShuffleTime wrong");
|
||||
assertEquals(ta.getSortFinishTime() - ta.getShuffleFinishTime(), elapsedMergeTime,
|
||||
"elapsedMergeTime wrong");
|
||||
assertEquals(ta.getFinishTime() - ta.getSortFinishTime(), elapsedReduceTime,
|
||||
"elapsedReduceTime wrong");
|
||||
assertEquals("shuffleFinishTime wrong", ta.getShuffleFinishTime(),
|
||||
shuffleFinishTime);
|
||||
assertEquals("mergeFinishTime wrong", ta.getSortFinishTime(),
|
||||
mergeFinishTime);
|
||||
assertEquals("elapsedShuffleTime wrong",
|
||||
ta.getShuffleFinishTime() - ta.getLaunchTime(), elapsedShuffleTime);
|
||||
assertEquals("elapsedMergeTime wrong",
|
||||
ta.getSortFinishTime() - ta.getShuffleFinishTime(), elapsedMergeTime);
|
||||
assertEquals("elapsedReduceTime wrong",
|
||||
ta.getFinishTime() - ta.getSortFinishTime(), elapsedReduceTime);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -571,7 +572,7 @@ public class TestAMWebServicesAttempts extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; "
|
||||
+ JettyUtils.UTF_8, response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
JSONObject info = json.getJSONObject("jobTaskAttemptCounters");
|
||||
verifyAMJobTaskAttemptCounters(info, att);
|
||||
}
|
||||
|
@ -616,7 +617,7 @@ public class TestAMWebServicesAttempts extends JerseyTestBase {
|
|||
public void verifyAMJobTaskAttemptCounters(JSONObject info, TaskAttempt att)
|
||||
throws JSONException {
|
||||
|
||||
assertEquals(2, info.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 2, info.length());
|
||||
|
||||
WebServicesTestUtils.checkStringMatch("id", MRApps.toString(att.getID()),
|
||||
info.getString("id"));
|
||||
|
@ -627,15 +628,15 @@ public class TestAMWebServicesAttempts extends JerseyTestBase {
|
|||
for (int i = 0; i < counterGroups.length(); i++) {
|
||||
JSONObject counterGroup = counterGroups.getJSONObject(i);
|
||||
String name = counterGroup.getString("counterGroupName");
|
||||
assertTrue((name != null && !name.isEmpty()), "name not set");
|
||||
assertTrue("name not set", (name != null && !name.isEmpty()));
|
||||
JSONArray counters = counterGroup.getJSONArray("counter");
|
||||
for (int j = 0; j < counters.length(); j++) {
|
||||
JSONObject counter = counters.getJSONObject(j);
|
||||
String counterName = counter.getString("name");
|
||||
assertTrue((counterName != null && !counterName.isEmpty()),
|
||||
"name not set");
|
||||
assertTrue("name not set",
|
||||
(counterName != null && !counterName.isEmpty()));
|
||||
long value = counter.getLong("value");
|
||||
assertTrue(value >= 0, "value >= 0");
|
||||
assertTrue("value >= 0", value >= 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -653,19 +654,20 @@ public class TestAMWebServicesAttempts extends JerseyTestBase {
|
|||
|
||||
for (int j = 0; j < groups.getLength(); j++) {
|
||||
Element counters = (Element) groups.item(j);
|
||||
assertNotNull(counters, "should have counters in the web service info");
|
||||
assertNotNull("should have counters in the web service info", counters);
|
||||
String name = WebServicesTestUtils.getXmlString(counters,
|
||||
"counterGroupName");
|
||||
assertTrue((name != null && !name.isEmpty()), "name not set");
|
||||
assertTrue("name not set", (name != null && !name.isEmpty()));
|
||||
NodeList counterArr = counters.getElementsByTagName("counter");
|
||||
for (int z = 0; z < counterArr.getLength(); z++) {
|
||||
Element counter = (Element) counterArr.item(z);
|
||||
String counterName = WebServicesTestUtils.getXmlString(counter,
|
||||
"name");
|
||||
assertTrue((counterName != null && !counterName.isEmpty()), "counter name not set");
|
||||
assertTrue("counter name not set",
|
||||
(counterName != null && !counterName.isEmpty()));
|
||||
|
||||
long value = WebServicesTestUtils.getXmlLong(counter, "value");
|
||||
assertTrue(value >= 0, "value not >= 0");
|
||||
assertTrue("value not >= 0", value >= 0);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
|
||||
package org.apache.hadoop.mapreduce.v2.app.webapp;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -52,9 +52,9 @@ import org.apache.hadoop.yarn.webapp.WebServicesTestUtils;
|
|||
import org.codehaus.jettison.json.JSONArray;
|
||||
import org.codehaus.jettison.json.JSONException;
|
||||
import org.codehaus.jettison.json.JSONObject;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
@ -126,7 +126,7 @@ public class TestAMWebServicesJobConf extends JerseyTestBase {
|
|||
Guice.createInjector(new WebServletModule()));
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
@Before
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
@ -135,7 +135,7 @@ public class TestAMWebServicesJobConf extends JerseyTestBase {
|
|||
Guice.createInjector(new WebServletModule()));
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
@AfterClass
|
||||
static public void stop() {
|
||||
FileUtil.fullyDelete(testConfDir);
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ public class TestAMWebServicesJobConf extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
JSONObject info = json.getJSONObject("conf");
|
||||
verifyAMJobConf(info, jobsMap.get(id));
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ public class TestAMWebServicesJobConf extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
JSONObject info = json.getJSONObject("conf");
|
||||
verifyAMJobConf(info, jobsMap.get(id));
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ public class TestAMWebServicesJobConf extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
JSONObject info = json.getJSONObject("conf");
|
||||
verifyAMJobConf(info, jobsMap.get(id));
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ public class TestAMWebServicesJobConf extends JerseyTestBase {
|
|||
|
||||
public void verifyAMJobConf(JSONObject info, Job job) throws JSONException {
|
||||
|
||||
assertEquals(2, info.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 2, info.length());
|
||||
|
||||
WebServicesTestUtils.checkStringMatch("path", job.getConfFile().toString(),
|
||||
info.getString("path"));
|
||||
|
@ -240,14 +240,14 @@ public class TestAMWebServicesJobConf extends JerseyTestBase {
|
|||
JSONObject prop = properties.getJSONObject(i);
|
||||
String name = prop.getString("name");
|
||||
String value = prop.getString("value");
|
||||
assertTrue((name != null && !name.isEmpty()), "name not set");
|
||||
assertTrue((value != null && !value.isEmpty()), "value not set");
|
||||
assertTrue("name not set", (name != null && !name.isEmpty()));
|
||||
assertTrue("value not set", (value != null && !value.isEmpty()));
|
||||
}
|
||||
}
|
||||
|
||||
public void verifyAMJobConfXML(NodeList nodes, Job job) {
|
||||
|
||||
assertEquals(1, nodes.getLength(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, nodes.getLength());
|
||||
|
||||
for (int i = 0; i < nodes.getLength(); i++) {
|
||||
Element element = (Element) nodes.item(i);
|
||||
|
@ -260,11 +260,11 @@ public class TestAMWebServicesJobConf extends JerseyTestBase {
|
|||
|
||||
for (int j = 0; j < properties.getLength(); j++) {
|
||||
Element property = (Element) properties.item(j);
|
||||
assertNotNull(property, "should have counters in the web service info");
|
||||
assertNotNull("should have counters in the web service info", property);
|
||||
String name = WebServicesTestUtils.getXmlString(property, "name");
|
||||
String value = WebServicesTestUtils.getXmlString(property, "value");
|
||||
assertTrue((name != null && !name.isEmpty()), "name not set");
|
||||
assertTrue((value != null && !value.isEmpty()), "name not set");
|
||||
assertTrue("name not set", (name != null && !name.isEmpty()));
|
||||
assertTrue("name not set", (value != null && !value.isEmpty()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,10 +20,10 @@ package org.apache.hadoop.mapreduce.v2.app.webapp;
|
|||
|
||||
import static org.apache.hadoop.yarn.util.StringHelper.ujoin;
|
||||
import static org.apache.hadoop.yarn.webapp.WebServicesTestUtils.assertResponseStatusCode;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.util.List;
|
||||
|
@ -54,8 +54,8 @@ import org.apache.hadoop.yarn.webapp.WebServicesTestUtils;
|
|||
import org.codehaus.jettison.json.JSONArray;
|
||||
import org.codehaus.jettison.json.JSONException;
|
||||
import org.codehaus.jettison.json.JSONObject;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
@ -103,7 +103,7 @@ public class TestAMWebServicesJobs extends JerseyTestBase {
|
|||
Guice.createInjector(new WebServletModule()));
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
@Before
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
@ -128,7 +128,7 @@ public class TestAMWebServicesJobs extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
JSONObject jobs = json.getJSONObject("jobs");
|
||||
JSONArray arr = jobs.getJSONArray("job");
|
||||
JSONObject info = arr.getJSONObject(0);
|
||||
|
@ -146,7 +146,7 @@ public class TestAMWebServicesJobs extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
JSONObject jobs = json.getJSONObject("jobs");
|
||||
JSONArray arr = jobs.getJSONArray("job");
|
||||
JSONObject info = arr.getJSONObject(0);
|
||||
|
@ -163,7 +163,7 @@ public class TestAMWebServicesJobs extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
JSONObject jobs = json.getJSONObject("jobs");
|
||||
JSONArray arr = jobs.getJSONArray("job");
|
||||
JSONObject info = arr.getJSONObject(0);
|
||||
|
@ -187,9 +187,9 @@ public class TestAMWebServicesJobs extends JerseyTestBase {
|
|||
is.setCharacterStream(new StringReader(xml));
|
||||
Document dom = db.parse(is);
|
||||
NodeList jobs = dom.getElementsByTagName("jobs");
|
||||
assertEquals(1, jobs.getLength(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, jobs.getLength());
|
||||
NodeList job = dom.getElementsByTagName("job");
|
||||
assertEquals(1, job.getLength(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, job.getLength());
|
||||
verifyAMJobXML(job, appContext);
|
||||
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ public class TestAMWebServicesJobs extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
JSONObject info = json.getJSONObject("job");
|
||||
verifyAMJob(info, jobsMap.get(id));
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ public class TestAMWebServicesJobs extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
JSONObject info = json.getJSONObject("job");
|
||||
verifyAMJob(info, jobsMap.get(id));
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ public class TestAMWebServicesJobs extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
JSONObject info = json.getJSONObject("job");
|
||||
verifyAMJob(info, jobsMap.get(id));
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ public class TestAMWebServicesJobs extends JerseyTestBase {
|
|||
response.getType().toString());
|
||||
JSONObject msg = response.getEntity(JSONObject.class);
|
||||
JSONObject exception = msg.getJSONObject("RemoteException");
|
||||
assertEquals(3, exception.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 3, exception.length());
|
||||
String message = exception.getString("message");
|
||||
String type = exception.getString("exception");
|
||||
String classname = exception.getString("javaClassName");
|
||||
|
@ -295,7 +295,7 @@ public class TestAMWebServicesJobs extends JerseyTestBase {
|
|||
response.getType().toString());
|
||||
JSONObject msg = response.getEntity(JSONObject.class);
|
||||
JSONObject exception = msg.getJSONObject("RemoteException");
|
||||
assertEquals(3, exception.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 3, exception.length());
|
||||
String message = exception.getString("message");
|
||||
String type = exception.getString("exception");
|
||||
String classname = exception.getString("javaClassName");
|
||||
|
@ -319,7 +319,7 @@ public class TestAMWebServicesJobs extends JerseyTestBase {
|
|||
response.getType().toString());
|
||||
JSONObject msg = response.getEntity(JSONObject.class);
|
||||
JSONObject exception = msg.getJSONObject("RemoteException");
|
||||
assertEquals(3, exception.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 3, exception.length());
|
||||
String message = exception.getString("message");
|
||||
String type = exception.getString("exception");
|
||||
String classname = exception.getString("javaClassName");
|
||||
|
@ -383,7 +383,7 @@ public class TestAMWebServicesJobs extends JerseyTestBase {
|
|||
response.getType().toString());
|
||||
JSONObject msg = response.getEntity(JSONObject.class);
|
||||
JSONObject exception = msg.getJSONObject("RemoteException");
|
||||
assertEquals(3, exception.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 3, exception.length());
|
||||
String message = exception.getString("message");
|
||||
String type = exception.getString("exception");
|
||||
String classname = exception.getString("javaClassName");
|
||||
|
@ -425,7 +425,7 @@ public class TestAMWebServicesJobs extends JerseyTestBase {
|
|||
|
||||
public void verifyAMJob(JSONObject info, Job job) throws JSONException {
|
||||
|
||||
assertEquals(31, info.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 31, info.length());
|
||||
|
||||
// everyone access fields
|
||||
verifyAMJobGeneric(job, info.getString("id"), info.getString("user"),
|
||||
|
@ -476,8 +476,8 @@ public class TestAMWebServicesJobs extends JerseyTestBase {
|
|||
} else {
|
||||
fail("should have acls in the web service info");
|
||||
}
|
||||
assertTrue(found,
|
||||
"acl: " + expectName + " not found in webservice output");
|
||||
assertTrue("acl: " + expectName + " not found in webservice output",
|
||||
found);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -485,14 +485,14 @@ public class TestAMWebServicesJobs extends JerseyTestBase {
|
|||
|
||||
public void verifyAMJobXML(NodeList nodes, AppContext appContext) {
|
||||
|
||||
assertEquals(1, nodes.getLength(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, nodes.getLength());
|
||||
|
||||
for (int i = 0; i < nodes.getLength(); i++) {
|
||||
Element element = (Element) nodes.item(i);
|
||||
|
||||
Job job = appContext.getJob(MRApps.toJobID(WebServicesTestUtils
|
||||
.getXmlString(element, "id")));
|
||||
assertNotNull(job, "Job not found - output incorrect");
|
||||
assertNotNull("Job not found - output incorrect", job);
|
||||
|
||||
verifyAMJobGeneric(job, WebServicesTestUtils.getXmlString(element, "id"),
|
||||
WebServicesTestUtils.getXmlString(element, "user"),
|
||||
|
@ -551,8 +551,8 @@ public class TestAMWebServicesJobs extends JerseyTestBase {
|
|||
} else {
|
||||
fail("should have acls in the web service info");
|
||||
}
|
||||
assertTrue(found,
|
||||
"acl: " + expectName + " not found in webservice output");
|
||||
assertTrue("acl: " + expectName + " not found in webservice output",
|
||||
found);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -572,21 +572,21 @@ public class TestAMWebServicesJobs extends JerseyTestBase {
|
|||
WebServicesTestUtils.checkStringMatch("state", job.getState().toString(),
|
||||
state);
|
||||
|
||||
assertEquals(report.getStartTime(), startTime, "startTime incorrect");
|
||||
assertEquals(report.getFinishTime(), finishTime, "finishTime incorrect");
|
||||
assertEquals(Times.elapsed(report.getStartTime(), report.getFinishTime()),
|
||||
elapsedTime, "elapsedTime incorrect");
|
||||
assertEquals(job.getTotalMaps(), mapsTotal, "mapsTotal incorrect");
|
||||
assertEquals(job.getCompletedMaps(), mapsCompleted,
|
||||
"mapsCompleted incorrect");
|
||||
assertEquals(job.getTotalReduces(), reducesTotal,
|
||||
"reducesTotal incorrect");
|
||||
assertEquals(job.getCompletedReduces(), reducesCompleted,
|
||||
"reducesCompleted incorrect");
|
||||
assertEquals(report.getMapProgress() * 100, mapProgress, 0,
|
||||
"mapProgress incorrect");
|
||||
assertEquals(report.getReduceProgress() * 100, reduceProgress, 0,
|
||||
"reduceProgress incorrect");
|
||||
assertEquals("startTime incorrect", report.getStartTime(), startTime);
|
||||
assertEquals("finishTime incorrect", report.getFinishTime(), finishTime);
|
||||
assertEquals("elapsedTime incorrect",
|
||||
Times.elapsed(report.getStartTime(), report.getFinishTime()),
|
||||
elapsedTime);
|
||||
assertEquals("mapsTotal incorrect", job.getTotalMaps(), mapsTotal);
|
||||
assertEquals("mapsCompleted incorrect", job.getCompletedMaps(),
|
||||
mapsCompleted);
|
||||
assertEquals("reducesTotal incorrect", job.getTotalReduces(), reducesTotal);
|
||||
assertEquals("reducesCompleted incorrect", job.getCompletedReduces(),
|
||||
reducesCompleted);
|
||||
assertEquals("mapProgress incorrect", report.getMapProgress() * 100,
|
||||
mapProgress, 0);
|
||||
assertEquals("reduceProgress incorrect", report.getReduceProgress() * 100,
|
||||
reduceProgress, 0);
|
||||
}
|
||||
|
||||
public void verifyAMJobGenericSecure(Job job, int mapsPending,
|
||||
|
@ -609,27 +609,28 @@ public class TestAMWebServicesJobs extends JerseyTestBase {
|
|||
WebServicesTestUtils.checkStringMatch("diagnostics", diagString,
|
||||
diagnostics);
|
||||
|
||||
assertEquals(job.isUber(), uberized, "isUber incorrect");
|
||||
assertEquals("isUber incorrect", job.isUber(), uberized);
|
||||
|
||||
// unfortunately the following fields are all calculated in JobInfo
|
||||
// so not easily accessible without doing all the calculations again.
|
||||
// For now just make sure they are present.
|
||||
assertTrue(mapsPending >= 0, "mapsPending not >= 0");
|
||||
assertTrue(mapsRunning >= 0, "mapsRunning not >= 0");
|
||||
assertTrue(reducesPending >= 0, "reducesPending not >= 0");
|
||||
assertTrue(reducesRunning >= 0, "reducesRunning not >= 0");
|
||||
assertTrue("mapsPending not >= 0", mapsPending >= 0);
|
||||
assertTrue("mapsRunning not >= 0", mapsRunning >= 0);
|
||||
assertTrue("reducesPending not >= 0", reducesPending >= 0);
|
||||
assertTrue("reducesRunning not >= 0", reducesRunning >= 0);
|
||||
|
||||
assertTrue(newReduceAttempts >= 0, "newReduceAttempts not >= 0");
|
||||
assertTrue(runningReduceAttempts >= 0, "runningReduceAttempts not >= 0");
|
||||
assertTrue(failedReduceAttempts >= 0, "failedReduceAttempts not >= 0");
|
||||
assertTrue(killedReduceAttempts >= 0, "killedReduceAttempts not >= 0");
|
||||
assertTrue(successfulReduceAttempts >= 0, "successfulReduceAttempts not >= 0");
|
||||
assertTrue("newReduceAttempts not >= 0", newReduceAttempts >= 0);
|
||||
assertTrue("runningReduceAttempts not >= 0", runningReduceAttempts >= 0);
|
||||
assertTrue("failedReduceAttempts not >= 0", failedReduceAttempts >= 0);
|
||||
assertTrue("killedReduceAttempts not >= 0", killedReduceAttempts >= 0);
|
||||
assertTrue("successfulReduceAttempts not >= 0",
|
||||
successfulReduceAttempts >= 0);
|
||||
|
||||
assertTrue(newMapAttempts >= 0, "newMapAttempts not >= 0");
|
||||
assertTrue(runningMapAttempts >= 0, "runningMapAttempts not >= 0");
|
||||
assertTrue(failedMapAttempts >= 0, "failedMapAttempts not >= 0");
|
||||
assertTrue(killedMapAttempts >= 0, "killedMapAttempts not >= 0");
|
||||
assertTrue(successfulMapAttempts >= 0, "successfulMapAttempts not >= 0");
|
||||
assertTrue("newMapAttempts not >= 0", newMapAttempts >= 0);
|
||||
assertTrue("runningMapAttempts not >= 0", runningMapAttempts >= 0);
|
||||
assertTrue("failedMapAttempts not >= 0", failedMapAttempts >= 0);
|
||||
assertTrue("killedMapAttempts not >= 0", killedMapAttempts >= 0);
|
||||
assertTrue("successfulMapAttempts not >= 0", successfulMapAttempts >= 0);
|
||||
|
||||
}
|
||||
|
||||
|
@ -646,8 +647,7 @@ public class TestAMWebServicesJobs extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(),
|
||||
"incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
JSONObject info = json.getJSONObject("jobCounters");
|
||||
verifyAMJobCounters(info, jobsMap.get(id));
|
||||
}
|
||||
|
@ -666,8 +666,7 @@ public class TestAMWebServicesJobs extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(),
|
||||
"incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
JSONObject info = json.getJSONObject("jobCounters");
|
||||
verifyAMJobCounters(info, jobsMap.get(id));
|
||||
}
|
||||
|
@ -685,8 +684,7 @@ public class TestAMWebServicesJobs extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(),
|
||||
"incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
JSONObject info = json.getJSONObject("jobCounters");
|
||||
verifyAMJobCounters(info, jobsMap.get(id));
|
||||
}
|
||||
|
@ -718,8 +716,7 @@ public class TestAMWebServicesJobs extends JerseyTestBase {
|
|||
public void verifyAMJobCounters(JSONObject info, Job job)
|
||||
throws JSONException {
|
||||
|
||||
assertEquals(2, info.length(),
|
||||
"incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 2, info.length());
|
||||
|
||||
WebServicesTestUtils.checkStringMatch("id", MRApps.toString(job.getID()),
|
||||
info.getString("id"));
|
||||
|
@ -729,22 +726,22 @@ public class TestAMWebServicesJobs extends JerseyTestBase {
|
|||
for (int i = 0; i < counterGroups.length(); i++) {
|
||||
JSONObject counterGroup = counterGroups.getJSONObject(i);
|
||||
String name = counterGroup.getString("counterGroupName");
|
||||
assertTrue((name != null && !name.isEmpty()), "name not set");
|
||||
assertTrue("name not set", (name != null && !name.isEmpty()));
|
||||
JSONArray counters = counterGroup.getJSONArray("counter");
|
||||
for (int j = 0; j < counters.length(); j++) {
|
||||
JSONObject counter = counters.getJSONObject(j);
|
||||
String counterName = counter.getString("name");
|
||||
assertTrue((counterName != null && !counterName.isEmpty()),
|
||||
"counter name not set");
|
||||
assertTrue("counter name not set",
|
||||
(counterName != null && !counterName.isEmpty()));
|
||||
|
||||
long mapValue = counter.getLong("mapCounterValue");
|
||||
assertTrue(mapValue >= 0, "mapCounterValue >= 0");
|
||||
assertTrue("mapCounterValue >= 0", mapValue >= 0);
|
||||
|
||||
long reduceValue = counter.getLong("reduceCounterValue");
|
||||
assertTrue(reduceValue >= 0, "reduceCounterValue >= 0");
|
||||
assertTrue("reduceCounterValue >= 0", reduceValue >= 0);
|
||||
|
||||
long totalValue = counter.getLong("totalCounterValue");
|
||||
assertTrue(totalValue >= 0, "totalCounterValue >= 0");
|
||||
assertTrue("totalCounterValue >= 0", totalValue >= 0);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -755,7 +752,7 @@ public class TestAMWebServicesJobs extends JerseyTestBase {
|
|||
for (int i = 0; i < nodes.getLength(); i++) {
|
||||
Element element = (Element) nodes.item(i);
|
||||
|
||||
assertNotNull(job, "Job not found - output incorrect");
|
||||
assertNotNull("Job not found - output incorrect", job);
|
||||
|
||||
WebServicesTestUtils.checkStringMatch("id", MRApps.toString(job.getID()),
|
||||
WebServicesTestUtils.getXmlString(element, "id"));
|
||||
|
@ -765,30 +762,29 @@ public class TestAMWebServicesJobs extends JerseyTestBase {
|
|||
|
||||
for (int j = 0; j < groups.getLength(); j++) {
|
||||
Element counters = (Element) groups.item(j);
|
||||
assertNotNull(counters,
|
||||
"should have counters in the web service info");
|
||||
assertNotNull("should have counters in the web service info", counters);
|
||||
String name = WebServicesTestUtils.getXmlString(counters,
|
||||
"counterGroupName");
|
||||
assertTrue((name != null && !name.isEmpty()), "name not set");
|
||||
assertTrue("name not set", (name != null && !name.isEmpty()));
|
||||
NodeList counterArr = counters.getElementsByTagName("counter");
|
||||
for (int z = 0; z < counterArr.getLength(); z++) {
|
||||
Element counter = (Element) counterArr.item(z);
|
||||
String counterName = WebServicesTestUtils.getXmlString(counter,
|
||||
"name");
|
||||
assertTrue((counterName != null && !counterName.isEmpty()),
|
||||
"counter name not set");
|
||||
assertTrue("counter name not set",
|
||||
(counterName != null && !counterName.isEmpty()));
|
||||
|
||||
long mapValue = WebServicesTestUtils.getXmlLong(counter,
|
||||
"mapCounterValue");
|
||||
assertTrue(mapValue >= 0, "mapCounterValue not >= 0");
|
||||
assertTrue("mapCounterValue not >= 0", mapValue >= 0);
|
||||
|
||||
long reduceValue = WebServicesTestUtils.getXmlLong(counter,
|
||||
"reduceCounterValue");
|
||||
assertTrue(reduceValue >= 0, "reduceCounterValue >= 0");
|
||||
assertTrue("reduceCounterValue >= 0", reduceValue >= 0);
|
||||
|
||||
long totalValue = WebServicesTestUtils.getXmlLong(counter,
|
||||
"totalCounterValue");
|
||||
assertTrue(totalValue >= 0, "totalCounterValue >= 0");
|
||||
assertTrue("totalCounterValue >= 0", totalValue >= 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -807,7 +803,7 @@ public class TestAMWebServicesJobs extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
JSONObject info = json.getJSONObject("jobAttempts");
|
||||
verifyJobAttempts(info, jobsMap.get(id));
|
||||
}
|
||||
|
@ -826,7 +822,7 @@ public class TestAMWebServicesJobs extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
JSONObject info = json.getJSONObject("jobAttempts");
|
||||
verifyJobAttempts(info, jobsMap.get(id));
|
||||
}
|
||||
|
@ -845,7 +841,7 @@ public class TestAMWebServicesJobs extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
JSONObject info = json.getJSONObject("jobAttempts");
|
||||
verifyJobAttempts(info, jobsMap.get(id));
|
||||
}
|
||||
|
@ -870,8 +866,7 @@ public class TestAMWebServicesJobs extends JerseyTestBase {
|
|||
is.setCharacterStream(new StringReader(xml));
|
||||
Document dom = db.parse(is);
|
||||
NodeList attempts = dom.getElementsByTagName("jobAttempts");
|
||||
assertEquals(1, attempts.getLength(),
|
||||
"incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, attempts.getLength());
|
||||
NodeList info = dom.getElementsByTagName("jobAttempt");
|
||||
verifyJobAttemptsXML(info, jobsMap.get(id));
|
||||
}
|
||||
|
@ -881,8 +876,7 @@ public class TestAMWebServicesJobs extends JerseyTestBase {
|
|||
throws JSONException {
|
||||
|
||||
JSONArray attempts = info.getJSONArray("jobAttempt");
|
||||
assertEquals(2, attempts.length(),
|
||||
"incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 2, attempts.length());
|
||||
for (int i = 0; i < attempts.length(); i++) {
|
||||
JSONObject attempt = attempts.getJSONObject(i);
|
||||
verifyJobAttemptsGeneric(job, attempt.getString("nodeHttpAddress"),
|
||||
|
@ -894,8 +888,7 @@ public class TestAMWebServicesJobs extends JerseyTestBase {
|
|||
|
||||
public void verifyJobAttemptsXML(NodeList nodes, Job job) {
|
||||
|
||||
assertEquals(2, nodes.getLength(),
|
||||
"incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 2, nodes.getLength());
|
||||
for (int i = 0; i < nodes.getLength(); i++) {
|
||||
Element element = (Element) nodes.item(i);
|
||||
verifyJobAttemptsGeneric(job,
|
||||
|
@ -921,17 +914,17 @@ public class TestAMWebServicesJobs extends JerseyTestBase {
|
|||
+ nmHttpPort, nodeHttpAddress);
|
||||
WebServicesTestUtils.checkStringMatch("nodeId",
|
||||
NodeId.newInstance(nmHost, nmPort).toString(), nodeId);
|
||||
assertTrue(startTime > 0, "startime not greater than 0");
|
||||
assertTrue("startime not greater than 0", startTime > 0);
|
||||
WebServicesTestUtils.checkStringMatch("containerId", amInfo
|
||||
.getContainerId().toString(), containerId);
|
||||
|
||||
String localLogsLink =ujoin("node", "containerlogs", containerId,
|
||||
job.getUserName());
|
||||
|
||||
assertTrue(logsLink.contains(localLogsLink), "logsLink");
|
||||
assertTrue("logsLink", logsLink.contains(localLogsLink));
|
||||
}
|
||||
}
|
||||
assertTrue(attemptFound, "attempt: " + id + " was not found");
|
||||
assertTrue("attempt: " + id + " was not found", attemptFound);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,10 +19,10 @@
|
|||
package org.apache.hadoop.mapreduce.v2.app.webapp;
|
||||
|
||||
import static org.apache.hadoop.yarn.webapp.WebServicesTestUtils.assertResponseStatusCode;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.util.Map;
|
||||
|
@ -50,8 +50,8 @@ import org.apache.hadoop.yarn.webapp.WebServicesTestUtils;
|
|||
import org.codehaus.jettison.json.JSONArray;
|
||||
import org.codehaus.jettison.json.JSONException;
|
||||
import org.codehaus.jettison.json.JSONObject;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
@ -99,7 +99,7 @@ public class TestAMWebServicesTasks extends JerseyTestBase {
|
|||
Guice.createInjector(new WebServletModule()));
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
@Before
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
@ -127,10 +127,10 @@ public class TestAMWebServicesTasks extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
JSONObject tasks = json.getJSONObject("tasks");
|
||||
JSONArray arr = tasks.getJSONArray("task");
|
||||
assertEquals(2, arr.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 2, arr.length());
|
||||
|
||||
verifyAMTask(arr, jobsMap.get(id), null);
|
||||
}
|
||||
|
@ -147,10 +147,10 @@ public class TestAMWebServicesTasks extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
JSONObject tasks = json.getJSONObject("tasks");
|
||||
JSONArray arr = tasks.getJSONArray("task");
|
||||
assertEquals(2, arr.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 2, arr.length());
|
||||
|
||||
verifyAMTask(arr, jobsMap.get(id), null);
|
||||
}
|
||||
|
@ -168,10 +168,10 @@ public class TestAMWebServicesTasks extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
JSONObject tasks = json.getJSONObject("tasks");
|
||||
JSONArray arr = tasks.getJSONArray("task");
|
||||
assertEquals(2, arr.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 2, arr.length());
|
||||
|
||||
verifyAMTask(arr, jobsMap.get(id), null);
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ public class TestAMWebServicesTasks extends JerseyTestBase {
|
|||
is.setCharacterStream(new StringReader(xml));
|
||||
Document dom = db.parse(is);
|
||||
NodeList tasks = dom.getElementsByTagName("tasks");
|
||||
assertEquals(1, tasks.getLength(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, tasks.getLength());
|
||||
NodeList task = dom.getElementsByTagName("task");
|
||||
verifyAMTaskXML(task, jobsMap.get(id));
|
||||
}
|
||||
|
@ -215,10 +215,10 @@ public class TestAMWebServicesTasks extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
JSONObject tasks = json.getJSONObject("tasks");
|
||||
JSONArray arr = tasks.getJSONArray("task");
|
||||
assertEquals(1, arr.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, arr.length());
|
||||
verifyAMTask(arr, jobsMap.get(id), type);
|
||||
}
|
||||
}
|
||||
|
@ -236,10 +236,10 @@ public class TestAMWebServicesTasks extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
JSONObject tasks = json.getJSONObject("tasks");
|
||||
JSONArray arr = tasks.getJSONArray("task");
|
||||
assertEquals(1, arr.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, arr.length());
|
||||
verifyAMTask(arr, jobsMap.get(id), type);
|
||||
}
|
||||
}
|
||||
|
@ -265,7 +265,7 @@ public class TestAMWebServicesTasks extends JerseyTestBase {
|
|||
response.getType().toString());
|
||||
JSONObject msg = response.getEntity(JSONObject.class);
|
||||
JSONObject exception = msg.getJSONObject("RemoteException");
|
||||
assertEquals(3, exception.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 3, exception.length());
|
||||
String message = exception.getString("message");
|
||||
String type = exception.getString("exception");
|
||||
String classname = exception.getString("javaClassName");
|
||||
|
@ -294,7 +294,7 @@ public class TestAMWebServicesTasks extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
JSONObject info = json.getJSONObject("task");
|
||||
verifyAMSingleTask(info, task);
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ public class TestAMWebServicesTasks extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
JSONObject info = json.getJSONObject("task");
|
||||
verifyAMSingleTask(info, task);
|
||||
}
|
||||
|
@ -338,7 +338,7 @@ public class TestAMWebServicesTasks extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
JSONObject info = json.getJSONObject("task");
|
||||
verifyAMSingleTask(info, task);
|
||||
}
|
||||
|
@ -363,7 +363,7 @@ public class TestAMWebServicesTasks extends JerseyTestBase {
|
|||
response.getType().toString());
|
||||
JSONObject msg = response.getEntity(JSONObject.class);
|
||||
JSONObject exception = msg.getJSONObject("RemoteException");
|
||||
assertEquals(3, exception.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 3, exception.length());
|
||||
String message = exception.getString("message");
|
||||
String type = exception.getString("exception");
|
||||
String classname = exception.getString("javaClassName");
|
||||
|
@ -398,7 +398,7 @@ public class TestAMWebServicesTasks extends JerseyTestBase {
|
|||
response.getType().toString());
|
||||
JSONObject msg = response.getEntity(JSONObject.class);
|
||||
JSONObject exception = msg.getJSONObject("RemoteException");
|
||||
assertEquals(3, exception.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 3, exception.length());
|
||||
String message = exception.getString("message");
|
||||
String type = exception.getString("exception");
|
||||
String classname = exception.getString("javaClassName");
|
||||
|
@ -431,7 +431,7 @@ public class TestAMWebServicesTasks extends JerseyTestBase {
|
|||
response.getType().toString());
|
||||
JSONObject msg = response.getEntity(JSONObject.class);
|
||||
JSONObject exception = msg.getJSONObject("RemoteException");
|
||||
assertEquals(3, exception.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 3, exception.length());
|
||||
String message = exception.getString("message");
|
||||
String type = exception.getString("exception");
|
||||
String classname = exception.getString("javaClassName");
|
||||
|
@ -466,7 +466,7 @@ public class TestAMWebServicesTasks extends JerseyTestBase {
|
|||
response.getType().toString());
|
||||
JSONObject msg = response.getEntity(JSONObject.class);
|
||||
JSONObject exception = msg.getJSONObject("RemoteException");
|
||||
assertEquals(3, exception.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 3, exception.length());
|
||||
String message = exception.getString("message");
|
||||
String type = exception.getString("exception");
|
||||
String classname = exception.getString("javaClassName");
|
||||
|
@ -501,7 +501,7 @@ public class TestAMWebServicesTasks extends JerseyTestBase {
|
|||
response.getType().toString());
|
||||
JSONObject msg = response.getEntity(JSONObject.class);
|
||||
JSONObject exception = msg.getJSONObject("RemoteException");
|
||||
assertEquals(3, exception.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 3, exception.length());
|
||||
String message = exception.getString("message");
|
||||
String type = exception.getString("exception");
|
||||
String classname = exception.getString("javaClassName");
|
||||
|
@ -550,7 +550,7 @@ public class TestAMWebServicesTasks extends JerseyTestBase {
|
|||
|
||||
public void verifyAMSingleTask(JSONObject info, Task task)
|
||||
throws JSONException {
|
||||
assertEquals(9, info.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 9, info.length());
|
||||
|
||||
verifyTaskGeneric(task, info.getString("id"), info.getString("state"),
|
||||
info.getString("type"), info.getString("successfulAttempt"),
|
||||
|
@ -574,7 +574,7 @@ public class TestAMWebServicesTasks extends JerseyTestBase {
|
|||
verifyAMSingleTask(info, task);
|
||||
}
|
||||
}
|
||||
assertTrue(found, "task with id: " + tid + " not in web service output");
|
||||
assertTrue("task with id: " + tid + " not in web service output", found);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -593,12 +593,12 @@ public class TestAMWebServicesTasks extends JerseyTestBase {
|
|||
WebServicesTestUtils.checkStringMatch("state", report.getTaskState()
|
||||
.toString(), state);
|
||||
// not easily checked without duplicating logic, just make sure its here
|
||||
assertNotNull(successfulAttempt, "successfulAttempt null");
|
||||
assertEquals(report.getStartTime(), startTime, "startTime wrong");
|
||||
assertEquals(report.getFinishTime(), finishTime, "finishTime wrong");
|
||||
assertEquals(finishTime - startTime, elapsedTime, "elapsedTime wrong");
|
||||
assertEquals(report.getProgress() * 100, progress, 1e-3f, "progress wrong");
|
||||
assertEquals(report.getStatus(), status, "status wrong");
|
||||
assertNotNull("successfulAttempt null", successfulAttempt);
|
||||
assertEquals("startTime wrong", report.getStartTime(), startTime);
|
||||
assertEquals("finishTime wrong", report.getFinishTime(), finishTime);
|
||||
assertEquals("elapsedTime wrong", finishTime - startTime, elapsedTime);
|
||||
assertEquals("progress wrong", report.getProgress() * 100, progress, 1e-3f);
|
||||
assertEquals("status wrong", report.getStatus(), status);
|
||||
}
|
||||
|
||||
public void verifyAMSingleTaskXML(Element element, Task task) {
|
||||
|
@ -615,7 +615,7 @@ public class TestAMWebServicesTasks extends JerseyTestBase {
|
|||
|
||||
public void verifyAMTaskXML(NodeList nodes, Job job) {
|
||||
|
||||
assertEquals(2, nodes.getLength(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 2, nodes.getLength());
|
||||
|
||||
for (Task task : job.getTasks().values()) {
|
||||
TaskId id = task.getID();
|
||||
|
@ -629,7 +629,7 @@ public class TestAMWebServicesTasks extends JerseyTestBase {
|
|||
verifyAMSingleTaskXML(element, task);
|
||||
}
|
||||
}
|
||||
assertTrue(found, "task with id: " + tid + " not in web service output");
|
||||
assertTrue("task with id: " + tid + " not in web service output", found);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -648,7 +648,7 @@ public class TestAMWebServicesTasks extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
JSONObject info = json.getJSONObject("jobTaskCounters");
|
||||
verifyAMJobTaskCounters(info, task);
|
||||
}
|
||||
|
@ -670,7 +670,7 @@ public class TestAMWebServicesTasks extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
JSONObject info = json.getJSONObject("jobTaskCounters");
|
||||
verifyAMJobTaskCounters(info, task);
|
||||
}
|
||||
|
@ -692,7 +692,7 @@ public class TestAMWebServicesTasks extends JerseyTestBase {
|
|||
assertEquals(MediaType.APPLICATION_JSON_TYPE + "; " + JettyUtils.UTF_8,
|
||||
response.getType().toString());
|
||||
JSONObject json = response.getEntity(JSONObject.class);
|
||||
assertEquals(1, json.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 1, json.length());
|
||||
JSONObject info = json.getJSONObject("jobTaskCounters");
|
||||
verifyAMJobTaskCounters(info, task);
|
||||
}
|
||||
|
@ -728,7 +728,7 @@ public class TestAMWebServicesTasks extends JerseyTestBase {
|
|||
public void verifyAMJobTaskCounters(JSONObject info, Task task)
|
||||
throws JSONException {
|
||||
|
||||
assertEquals(2, info.length(), "incorrect number of elements");
|
||||
assertEquals("incorrect number of elements", 2, info.length());
|
||||
|
||||
WebServicesTestUtils.checkStringMatch("id", MRApps.toString(task.getID()),
|
||||
info.getString("id"));
|
||||
|
@ -738,14 +738,15 @@ public class TestAMWebServicesTasks extends JerseyTestBase {
|
|||
for (int i = 0; i < counterGroups.length(); i++) {
|
||||
JSONObject counterGroup = counterGroups.getJSONObject(i);
|
||||
String name = counterGroup.getString("counterGroupName");
|
||||
assertTrue((name != null && !name.isEmpty()), "name not set");
|
||||
assertTrue("name not set", (name != null && !name.isEmpty()));
|
||||
JSONArray counters = counterGroup.getJSONArray("counter");
|
||||
for (int j = 0; j < counters.length(); j++) {
|
||||
JSONObject counter = counters.getJSONObject(j);
|
||||
String counterName = counter.getString("name");
|
||||
assertTrue((counterName != null && !counterName.isEmpty()), "name not set");
|
||||
assertTrue("name not set",
|
||||
(counterName != null && !counterName.isEmpty()));
|
||||
long value = counter.getLong("value");
|
||||
assertTrue(value >= 0, "value >= 0");
|
||||
assertTrue("value >= 0", value >= 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -764,20 +765,20 @@ public class TestAMWebServicesTasks extends JerseyTestBase {
|
|||
|
||||
for (int j = 0; j < groups.getLength(); j++) {
|
||||
Element counters = (Element) groups.item(j);
|
||||
assertNotNull(counters, "should have counters in the web service info");
|
||||
assertNotNull("should have counters in the web service info", counters);
|
||||
String name = WebServicesTestUtils.getXmlString(counters,
|
||||
"counterGroupName");
|
||||
assertTrue((name != null && !name.isEmpty()), "name not set");
|
||||
assertTrue("name not set", (name != null && !name.isEmpty()));
|
||||
NodeList counterArr = counters.getElementsByTagName("counter");
|
||||
for (int z = 0; z < counterArr.getLength(); z++) {
|
||||
Element counter = (Element) counterArr.item(z);
|
||||
String counterName = WebServicesTestUtils.getXmlString(counter,
|
||||
"name");
|
||||
assertTrue((counterName != null && !counterName.isEmpty()),
|
||||
"counter name not set");
|
||||
assertTrue("counter name not set",
|
||||
(counterName != null && !counterName.isEmpty()));
|
||||
|
||||
long value = WebServicesTestUtils.getXmlLong(counter, "value");
|
||||
assertTrue(value >= 0, "value not >= 0");
|
||||
assertTrue("value not >= 0", value >= 0);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,8 +37,8 @@ import org.apache.hadoop.yarn.api.records.ApplicationId;
|
|||
import org.apache.hadoop.yarn.webapp.Controller.RequestContext;
|
||||
import org.apache.hadoop.yarn.webapp.MimeType;
|
||||
import org.apache.hadoop.yarn.webapp.ResponseInfo;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class TestAppController {
|
||||
|
@ -48,7 +48,7 @@ public class TestAppController {
|
|||
private Job job;
|
||||
private static final String taskId = "task_01_01_m_01";
|
||||
|
||||
@BeforeEach
|
||||
@Before
|
||||
public void setUp() throws IOException {
|
||||
AppContext context = mock(AppContext.class);
|
||||
when(context.getApplicationID()).thenReturn(
|
||||
|
|
|
@ -26,7 +26,7 @@ import java.util.Map;
|
|||
import org.apache.hadoop.mapreduce.MRJobConfig;
|
||||
import org.apache.hadoop.mapreduce.util.MRJobConfUtil;
|
||||
import org.apache.hadoop.yarn.webapp.View;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.Test;
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.fs.Path;
|
||||
import org.apache.hadoop.mapreduce.v2.api.records.JobId;
|
||||
|
@ -52,7 +52,7 @@ import org.apache.hadoop.yarn.webapp.view.HtmlBlock;
|
|||
import org.apache.hadoop.yarn.webapp.view.HtmlBlock.Block;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class TestBlocks {
|
||||
private ByteArrayOutputStream data = new ByteArrayOutputStream();
|
||||
|
|
Loading…
Reference in New Issue