From a51fa584e092a0e27c9d9b61d5f797b11aa71eff Mon Sep 17 00:00:00 2001 From: MOOOOOSER Date: Mon, 11 Sep 2023 11:05:15 +0200 Subject: [PATCH 1/5] moved BackgroundLoopSpec to kotlin file --- .../sirius/kernel/async/BackgroundLoopTest.kt | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/test/kotlin/sirius/kernel/async/BackgroundLoopTest.kt diff --git a/src/test/kotlin/sirius/kernel/async/BackgroundLoopTest.kt b/src/test/kotlin/sirius/kernel/async/BackgroundLoopTest.kt new file mode 100644 index 00000000..d9274fb0 --- /dev/null +++ b/src/test/kotlin/sirius/kernel/async/BackgroundLoopTest.kt @@ -0,0 +1,41 @@ +/* + * Made with all the love in the world + * by scireum in Remshalden, Germany + * + * Copyright by scireum GmbH + * http://www.scireum.de - info@scireum.de + */ + +package sirius.kernel.async + +import org.junit.jupiter.api.Tag +import sirius.kernel.BaseSpecification +import sirius.kernel.commons.Wait + +@Tag("nightly") +class BackgroundLoopSpec extends BaseSpecification { + + def "BackgroundLoop limits to max frequency"() { + given: + int currentCounter = FastTestLoop.counter + when: + Wait.seconds(10) + int delta = FastTestLoop.counter - currentCounter + then: "the background loop executed enough calls (should be 10 but we're a bit tolerant here)" + delta >= 8 + and: "the background loop was limited not to execute too often (should be 10 but we're a bit tolerant here)" + delta <= 12 + } + + def "BackgroundLoop executes as fast as possible if loop is slow"() { + given: + int currentCounter = SlowTestLoop.counter + when: + Wait.seconds(10) + int delta = SlowTestLoop.counter - currentCounter + then: "the background loop executed enough calls (should be 5 but we're a bit tolerant here)" + delta >= 3 + and: "the background loop was limited not to execute too often (should be 5 but we're a bit tolerant here)" + delta <= 6 + } +} From fb2cee4708364a5478f4d3015f67a92644d24dfe Mon Sep 17 00:00:00 2001 From: MOOOOOSER Date: Mon, 11 Sep 2023 11:32:55 +0200 Subject: [PATCH 2/5] converted Syntax to kotlin --- .../sirius/kernel/async/BackgroundLoopTest.kt | 47 ++++++++++--------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/test/kotlin/sirius/kernel/async/BackgroundLoopTest.kt b/src/test/kotlin/sirius/kernel/async/BackgroundLoopTest.kt index d9274fb0..63242f8a 100644 --- a/src/test/kotlin/sirius/kernel/async/BackgroundLoopTest.kt +++ b/src/test/kotlin/sirius/kernel/async/BackgroundLoopTest.kt @@ -9,33 +9,34 @@ package sirius.kernel.async import org.junit.jupiter.api.Tag -import sirius.kernel.BaseSpecification +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import sirius.kernel.SiriusExtension import sirius.kernel.commons.Wait +import kotlin.test.assertTrue @Tag("nightly") -class BackgroundLoopSpec extends BaseSpecification { - - def "BackgroundLoop limits to max frequency"() { - given: - int currentCounter = FastTestLoop.counter - when: - Wait.seconds(10) - int delta = FastTestLoop.counter - currentCounter - then: "the background loop executed enough calls (should be 10 but we're a bit tolerant here)" - delta >= 8 - and: "the background loop was limited not to execute too often (should be 10 but we're a bit tolerant here)" - delta <= 12 +@ExtendWith(SiriusExtension::class) +class BackgroundLoopSpec { + @Test + fun `BackgroundLoop limits to max frequency`() { + val currentCounter = FastTestLoop.counter.toInt() + Wait.seconds(10.0) + val delta = FastTestLoop.counter.toInt() - currentCounter + //the background loop executed enough calls (should be 10 but we're a bit tolerant here) + assertTrue { delta >= 8 } + //the background loop was limited not to execute too often (should be 10 but we're a bit tolerant here) + assertTrue { delta <= 12 } } - def "BackgroundLoop executes as fast as possible if loop is slow"() { - given: - int currentCounter = SlowTestLoop.counter - when: - Wait.seconds(10) - int delta = SlowTestLoop.counter - currentCounter - then: "the background loop executed enough calls (should be 5 but we're a bit tolerant here)" - delta >= 3 - and: "the background loop was limited not to execute too often (should be 5 but we're a bit tolerant here)" - delta <= 6 + @Test + fun `BackgroundLoop executes as fast as possible if loop is slow`() { + val currentCounter = SlowTestLoop.counter.toInt() + Wait.seconds(10.0) + val delta = SlowTestLoop.counter.toInt() - currentCounter + // the background loop executed enough calls (should be 10 but we're a bit tolerant here) + assertTrue { delta >= 3 } + // the background loop was limited not to execute too often (should be 10 but we're a bit tolerant here) + assertTrue { delta <= 6 } } } From 16ac3471296dce89da8a120d330ce2cbb879c862 Mon Sep 17 00:00:00 2001 From: MOOOOOSER Date: Mon, 11 Sep 2023 11:33:09 +0200 Subject: [PATCH 3/5] deleted BackgroundLoopSpec.groovy --- .../kernel/async/BackgroundLoopSpec.groovy | 41 ------------------- 1 file changed, 41 deletions(-) delete mode 100644 src/test/java/sirius/kernel/async/BackgroundLoopSpec.groovy diff --git a/src/test/java/sirius/kernel/async/BackgroundLoopSpec.groovy b/src/test/java/sirius/kernel/async/BackgroundLoopSpec.groovy deleted file mode 100644 index 82d92413..00000000 --- a/src/test/java/sirius/kernel/async/BackgroundLoopSpec.groovy +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Made with all the love in the world - * by scireum in Remshalden, Germany - * - * Copyright by scireum GmbH - * http://www.scireum.de - info@scireum.de - */ - -package sirius.kernel.async - -import org.junit.jupiter.api.Tag -import sirius.kernel.BaseSpecification -import sirius.kernel.commons.Wait - -@Tag("nightly") -class BackgroundLoopSpec extends BaseSpecification { - - def "BackgroundLoop limits to max frequency"() { - given: - int currentCounter = FastTestLoop.counter - when: - Wait.seconds(10) - int delta = FastTestLoop.counter - currentCounter - then: "the background loop executed enough calls (should be 10 but we're a bit tolerant here)" - delta >= 8 - and: "the background loop was limited not to execute too often (should be 10 but we're a bit tolerant here)" - delta <= 12 - } - - def "BackgroundLoop executes as fast as possible if loop is slow"() { - given: - int currentCounter = SlowTestLoop.counter - when: - Wait.seconds(10) - int delta = SlowTestLoop.counter - currentCounter - then: "the background loop executed enough calls (should be 5 but we're a bit tolerant here)" - delta >= 3 - and: "the background loop was limited not to execute too often (should be 5 but we're a bit tolerant here)" - delta <= 6 - } -} From 6d4eaf910f3793747eea5f257553a3b108f94cec Mon Sep 17 00:00:00 2001 From: MOOOOOSER Date: Mon, 11 Sep 2023 11:35:47 +0200 Subject: [PATCH 4/5] corrected comments --- src/test/kotlin/sirius/kernel/async/BackgroundLoopTest.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/kotlin/sirius/kernel/async/BackgroundLoopTest.kt b/src/test/kotlin/sirius/kernel/async/BackgroundLoopTest.kt index 63242f8a..c25861b4 100644 --- a/src/test/kotlin/sirius/kernel/async/BackgroundLoopTest.kt +++ b/src/test/kotlin/sirius/kernel/async/BackgroundLoopTest.kt @@ -34,9 +34,9 @@ class BackgroundLoopSpec { val currentCounter = SlowTestLoop.counter.toInt() Wait.seconds(10.0) val delta = SlowTestLoop.counter.toInt() - currentCounter - // the background loop executed enough calls (should be 10 but we're a bit tolerant here) + //the background loop executed enough calls (should be 5 but we're a bit tolerant here) assertTrue { delta >= 3 } - // the background loop was limited not to execute too often (should be 10 but we're a bit tolerant here) + //the background loop was limited not to execute too often (should be 5 but we're a bit tolerant here) assertTrue { delta <= 6 } } } From 1643c8e3f114efc4f8dafdfa9ab7e241d4857caf Mon Sep 17 00:00:00 2001 From: MOOOOOSER Date: Mon, 11 Sep 2023 12:16:14 +0200 Subject: [PATCH 5/5] added correct decorator for nightly test --- src/test/kotlin/sirius/kernel/async/BackgroundLoopTest.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/kotlin/sirius/kernel/async/BackgroundLoopTest.kt b/src/test/kotlin/sirius/kernel/async/BackgroundLoopTest.kt index c25861b4..6fd75259 100644 --- a/src/test/kotlin/sirius/kernel/async/BackgroundLoopTest.kt +++ b/src/test/kotlin/sirius/kernel/async/BackgroundLoopTest.kt @@ -8,14 +8,14 @@ package sirius.kernel.async -import org.junit.jupiter.api.Tag import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith +import sirius.kernel.NightlyTest import sirius.kernel.SiriusExtension import sirius.kernel.commons.Wait import kotlin.test.assertTrue -@Tag("nightly") +@NightlyTest @ExtendWith(SiriusExtension::class) class BackgroundLoopSpec { @Test