Browse Source

AMBARI-14439. Categorize unit tests so can run mvn test -P $PROFILE (alejandro)

Alejandro Fernandez 9 years ago
parent
commit
c7e6b1c56c
34 changed files with 451 additions and 4 deletions
  1. 13 0
      ambari-logsearch/pom.xml
  2. 9 0
      ambari-metrics/ambari-metrics-timelineservice/pom.xml
  3. 28 2
      ambari-metrics/pom.xml
  4. 11 0
      ambari-server/pom.xml
  5. 2 0
      ambari-server/src/test/java/org/apache/ambari/server/state/alerts/AggregateAlertListenerTest.java
  6. 2 0
      ambari-server/src/test/java/org/apache/ambari/server/state/alerts/AlertDefinitionEqualityTest.java
  7. 2 0
      ambari-server/src/test/java/org/apache/ambari/server/state/alerts/AlertDefinitionHashTest.java
  8. 2 0
      ambari-server/src/test/java/org/apache/ambari/server/state/alerts/AlertEventPublisherTest.java
  9. 2 0
      ambari-server/src/test/java/org/apache/ambari/server/state/alerts/AlertReceivedListenerTest.java
  10. 2 0
      ambari-server/src/test/java/org/apache/ambari/server/state/alerts/AlertStateChangedEventTest.java
  11. 2 0
      ambari-server/src/test/java/org/apache/ambari/server/state/alerts/InitialAlertEventTest.java
  12. 2 0
      ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosComponentDescriptorTest.java
  13. 2 0
      ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosConfigurationDescriptorTest.java
  14. 2 0
      ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosDescriptorTest.java
  15. 2 0
      ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosDescriptorUpdateHelperTest.java
  16. 2 0
      ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosIdentityDescriptorTest.java
  17. 2 0
      ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosKeytabDescriptorTest.java
  18. 2 0
      ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosPrincipalDescriptorTest.java
  19. 2 0
      ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosServiceDescriptorTest.java
  20. 2 0
      ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/VariableReplacementHelperTest.java
  21. 2 0
      ambari-server/src/test/java/org/apache/ambari/server/state/stack/ConfigUpgradePackTest.java
  22. 2 0
      ambari-server/src/test/java/org/apache/ambari/server/state/stack/ConfigUpgradeValidityTest.java
  23. 3 0
      ambari-server/src/test/java/org/apache/ambari/server/state/stack/OSFamilyTest.java
  24. 2 0
      ambari-server/src/test/java/org/apache/ambari/server/state/stack/UpgradePackTest.java
  25. 84 2
      pom.xml
  26. 49 0
      utility/pom.xml
  27. 27 0
      utility/src/main/java/category/AlertTest.java
  28. 27 0
      utility/src/main/java/category/AmbariUpgradeTest.java
  29. 27 0
      utility/src/main/java/category/BlueprintTest.java
  30. 27 0
      utility/src/main/java/category/FastTest.java
  31. 27 0
      utility/src/main/java/category/KerberosTest.java
  32. 27 0
      utility/src/main/java/category/MetricsTest.java
  33. 27 0
      utility/src/main/java/category/SlowTest.java
  34. 27 0
      utility/src/main/java/category/StackUpgradeTest.java

+ 13 - 0
ambari-logsearch/pom.xml

@@ -70,6 +70,9 @@
         <artifactId>maven-surefire-plugin</artifactId>
         <artifactId>maven-surefire-plugin</artifactId>
         <configuration>
         <configuration>
           <skip>${skipSurefireTests}</skip>
           <skip>${skipSurefireTests}</skip>
+
+          <!-- Each profile in the top-level pom.xml defines which test group categories to run. -->
+          <groups>${testcase.groups}</groups>
         </configuration>
         </configuration>
       </plugin>
       </plugin>
       <plugin>
       <plugin>
@@ -174,4 +177,14 @@
     </plugins>
     </plugins>
   </build>
   </build>
 
 
+  <dependencies>
+    <!-- Dependency in order to annotate unit tests with a category. -->
+    <dependency>
+      <groupId>utility</groupId>
+      <artifactId>utility</artifactId>
+      <version>1.0.0.0-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
 </project>
 </project>

