Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;

import org.junit.Test;
import org.junit.Assert;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class TestTaskContext {

Expand All @@ -33,19 +34,19 @@ public void testTaskContext() {
null);

context.setInputKeyClass(IntWritable.class);
Assert.assertEquals(IntWritable.class.getName(), context.getInputKeyClass
assertEquals(IntWritable.class.getName(), context.getInputKeyClass
().getName());

context.setInputValueClass(Text.class);
Assert.assertEquals(Text.class.getName(), context.getInputValueClass()
assertEquals(Text.class.getName(), context.getInputValueClass()
.getName());

context.setOutputKeyClass(LongWritable.class);
Assert.assertEquals(LongWritable.class.getName(), context
assertEquals(LongWritable.class.getName(), context
.getOutputKeyClass().getName());

context.setOutputValueClass(FloatWritable.class);
Assert.assertEquals(FloatWritable.class.getName(), context
assertEquals(FloatWritable.class.getName(), context
.getOutputValueClass().getName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@
import org.apache.hadoop.mapred.nativetask.testutil.TestInput.KV;
import org.apache.hadoop.util.Progress;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

@SuppressWarnings({ "rawtypes", "unchecked"})
public class TestBufferPushPull {
Expand All @@ -50,7 +51,7 @@ public class TestBufferPushPull {
public static int INPUT_KV_COUNT = 1000;
private KV<BytesWritable, BytesWritable>[] dataInput;

@Before
@BeforeEach
public void setUp() {
this.dataInput = TestInput.getMapInputs(INPUT_KV_COUNT);
}
Expand All @@ -70,8 +71,8 @@ public void testPush() throws Exception {
@Override
public void write(BytesWritable key, BytesWritable value) throws IOException {
final KV expect = dataInput[count++];
Assert.assertEquals(expect.key.toString(), key.toString());
Assert.assertEquals(expect.value.toString(), value.toString());
assertEquals(expect.key.toString(), key.toString());
assertEquals(expect.value.toString(), value.toString());
}
};

Expand Down Expand Up @@ -130,8 +131,8 @@ public void testPull() throws Exception {
keyBytes.readFields(key);
valueBytes.readFields(value);

Assert.assertEquals(dataInput[count].key.toString(), keyBytes.toString());
Assert.assertEquals(dataInput[count].value.toString(), valueBytes.toString());
assertEquals(dataInput[count].key.toString(), keyBytes.toString());
assertEquals(dataInput[count].value.toString(), valueBytes.toString());

count++;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import org.apache.hadoop.mapred.nativetask.NativeDataTarget;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import org.mockito.Mockito;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package org.apache.hadoop.mapred.nativetask.buffer;

import java.io.IOException;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
package org.apache.hadoop.mapred.nativetask.buffer;

import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,16 @@
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.SequenceFileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.junit.AfterClass;
import org.junit.jupiter.api.AfterAll;
import org.apache.hadoop.util.NativeCodeLoader;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Test;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.io.IOException;

import static org.junit.jupiter.api.Assumptions.assumeTrue;

public class CombinerTest {
private FileSystem fs;
private String inputpath;
Expand All @@ -66,10 +68,10 @@ public void testWordCountCombiner() throws Exception {
ResultVerifier.verifyCounters(normaljob, nativejob, true);
}

@Before
@BeforeEach
public void startUp() throws Exception {
Assume.assumeTrue(NativeCodeLoader.isNativeCodeLoaded());
Assume.assumeTrue(NativeRuntime.isNativeLibraryLoaded());
assumeTrue(NativeCodeLoader.isNativeCodeLoaded());
assumeTrue(NativeRuntime.isNativeLibraryLoaded());
final ScenarioConfiguration conf = new ScenarioConfiguration();
conf.addcombinerConf();

Expand All @@ -90,7 +92,7 @@ public void startUp() throws Exception {
"/normalwordcount";
}

@AfterClass
@AfterAll
public static void cleanUp() throws IOException {
final FileSystem fs = FileSystem.get(new ScenarioConfiguration());
fs.delete(new Path(TestConstants.NATIVETASK_COMBINER_TEST_DIR), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,25 @@
import org.apache.hadoop.mapred.nativetask.testutil.ScenarioConfiguration;
import org.apache.hadoop.mapred.nativetask.testutil.TestConstants;
import org.apache.hadoop.mapreduce.Job;
import org.junit.AfterClass;
import org.junit.jupiter.api.AfterAll;
import org.apache.hadoop.util.NativeCodeLoader;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;

import static org.junit.jupiter.api.Assumptions.assumeTrue;

public class LargeKVCombinerTest {
private static final Logger LOG =
LoggerFactory.getLogger(LargeKVCombinerTest.class);

@Before
@BeforeEach
public void startUp() throws Exception {
Assume.assumeTrue(NativeCodeLoader.isNativeCodeLoaded());
Assume.assumeTrue(NativeRuntime.isNativeLibraryLoaded());
assumeTrue(NativeCodeLoader.isNativeCodeLoaded());
assumeTrue(NativeRuntime.isNativeLibraryLoaded());
}

@Test
Expand Down Expand Up @@ -102,7 +103,7 @@ public void testLargeValueCombiner() throws Exception {
fs.close();
}

@AfterClass
@AfterAll
public static void cleanUp() throws IOException {
final FileSystem fs = FileSystem.get(new ScenarioConfiguration());
fs.delete(new Path(TestConstants.NATIVETASK_COMBINER_TEST_DIR), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.hadoop.mapred.nativetask.combinertest;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assumptions.assumeTrue;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
Expand All @@ -38,11 +39,10 @@
import org.apache.hadoop.mapred.nativetask.testutil.TestConstants;
import org.apache.hadoop.mapreduce.Counter;
import org.apache.hadoop.mapreduce.TaskCounter;
import org.junit.AfterClass;
import org.junit.jupiter.api.AfterAll;
import org.apache.hadoop.util.NativeCodeLoader;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.io.IOException;

Expand Down Expand Up @@ -83,10 +83,10 @@ public void testWordCountCombinerWithOldAPI() throws Exception {
.isEqualTo(normalReduceGroups.getValue());
}

@Before
@BeforeEach
public void startUp() throws Exception {
Assume.assumeTrue(NativeCodeLoader.isNativeCodeLoaded());
Assume.assumeTrue(NativeRuntime.isNativeLibraryLoaded());
assumeTrue(NativeCodeLoader.isNativeCodeLoaded());
assumeTrue(NativeRuntime.isNativeLibraryLoaded());
final ScenarioConfiguration conf = new ScenarioConfiguration();
conf.addcombinerConf();
this.fs = FileSystem.get(conf);
Expand All @@ -99,7 +99,7 @@ public void startUp() throws Exception {
}
}

@AfterClass
@AfterAll
public static void cleanUp() throws IOException {
final FileSystem fs = FileSystem.get(new ScenarioConfiguration());
fs.delete(new Path(TestConstants.NATIVETASK_COMBINER_TEST_DIR), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.hadoop.mapred.nativetask.compresstest;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assumptions.assumeTrue;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
Expand All @@ -30,11 +31,10 @@
import org.apache.hadoop.mapred.nativetask.testutil.TestConstants;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.MRJobConfig;
import org.junit.AfterClass;
import org.junit.jupiter.api.AfterAll;
import org.apache.hadoop.util.NativeCodeLoader;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.io.IOException;

Expand Down Expand Up @@ -125,10 +125,10 @@ public void testLz4Compress() throws Exception {
ResultVerifier.verifyCounters(hadoopJob, nativeJob);
}

@Before
@BeforeEach
public void startUp() throws Exception {
Assume.assumeTrue(NativeCodeLoader.isNativeCodeLoaded());
Assume.assumeTrue(NativeRuntime.isNativeLibraryLoaded());
assumeTrue(NativeCodeLoader.isNativeCodeLoaded());
assumeTrue(NativeRuntime.isNativeLibraryLoaded());
final ScenarioConfiguration conf = new ScenarioConfiguration();
final FileSystem fs = FileSystem.get(conf);
final Path path = new Path(TestConstants.NATIVETASK_COMPRESS_TEST_INPUTDIR);
Expand All @@ -142,7 +142,7 @@ public void startUp() throws Exception {
fs.close();
}

@AfterClass
@AfterAll
public static void cleanUp() throws IOException {
final FileSystem fs = FileSystem.get(new ScenarioConfiguration());
fs.delete(new Path(TestConstants.NATIVETASK_COMPRESS_TEST_DIR), true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
import org.apache.hadoop.mapred.nativetask.INativeHandler;
import org.apache.hadoop.mapred.nativetask.buffer.BufferType;
import org.apache.hadoop.mapred.nativetask.buffer.InputBuffer;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -40,7 +40,7 @@ public class TestCombineHandler {
private BufferPuller puller;
private CombinerRunner combinerRunner;

@Before
@BeforeEach
public void setUp() throws IOException {
this.nativeHandler = Mockito.mock(INativeHandler.class);
this.pusher = Mockito.mock(BufferPusher.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@
import org.apache.hadoop.mapred.nativetask.util.OutputUtil;
import org.apache.hadoop.mapred.nativetask.util.ReadWriteBuffer;
import org.apache.hadoop.util.StringUtils;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;

Expand All @@ -54,7 +55,7 @@ public class TestNativeCollectorOnlyHandler {
private TaskContext taskContext;
private static final String LOCAL_DIR = TestConstants.NATIVETASK_TEST_DIR + "/local";

@Before
@BeforeEach
public void setUp() throws IOException {
this.nativeHandler = Mockito.mock(INativeHandler.class);
this.pusher = Mockito.mock(BufferPusher.class);
Expand All @@ -74,7 +75,7 @@ public void setUp() throws IOException {
new InputBuffer(BufferType.HEAP_BUFFER, 100));
}

@After
@AfterEach
public void tearDown() throws IOException {
FileSystem.getLocal(new Configuration()).delete(new Path(LOCAL_DIR));
}
Expand All @@ -100,7 +101,7 @@ public void testGetCombiner() throws IOException {
Mockito.when(combiner.getId()).thenReturn(100L);
final ReadWriteBuffer result = handler.onCall(
NativeCollectorOnlyHandler.GET_COMBINE_HANDLER, null);
Assert.assertEquals(100L, result.readLong());
assertEquals(100L, result.readLong());
}

@Test
Expand All @@ -112,7 +113,7 @@ public void testOnCall() throws IOException {
} catch(final IOException e) {
thrown = true;
}
Assert.assertTrue("exception thrown", thrown);
assertTrue(thrown, "exception thrown");

final String expectedOutputPath = StringUtils.join(File.separator,
new String[] {LOCAL_DIR, "output", "file.out"});
Expand All @@ -123,14 +124,14 @@ public void testOnCall() throws IOException {

final String outputPath = handler.onCall(
NativeCollectorOnlyHandler.GET_OUTPUT_PATH, null).readString();
Assert.assertEquals(expectedOutputPath, outputPath);
assertEquals(expectedOutputPath, outputPath);

final String outputIndexPath = handler.onCall(
NativeCollectorOnlyHandler.GET_OUTPUT_INDEX_PATH, null).readString();
Assert.assertEquals(expectedOutputIndexPath, outputIndexPath);
assertEquals(expectedOutputIndexPath, outputIndexPath);

final String spillPath = handler.onCall(
NativeCollectorOnlyHandler.GET_SPILL_PATH, null).readString();
Assert.assertEquals(expectedSpillPath, spillPath);
assertEquals(expectedSpillPath, spillPath);
}
}
Loading