Skip to content

Commit 6036ae4

Browse files
committed
build: streamline test setup in otter modules
Signed-off-by: Jendrik Johannes <[email protected]>
1 parent 6e228a8 commit 6036ae4

File tree

9 files changed

+68
-137
lines changed

9 files changed

+68
-137
lines changed

platform-sdk/base-crypto/src/main/java/module-info.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
com.swirlds.platform.core,
99
com.swirlds.common.test.fixtures,
1010
com.swirlds.platform.core.test.fixtures,
11-
org.hiero.base.crypto.test.fixtures;
11+
org.hiero.base.crypto.test.fixtures,
12+
org.hiero.otter.test;
1213
exports org.hiero.base.crypto.engine to
1314
com.swirlds.common,
1415
com.swirlds.common.test.fixtures,

platform-sdk/consensus-otter-docker-app/build.gradle.kts

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
11
// SPDX-License-Identifier: Apache-2.0
22
plugins {
3-
id("java-library")
4-
id("jacoco")
5-
id("org.hiero.gradle.base.jpms-modules")
6-
id("org.hiero.gradle.base.lifecycle")
7-
id("org.hiero.gradle.base.version")
8-
id("org.hiero.gradle.check.dependencies")
9-
id("org.hiero.gradle.check.javac-lint")
10-
id("org.hiero.gradle.check.spotless")
11-
id("org.hiero.gradle.check.spotless-java")
12-
id("org.hiero.gradle.check.spotless-kotlin")
13-
id("org.hiero.gradle.feature.git-properties-file")
14-
id("org.hiero.gradle.feature.java-compile")
15-
id("org.hiero.gradle.feature.java-execute")
16-
id("org.hiero.gradle.feature.test")
17-
id("org.hiero.gradle.report.test-logger")
3+
id("org.hiero.gradle.module.library")
184
id("org.hiero.gradle.feature.test-fixtures")
195
id("org.hiero.gradle.feature.protobuf")
206
}

platform-sdk/consensus-otter-docker-app/src/main/java/module-info.java

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 31 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,42 @@
11
// SPDX-License-Identifier: Apache-2.0
2+
import org.gradlex.javamodule.dependencies.dsl.GradleOnlyDirectives
3+
24
plugins {
3-
id("java-library")
4-
id("jacoco")
5-
id("org.hiero.gradle.base.jpms-modules")
6-
id("org.hiero.gradle.base.lifecycle")
7-
id("org.hiero.gradle.base.version")
8-
id("org.hiero.gradle.check.dependencies")
9-
id("org.hiero.gradle.check.javac-lint")
10-
id("org.hiero.gradle.check.spotless")
11-
id("org.hiero.gradle.check.spotless-java")
12-
id("org.hiero.gradle.check.spotless-kotlin")
13-
id("org.hiero.gradle.feature.git-properties-file")
14-
id("org.hiero.gradle.feature.java-compile")
15-
id("org.hiero.gradle.feature.java-execute")
16-
id("org.hiero.gradle.feature.test")
17-
id("org.hiero.gradle.report.test-logger")
5+
id("org.hiero.gradle.module.library")
186
id("org.hiero.gradle.feature.test-fixtures")
197
id("org.hiero.gradle.feature.test-integration")
208
id("org.hiero.gradle.feature.protobuf")
219
}
2210

2311
description = "Consensus Otter Test Framework"
2412

