|
@@ -17,16 +17,19 @@
|
|
|
*/
|
|
|
package org.apache.hadoop.mapred;
|
|
|
|
|
|
-import junit.framework.TestCase;
|
|
|
+import static org.junit.Assert.assertEquals;
|
|
|
+
|
|
|
import java.io.IOException;
|
|
|
import java.text.ParseException;
|
|
|
|
|
|
+import org.apache.hadoop.mapreduce.JobCounter;
|
|
|
import org.apache.hadoop.mapreduce.TaskCounter;
|
|
|
+import org.junit.Test;
|
|
|
|
|
|
/**
|
|
|
* TestCounters checks the sanity and recoverability of {@code Counters}
|
|
|
*/
|
|
|
-public class TestCounters extends TestCase {
|
|
|
+public class TestCounters {
|
|
|
enum myCounters {TEST1, TEST2};
|
|
|
private static final long MAX_VALUE = 10;
|
|
|
|
|
@@ -69,6 +72,7 @@ public class TestCounters extends TestCase {
|
|
|
counter.hashCode(), recoveredCounter.hashCode());
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
public void testCounters() throws IOException {
|
|
|
Enum[] keysWithResource = {TaskCounter.MAP_INPUT_RECORDS,
|
|
|
TaskCounter.MAP_OUTPUT_BYTES};
|
|
@@ -92,6 +96,26 @@ public class TestCounters extends TestCase {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @SuppressWarnings("deprecation")
|
|
|
+ @Test
|
|
|
+ public void testLegacyNames() {
|
|
|
+ Counters counters = new Counters();
|
|
|
+ counters.incrCounter(TaskCounter.MAP_INPUT_RECORDS, 1);
|
|
|
+ counters.incrCounter(JobCounter.DATA_LOCAL_MAPS, 1);
|
|
|
+
|
|
|
+ assertEquals("New name", 1, counters.findCounter(
|
|
|
+ TaskCounter.class.getName(), "MAP_INPUT_RECORDS").getValue());
|
|
|
+ assertEquals("Legacy name", 1, counters.findCounter(
|
|
|
+ "org.apache.hadoop.mapred.Task$Counter",
|
|
|
+ "MAP_INPUT_RECORDS").getValue());
|
|
|
+
|
|
|
+ assertEquals("New name", 1, counters.findCounter(
|
|
|
+ JobCounter.class.getName(), "DATA_LOCAL_MAPS").getValue());
|
|
|
+ assertEquals("Legacy name", 1, counters.findCounter(
|
|
|
+ "org.apache.hadoop.mapred.JobInProgress$Counter",
|
|
|
+ "DATA_LOCAL_MAPS").getValue());
|
|
|
+ }
|
|
|
+
|
|
|
public static void main(String[] args) throws IOException {
|
|
|
new TestCounters().testCounters();
|
|
|
}
|