|
1 | 1 | // SPDX-License-Identifier: Apache-2.0 |
| 2 | +import org.gradlex.javamodule.dependencies.dsl.GradleOnlyDirectives |
| 3 | + |
2 | 4 | 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") |
18 | 6 | id("org.hiero.gradle.feature.test-fixtures") |
19 | 7 | id("org.hiero.gradle.feature.test-integration") |
20 | 8 | id("org.hiero.gradle.feature.protobuf") |
21 | 9 | } |
22 | 10 |
|
23 | 11 | description = "Consensus Otter Test Framework" |
24 | 12 |
|
| 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 | + |
25 | 35 | testModuleInfo { |
26 | 36 | requires("com.swirlds.base") |
27 | 37 | requires("com.swirlds.base.test.fixtures") |
28 | 38 | requires("com.swirlds.common.test.fixtures") |
| 39 | + requires("com.swirlds.component.framework") |
| 40 | + requires("com.swirlds.metrics.api") |
29 | 41 | requires("com.swirlds.platform.core.test.fixtures") |
30 | | - requires("org.hiero.otter.fixtures") |
| 42 | + requires("org.apache.logging.log4j") |
31 | 43 | requires("org.assertj.core") |
| 44 | + requires("org.hiero.consensus.utility") |
32 | 45 | requires("org.junit.jupiter.params") |
33 | 46 | requires("org.mockito") |
34 | | - requires("com.github.spotbugs.annotations") |
35 | | - requires("com.swirlds.component.framework") |
36 | | - requires("com.swirlds.metrics.api") |
37 | | - requires("org.hiero.consensus.utility") |
38 | | - requires("org.apache.logging.log4j") |
39 | | -} |
40 | | - |
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 | | - } |
| 47 | + requiresStatic("com.github.spotbugs.annotations") |
74 | 48 | } |
75 | 49 |
|
76 | 50 | testIntegrationModuleInfo { |
| 51 | + requires("awaitility") |
77 | 52 | requires("com.swirlds.common.test.fixtures") |
78 | 53 | requires("com.swirlds.logging") |
79 | | - requires("org.hiero.otter.fixtures") |
| 54 | + requires("org.apache.logging.log4j") |
80 | 55 | requires("org.assertj.core") |
| 56 | + requires("org.hiero.otter.fixtures") |
81 | 57 | requires("org.junit.jupiter.params") |
82 | | - requires("com.github.spotbugs.annotations") |
83 | | - requires("org.apache.logging.log4j") |
84 | | - requires("awaitility") |
| 58 | + requiresStatic("com.github.spotbugs.annotations") |
| 59 | + runtimeOnly("io.grpc.netty.shaded") |
| 60 | + |
| 61 | + opensTo("com.fasterxml.jackson.databind") |
| 62 | +} |
| 63 | + |
| 64 | +extensions.getByName<GradleOnlyDirectives>("testOtterModuleInfo").apply { |
85 | 65 | runtimeOnly("io.grpc.netty.shaded") |
86 | 66 | } |
87 | 67 |
|
| 68 | +tasks.withType<Test>().configureEach { maxHeapSize = "8g" } |
| 69 | + |
88 | 70 | // This should probably not be necessary (Log4j issue?) |
89 | 71 | // https://github.com/apache/logging-log4j2/pull/3053 |
90 | 72 | tasks.compileTestFixturesJava { |
91 | 73 | options.compilerArgs.add("-Alog4j.graalvm.groupId=${project.group}") |
92 | 74 | options.compilerArgs.add("-Alog4j.graalvm.artifactId=${project.name}") |
93 | 75 | } |
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 | | -} |
0 commit comments