Test: refactor Gradle daemon memory test
Currently the test makes more harm than use: * It is too slow: two executions (with different Gradle versions) take 5 minute on CI. * It is unreliable: the test fails on CI for months with insignificant violation of the memory growth limit. After this change: * the memory growth limit is increased; * the test run count is decreased; * changes the test to use separate project with minimal amount of classes (we're not interested in compiler's memory leaks; only Gradle plugin specific ones);
This commit is contained in:
+5
-4
@@ -14,11 +14,11 @@ class GradleDaemonMemoryIT : BaseGradleIT() {
|
||||
// In order to stop daemon process, special exit task is used ( System.exit(0) ).
|
||||
@Test
|
||||
fun testGradleDaemonMemory() {
|
||||
val project = Project("kotlinProject")
|
||||
val project = Project("gradleDaemonMemory")
|
||||
val VARIANT_CONSTANT = "ForTest"
|
||||
val userVariantArg = "-Duser.variant=$VARIANT_CONSTANT"
|
||||
val MEMORY_MAX_GROWTH_LIMIT_KB = 500
|
||||
val BUILD_COUNT = 15
|
||||
val MEMORY_MAX_GROWTH_LIMIT_KB = 5000
|
||||
val BUILD_COUNT = 10
|
||||
val reportMemoryUsage = "-Dkotlin.gradle.test.report.memory.usage=true"
|
||||
val options = BaseGradleIT.BuildOptions(withDaemon = true)
|
||||
|
||||
@@ -32,10 +32,11 @@ class GradleDaemonMemoryIT : BaseGradleIT() {
|
||||
fun buildAndGetMemoryAfterBuild(): Int {
|
||||
var reportedMemory: Int? = null
|
||||
|
||||
project.build(userVariantArg, reportMemoryUsage, "clean", "build", options = options) {
|
||||
project.build(userVariantArg, reportMemoryUsage, "clean", "assemble", options = options) {
|
||||
assertSuccessful()
|
||||
val matches = "\\[KOTLIN\\]\\[PERF\\] Used memory after build: (\\d+) kb \\(difference since build start: ([+-]?\\d+) kb\\)"
|
||||
.toRegex().find(output)
|
||||
assertTasksExecuted(":compileKotlin")
|
||||
assert(matches != null && matches.groups.size == 3) { "Used memory after build is not reported by plugin" }
|
||||
reportedMemory = matches!!.groupValues[1].toInt()
|
||||
}
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: "kotlin"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "org.jetbrains.kotlin:kotlin-runtime:$kotlin_version"
|
||||
}
|
||||
|
||||
task exit << {
|
||||
System.exit(0)
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
org.gradle.jvmargs=-Xmx1024m -XX:MaxPermSize=512m
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
class Dummy
|
||||
-4
@@ -24,7 +24,3 @@ dependencies {
|
||||
test {
|
||||
useTestNG()
|
||||
}
|
||||
|
||||
task exit << {
|
||||
System.exit(0)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user