+ 9 - 0
ambari-metrics/ambari-metrics-timelineservice/pom.xml

@@ -226,6 +226,8 @@
           <redirectTestOutputToFile>true</redirectTestOutputToFile>
           <redirectTestOutputToFile>true</redirectTestOutputToFile>
           <forkMode>always</forkMode>
           <forkMode>always</forkMode>
           <argLine>-XX:-UseSplitVerifier</argLine>
           <argLine>-XX:-UseSplitVerifier</argLine>
+          <!-- Each profile in the top-level pom.xml defines which test group categories to run. -->
+          <groups>${testcase.groups}</groups>
         </configuration>
         </configuration>
       </plugin>
       </plugin>
       <plugin>
       <plugin>
@@ -592,6 +594,13 @@
       <scope>test</scope>
       <scope>test</scope>
     </dependency>
     </dependency>
 
 
+    <!-- Dependency in order to annotate unit tests with a category. -->
+    <dependency>
+      <groupId>utility</groupId>
+      <artifactId>utility</artifactId>
+      <version>1.0.0.0-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   </dependencies>
 
 
   <profiles>
   <profiles>

+ 28 - 2
ambari-metrics/pom.xml

@@ -14,13 +14,15 @@
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    See the License for the specific language governing permissions and
    limitations under the License.
    limitations under the License.
---><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0                              http://maven.apache.org/xsd/maven-4.0.0.xsd">
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0                              http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <groupId>org.apache.ambari</groupId>
   <groupId>org.apache.ambari</groupId>
   <modelVersion>4.0.0</modelVersion>
   <modelVersion>4.0.0</modelVersion>
   <artifactId>ambari-metrics</artifactId>
   <artifactId>ambari-metrics</artifactId>
   <version>2.5.0.0.0</version>
   <version>2.5.0.0.0</version>
   <packaging>pom</packaging>
   <packaging>pom</packaging>
   <modules>
   <modules>
+    <module>../utility</module>
     <module>ambari-metrics-common</module>
     <module>ambari-metrics-common</module>
     <module>ambari-metrics-hadoop-sink</module>
     <module>ambari-metrics-hadoop-sink</module>
     <module>ambari-metrics-flume-sink</module>
     <module>ambari-metrics-flume-sink</module>
@@ -168,6 +170,9 @@
         <artifactId>maven-surefire-plugin</artifactId>
         <artifactId>maven-surefire-plugin</artifactId>
         <configuration>
         <configuration>
           <skip>${skipSurefireTests}</skip>
           <skip>${skipSurefireTests}</skip>
+
+          <!-- Each profile in the top-level pom.xml defines which test group categories to run. -->
+          <groups>${testcase.groups}</groups>
         </configuration>
         </configuration>
       </plugin>
       </plugin>
       <plugin>
       <plugin>
@@ -297,7 +302,28 @@
   </build>
   </build>
 
 
   <dependencies>
   <dependencies>
+    <!-- Dependency in order to annotate unit tests with a category. -->
+    <dependency>
+      <groupId>utility</groupId>
+      <artifactId>utility</artifactId>
+      <version>1.0.0.0-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   </dependencies>
 
 
-
+  <profiles>
+    <profile>
+      <id>FastTests</id>
+      <properties>
+        <testcase.groups>category.FastTest</testcase.groups>
+      </properties>
+      <dependencies>
+        <dependency>
+          <groupId>utility</groupId>
+          <artifactId>utility</artifactId>
+          <version>1.0.0.0-SNAPSHOT</version>
+        </dependency>
+      </dependencies>
+    </profile>
+  </profiles>
 </project>
 </project>

+ 11 - 0
ambari-server/pom.xml

@@ -572,6 +572,9 @@
         <configuration>
         <configuration>
           <skip>${skipSurefireTests}</skip>
           <skip>${skipSurefireTests}</skip>
           <argLine>-Xmx1024m -XX:MaxPermSize=512m -Xms512m</argLine>
           <argLine>-Xmx1024m -XX:MaxPermSize=512m -Xms512m</argLine>
