Author: krosenvold
Date: Thu Jan 27 20:13:45 2011
New Revision: 1064286

URL: http://svn.apache.org/viewvc?rev=1064286&view=rev
Log:
o Added profile 'parallel' that allows running integration tests in parallel

mvn -Pparallel clean install to use it.

Note: At the moment this has to use the version of failsafe that is being built 
in the profile, which
has to be this way until 2.7.3 is released. After 2.7.3 is released we can run 
with that,
and activate parallel test running as default

Note2: It is definitely best to use maven 3.0.2 if you're going to be pushing 
to the max. guice injector bugs
in earlier 3.0/3.0.1 may show up

Modified:
    maven/surefire/trunk/surefire-integration-tests/pom.xml
    
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgReportTestIT.java
    
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgSuiteXmlSingleIT.java
    
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/SurefireVerifierTestClass.java

Modified: maven/surefire/trunk/surefire-integration-tests/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/pom.xml?rev=1064286&r1=1064285&r2=1064286&view=diff
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/pom.xml (original)
+++ maven/surefire/trunk/surefire-integration-tests/pom.xml Thu Jan 27 20:13:45 
2011
@@ -18,7 +18,8 @@
   ~ 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";>
   <modelVersion>4.0.0</modelVersion>
 
   <parent>
@@ -90,14 +91,47 @@
       <artifactId>plexus-utils</artifactId>
       <scope>test</scope>
     </dependency>
-      <dependency>
-        <groupId>net.sourceforge.htmlunit</groupId>
-        <artifactId>htmlunit</artifactId>
-        <version>2.8</version>
-        <scope>test</scope>
-      </dependency>
+    <dependency>
+      <groupId>net.sourceforge.htmlunit</groupId>
+      <artifactId>htmlunit</artifactId>
+      <version>2.8</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
+  <profiles>
+    <profile>
+      <id>parallel</id>  <!-- Experimental profile to try out parallel 
building of surefire itself -->
+      <build>
+        <pluginManagement>
+          <plugins>
+            <plugin>
+              <artifactId>maven-failsafe-plugin</artifactId>
+              <version>${surefire.build.version}</version>
+              <configuration>
+                <parallel>classes</parallel>
+                <threadCount>${surefire.threadcount}</threadCount>
+              </configuration>
+            </plugin>
+
+          </plugins>
+        </pluginManagement>
+
+      </build>
+      <dependencies>
+        <dependency>
+          <groupId>junit</groupId>
+          <artifactId>junit</artifactId>
+          <version>4.8.2</version>
+          <scope>test</scope>
+        </dependency>
+      </dependencies>
+      <properties>
+        <surefire.build.version>${project.version}</surefire.build.version> 
<!-- Until we release 2.7.3 -->
+      </properties>
+    </profile>
+
+  </profiles>
   <build>
     <plugins>
       <plugin>
@@ -171,7 +205,7 @@
       </plugin>
       <plugin>
         <artifactId>maven-failsafe-plugin</artifactId>
-        <version>2.7.2</version>
+        <version>${surefire.build.version}</version>
         <configuration>
           <!-- Pass current surefire version to the main suite so that it -->
           <!-- can forward to all integration test projects. SUREFIRE-513 -->
@@ -234,5 +268,7 @@
     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
     <it.settings.showPasswords>false</it.settings.showPasswords>
     <testng.version>5.7</testng.version>
+    <surefire.threadcount>2</surefire.threadcount>
+    <surefire.build.version>2.7.2</surefire.build.version>
   </properties>
 </project>

Modified: 
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgReportTestIT.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgReportTestIT.java?rev=1064286&r1=1064285&r2=1064286&view=diff
==============================================================================
--- 
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgReportTestIT.java
 (original)
+++ 
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgReportTestIT.java
 Thu Jan 27 20:13:45 2011
@@ -30,21 +30,22 @@ import java.io.File;
  * @author <a href="mailto:[email protected]";>Dan Fabulich</a>
  */
 public class CheckTestNgReportTestIT
-    extends AbstractSurefireIntegrationTestClass
+    extends SurefireVerifierTestClass
 {
+
+    public CheckTestNgReportTestIT()
+    {
+        super( "/testng-simple" );
+    }
+
     public void testTestNgReport()
         throws Exception
     {
-        File testDir = ResourceExtractor.simpleExtractResources( getClass(), 
"/testng-simple" );
-
-        Verifier verifier = new Verifier( testDir.getAbsolutePath() );
-        this.executeGoal( verifier,
-                          
"org.apache.maven.plugins:maven-surefire-report-plugin:" + getSurefireVersion() 
+ ":report" );
-        verifier.verifyErrorFreeLog();
-        verifier.resetStreams();
+        execute( "org.apache.maven.plugins:maven-surefire-report-plugin:" + 
getSurefireVersion() + ":report" );
+        verifyErrorFreeLog();
 
-        HelperAssertions.assertTestSuiteResults( 1, 0, 0, 0, testDir );
-        File reportHtml = new File( testDir, 
"target/site/surefire-report.html" );
+        HelperAssertions.assertTestSuiteResults( 1, 0, 0, 0, getTestDir() );
+        File reportHtml = new File( getTestDir(), 
"target/site/surefire-report.html" );
         Assert.assertTrue( "surefire-report is missing", reportHtml.exists() );
     }
 }

