Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some gradle configuration #247

Merged
merged 7 commits into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 12 additions & 12 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@ 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
alias(libs.plugins.jib) apply false

// 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
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()
Expand Down Expand Up @@ -75,7 +79,10 @@ allprojects {
}
}

java { toolchain { languageVersion = JavaLanguageVersion.of(11) } }
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This toolchain thing fixes to a specific java version, which causes #237. Using source/target compatibility should work with any sdk version >= 17

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried now to enable the auto jvm download in the last commit, it sounds like a useful feature. I wonder though if it works on NixOS, perhaps @igalshilman give this a try to see if your machine likes it :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works like magic 🪄

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm that it works on my machine as well. Thanks @slinkydeveloper for working your magic on this ❤️

}

buildscript {
Expand All @@ -88,15 +95,8 @@ subprojects {
apply(plugin = "kotlin")
apply(plugin = "com.diffplug.spotless")

val testReport =
tasks.register<TestReport>("testReport") {
destinationDirectory.set(layout.buildDirectory.dir("reports/tests/test"))
testResults.setFrom(subprojects.mapNotNull { it.tasks.findByPath("test") })
}

tasks.withType<Test> {
useJUnitPlatform()
finalizedBy(testReport)
testLogging {
events(
TestLogEvent.PASSED,
Expand Down
2 changes: 1 addition & 1 deletion contracts/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import com.google.protobuf.gradle.protobuf
plugins {
java
kotlin("jvm")
alias(libs.plugins.protobuf)
id("com.google.protobuf")
}

dependencies {
Expand Down
7 changes: 2 additions & 5 deletions services/http-server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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" }
}
6 changes: 2 additions & 4 deletions services/java-services/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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") }
8 changes: 0 additions & 8 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
}
Expand Down
137 changes: 71 additions & 66 deletions tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -73,78 +73,83 @@ tasks {
}
}

register<Test>("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<Test>("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<Test>("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<Test>("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<Test>().configureEach {
dependsOn(":services:http-server:jibDockerBuild")
dependsOn(":services:java-services:jibDockerBuild")
dependsOn(":services:node-services:dockerBuild")

maxParallelForks = 3
}
}

tasks.named("check") {
dependsOn("testAlwaysSuspending")
dependsOn("testSingleThreadSinglePartition")
dependsOn("testPersistedTimers")
dependsOn("testLazyState")
check {
dependsOn(testAlwaysSuspending)
dependsOn(testSingleThreadSinglePartition)
dependsOn(testPersistedTimers)
dependsOn(testLazyState)
}
Comment on lines +149 to +154
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, really cool. Now it is actually possible to run individually tests via --tests. I think this is now also possible because you've removed the explicit TestReport task. Really good! I guess we can then also close #115.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't notice that I fixed that as well 🤣

}