5
0
mirror of https://github.com/apache/sqoop.git synced 2025-05-08 02:50:38 +08:00

Sqoop2: Add test categories

(Abraham Elmahrek via Hari Shreedharan)
This commit is contained in:
Hari Shreedharan 2014-12-19 15:33:43 -08:00
parent 8cb7fc48ab
commit 2fdeeb06d6
6 changed files with 82 additions and 3 deletions

View File

@ -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 {}

View File

@ -32,6 +32,10 @@ limitations under the License.
<name>Sqoop Common</name>
<dependencies>
<dependency>
<groupId>org.apache.sqoop</groupId>
<artifactId>sqoop-common-test</artifactId>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>

View File

@ -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();

View File

@ -31,6 +31,14 @@ limitations under the License.
<artifactId>sqoop-docs</artifactId>
<name>Sqoop Documentation</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<reporting>
<plugins>

View File

@ -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

34
pom.xml
View File

@ -133,6 +133,37 @@ limitations under the License.
<!-- Profiles for various supported Hadoop distributions -->
<profiles>
<profile>
<id>fast</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludedGroups>org.apache.sqoop.common.test.categories.SlowTests</excludedGroups>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>slow</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<groups>org.apache.sqoop.common.test.categories.SlowTests</groups>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<!-- Hadoop 1.x -->
<profile>
@ -639,11 +670,10 @@ limitations under the License.
<version>2.3.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<version>2.13</version>
<configuration>
<forkMode>always</forkMode>
<forkedProcessTimeoutInSeconds>3600</forkedProcessTimeoutInSeconds>