You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2018/08/23 20:03:08 UTC

[maven-surefire] branch SUREFIRE-1535 created (now 99083b2)

This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a change to branch SUREFIRE-1535
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git.


      at 99083b2  [SUREFIRE-1535] Surefire unable to run testng suites in parallel

This branch includes the following new commits:

     new 99083b2  [SUREFIRE-1535] Surefire unable to run testng suites in parallel

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven-surefire] 01/01: [SUREFIRE-1535] Surefire unable to run testng suites in parallel

Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch SUREFIRE-1535
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git

commit 99083b26bad8a6bf5305aaad08573850623b19d2
Author: apanfilov <an...@panfilov.tel>
AuthorDate: Wed Jul 11 12:53:12 2018 +1000

    [SUREFIRE-1535] Surefire unable to run testng suites in parallel
---
 .../surefire/booterclient/BooterSerializer.java    | 10 ++-
 .../jiras/Surefire1535TestNGParallelSuitesIT.java  | 62 ++++++++++++++++
 .../surefire-1535-parallel-testng/pom.xml          | 83 ++++++++++++++++++++++
 .../src/test/java/it/ParallelTest.java             | 46 ++++++++++++
 .../src/test/java/it/ParallelTest1.java            | 34 +++++++++
 .../src/test/java/it/ParallelTest2.java            | 34 +++++++++
 .../src/test/resources/Suite1.xml                  | 10 +++
 .../src/test/resources/Suite2.xml                  | 10 +++
 8 files changed, 288 insertions(+), 1 deletion(-)

diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
index 97140ef..9c501db 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/BooterSerializer.java
@@ -36,6 +36,7 @@ import org.apache.maven.surefire.util.RunOrder;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.Collections;
 import java.util.List;
 
 import static org.apache.maven.surefire.booter.AbstractPathConfiguration.CHILD_DELEGATION;