13+
@Suppress("UnstableApiUsage")
14+
testing {
15+
javaModuleTesting.whitebox(suites["test"]) { //
16+
sourcesUnderTest = sourceSets.testFixtures.get()
17+
}
18+
javaModuleTesting.whitebox(suites["testIntegration"]) {
19+
sourcesUnderTest = sourceSets.testFixtures.get()
20+
}
21+
suites.register<JvmTestSuite>("testOtter") {
22+
// Runs tests against the Container environment
23+
targets.register("testContainer") {
24+
testTask {
25+
dependsOn(":consensus-otter-docker-app:copyDockerizedApp")
26+
systemProperty("otter.env", "container")
27+
}
28+
}
29+
30+
// Runs tests against the Turtle environment
31+
targets.register("testTurtle") { testTask { systemProperty("otter.env", "turtle") } }
32+
}
33+
}
34+
2535
testModuleInfo {
2636
requires("com.swirlds.base")
2737
requires("com.swirlds.base.test.fixtures")
2838
requires("com.swirlds.common.test.fixtures")
2939
requires("com.swirlds.platform.core.test.fixtures")
30-
requires("org.hiero.otter.fixtures")
3140
requires("org.assertj.core")
3241
requires("org.junit.jupiter.params")
3342
requires("org.mockito")
@@ -38,41 +47,6 @@ testModuleInfo {
3847
requires("org.apache.logging.log4j")
3948
}
4049

41-
testing.suites {
42-
val testOtter by
43-
registering(JvmTestSuite::class) {
44-
useJUnitJupiter()
45-
46-
dependencies {
47-
implementation(project())
48-
implementation(project.dependencies.testFixtures(project()))
49-
implementation(project(":swirlds-common"))
50-
implementation(project(":swirlds-platform-core"))
51-
implementation(project(":base-crypto"))
52-
implementation("org.junit.jupiter:junit-jupiter-params")
53-
implementation("com.github.spotbugs:spotbugs-annotations")
54-
runtimeOnly("io.grpc:grpc-netty-shaded")
55-
}
56-
57-
targets {
58-
all {
59-
testTask.configure {
60-
// Disable all parallelism
61-
systemProperty("junit.jupiter.execution.parallel.enabled", false)
62-
systemProperty(
63-
"junit.jupiter.testclass.order.default",
64-
"org.junit.jupiter.api.ClassOrderer\$OrderAnnotation",
65-
)
66-
67-
// Limit heap and number of processors
68-
maxHeapSize = "8g"
69-
jvmArgs("-XX:ActiveProcessorCount=6")
70-
}
71-
}
72-
}
73-
}
74-
}
75-
7650
testIntegrationModuleInfo {
7751
requires("com.swirlds.common.test.fixtures")
7852
requires("com.swirlds.logging")
@@ -85,70 +59,15 @@ testIntegrationModuleInfo {
8559
runtimeOnly("io.grpc.netty.shaded")
8660
}
8761

62+
extensions.getByName<GradleOnlyDirectives>("testOtterModuleInfo").apply {
63+
runtimeOnly("io.grpc.netty.shaded")
64+
}
65+
66+
tasks.withType<Test>().configureEach { maxHeapSize = "8g" }
67+
8868
// This should probably not be necessary (Log4j issue?)
8969
// https://github.com/apache/logging-log4j2/pull/3053
9070
tasks.compileTestFixturesJava {
9171
options.compilerArgs.add("-Alog4j.graalvm.groupId=${project.group}")
9272
options.compilerArgs.add("-Alog4j.graalvm.artifactId=${project.name}")
9373
}
94-
95-
// Runs tests against the Turtle environment
96-
tasks.register<Test>("testTurtle") {
97-
useJUnitPlatform()
98-
testClassesDirs = sourceSets.named("testOtter").get().output.classesDirs
99-
classpath = sourceSets.named("testOtter").get().runtimeClasspath
100-
101-
// Disable all parallelism
102-
systemProperty("junit.jupiter.execution.parallel.enabled", false)
103-
systemProperty(
104-
"junit.jupiter.testclass.order.default",
105-
"org.junit.jupiter.api.ClassOrderer\$OrderAnnotation",
106-
)
107-
// Tell our launcher to target a Turtle network
108-
systemProperty("otter.env", "turtle")
109-
110-
// Limit heap and number of processors
111-
maxHeapSize = "8g"
112-
jvmArgs("-XX:ActiveProcessorCount=6")
113-
}
114-
115-
// Runs tests against the Container environment
116-
tasks.register<Test>("testContainer") {
117-
dependsOn(":consensus-otter-docker-app:copyDockerizedApp")
118-
119-
useJUnitPlatform()
120-
testClassesDirs = sourceSets.named("testOtter").get().output.classesDirs
121-
classpath = sourceSets.named("testOtter").get().runtimeClasspath
122-
123-
// Disable all parallelism
124-
systemProperty("junit.jupiter.execution.parallel.enabled", false)
125-
systemProperty(
126-
"junit.jupiter.testclass.order.default",
127-
"org.junit.jupiter.api.ClassOrderer\$OrderAnnotation",
128-
)
129-
130-
// Tell our launcher to target a testcontainer-based network
131-
systemProperty("otter.env", "container")
132-
133-
// Limit heap and number of processors
134-
maxHeapSize = "8g"
135-
jvmArgs("-XX:ActiveProcessorCount=6")
136-
}
137-
138-
// Configure the default testIntegration task with proper memory settings
139-
tasks.testIntegration {
140-
useJUnitPlatform()
141-
testClassesDirs = sourceSets.testIntegration.get().output.classesDirs
142-
classpath = sourceSets.testIntegration.get().runtimeClasspath
143-
144-
// Disable all parallelism
145-
systemProperty("junit.jupiter.execution.parallel.enabled", false)
146-
systemProperty(
147-
"junit.jupiter.testclass.order.default",
148-
"org.junit.jupiter.api.ClassOrderer\$OrderAnnotation",
149-
)
150-
151-
// Limit heap and number of processors
152-
maxHeapSize = "8g"
153-
jvmArgs("-XX:ActiveProcessorCount=6")
154-
}

platform-sdk/consensus-otter-tests/src/main/java/module-info.java

Lines changed: 0 additions & 2 deletions
This file was deleted.

platform-sdk/consensus-otter-tests/src/testFixtures/java/module-info.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
module org.hiero.otter.fixtures {
33
requires transitive com.hedera.node.hapi;
44
requires transitive com.hedera.pbj.runtime;
5+
requires transitive com.swirlds.base.test.fixtures;
56
requires transitive com.swirlds.base;
67
requires transitive com.swirlds.common.test.fixtures;
78
requires transitive com.swirlds.common;
@@ -25,7 +26,6 @@
2526
requires transitive org.junit.jupiter.api;
2627
requires transitive org.testcontainers;
2728
requires com.hedera.node.app.hapi.utils;
28-
requires com.swirlds.base.test.fixtures;
2929
requires com.swirlds.config.extensions;
3030
requires com.swirlds.platform.core.test.fixtures;
3131
requires org.hiero.consensus.utility;
@@ -51,13 +51,20 @@
5151
exports org.hiero.otter.fixtures.result;
5252
exports org.hiero.otter.fixtures.container.proto;
5353
exports org.hiero.otter.fixtures.app;
54-
exports org.hiero.otter.fixtures.logging.internal to
55-
org.hiero.consensus.otter.docker.app;
54+
exports org.hiero.otter.fixtures.logging.internal;
5655
exports org.hiero.otter.fixtures.internal.helpers to
5756
org.hiero.consensus.otter.docker.app;
5857
exports org.hiero.otter.fixtures.util;
5958
exports org.hiero.otter.fixtures.container.utils to
6059
org.hiero.consensus.otter.docker.app;
6160
exports org.hiero.otter.fixtures.network.utils;
6261
exports org.hiero.otter.fixtures.app.state;
62+
exports org.hiero.otter.fixtures.container;
63+
exports org.hiero.otter.fixtures.internal;
64+
exports org.hiero.otter.fixtures.internal.network;
65+
exports org.hiero.otter.fixtures.turtle;
66+
exports org.hiero.otter.fixtures.turtle.logging;
67+
exports org.hiero.otter.fixtures.turtle.gossip;
68+
exports org.hiero.otter.fixtures.internal.result;
69+
exports org.hiero.otter.fixtures.app.services.consistency;
6370
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
open module org.hiero.otter.test {
3+
requires com.swirlds.common;
4+
requires com.swirlds.platform.core;
5+
requires org.hiero.base.crypto;
6+
requires org.hiero.otter.fixtures;
7+
requires org.junit.jupiter.params;
8+
requires static com.github.spotbugs.annotations;
9+
}

platform-sdk/swirlds-platform-core/src/main/java/module-info.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@
6868
com.swirlds.config.impl,
6969
com.swirlds.platform.core.test.fixtures,
7070
com.hedera.node.app,
71-
org.hiero.otter.fixtures;
71+
org.hiero.otter.fixtures,
72+
org.hiero.otter.test;
7273
exports com.swirlds.platform.event.linking to
7374
com.swirlds.common,
7475
com.swirlds.platform.core.test.fixtures;
@@ -106,6 +107,7 @@
106107
exports com.swirlds.platform.config.internal;
107108
exports com.swirlds.platform.freeze;
108109
exports com.swirlds.platform.network.protocol.rpc;
110+
exports com.swirlds.platform.state.iss to org.hiero.otter.test;
109111

110112
requires transitive com.hedera.node.hapi;
111113
requires transitive com.hedera.pbj.runtime;

settings.gradle.kts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
// SPDX-License-Identifier: Apache-2.0
2+
pluginManagement {
3+
repositories {
4+
gradlePluginPortal()
5+
maven("https://central.sonatype.com/repository/maven-snapshots")
6+
}
7+
}
8+
9+
buildscript {
10+
configurations.classpath { resolutionStrategy.cacheChangingModulesFor(0, "seconds") }
11+
}
12+
213
plugins {
3-
id("org.hiero.gradle.build") version "0.6.0"
14+
id("org.hiero.gradle.build") version "0.6.1-SNAPSHOT"
415
id("com.hedera.pbj.pbj-compiler") version "0.12.2" apply false
516
}
617

0 commit comments

Comments
 (0)