From 5ba8046b480af6097666f0037dc63ba3465af5a0 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Wed, 11 May 2016 17:53:42 +0300 Subject: [PATCH] Change memory growth assertions in testKotlinOnlyDaemonMemory: ensure that the maximum of the used memory established after several first builds doesn't raise significantly in the subsequent builds. Current constraint is 500K per 10 builds which gives 50K per build at average. --- .../kotlin/gradle/KotlinGradlePluginIT.kt | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt index e53b5028132..691500c9bba 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/test/kotlin/org/jetbrains/kotlin/gradle/KotlinGradlePluginIT.kt @@ -56,7 +56,8 @@ class KotlinGradleIT: BaseGradleIT() { val project = Project("kotlinProject", GRADLE_VERSION) val VARIANT_CONSTANT = "ForTest" val userVariantArg = "-Duser.variant=$VARIANT_CONSTANT" - val MEMORY_GROWTH_LIMIT_KB = 3000 + val MEMORY_MAX_GROWTH_LIMIT_KB = 500 + val BUILD_COUNT = 15 fun exitTestDaemon() { project.build(userVariantArg, "exit", options = BaseGradleIT.BuildOptions(withDaemon = true)) { @@ -81,10 +82,15 @@ class KotlinGradleIT: BaseGradleIT() { exitTestDaemon() try { - val startMemory = buildAndGetMemoryAfterBuild() - val endMemory = (1..10).map { buildAndGetMemoryAfterBuild() }.last() - val growth = endMemory - startMemory - assert(growth <= MEMORY_GROWTH_LIMIT_KB) { "Used memory growth $growth kb > $MEMORY_GROWTH_LIMIT_KB kb" } + val usedMemory = (1..BUILD_COUNT).map { buildAndGetMemoryAfterBuild() } + + // ensure that the maximum of the used memory established after several first builds doesn't raise significantly in the subsequent builds + val establishedMaximum = usedMemory.take(5).max()!! + val totalMaximum = usedMemory.max()!! + + val maxGrowth = totalMaximum - establishedMaximum + assertTrue(maxGrowth <= MEMORY_MAX_GROWTH_LIMIT_KB, + "Maximum used memory over series of builds growth $maxGrowth (from $establishedMaximum to $totalMaximum) kb > $MEMORY_MAX_GROWTH_LIMIT_KB kb") // testing that nothing remains locked by daemon, see KT-9440 project.build(userVariantArg, "clean", options = BaseGradleIT.BuildOptions(withDaemon = true)) {