@@ -125,7 +126,14 @@ class BooterSerializer
         if ( testSuiteDefinition != null )
         {
             properties.setProperty( SOURCE_DIRECTORY, testSuiteDefinition.getTestSourceDirectory() );
-            properties.addList( testSuiteDefinition.getSuiteXmlFiles(), TEST_SUITE_XML_FILES );
+            if ( testSet instanceof File )
+            {
+                properties.addList( Collections.singletonList( (File) testSet ), TEST_SUITE_XML_FILES );
+            }
+            else
+            {
+                properties.addList( testSuiteDefinition.getSuiteXmlFiles(), TEST_SUITE_XML_FILES );
+            }
             TestListResolver testFilter = testSuiteDefinition.getTestListResolver();
             properties.setProperty( REQUESTEDTEST, testFilter == null ? "" : testFilter.getPluginParameterTest() );
             int rerunFailingTestsCount = testSuiteDefinition.getRerunFailingTestsCount();
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1535TestNGParallelSuitesIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1535TestNGParallelSuitesIT.java
new file mode 100644
index 0000000..3e4b0f2
--- /dev/null
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1535TestNGParallelSuitesIT.java
@@ -0,0 +1,62 @@
+package org.apache.maven.surefire.its.jiras;
+
+/*
+ * 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.
+ */
+
+import java.io.File;
+
+import org.apache.maven.surefire.its.fixture.OutputValidator;
+import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class Surefire1535TestNGParallelSuitesIT extends SurefireJUnit4IntegrationTestCase
+{
+    @Test
+    public void testParallelSuites() throws Exception 
+    {
+        File tmp1 = null;
+        File tmp2 = null;
+        try
+        {
+            tmp1 = File.createTempFile( getClass().getName(), "tmp" );
+            tmp2 = File.createTempFile( getClass().getName(), "tmp" );
+            OutputValidator validator = unpack("/surefire-1535-parallel-testng").maven()
+                    .sysProp( "testNgVersion", "5.7" )
+                    .sysProp( "testNgClassifier", "jdk15" )
+                    .sysProp( "it.ParallelTest1", tmp1.getAbsolutePath() )
+                    .sysProp( "it.ParallelTest2", tmp2.getAbsolutePath() )
+                    .executeTest();
+            Assert.assertFalse(tmp1.exists());
+            Assert.assertFalse(tmp2.exists());
+            validator.assertTestSuiteResults( 2, 0, 0, 0 );
+        }
+        finally
+        {
+            if (tmp1 != null)
+            {
+                tmp1.delete();
+            }
+            if (tmp2 != null)
+            {
+                tmp2.delete();
+            }
+        }
+    }
+}
diff --git a/surefire-its/src/test/resources/surefire-1535-parallel-testng/pom.xml b/surefire-its/src/test/resources/surefire-1535-parallel-testng/pom.xml
new file mode 100644
index 0000000..942ddb6
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1535-parallel-testng/pom.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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>
+
+    <groupId>org.apache.maven.plugins.surefire</groupId>
+    <artifactId>surefire-1535-parallel-testng</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <name>Test execution testng suites in parallel</name>
+
+    <properties>
+        <maven.compiler.source>1.6</maven.compiler.source>
+        <maven.compiler.target>1.6</maven.compiler.target>
+    </properties>
+
+    <profiles>
+        <profile>
+            <id>testng-old</id>
+            <activation>
+                <property><name>testNgClassifier</name></property>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.testng</groupId>
+                    <artifactId>testng</artifactId>
+                    <version>${testNgVersion}</version>
+                    <classifier>${testNgClassifier}</classifier>
+                </dependency>
+            </dependencies>
+        </profile>
+        <profile>
+            <id>testng-new</id>
+            <activation>
+                <property><name>!testNgClassifier</name></property>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>org.testng</groupId>
+                    <artifactId>testng</artifactId>
+                    <version>${testNgVersion}</version>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>
+
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>${surefire.version}</version>
+                <configuration>
+                    <forkCount>2</forkCount>
+                    <reuseForks>false</reuseForks>
+                    <suiteXmlFiles>
+                        <suiteXmlFile>src/test/resources/Suite1.xml</suiteXmlFile>
+                        <suiteXmlFile>src/test/resources/Suite2.xml</suiteXmlFile>
+                    </suiteXmlFiles>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
diff --git a/surefire-its/src/test/resources/surefire-1535-parallel-testng/src/test/java/it/ParallelTest.java b/surefire-its/src/test/resources/surefire-1535-parallel-testng/src/test/java/it/ParallelTest.java
new file mode 100644
index 0000000..cd7a06c
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1535-parallel-testng/src/test/java/it/ParallelTest.java
@@ -0,0 +1,46 @@
+package it;
+
+/*
+ * 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.
+ */
+
+import java.io.File;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+public class ParallelTest {
+
+    protected final boolean deleteFile() throws Exception
+    {
+        return deleteFile( getClass().getName() );
+    }
+
+    protected final boolean deleteFile( final String propName ) throws Exception
+    {
+        File temp = new File( AccessController.doPrivileged( new PrivilegedAction<String>()
+        {
+            @Override
+            public String run()
+            {
+                return System.getProperty( propName );
+            }
+        } ) );
+        return temp.delete();
+    }
+
+}
diff --git a/surefire-its/src/test/resources/surefire-1535-parallel-testng/src/test/java/it/ParallelTest1.java b/surefire-its/src/test/resources/surefire-1535-parallel-testng/src/test/java/it/ParallelTest1.java
new file mode 100644
index 0000000..b9b9c98
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1535-parallel-testng/src/test/java/it/ParallelTest1.java
@@ -0,0 +1,34 @@
+package it;
+
+/*
+ * 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.
+ */
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+@Test
+public class ParallelTest1 extends ParallelTest
+{
+
+    public void test() throws Exception
+    {
+        Assert.assertTrue( deleteFile() );
+    }
+
+}
diff --git a/surefire-its/src/test/resources/surefire-1535-parallel-testng/src/test/java/it/ParallelTest2.java b/surefire-its/src/test/resources/surefire-1535-parallel-testng/src/test/java/it/ParallelTest2.java
new file mode 100644
index 0000000..158e6dc
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1535-parallel-testng/src/test/java/it/ParallelTest2.java
@@ -0,0 +1,34 @@
+package it;
+
+/*
+ * 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.
+ */
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+@Test
+public class ParallelTest2 extends ParallelTest
+{
+
+    public void test() throws Exception
+    {
+        Assert.assertTrue( deleteFile() );
+    }
+
+}
diff --git a/surefire-its/src/test/resources/surefire-1535-parallel-testng/src/test/resources/Suite1.xml b/surefire-its/src/test/resources/surefire-1535-parallel-testng/src/test/resources/Suite1.xml
new file mode 100644
index 0000000..b6ca16b
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1535-parallel-testng/src/test/resources/Suite1.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
+
+<suite name="Suite1" verbose="5">
+    <test name="Suite1">
+        <classes>
+            <class name="it.ParallelTest1" />
+        </classes>
+    </test>
+</suite>
\ No newline at end of file
diff --git a/surefire-its/src/test/resources/surefire-1535-parallel-testng/src/test/resources/Suite2.xml b/surefire-its/src/test/resources/surefire-1535-parallel-testng/src/test/resources/Suite2.xml
new file mode 100644
index 0000000..aef1754
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1535-parallel-testng/src/test/resources/Suite2.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
+
+<suite name="Suite2" verbose="5">
+    <test name="Suite2">
+        <classes>
+            <class name="it.ParallelTest2" />
+        </classes>
+    </test>
+</suite>
\ No newline at end of file