+
+          <!-- Each profile in the top-level pom.xml defines which test group categories to run. -->
+          <groups>${testcase.groups}</groups>
         </configuration>
         </configuration>
       </plugin>
       </plugin>
       <plugin>
       <plugin>
@@ -1442,6 +1445,14 @@
       <artifactId>jul-to-slf4j</artifactId>
       <artifactId>jul-to-slf4j</artifactId>
       <version>1.7.2</version>
       <version>1.7.2</version>
     </dependency>
     </dependency>
+
+    <!-- Dependency in order to annotate unit tests with a category. -->
+    <dependency>
+      <groupId>utility</groupId>
+      <artifactId>utility</artifactId>
+      <version>1.0.0.0-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   </dependencies>
 
 
   <pluginRepositories>
   <pluginRepositories>

+ 2 - 0
ambari-server/src/test/java/org/apache/ambari/server/state/alerts/AggregateAlertListenerTest.java

@@ -48,10 +48,12 @@ import com.google.inject.persist.PersistService;
 import com.google.inject.util.Modules;
 import com.google.inject.util.Modules;
 
 
 import junit.framework.Assert;
 import junit.framework.Assert;
+import org.junit.experimental.categories.Category;
 
 
 /**
 /**
  * Tests the {@link AlertAggregateListener}.
  * Tests the {@link AlertAggregateListener}.
  */
  */
