Limit max number of active Gradle processes for the test run
This is needed to avoid retaining memory by each Gradle version which is critical for running tests on CI server.
This commit is contained in:
+11
@@ -53,6 +53,7 @@ abstract class BaseGradleIT {
|
||||
// gradle wrapper version to wrapper directory
|
||||
private val gradleWrappers = hashMapOf<String, File>()
|
||||
private const val MAX_DAEMON_RUNS = 30
|
||||
private const val MAX_ACTIVE_GRADLE_PROCESSES = 1
|
||||
|
||||
private fun getEnvJDK_18() = System.getenv()["JDK_18"]
|
||||
|
||||
@@ -82,6 +83,16 @@ abstract class BaseGradleIT {
|
||||
): File {
|
||||
val wrapperDir = gradleWrappers.getOrPut(version) { createNewWrapperDir(version) }
|
||||
|
||||
// Even if gradle is run with --no-daemon, we should check,
|
||||
// that common active process count does not exceed the threshold,
|
||||
// to avoid retaining too much memory (which is critical for CI)
|
||||
val activeDaemonsCount = daemonRunCount.keys.size
|
||||
val nonDaemonCount = if (!withDaemon) 1 else 0
|
||||
if (activeDaemonsCount + nonDaemonCount > MAX_ACTIVE_GRADLE_PROCESSES) {
|
||||
println("Too many Gradle active processes (max is $MAX_ACTIVE_GRADLE_PROCESSES). Stopping all daemons")
|
||||
stopAllDaemons(environmentVariables)
|
||||
}
|
||||
|
||||
if (withDaemon) {
|
||||
val timesDaemonUsed = daemonRunCount[version] ?: 0
|
||||
if (timesDaemonUsed >= MAX_DAEMON_RUNS) {
|
||||
|
||||
Reference in New Issue
Block a user