From 2fdeeb06d6a7dc41e18c61f32a3ada73203cf545 Mon Sep 17 00:00:00 2001 From: Hari Shreedharan Date: Fri, 19 Dec 2014 15:33:43 -0800 Subject: [PATCH] Sqoop2: Add test categories (Abraham Elmahrek via Hari Shreedharan) --- .../common/test/categories/SlowTests.java | 27 +++++++++++++++ common/pom.xml | 4 +++ .../connector/kafka/TestKafkaLoader.java | 3 ++ docs/pom.xml | 8 +++++ docs/src/site/sphinx/BuildingSqoop2.rst | 9 ++++- pom.xml | 34 +++++++++++++++++-- 6 files changed, 82 insertions(+), 3 deletions(-) create mode 100644 common-test/src/main/java/org/apache/sqoop/common/test/categories/SlowTests.java diff --git a/common-test/src/main/java/org/apache/sqoop/common/test/categories/SlowTests.java b/common-test/src/main/java/org/apache/sqoop/common/test/categories/SlowTests.java new file mode 100644 index 00000000..f8ce4747 --- /dev/null +++ b/common-test/src/main/java/org/apache/sqoop/common/test/categories/SlowTests.java @@ -0,0 +1,27 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.sqoop.common.test.categories; + +/** + * Slow tests interface for JUnit categories. + * This should be used if your unit tests rely on + * some piece of infrastructure that takes time to start. + * For example, using a MySQL database takes time to setup + * and start because it is in a separate process. + */ +public interface SlowTests {} diff --git a/common/pom.xml b/common/pom.xml index 04119f20..e8a8010e 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -32,6 +32,10 @@ limitations under the License. Sqoop Common + + org.apache.sqoop + sqoop-common-test + com.googlecode.json-simple json-simple diff --git a/connector/connector-kafka/src/test/java/org/apache/sqoop/connector/kafka/TestKafkaLoader.java b/connector/connector-kafka/src/test/java/org/apache/sqoop/connector/kafka/TestKafkaLoader.java index f896e9e6..4ed027fa 100644 --- a/connector/connector-kafka/src/test/java/org/apache/sqoop/connector/kafka/TestKafkaLoader.java +++ b/connector/connector-kafka/src/test/java/org/apache/sqoop/connector/kafka/TestKafkaLoader.java @@ -18,6 +18,7 @@ package org.apache.sqoop.connector.kafka; import kafka.message.MessageAndMetadata; +import org.apache.sqoop.common.test.categories.SlowTests; import org.apache.sqoop.connector.kafka.configuration.ToJobConfiguration; import org.apache.sqoop.connector.kafka.configuration.LinkConfiguration; import org.apache.sqoop.common.test.kafka.TestUtil; @@ -27,11 +28,13 @@ import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; +import org.junit.experimental.categories.Category; import java.io.IOException; import java.util.ArrayList; import java.util.List; +@Category({ SlowTests.class }) public class TestKafkaLoader { private static TestUtil testUtil = TestUtil.getInstance(); diff --git a/docs/pom.xml b/docs/pom.xml index 75f428c4..f8ccc344 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -31,6 +31,14 @@ limitations under the License. sqoop-docs Sqoop Documentation + + + junit + junit + test + + + diff --git a/docs/src/site/sphinx/BuildingSqoop2.rst b/docs/src/site/sphinx/BuildingSqoop2.rst index ad07d460..35b22d4e 100644 --- a/docs/src/site/sphinx/BuildingSqoop2.rst +++ b/docs/src/site/sphinx/BuildingSqoop2.rst @@ -54,7 +54,7 @@ Maven target ``package`` can be used to create Sqoop packages similar to the one Running tests ------------- -Sqoop supports two different sets of tests. First smaller and much faster set is called unit tests and will be executed on maven target ``test``. Second larger set of integration tests will be executed on maven target ``integration-test``. Please note that integration tests might require manual steps for installing various JDBC drivers into your local maven cache. +Sqoop supports two different sets of tests. First smaller and much faster set is called **unit tests** and will be executed on maven target ``test``. Second larger set of **integration tests** will be executed on maven target ``integration-test``. Please note that integration tests might require manual steps for installing various JDBC drivers into your local maven cache. Example for running unit tests: @@ -67,3 +67,10 @@ Example for running integration tests: :: mvn integration-test + +For the **unit tests**, there are two helpful profiles: **fast** and **slow**. The **fast** unit tests do not start or use any services. The **slow** unit tests, may start services or use an external service (ie. MySQL). + +:: + + mvn test -Pfast,hadoop200 + mvn test -Pslow,hadoop200 \ No newline at end of file diff --git a/pom.xml b/pom.xml index aa4231e9..afdeb75d 100644 --- a/pom.xml +++ b/pom.xml @@ -133,6 +133,37 @@ limitations under the License. + + fast + + + + + org.apache.maven.plugins + maven-surefire-plugin + + org.apache.sqoop.common.test.categories.SlowTests + + + + + + + + slow + + + + + org.apache.maven.plugins + maven-surefire-plugin + + org.apache.sqoop.common.test.categories.SlowTests + + + + + @@ -639,11 +670,10 @@ limitations under the License. 2.3.2 - org.apache.maven.plugins maven-surefire-plugin - 2.12 + 2.13 always 3600