Skip to content

Commit e066ca0

Browse files
authored
Merge branch 'apache:trunk' into MAPREDUCE-7421
2 parents a015602 + 8424c15 commit e066ca0

File tree

65 files changed

+1274
-1136
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1274
-1136
lines changed

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@
9797
<artifactId>junit-vintage-engine</artifactId>
9898
<scope>test</scope>
9999
</dependency>
100+
<dependency>
101+
<groupId>org.mockito</groupId>
102+
<artifactId>mockito-junit-jupiter</artifactId>
103+
<scope>test</scope>
104+
</dependency>
100105
</dependencies>
101106

102107
<build>

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestClock.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,22 @@
1818
*/
1919
package org.apache.hadoop.mapred;
2020

21-
import org.junit.Test;
21+
import org.junit.jupiter.api.Test;
22+
import org.junit.jupiter.api.Timeout;
23+
24+
import static org.junit.jupiter.api.Assertions.assertEquals;
2225

23-
import static org.junit.Assert.*;
2426
/**
25-
* test Clock class
26-
*
27+
* test Clock class
2728
*/
2829
public class TestClock {
2930

30-
@Test (timeout=10000)
31+
@Test
32+
@Timeout(value = 10)
3133
public void testClock(){
32-
Clock clock= new Clock();
33-
long templateTime=System.currentTimeMillis();
34-
long time=clock.getTime();
35-
assertEquals(templateTime, time,30);
36-
34+
Clock clock = new Clock();
35+
long templateTime = System.currentTimeMillis();
36+
long time = clock.getTime();
37+
assertEquals(templateTime, time, 30);
3738
}
3839
}

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestClusterStatus.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,29 @@
1717
*/
1818
package org.apache.hadoop.mapred;
1919

20-
import org.junit.Assert;
20+
import org.junit.jupiter.api.Test;
21+
import org.junit.jupiter.api.Timeout;
2122

22-
import org.junit.Test;
23+
import static org.junit.jupiter.api.Assertions.assertEquals;
24+
import static org.junit.jupiter.api.Assertions.assertTrue;
2325

