HADOOP-12280. Skip unit tests based on maven profile rather than NativeCodeLoader.isNativeCodeLoaded (Masatake Iwasaki via Colin P. McCabe)

(cherry picked from commit 6f83274afc1eba1159427684d72d8f13778c5a88)
(cherry picked from commit e92107b18f82b3501deaa6170d322a0fb512ec71)
This commit is contained in:
Colin Patrick Mccabe 2015-08-04 13:51:04 -07:00 committed by Vinod Kumar Vavilapalli
parent d8ddfea491
commit 3bd9b7459b
5 changed files with 24 additions and 8 deletions

View File

@ -11,6 +11,9 @@ Release 2.6.1 - UNRELEASED
HADOOP-7139. Allow appending to existing SequenceFiles
(kanaka kumar avvaru via vinayakumarb)
HADOOP-12280. Skip unit tests based on maven profile rather than
NativeCodeLoader.isNativeCodeLoaded (Masatake Iwasaki via Colin P. McCabe)
OPTIMIZATIONS
HADOOP-11238. Update the NameNode's Group Cache in the background when

View File

@ -37,6 +37,7 @@
import org.apache.hadoop.io.DataInputBuffer;
import org.apache.hadoop.io.DataOutputBuffer;
import org.apache.hadoop.io.RandomDatum;
import org.apache.hadoop.test.GenericTestUtils;
import org.apache.hadoop.util.NativeCodeLoader;
import org.apache.hadoop.util.ReflectionUtils;
import org.junit.Assert;
@ -63,10 +64,7 @@ public class TestCryptoCodec {
@Test(timeout=120000)
public void testJceAesCtrCryptoCodec() throws Exception {
if (!"true".equalsIgnoreCase(System.getProperty("runningWithNative"))) {
LOG.warn("Skipping since test was not run with -Pnative flag");
Assume.assumeTrue(false);
}
GenericTestUtils.assumeInNativeProfile();
if (!NativeCodeLoader.buildSupportsOpenssl()) {
LOG.warn("Skipping test since openSSL library not loaded");
Assume.assumeTrue(false);
@ -79,10 +77,7 @@ public void testJceAesCtrCryptoCodec() throws Exception {
@Test(timeout=120000)
public void testOpensslAesCtrCryptoCodec() throws Exception {
if (!"true".equalsIgnoreCase(System.getProperty("runningWithNative"))) {
LOG.warn("Skipping since test was not run with -Pnative flag");
Assume.assumeTrue(false);
}
GenericTestUtils.assumeInNativeProfile();
if (!NativeCodeLoader.buildSupportsOpenssl()) {
LOG.warn("Skipping test since openSSL library not loaded");
Assume.assumeTrue(false);

View File

@ -18,6 +18,7 @@
package org.apache.hadoop.crypto;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.test.GenericTestUtils;
import org.junit.BeforeClass;
public class TestCryptoStreamsWithOpensslAesCtrCryptoCodec
@ -25,6 +26,7 @@ public class TestCryptoStreamsWithOpensslAesCtrCryptoCodec
@BeforeClass
public static void init() throws Exception {
GenericTestUtils.assumeInNativeProfile();
Configuration conf = new Configuration();
codec = CryptoCodec.getInstance(conf);
}

View File

@ -34,6 +34,7 @@
import org.apache.hadoop.io.compress.DefaultCodec;
import org.apache.hadoop.io.compress.GzipCodec;
import org.apache.hadoop.io.serializer.JavaSerializationComparator;
import org.apache.hadoop.test.GenericTestUtils;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@ -140,6 +141,7 @@ public void testAppend() throws Exception {
@Test(timeout = 30000)
public void testAppendRecordCompression() throws Exception {
GenericTestUtils.assumeInNativeProfile();
Path file = new Path(ROOT_PATH, "testseqappendblockcompr.seq");
fs.delete(file, true);
@ -173,6 +175,7 @@ public void testAppendRecordCompression() throws Exception {
@Test(timeout = 30000)
public void testAppendBlockCompression() throws Exception {
GenericTestUtils.assumeInNativeProfile();
Path file = new Path(ROOT_PATH, "testseqappendblockcompr.seq");
fs.delete(file, true);
@ -247,6 +250,8 @@ public void testAppendBlockCompression() throws Exception {
@Test(timeout = 30000)
public void testAppendSort() throws Exception {
GenericTestUtils.assumeInNativeProfile();
Path file = new Path(ROOT_PATH, "testseqappendSort.seq");
fs.delete(file, true);

View File

@ -41,6 +41,7 @@
import org.apache.log4j.Logger;
import org.apache.log4j.WriterAppender;
import org.junit.Assert;
import org.junit.Assume;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@ -368,4 +369,14 @@ public static void assertNoThreadsMatching(String regex) {
}
}
}
/**
* Skip test if native build profile of Maven is not activated.
* Sub-project using this must set 'runningWithNative' property to true
* in the definition of native profile in pom.xml.
*/
public static void assumeInNativeProfile() {
Assume.assumeTrue(
Boolean.valueOf(System.getProperty("runningWithNative", "false")));
}
}