+@Category({ category.AlertTest.class})
 public class AggregateAlertListenerTest {
 public class AggregateAlertListenerTest {
 
 
   private Injector m_injector;
   private Injector m_injector;

+ 2 - 0
ambari-server/src/test/java/org/apache/ambari/server/state/alerts/AlertDefinitionEqualityTest.java

@@ -32,10 +32,12 @@ import org.apache.ambari.server.state.alert.ScriptSource;
 import org.apache.ambari.server.state.alert.Source;
 import org.apache.ambari.server.state.alert.Source;
 import org.apache.ambari.server.state.alert.SourceType;
 import org.apache.ambari.server.state.alert.SourceType;
 import org.junit.Test;
 import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
 
 /**
 /**
  * Tests equality of {@link AlertDefinition} for hashing and merging purposes.
  * Tests equality of {@link AlertDefinition} for hashing and merging purposes.
  */
  */
+@Category({ category.AlertTest.class})
 public class AlertDefinitionEqualityTest extends TestCase {
 public class AlertDefinitionEqualityTest extends TestCase {
 
 
   @Test
   @Test

+ 2 - 0
ambari-server/src/test/java/org/apache/ambari/server/state/alerts/AlertDefinitionHashTest.java

@@ -62,10 +62,12 @@ import com.google.inject.Guice;
 import com.google.inject.Injector;
 import com.google.inject.Injector;
 import com.google.inject.Module;
 import com.google.inject.Module;
 import com.google.inject.util.Modules;
 import com.google.inject.util.Modules;
+import org.junit.experimental.categories.Category;
 
 
 /**
 /**
  * Tests for {@link AlertDefinitionHash}.
  * Tests for {@link AlertDefinitionHash}.
  */
  */
+@Category({ category.AlertTest.class})
 public class AlertDefinitionHashTest extends TestCase {
 public class AlertDefinitionHashTest extends TestCase {
 
 
   private AlertDefinitionHash m_hash;
   private AlertDefinitionHash m_hash;

+ 2 - 0
ambari-server/src/test/java/org/apache/ambari/server/state/alerts/AlertEventPublisherTest.java

@@ -56,11 +56,13 @@ import com.google.gson.Gson;
 import com.google.inject.Guice;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 import com.google.inject.Injector;
 import com.google.inject.persist.PersistService;
 import com.google.inject.persist.PersistService;
+import org.junit.experimental.categories.Category;
 
 
 /**
 /**
  * Tests that {@link AmbariEvent} instances are fired correctly and that alert
  * Tests that {@link AmbariEvent} instances are fired correctly and that alert
  * data is bootstrapped into the database.
  * data is bootstrapped into the database.
  */
  */
+@Category({ category.AlertTest.class})
 public class AlertEventPublisherTest {
 public class AlertEventPublisherTest {
 
 
   private AlertDispatchDAO dispatchDao;
   private AlertDispatchDAO dispatchDao;

+ 2 - 0
ambari-server/src/test/java/org/apache/ambari/server/state/alerts/AlertReceivedListenerTest.java

@@ -61,10 +61,12 @@ import com.google.inject.Guice;
 import com.google.inject.Injector;
 import com.google.inject.Injector;
 import com.google.inject.persist.PersistService;
 import com.google.inject.persist.PersistService;
 import com.google.inject.persist.UnitOfWork;
 import com.google.inject.persist.UnitOfWork;
+import org.junit.experimental.categories.Category;
 
 
 /**
 /**
  * Tests the {@link AlertReceivedListener}.
  * Tests the {@link AlertReceivedListener}.
  */
  */
+@Category({ category.AlertTest.class})
 public class AlertReceivedListenerTest {
 public class AlertReceivedListenerTest {
 
 
   private static final String ALERT_DEFINITION = "alert_definition_";
   private static final String ALERT_DEFINITION = "alert_definition_";

+ 2 - 0
ambari-server/src/test/java/org/apache/ambari/server/state/alerts/AlertStateChangedEventTest.java

@@ -61,6 +61,7 @@ import com.google.inject.persist.PersistService;
 import com.google.inject.util.Modules;
 import com.google.inject.util.Modules;
 
 
 import junit.framework.Assert;
 import junit.framework.Assert;
+import org.junit.experimental.categories.Category;
 
 
 /**
 /**
  * Tests that {@link AlertStateChangeEvent} instances cause
  * Tests that {@link AlertStateChangeEvent} instances cause
@@ -68,6 +69,7 @@ import junit.framework.Assert;
  * should only be created when received alerts which have a firmness of
  * should only be created when received alerts which have a firmness of
  * {@link AlertFirmness#HARD}.
  * {@link AlertFirmness#HARD}.
  */
  */
+@Category({ category.AlertTest.class})
 public class AlertStateChangedEventTest extends EasyMockSupport {
 public class AlertStateChangedEventTest extends EasyMockSupport {
 
 
   private AlertEventPublisher eventPublisher;
   private AlertEventPublisher eventPublisher;

+ 2 - 0
ambari-server/src/test/java/org/apache/ambari/server/state/alerts/InitialAlertEventTest.java

@@ -51,10 +51,12 @@ import com.google.inject.persist.PersistService;
 import com.google.inject.util.Modules;
 import com.google.inject.util.Modules;
 
 
 import junit.framework.Assert;
 import junit.framework.Assert;
+import org.junit.experimental.categories.Category;
 
 
 /**
 /**
  * Tests that {@link InitialAlertEventTest} instances are fired correctly.
  * Tests that {@link InitialAlertEventTest} instances are fired correctly.
  */
  */
+@Category({ category.AlertTest.class })
 public class InitialAlertEventTest {
 public class InitialAlertEventTest {
 
 
   private AlertsDAO m_alertsDao;
   private AlertsDAO m_alertsDao;

+ 2 - 0
ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosComponentDescriptorTest.java

@@ -22,6 +22,7 @@ import com.google.gson.reflect.TypeToken;
 import junit.framework.Assert;
 import junit.framework.Assert;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.AmbariException;
 import org.junit.Test;
 import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collection;
@@ -32,6 +33,7 @@ import java.util.Set;
 import java.util.TreeMap;
 import java.util.TreeMap;
 import java.util.TreeSet;
 import java.util.TreeSet;
 
 
+@Category({ category.KerberosTest.class})
 public class KerberosComponentDescriptorTest {
 public class KerberosComponentDescriptorTest {
   public static final String JSON_VALUE =
   public static final String JSON_VALUE =
       " {" +
       " {" +

+ 2 - 0
ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosConfigurationDescriptorTest.java

@@ -22,9 +22,11 @@ import com.google.gson.reflect.TypeToken;
 import junit.framework.Assert;
 import junit.framework.Assert;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.AmbariException;
 import org.junit.Test;
 import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
 
 import java.util.*;
 import java.util.*;
 
 
+@Category({ category.KerberosTest.class})
 public class KerberosConfigurationDescriptorTest {
 public class KerberosConfigurationDescriptorTest {
   private static final String JSON_SINGLE_VALUE =
   private static final String JSON_SINGLE_VALUE =
       "{ \"configuration-type\": {" +
       "{ \"configuration-type\": {" +

+ 2 - 0
ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosDescriptorTest.java

@@ -21,6 +21,7 @@ import com.google.gson.*;
 import junit.framework.Assert;
 import junit.framework.Assert;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.AmbariException;
 import org.junit.Test;
 import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
 
 import java.io.File;
 import java.io.File;
 import java.io.IOException;
 import java.io.IOException;
@@ -34,6 +35,7 @@ import java.util.Set;
 import java.util.TreeMap;
 import java.util.TreeMap;
 import java.util.TreeSet;
 import java.util.TreeSet;
 
 
+@Category({ category.KerberosTest.class})
 public class KerberosDescriptorTest {
 public class KerberosDescriptorTest {
   private static final KerberosDescriptorFactory KERBEROS_DESCRIPTOR_FACTORY = new KerberosDescriptorFactory();
   private static final KerberosDescriptorFactory KERBEROS_DESCRIPTOR_FACTORY = new KerberosDescriptorFactory();
   private static final KerberosServiceDescriptorFactory KERBEROS_SERVICE_DESCRIPTOR_FACTORY = new KerberosServiceDescriptorFactory();
   private static final KerberosServiceDescriptorFactory KERBEROS_SERVICE_DESCRIPTOR_FACTORY = new KerberosServiceDescriptorFactory();

+ 2 - 0
ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosDescriptorUpdateHelperTest.java

@@ -38,6 +38,7 @@ import org.apache.ambari.server.state.stack.OsFamily;
 import org.easymock.EasyMock;
 import org.easymock.EasyMock;
 import org.easymock.EasyMockSupport;
 import org.easymock.EasyMockSupport;
 import org.junit.Test;
 import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
 
 import javax.persistence.EntityManager;
 import javax.persistence.EntityManager;
 import javax.persistence.TypedQuery;
 import javax.persistence.TypedQuery;
@@ -47,6 +48,7 @@ import java.util.Properties;
 import static org.easymock.EasyMock.anyString;
 import static org.easymock.EasyMock.anyString;
 import static org.easymock.EasyMock.expect;
 import static org.easymock.EasyMock.expect;
 
 
+@Category({ category.KerberosTest.class})
 public class KerberosDescriptorUpdateHelperTest extends EasyMockSupport {
 public class KerberosDescriptorUpdateHelperTest extends EasyMockSupport {
   private static final KerberosDescriptorFactory KERBEROS_DESCRIPTOR_FACTORY = new KerberosDescriptorFactory();
   private static final KerberosDescriptorFactory KERBEROS_DESCRIPTOR_FACTORY = new KerberosDescriptorFactory();
   private static final Gson GSON = new Gson();
   private static final Gson GSON = new Gson();

+ 2 - 0
ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosIdentityDescriptorTest.java

@@ -22,12 +22,14 @@ import com.google.gson.reflect.TypeToken;
 import junit.framework.Assert;
 import junit.framework.Assert;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.AmbariException;
 import org.junit.Test;
 import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
 
 import java.util.Arrays;
 import java.util.Arrays;
 import java.util.HashSet;
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Map;
 import java.util.TreeMap;
 import java.util.TreeMap;
 
 
+@Category({ category.KerberosTest.class})
 public class KerberosIdentityDescriptorTest {
 public class KerberosIdentityDescriptorTest {
   public static final String JSON_VALUE =
   public static final String JSON_VALUE =
       "{" +
       "{" +

+ 2 - 0
ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosKeytabDescriptorTest.java

@@ -22,10 +22,12 @@ import com.google.gson.reflect.TypeToken;
 import junit.framework.Assert;
 import junit.framework.Assert;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.AmbariException;
 import org.junit.Test;
 import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
 
 import java.util.Map;
 import java.util.Map;
 import java.util.TreeMap;
 import java.util.TreeMap;
 
 
+@Category({ category.KerberosTest.class})
 public class KerberosKeytabDescriptorTest {
 public class KerberosKeytabDescriptorTest {
   public static final String JSON_VALUE =
   public static final String JSON_VALUE =
       "{" +
       "{" +

+ 2 - 0
ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosPrincipalDescriptorTest.java

@@ -22,9 +22,11 @@ import com.google.gson.reflect.TypeToken;
 import junit.framework.Assert;
 import junit.framework.Assert;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.AmbariException;
 import org.junit.Test;
 import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
 
 import java.util.*;
 import java.util.*;
 
 
+@Category({ category.KerberosTest.class})
 public class KerberosPrincipalDescriptorTest {
 public class KerberosPrincipalDescriptorTest {
   public static final String JSON_VALUE =
   public static final String JSON_VALUE =
       "{" +
       "{" +

+ 2 - 0
ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/KerberosServiceDescriptorTest.java

@@ -21,6 +21,7 @@ import com.google.gson.Gson;
 import junit.framework.Assert;
 import junit.framework.Assert;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.AmbariException;
 import org.junit.Test;
 import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
 
 import java.io.File;
 import java.io.File;
 import java.io.IOException;
 import java.io.IOException;
@@ -34,6 +35,7 @@ import java.util.Set;
 import java.util.TreeMap;
 import java.util.TreeMap;
 import java.util.TreeSet;
 import java.util.TreeSet;
 
 
+@Category({ category.KerberosTest.class})
 public class KerberosServiceDescriptorTest {
 public class KerberosServiceDescriptorTest {
   public static final String JSON_VALUE =
   public static final String JSON_VALUE =
       "{" +
       "{" +

+ 2 - 0
ambari-server/src/test/java/org/apache/ambari/server/state/kerberos/VariableReplacementHelperTest.java

@@ -21,10 +21,12 @@ package org.apache.ambari.server.state.kerberos;
 import junit.framework.Assert;
 import junit.framework.Assert;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.AmbariException;
 import org.junit.Test;
 import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
 
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Map;
 
 
+@Category({ category.KerberosTest.class})
 public class VariableReplacementHelperTest {
 public class VariableReplacementHelperTest {
   VariableReplacementHelper helper = new VariableReplacementHelper();
   VariableReplacementHelper helper = new VariableReplacementHelper();
 
 

+ 2 - 0
ambari-server/src/test/java/org/apache/ambari/server/state/stack/ConfigUpgradePackTest.java

@@ -28,6 +28,7 @@ import org.apache.ambari.server.state.stack.upgrade.ClusterGrouping.ExecuteStage
 import org.junit.After;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Arrays;
@@ -43,6 +44,7 @@ import static org.junit.Assert.*;
 /**
 /**
  * Tests for the config upgrade pack
  * Tests for the config upgrade pack
  */
  */
+@Category({ category.StackUpgradeTest.class})
 public class ConfigUpgradePackTest {
 public class ConfigUpgradePackTest {
 
 
   private Injector injector;
   private Injector injector;

+ 2 - 0
ambari-server/src/test/java/org/apache/ambari/server/state/stack/ConfigUpgradeValidityTest.java

@@ -39,6 +39,7 @@ import org.apache.ambari.server.state.stack.upgrade.Task.Type;
 import org.junit.After;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.Test;
+import org.junit.experimental.categories.Category;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 
 
@@ -52,6 +53,7 @@ import junit.framework.Assert;
  * Tests that for every upgrade pack found, that all referenced configuration
  * Tests that for every upgrade pack found, that all referenced configuration
  * IDs exist in the {@code config-upgrade.xml} which will be used/created.
  * IDs exist in the {@code config-upgrade.xml} which will be used/created.
  */
  */
+@Category({ category.StackUpgradeTest.class})
 public class ConfigUpgradeValidityTest {
 public class ConfigUpgradeValidityTest {
 
 
   private static final Logger LOG = LoggerFactory.getLogger(ConfigUpgradeValidityTest.class);
   private static final Logger LOG = LoggerFactory.getLogger(ConfigUpgradeValidityTest.class);

+ 3 - 0
ambari-server/src/test/java/org/apache/ambari/server/state/stack/OSFamilyTest.java

@@ -25,10 +25,13 @@ import junit.framework.Assert;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
 import org.apache.ambari.server.orm.InMemoryDefaultTestModule;
 import org.junit.Before;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
 import java.lang.reflect.Method;
 import java.lang.reflect.Method;
 import java.util.*;
 import java.util.*;
 
 
 
 
+@Category({ category.StackUpgradeTest.class})
 public class OSFamilyTest {
 public class OSFamilyTest {
    OsFamily os_family = null;
    OsFamily os_family = null;
    private Injector injector;
    private Injector injector;

+ 2 - 0
ambari-server/src/test/java/org/apache/ambari/server/state/stack/UpgradePackTest.java

@@ -52,6 +52,7 @@ import org.junit.After;
 import org.junit.Assert;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.Test;
+import org.junit.experimental.categories.Category;
 
 
 import com.google.inject.Guice;
 import com.google.inject.Guice;
 import com.google.inject.Injector;
 import com.google.inject.Injector;
@@ -60,6 +61,7 @@ import com.google.inject.persist.PersistService;
 /**
 /**
  * Tests for the upgrade pack
  * Tests for the upgrade pack
  */
  */
+@Category({ category.StackUpgradeTest.class})
 public class UpgradePackTest {
 public class UpgradePackTest {
 
 
   private Injector injector;
   private Injector injector;

+ 84 - 2
pom.xml

@@ -515,7 +515,7 @@
         <module>ambari-client</module>
         <module>ambari-client</module>
         <module>ambari-shell</module>
         <module>ambari-shell</module>
         <module>ambari-logsearch</module>
         <module>ambari-logsearch</module>
-      </modules>
+        </modules>
     </profile>
     </profile>
     <profile>
     <profile>
       <id>ambari-metrics</id>
       <id>ambari-metrics</id>
@@ -541,7 +541,7 @@
         <module>ambari-agent</module>
         <module>ambari-agent</module>
         <module>ambari-client</module>
         <module>ambari-client</module>
         <module>ambari-shell</module>
         <module>ambari-shell</module>
-      </modules>
+        </modules>
     </profile>
     </profile>
     <profile>
     <profile>
       <id>clover</id>
       <id>clover</id>
@@ -661,5 +661,87 @@ instead of a SNAPSHOT. -->
         </plugins>
         </plugins>
       </build>
       </build>
     </profile>
     </profile>
+
+    <!-- Start of profiles for running unit tests.
+     The category names are Java interfaces in utility/src/main/java/category/
+     The testcase.groups property contains a csv list of these categories (including the Java package name).
+
+     To run a suite of all test cases annotated with a list of categories, run the command
+     mvn test -P $PROFILE_ID
+
+     E.g.,
+     mvn test -P FastTests
+     -->
+
+    <!-- Tests are are explicitly fast. -->
+    <profile>
+      <id>FastTests</id>
+      <properties>
+        <testcase.groups>category.FastTest</testcase.groups>
+      </properties>
+    </profile>
+
+    <!-- Tests are are explicitly slow. -->
+    <profile>
+      <id>SlowTests</id>
+      <properties>
+        <testcase.groups>category.SlowTest</testcase.groups>
+      </properties>
+    </profile>
+
+    <!-- Slow tests, or tests that are not annotated. -->
+    <profile>
+      <id>NonFastTests</id>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <excludedGroups>org.apache.ambari.server.FastTest</excludedGroups>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+
+    <!-- Unit test Profiles based on features. -->
+    <profile>
+      <id>AlertTests</id>
+      <properties>
+        <testcase.groups>category.AlertTest</testcase.groups>
+      </properties>
+    </profile>
+    <profile>
+      <id>AmbariUpgradeTests</id>
+      <properties>
+        <testcase.groups>category.AmbariUpgradeTest</testcase.groups>
+      </properties>
+    </profile>
+    <profile>
+      <id>BlueprintTests</id>
+      <properties>
+        <testcase.groups>category.BlueprintTest</testcase.groups>
+      </properties>
+    </profile>
+    <profile>
+      <id>KerberosTests</id>
+      <properties>
+        <testcase.groups>category.KerberosTest</testcase.groups>
+      </properties>
+    </profile>
+    <profile>
+      <id>MetricsTests</id>
+      <properties>
+        <testcase.groups>category.MetricsTest</testcase.groups>
+      </properties>
+    </profile>
+    <profile>
+      <id>StackUpgradeTests</id>
+      <properties>
+        <testcase.groups>category.StackUpgradeTest</testcase.groups>
+      </properties>
+    </profile>
   </profiles>
   </profiles>
+  <!-- End of profiles for running unit tests. -->
 </project>
 </project>

+ 49 - 0
utility/pom.xml

@@ -0,0 +1,49 @@
+<?xml version="1.0"?>
+<!--
+   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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>utility</artifactId>
+  <groupId>utility</groupId>
+  <version>1.0.0.0-SNAPSHOT</version>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>4.12</version>
+      <scope>compile</scope>    <!-- has to be compile-time dependency on junit -->
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>3.2</version>
+        <configuration>
+          <source>1.7</source>
+          <target>1.7</target>
+          <useIncrementalCompilation>false</useIncrementalCompilation>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

+ 27 - 0
utility/src/main/java/category/AlertTest.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 category;
+
+/**
+ * Category of unit tests that can be annotated. E.g.,
+ * {@code @Category({ category.AlertTest.class}) }
+ *
+ * A Profile can have csv of categories, in order to run the unit tests like,
+ * mvn clean test -P AlertTests
+ */
+public interface AlertTest {}

+ 27 - 0
utility/src/main/java/category/AmbariUpgradeTest.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 category;
+
+/**
+ * Category of unit tests that can be annotated. E.g.,
+ * {@code @Category({ category.AmbariUpgradeTest.class}) }
+ *
+ * A Profile can have csv of categories, in order to run the unit tests like,
+ * mvn clean test -P AmbariUpgradeTests
+ */
+public interface AmbariUpgradeTest {}

+ 27 - 0
utility/src/main/java/category/BlueprintTest.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 category;
+
+/**
+ * Category of unit tests that can be annotated. E.g.,
+ * {@code @Category({ category.BlueprintTest.class}) }
+ *
+ * A Profile can have csv of categories, in order to run the unit tests like,
+ * mvn clean test -P BlueprintTests
+ */
+public interface BlueprintTest {}

+ 27 - 0
utility/src/main/java/category/FastTest.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 category;
+
+/**
+ * Category of unit tests that can be annotated. E.g.,
+ * {@code @Category({ category.FastTest.class}) }
+ *
+ * A Profile can have csv of categories, in order to run the unit tests like,
+ * mvn clean test -P FastTests
+ */
+public interface FastTest {}

+ 27 - 0
utility/src/main/java/category/KerberosTest.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 category;
+
+/**
+ * Category of unit tests that can be annotated. E.g.,
+ * {@code @Category({ category.KerberosTest.class}) }
+ *
+ * A Profile can have csv of categories, in order to run the unit tests like,
+ * mvn clean test -P KerberosTests
+ */
+public interface KerberosTest {}

+ 27 - 0
utility/src/main/java/category/MetricsTest.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 category;
+
+/**
+ * Category of unit tests that can be annotated. E.g.,
+ * {@code @Category({ category.MetricsTest.class}) }
+ *
+ * A Profile can have csv of categories, in order to run the unit tests like,
+ * mvn clean test -P MetricsTests
+ */
+public interface MetricsTest {}

+ 27 - 0
utility/src/main/java/category/SlowTest.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 category;
+
+/**
+ * Category of unit tests that can be annotated. E.g.,
+ * {@code @Category({ category.SlowTest.class}) }
+ *
+ * A Profile can have csv of categories, in order to run the unit tests like,
+ * mvn clean test -P SlowTests
+ */
+public interface SlowTest {}

+ 27 - 0
utility/src/main/java/category/StackUpgradeTest.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 category;
+
+/**
+ * Category of unit tests that can be annotated. E.g.,
+ * {@code @Category({ category.StackUpgradeTest.class}) }
+ *
+ * A Profile can have csv of categories, in order to run the unit tests like,
+ * mvn clean test -P StackUpgradeTests
+ */
+public interface StackUpgradeTest {}