From 0035af9be228225dd3171f732640a69e607b2c60 Mon Sep 17 00:00:00 2001 From: slinkydeveloper Date: Tue, 9 Jan 2024 12:09:34 +0100 Subject: [PATCH 1/7] Remove toolchain resolver, and use only the source/target compatibility --- build.gradle.kts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 63362345..22cd5595 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -75,7 +75,10 @@ allprojects { } } - java { toolchain { languageVersion = JavaLanguageVersion.of(11) } } + java { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } } buildscript { From 89550f605ca221840515b7a336a2944d4d971e78 Mon Sep 17 00:00:00 2001 From: slinkydeveloper Date: Tue, 9 Jan 2024 12:09:47 +0100 Subject: [PATCH 2/7] Bump kotlin plugin --- build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 22cd5595..c8f0a77c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,8 +14,8 @@ import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.getCurr plugins { java alias(libs.plugins.spotless) - kotlin("jvm") version "1.8.21" apply false - kotlin("plugin.serialization") version "1.8.21" apply false + kotlin("jvm") version "1.9.22" apply false + kotlin("plugin.serialization") version "1.9.22" apply false alias(libs.plugins.jib) apply false } From cf3cbfe74bb943b5e1e383560fd6b0aeaf1b9019 Mon Sep 17 00:00:00 2001 From: slinkydeveloper Date: Tue, 9 Jan 2024 15:51:03 +0100 Subject: [PATCH 3/7] Simplify plugin version management --- build.gradle.kts | 8 ++++++-- contracts/build.gradle.kts | 2 +- services/http-server/build.gradle.kts | 7 ++----- services/java-services/build.gradle.kts | 6 ++---- settings.gradle.kts | 8 -------- 5 files changed, 11 insertions(+), 20 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index c8f0a77c..09aefc7b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -13,10 +13,14 @@ import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.getCurr plugins { java - alias(libs.plugins.spotless) + + // Declare plugins used by subprojects + id("com.diffplug.spotless") version "6.22.0" apply false kotlin("jvm") version "1.9.22" apply false kotlin("plugin.serialization") version "1.9.22" apply false - alias(libs.plugins.jib) apply false + id("com.google.cloud.tools.jib") version "3.2.1" apply false + id("net.ltgt.errorprone") version "3.1.0" apply false + id("com.google.protobuf") version "0.9.4" apply false } val restateVersion = libs.versions.restate.get() diff --git a/contracts/build.gradle.kts b/contracts/build.gradle.kts index d27f1d59..91f518f8 100644 --- a/contracts/build.gradle.kts +++ b/contracts/build.gradle.kts @@ -13,7 +13,7 @@ import com.google.protobuf.gradle.protobuf plugins { java kotlin("jvm") - alias(libs.plugins.protobuf) + id("com.google.protobuf") } dependencies { diff --git a/services/http-server/build.gradle.kts b/services/http-server/build.gradle.kts index cecfd0b0..f583373b 100644 --- a/services/http-server/build.gradle.kts +++ b/services/http-server/build.gradle.kts @@ -9,10 +9,8 @@ plugins { java - idea - alias(libs.plugins.shadowJar) - alias(libs.plugins.errorprone) - alias(libs.plugins.jib) + id("net.ltgt.errorprone") + id("com.google.cloud.tools.jib") } dependencies { @@ -43,7 +41,6 @@ jib { } } -// Use gradle shadowJar to build the fat jar tasks.jar { manifest { attributes["Main-Class"] = "dev.restate.e2e.testing.externalhttpserver.Main" } } diff --git a/services/java-services/build.gradle.kts b/services/java-services/build.gradle.kts index 7179ee7f..e2a92b0c 100644 --- a/services/java-services/build.gradle.kts +++ b/services/java-services/build.gradle.kts @@ -13,9 +13,8 @@ import com.google.protobuf.gradle.protobuf plugins { java application - alias(libs.plugins.protobuf) - alias(libs.plugins.shadowJar) - alias(libs.plugins.jib) + id("com.google.protobuf") + id("com.google.cloud.tools.jib") } dependencies { @@ -65,7 +64,6 @@ jib { } } -// Use gradle shadowJar to build the fat jar tasks.jar { manifest { attributes["Main-Class"] = "dev.restate.e2e.services.Main" } } application { mainClass.set("dev.restate.e2e.services.Main") } diff --git a/settings.gradle.kts b/settings.gradle.kts index e5d2bbf7..d44c7c32 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -80,14 +80,6 @@ dependencyResolutionManagement { library("awaitility", "org.awaitility", "awaitility-kotlin").versionRef("awaitility") library("errorprone", "com.google.errorprone", "error_prone_core").versionRef("errorprone") - - // Plugins - plugin("spotless", "com.diffplug.spotless").version("6.22.0") - plugin("protobuf", "com.google.protobuf").version("0.9.4") - plugin("test-logger", "com.adarshr.test-logger").version("4.0.0") - plugin("errorprone", "net.ltgt.errorprone").version("3.1.0") - plugin("shadowJar", "com.github.johnrengelman.shadow").version("7.1.2") - plugin("jib", "com.google.cloud.tools.jib").version("3.2.1") } } } From 55ed2eff17bccb13a3b6519f8c29ab9e71584455 Mon Sep 17 00:00:00 2001 From: slinkydeveloper Date: Tue, 9 Jan 2024 15:52:16 +0100 Subject: [PATCH 4/7] Remove testReport custom configuration as we don't need it, because testReports are automatically generated by the built-in test configuration. --- build.gradle.kts | 7 ------- 1 file changed, 7 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 09aefc7b..8841a6bb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -95,15 +95,8 @@ subprojects { apply(plugin = "kotlin") apply(plugin = "com.diffplug.spotless") - val testReport = - tasks.register("testReport") { - destinationDirectory.set(layout.buildDirectory.dir("reports/tests/test")) - testResults.setFrom(subprojects.mapNotNull { it.tasks.findByPath("test") }) - } - tasks.withType { useJUnitPlatform() - finalizedBy(testReport) testLogging { events( TestLogEvent.PASSED, From bf860d4545937ed715149f40f29fefcb8db50551 Mon Sep 17 00:00:00 2001 From: slinkydeveloper Date: Tue, 9 Jan 2024 15:52:50 +0100 Subject: [PATCH 5/7] Little refactor of test registration configuration --- tests/build.gradle.kts | 137 +++++++++++++++++++++-------------------- 1 file changed, 71 insertions(+), 66 deletions(-) diff --git a/tests/build.gradle.kts b/tests/build.gradle.kts index d645d308..11d0442c 100644 --- a/tests/build.gradle.kts +++ b/tests/build.gradle.kts @@ -73,66 +73,71 @@ tasks { } } - register("testAlwaysSuspending") { - environment = - environment + - baseRestateEnvironment(name) + - mapOf("RESTATE_WORKER__INVOKER__INACTIVITY_TIMEOUT" to "0s") - - useJUnitPlatform { - // Run all the tests with always-suspending or only-always-suspending tag - includeTags("always-suspending | only-always-suspending") - } - // Increase a bit the default timeout - systemProperties["junit.jupiter.execution.timeout.testable.method.default"] = "30 s" - } - - register("testSingleThreadSinglePartition") { - environment = - environment + - baseRestateEnvironment(name) + - mapOf( - "RESTATE_WORKER__PARTITIONS" to "1", - "RESTATE_TOKIO_RUNTIME__WORKER_THREADS" to "1", - "RESTATE_TOKIO_RUNTIME__MAX_BLOCKING_THREADS" to "1", - ) - - useJUnitPlatform { - // Run all the tests with either no tags, or always-suspending tag - includeTags("none() | always-suspending") - } - // Increase a bit the default timeout - systemProperties["junit.jupiter.execution.timeout.testable.method.default"] = "30 s" - } - - register("testLazyState") { - environment = - environment + - baseRestateEnvironment(name) + - mapOf( - "RESTATE_WORKER__INVOKER__DISABLE_EAGER_STATE" to "true", - ) - - useJUnitPlatform { - // Run all the tests with either no tags, or always-suspending tag - includeTags("lazy-state") - } - } - - register("testPersistedTimers") { - environment = - environment + - baseRestateEnvironment(name) + - mapOf("RESTATE_WORKER__TIMERS__NUM_TIMERS_IN_MEMORY_LIMIT" to "1") - - useJUnitPlatform { - // Run all the tests with always-suspending or only-always-suspending tag - includeTags("timers") - } - // Increase a bit the default timeout - systemProperties["junit.jupiter.execution.timeout.testable.method.default"] = "20 s" - } - + val testAlwaysSuspending by + registering(Test::class) { + environment = + environment + + baseRestateEnvironment(name) + + mapOf("RESTATE_WORKER__INVOKER__INACTIVITY_TIMEOUT" to "0s") + + useJUnitPlatform { + // Run all the tests with always-suspending or only-always-suspending tag + includeTags("always-suspending | only-always-suspending") + } + // Increase a bit the default timeout + systemProperties["junit.jupiter.execution.timeout.testable.method.default"] = "30 s" + } + + val testSingleThreadSinglePartition by + registering(Test::class) { + environment = + environment + + baseRestateEnvironment(name) + + mapOf( + "RESTATE_WORKER__PARTITIONS" to "1", + "RESTATE_TOKIO_RUNTIME__WORKER_THREADS" to "1", + "RESTATE_TOKIO_RUNTIME__MAX_BLOCKING_THREADS" to "1", + ) + + useJUnitPlatform { + // Run all the tests with either no tags, or always-suspending tag + includeTags("none() | always-suspending") + } + // Increase a bit the default timeout + systemProperties["junit.jupiter.execution.timeout.testable.method.default"] = "30 s" + } + + val testLazyState by + registering(Test::class) { + environment = + environment + + baseRestateEnvironment(name) + + mapOf( + "RESTATE_WORKER__INVOKER__DISABLE_EAGER_STATE" to "true", + ) + + useJUnitPlatform { + // Run all the tests with either no tags, or always-suspending tag + includeTags("lazy-state") + } + } + + val testPersistedTimers by + registering(Test::class) { + environment = + environment + + baseRestateEnvironment(name) + + mapOf("RESTATE_WORKER__TIMERS__NUM_TIMERS_IN_MEMORY_LIMIT" to "1") + + useJUnitPlatform { + // Run all the tests with always-suspending or only-always-suspending tag + includeTags("timers") + } + // Increase a bit the default timeout + systemProperties["junit.jupiter.execution.timeout.testable.method.default"] = "20 s" + } + + // Common configuration for all test tasks withType().configureEach { dependsOn(":services:http-server:jibDockerBuild") dependsOn(":services:java-services:jibDockerBuild") @@ -140,11 +145,11 @@ tasks { maxParallelForks = 3 } -} -tasks.named("check") { - dependsOn("testAlwaysSuspending") - dependsOn("testSingleThreadSinglePartition") - dependsOn("testPersistedTimers") - dependsOn("testLazyState") + check { + dependsOn(testAlwaysSuspending) + dependsOn(testSingleThreadSinglePartition) + dependsOn(testPersistedTimers) + dependsOn(testLazyState) + } } From d1508d792ca3f5b63b23277c1c3b4bf9600e55a1 Mon Sep 17 00:00:00 2001 From: slinkydeveloper Date: Tue, 9 Jan 2024 15:53:32 +0100 Subject: [PATCH 6/7] Use `--continue` when running tests on CI to make sure the test runner doesn't exit on the first failed test configuration, but runs all the test tasks, then fails. --- .github/workflows/e2e.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 2a7eee72..a7f4484a 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -163,7 +163,7 @@ jobs: RESTATE_CONTAINER_IMAGE: ${{ inputs.restateCommit != '' && 'localhost:5000/restatedev/restate:latest' || '' }} JAVA_SDK_LOCAL_BUILD: ${{ inputs.sdkJavaCommit != '' && 'true' || '' }} with: - arguments: -Djib.console=plain check + arguments: --continue -Djib.console=plain check build-root-directory: e2e # Upload container logs From 80d88fcc2635a9497edc5d62943d89f2b0e63cb7 Mon Sep 17 00:00:00 2001 From: slinkydeveloper Date: Tue, 9 Jan 2024 16:17:50 +0100 Subject: [PATCH 7/7] Use the java toolchains plugin --- .github/workflows/e2e.yaml | 2 +- build.gradle.kts | 6 ++---- settings.gradle.kts | 2 ++ 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index a7f4484a..318afbf5 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -83,7 +83,7 @@ jobs: - uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '11' + java-version: '17' # Setup node - uses: actions/setup-node@v3 diff --git a/build.gradle.kts b/build.gradle.kts index 8841a6bb..b60ca057 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -79,10 +79,8 @@ allprojects { } } - java { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } + // Configure the java toolchain to use. If not found, it will be downloaded automatically + java { toolchain { languageVersion = JavaLanguageVersion.of(11) } } } buildscript { diff --git a/settings.gradle.kts b/settings.gradle.kts index d44c7c32..0a598ec2 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -9,6 +9,8 @@ rootProject.name = "restate-e2e" +plugins { id("org.gradle.toolchains.foojay-resolver-convention") version "0.7.0" } + include( "contracts", "services:java-services",