Skip to content

Commit 231bc3e

Browse files
committed
Parallelize tests (except on CI)
This change enables JUnit 5's parallel mode. On my machine, this change causes `./mvnw` to run in a third of the time (from 90 seconds to 30 seconds). Integration test time specifically has been reduced 80% (from 75 seconds to 15 seconds). In order to prevent the introduction of reliability issues with CI builds, parallel execution is disabled in our `maven.yml`.
1 parent bb1fe81 commit 231bc3e

File tree

6 files changed

+91
-1
lines changed

6 files changed

+91
-1
lines changed

.github/workflows/maven.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,4 @@ jobs:
4949
distribution: 'temurin'
5050
java-version: ${{ matrix.java }}
5151
- name: Build with Maven
52-
run: ./mvnw -V --file pom.xml --no-transfer-progress -DtrimStackTrace=false -P-use-toolchains,docker
52+
run: ./mvnw -V --file pom.xml --no-transfer-progress -DtrimStackTrace=false -Djunit.jupiter.execution.parallel.enabled=false -P-use-toolchains,docker
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
junit.jupiter.execution.parallel.enabled = true
20+
junit.jupiter.execution.parallel.mode.default = concurrent
21+
junit.jupiter.execution.parallel.mode.classes.default = concurrent
22+
junit.jupiter.execution.parallel.config.strategy = dynamic
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
junit.jupiter.execution.parallel.enabled = true
20+
junit.jupiter.execution.parallel.mode.default = concurrent
21+
junit.jupiter.execution.parallel.mode.classes.default = concurrent
22+
junit.jupiter.execution.parallel.config.strategy = dynamic
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
junit.jupiter.execution.parallel.enabled = true
20+
junit.jupiter.execution.parallel.mode.default = concurrent
21+
junit.jupiter.execution.parallel.mode.classes.default = concurrent
22+
junit.jupiter.execution.parallel.config.strategy = dynamic

httpcore5/src/test/java/org/apache/hc/core5/ssl/TestSSLContextBuilder.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,12 @@
6666
import org.junit.jupiter.api.AfterEach;
6767
import org.junit.jupiter.api.Assertions;
6868
import org.junit.jupiter.api.Test;
69+
import org.junit.jupiter.api.parallel.Isolated;
6970

7071
/**
7172
* Unit tests for {@link SSLContextBuilder}.
7273
*/
74+
@Isolated
7375
class TestSSLContextBuilder {
7476

7577
static final String PROVIDER_SUN_JSSE = "SunJSSE";
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
junit.jupiter.execution.parallel.enabled = true
20+
junit.jupiter.execution.parallel.mode.default = concurrent
21+
junit.jupiter.execution.parallel.mode.classes.default = concurrent
22+
junit.jupiter.execution.parallel.config.strategy = dynamic

0 commit comments

Comments
 (0)