2426
public class TestClusterStatus {
2527

2628
private ClusterStatus clusterStatus = new ClusterStatus();
2729

2830
@SuppressWarnings("deprecation")
29-
@Test (timeout = 10000)
30-
public void testGraylistedTrackers() {
31-
Assert.assertEquals(0, clusterStatus.getGraylistedTrackers());
32-
Assert.assertTrue(clusterStatus.getGraylistedTrackerNames().isEmpty());
31+
@Test
32+
@Timeout(value = 10)
33+
public void testGrayListedTrackers() {
34+
assertEquals(0, clusterStatus.getGraylistedTrackers());
35+
assertTrue(clusterStatus.getGraylistedTrackerNames().isEmpty());
3336
}
3437

3538
@SuppressWarnings("deprecation")
36-
@Test (timeout = 10000)
39+
@Test
40+
@Timeout(value = 10)
3741
public void testJobTrackerState() {
38-
Assert.assertEquals(JobTracker.State.RUNNING,
42+
assertEquals(JobTracker.State.RUNNING,
3943
clusterStatus.getJobTrackerState());
4044
}
4145
}

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/test/java/org/apache/hadoop/mapred/TestCounters.java

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,19 @@
1717
*/
1818
package org.apache.hadoop.mapred;
1919

20-
import static org.junit.Assert.assertEquals;
21-
import static org.junit.Assert.assertFalse;
22-
import static org.junit.Assert.assertTrue;
20+
import static org.junit.jupiter.api.Assertions.assertEquals;
21+
import static org.junit.jupiter.api.Assertions.assertFalse;
22+
import static org.junit.jupiter.api.Assertions.assertNotNull;
23+
import static org.junit.jupiter.api.Assertions.assertNull;
24+
import static org.junit.jupiter.api.Assertions.assertTrue;
25+
import static org.junit.jupiter.api.Assertions.fail;
2326

2427
import java.io.IOException;
2528
import java.text.ParseException;
2629
import java.util.HashSet;
2730
import java.util.Iterator;
2831
import java.util.Random;
2932

30-
import org.junit.Assert;
31-
3233
import org.apache.hadoop.mapred.Counters.Counter;
3334
import org.apache.hadoop.mapred.Counters.CountersExceededException;
3435
import org.apache.hadoop.mapred.Counters.Group;
@@ -38,7 +39,7 @@
3839
import org.apache.hadoop.mapreduce.TaskCounter;
3940
import org.apache.hadoop.mapreduce.counters.FrameworkCounterGroup;
4041
import org.apache.hadoop.mapreduce.counters.CounterGroupFactory.FrameworkGroupFactory;
41-
import org.junit.Test;
42+
import org.junit.jupiter.api.Test;
4243
import org.slf4j.Logger;
4344
import org.slf4j.LoggerFactory;
4445

@@ -85,14 +86,14 @@ private Counters getEnumCounters(String[] gNames, String[] cNames) {
8586
*/
8687
private void testCounter(Counters counter) throws ParseException {
8788
String compactEscapedString = counter.makeEscapedCompactString();
88-
assertFalse("compactEscapedString should not contain null",
89-
compactEscapedString.contains("null"));
89+
assertFalse(compactEscapedString.contains("null"),
90+
"compactEscapedString should not contain null");
9091

9192
Counters recoveredCounter =
9293
Counters.fromEscapedCompactString(compactEscapedString);
9394
// Check for recovery from string
94-
assertEquals("Recovered counter does not match on content",
95-
counter, recoveredCounter);
95+
assertEquals(counter, recoveredCounter,
96+
"Recovered counter does not match on content");
9697
}
9798

9899
@Test
@@ -134,19 +135,19 @@ public void testCounterValue() {
134135
long expectedValue = initValue;
135136
Counter counter = counters.findCounter("foo", "bar");
136137
counter.setValue(initValue);
137-
assertEquals("Counter value is not initialized correctly",
138-
expectedValue, counter.getValue());
138+
assertEquals(expectedValue, counter.getValue(),
139+
"Counter value is not initialized correctly");
139140
for (int j = 0; j < NUMBER_INC; j++) {
140141
int incValue = rand.nextInt();
141142
counter.increment(incValue);
142143
expectedValue += incValue;
143-
assertEquals("Counter value is not incremented correctly",
144-
expectedValue, counter.getValue());
144+
assertEquals(expectedValue, counter.getValue(),
145+
"Counter value is not incremented correctly");
145146
}
146147
expectedValue = rand.nextInt();
147148
counter.setValue(expectedValue);
148-
assertEquals("Counter value is not set correctly",
149-
expectedValue, counter.getValue());
149+
assertEquals(expectedValue, counter.getValue(),
150+
"Counter value is not set correctly");
150151
}
151152
}
152153

@@ -174,29 +175,28 @@ public void testWriteWithLegacyNames() {
174175

175176
@SuppressWarnings("deprecation")
176177
private void checkLegacyNames(Counters counters) {
177-
assertEquals("New name", 1, counters.findCounter(
178-
TaskCounter.class.getName(), "MAP_INPUT_RECORDS").getValue());
179-
assertEquals("Legacy name", 1, counters.findCounter(
178+
assertEquals(1, counters.findCounter(
179+
TaskCounter.class.getName(), "MAP_INPUT_RECORDS").getValue(), "New name");
180+
assertEquals(1, counters.findCounter(
180181
"org.apache.hadoop.mapred.Task$Counter",
181-
"MAP_INPUT_RECORDS").getValue());
182-
assertEquals("Legacy enum", 1,
183-
counters.findCounter(Task.Counter.MAP_INPUT_RECORDS).getValue());
182+
"MAP_INPUT_RECORDS").getValue(), "Legacy name");
183+
assertEquals(1, counters.findCounter(Task.Counter.MAP_INPUT_RECORDS).getValue(), "Legacy enum");
184184

185-
assertEquals("New name", 1, counters.findCounter(
186-
JobCounter.class.getName(), "DATA_LOCAL_MAPS").getValue());
187-
assertEquals("Legacy name", 1, counters.findCounter(
185+
assertEquals(1, counters.findCounter(
186+
JobCounter.class.getName(), "DATA_LOCAL_MAPS").getValue(), "New name");
187+
assertEquals(1, counters.findCounter(
188188
"org.apache.hadoop.mapred.JobInProgress$Counter",
189-
"DATA_LOCAL_MAPS").getValue());
190-
assertEquals("Legacy enum", 1,
191-
counters.findCounter(JobInProgress.Counter.DATA_LOCAL_MAPS).getValue());
189+
"DATA_LOCAL_MAPS").getValue(), "Legacy name");
190+
assertEquals(1,
191+
counters.findCounter(JobInProgress.Counter.DATA_LOCAL_MAPS).getValue(), "Legacy enum");
192192

193-
assertEquals("New name", 1, counters.findCounter(
194-
FileSystemCounter.class.getName(), "FILE_BYTES_READ").getValue());
195-
assertEquals("New name and method", 1, counters.findCounter("file",
196-
FileSystemCounter.BYTES_READ).getValue());
197-
assertEquals("Legacy name", 1, counters.findCounter(
193+
assertEquals(1, counters.findCounter(
194+
FileSystemCounter.class.getName(), "FILE_BYTES_READ").getValue(), "New name");
195+
assertEquals(1, counters.findCounter("file",
196+
FileSystemCounter.BYTES_READ).getValue(), "New name and method");
197+
assertEquals(1, counters.findCounter(
198198
"FileSystemCounters",
199-
"FILE_BYTES_READ").getValue());
199+
"FILE_BYTES_READ").getValue(), "Legacy name");
200200
}
201201

202202
@SuppressWarnings("deprecation")
@@ -266,8 +266,8 @@ public void testMakeCompactString() {
266266
assertEquals("group1.counter1:1", counters.makeCompactString());
267267
counters.incrCounter("group2", "counter2", 3);
268268
String cs = counters.makeCompactString();
269-
assertTrue("Bad compact string",
270-
cs.equals(GC1 + ',' + GC2) || cs.equals(GC2 + ',' + GC1));
269+
assertTrue(cs.equals(GC1 + ',' + GC2) || cs.equals(GC2 + ',' + GC1),
270+
"Bad compact string");
271271
}
272272

273273
@Test
@@ -321,7 +321,7 @@ private void shouldThrow(Class<? extends Exception> ecls, Runnable runnable) {
321321
} catch (CountersExceededException e) {
322322
return;
323323
}
324-
Assert.fail("Should've thrown " + ecls.getSimpleName());
324+
fail("Should've thrown " + ecls.getSimpleName());
325325
}
326326

327327
public static void main(String[] args) throws IOException {
@@ -341,12 +341,12 @@ public void testFrameworkCounter() {
341341

342342
org.apache.hadoop.mapreduce.Counter count1 =
343343
counterGroup.findCounter(JobCounter.NUM_FAILED_MAPS.toString());
344-
Assert.assertNotNull(count1);
344+
assertNotNull(count1);
345345

346346
// Verify no exception get thrown when finding an unknown counter
347347
org.apache.hadoop.mapreduce.Counter count2 =
348348
counterGroup.findCounter("Unknown");
349-
Assert.assertNull(count2);
349+
assertNull(count2);
350350
}
351351

352352
@SuppressWarnings("rawtypes")
@@ -363,19 +363,19 @@ public void testTaskCounter() {
363363
org.apache.hadoop.mapreduce.Counter count1 =
364364
counterGroup.findCounter(
365365
TaskCounter.PHYSICAL_MEMORY_BYTES.toString());
366-
Assert.assertNotNull(count1);
366+
assertNotNull(count1);
367367
count1.increment(10);
368368
count1.increment(10);
369-
Assert.assertEquals(20, count1.getValue());
369+
assertEquals(20, count1.getValue());
370370

371371
// Verify no exception get thrown when finding an unknown counter
372372
org.apache.hadoop.mapreduce.Counter count2 =
373373
counterGroup.findCounter(
374374
TaskCounter.MAP_PHYSICAL_MEMORY_BYTES_MAX.toString());
375-
Assert.assertNotNull(count2);
375+
assertNotNull(count2);
376376
count2.increment(5);
377377
count2.increment(10);
378-
Assert.assertEquals(10, count2.getValue());
378+
assertEquals(10, count2.getValue());
379379
}
380380

381381
@Test
@@ -385,12 +385,12 @@ public void testFilesystemCounter() {
385385

386386
org.apache.hadoop.mapreduce.Counter count1 =
387387
fsGroup.findCounter("ANY_BYTES_READ");
388-
Assert.assertNotNull(count1);
388+
assertNotNull(count1);
389389

390390
// Verify no exception get thrown when finding an unknown counter
391391
org.apache.hadoop.mapreduce.Counter count2 =
392392
fsGroup.findCounter("Unknown");
393-
Assert.assertNull(count2);
393+
assertNull(count2);
394394
}
395395

396396
}

0 commit comments

Comments
 (0)