From 86d11c90e20197d9142a5aac18d8e6b2f03bb567 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 26 Mar 2025 19:25:05 +0000 Subject: [PATCH] Allow dockerTest tasks to be run in parallel through configuration Closes gh-44913 --- .../build/test/DockerTestBuildService.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/buildSrc/src/main/java/org/springframework/boot/build/test/DockerTestBuildService.java b/buildSrc/src/main/java/org/springframework/boot/build/test/DockerTestBuildService.java index 2f70a735513..016db7abe1b 100644 --- a/buildSrc/src/main/java/org/springframework/boot/build/test/DockerTestBuildService.java +++ b/buildSrc/src/main/java/org/springframework/boot/build/test/DockerTestBuildService.java @@ -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 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()); } }