Modified: 
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgSuiteXmlSingleIT.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgSuiteXmlSingleIT.java?rev=1064286&r1=1064285&r2=1064286&view=diff
==============================================================================
--- 
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgSuiteXmlSingleIT.java
 (original)
+++ 
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/CheckTestNgSuiteXmlSingleIT.java
 Thu Jan 27 20:13:45 2011
@@ -31,22 +31,21 @@ import java.util.List;
  * @author <a href="mailto:[email protected]";>Dan Fabulich</a>
  */
 public class CheckTestNgSuiteXmlSingleIT
-    extends AbstractSurefireIntegrationTestClass
+    extends SurefireVerifierTestClass
 {
+    public CheckTestNgSuiteXmlSingleIT()
+    {
+        super( "/testng-twoTestCaseSuite" );
+    }
+
     public void testTestNGSuite()
         throws Exception
     {
-        File testDir = ResourceExtractor.simpleExtractResources( getClass(), 
"/testng-twoTestCaseSuite" );
-
-        Verifier verifier = new Verifier( testDir.getAbsolutePath() );
-        List goals = this.getInitialGoals();
-        goals.add( "test" );
-        goals.add( "-Dtest=TestNGTestTwo" );
-        executeGoals( verifier, goals );
-        verifier.verifyErrorFreeLog();
-        verifier.resetStreams();
+        addGoal( "-Dtest=TestNGTestTwo"  );
+        executeTest();
+        verifyErrorFreeLog();
 
-        List reports = HelperAssertions.extractReports( ( new File[]{ testDir 
} ) );
+        List reports = HelperAssertions.extractReports( ( new File[]{ 
getTestDir() } ) );
         IntegrationTestSuiteResults results = 
HelperAssertions.parseReportList( reports );
         HelperAssertions.assertTestSuiteResults( 1, 0, 0, 0, results );
     }

Modified: 
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/SurefireVerifierTestClass.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/SurefireVerifierTestClass.java?rev=1064286&r1=1064285&r2=1064286&view=diff
==============================================================================
--- 
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/SurefireVerifierTestClass.java
 (original)
+++ 
maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/SurefireVerifierTestClass.java
 Thu Jan 27 20:13:45 2011
@@ -27,6 +27,7 @@ import org.apache.maven.artifact.version
 import org.apache.maven.artifact.versioning.VersionRange;
 import org.apache.maven.it.VerificationException;
 import org.apache.maven.it.Verifier;
+import org.apache.maven.it.util.FileUtils;
 import org.apache.maven.it.util.ResourceExtractor;
 import org.apache.maven.reporting.MavenReportException;
 
@@ -37,7 +38,11 @@ import java.util.List;
 
 /**
  * Contains commonly used featurtes for most tests, encapsulating
- * common use cases
+ * common use cases.
+ *
+ * Also includes thread-safe access to the extracted resource
+ * files, which AbstractSurefireIntegrationTestClass does not.
+ * Thread safe only for running in "classes" mode.
  *
  * @author Kristian Rosenvold
  */
@@ -57,7 +62,7 @@ public abstract class SurefireVerifierTe
 
     protected SurefireVerifierTestClass(String testProject) {
         try {
-            testDir = ResourceExtractor.simpleExtractResources(getClass(), 
testProject);
+            testDir = simpleExtractResources(getClass(), testProject);
             this.goals = getInitialGoals();
             this.verifier = new Verifier(testDir.getAbsolutePath());
         } catch (VerificationException e) {
@@ -67,6 +72,18 @@ public abstract class SurefireVerifierTe
         }
     }
 
+    private File simpleExtractResources(Class cl, String resourcePath) throws 
IOException {
+        String tempDirPath = System.getProperty( "maven.test.tmpdir", 
System.getProperty( "java.io.tmpdir" ) );
+        File tempDir = new File(tempDirPath, this.getClass().getSimpleName());
+        System.out.println( "tempDir = " + tempDir );
+
+        File testDir = new File( tempDir, resourcePath );
+        FileUtils.deleteDirectory( testDir );
+
+        return ResourceExtractor.extractResourcePath(cl, resourcePath, 
tempDir, true);
+    }
+
+
 
     protected void reset(){
         goals.clear();
@@ -277,6 +294,12 @@ public abstract class SurefireVerifierTe
             throw new IllegalStateException("Cannot determine maven version");
         }
     }
+
+    protected String getSurefireVersion()
+    {
+        return surefireVersion;
+    }
+
 }
 
 


Reply via email to