Allow dockerTest tasks to be run in parallel through configuration
Closes gh-44913
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2024 the original author or authors.
|
||||
* Copyright 2012-2025 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,8 +22,10 @@ import org.gradle.api.services.BuildService;
|
||||
import org.gradle.api.services.BuildServiceParameters;
|
||||
|
||||
/**
|
||||
* Build service for Docker-based tests. Configured to only allow serial execution,
|
||||
* thereby ensuring that Docker-based tests do not run in parallel.
|
||||
* Build service for Docker-based tests. The maximum number of {@code dockerTest} tasks
|
||||
* that can run in parallel can be configured using
|
||||
* {@code org.springframework.boot.dockertest.max-parallel-tasks}. By default, only a
|
||||
* single {@code dockerTest} task will run at a time.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
*/
|
||||
@@ -32,7 +34,16 @@ abstract class DockerTestBuildService implements BuildService<BuildServiceParame
|
||||
static Provider<DockerTestBuildService> registerIfNecessary(Project project) {
|
||||
return project.getGradle()
|
||||
.getSharedServices()
|
||||
.registerIfAbsent("dockerTest", DockerTestBuildService.class, (spec) -> spec.getMaxParallelUsages().set(1));
|
||||
.registerIfAbsent("dockerTest", DockerTestBuildService.class,
|
||||
(spec) -> spec.getMaxParallelUsages().set(maxParallelTasks(project)));
|
||||
}
|
||||
|
||||
private static int maxParallelTasks(Project project) {
|
||||
Object property = project.findProperty("org.springframework.boot.dockertest.max-parallel-tasks");
|
||||
if (property == null) {
|
||||
return 1;
|
||||
}
|
||||
return Integer.parseInt(property.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user