Skip to content

Commit a4252d6

Browse files
pouloknetopyr
andauthored
chore: Aggregate Otter test output directories (#22227)
Signed-off-by: Kelly Greco <[email protected]> Signed-off-by: Michael Heinrichs <[email protected]> Co-authored-by: Michael Heinrichs <[email protected]>
1 parent 89a6b33 commit a4252d6

19 files changed

+297
-118
lines changed

.github/workflows/node-zxc-compile-application-code.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,17 +348,15 @@ jobs:
348348
if: ${{ inputs.enable-integration-tests && inputs.enable-network-log-capture && steps.gradle-integration-tests.conclusion == 'failure' && !cancelled() }}
349349
with:
350350
name: Otter Integration Tests Turtle Logs
351-
path: |
352-
platform-sdk/consensus-otter-tests/build/turtle/**
351+
path: platform-sdk/consensus-otter-tests/build/turtle
353352
retention-days: 7
354353

355354
- name: Upload Otter Integration Tests Container Logs
356355
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
357356
if: ${{ inputs.enable-integration-tests && inputs.enable-network-log-capture && steps.gradle-integration-tests.conclusion == 'failure' && !cancelled() }}
358357
with:
359358
name: Otter Integration Tests Container Logs
360-
path: |
361-
platform-sdk/consensus-otter-tests/build/container/**
359+
path: platform-sdk/consensus-otter-tests/build/container
362360
retention-days: 7
363361

364362
- name: HAPI Testing (Misc)

.github/workflows/zxc-execute-otter-tests.yaml

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,15 @@ jobs:
152152
if: ${{ inputs.enable-fast-otter-tests && inputs.enable-network-log-capture && steps.gradle-fast-otter-tests.conclusion == 'failure' && !cancelled() }}
153153
with:
154154
name: Otter Tests Turtle Logs
155-
path: |
156-
platform-sdk/consensus-otter-tests/build/turtle/**
155+
path: platform-sdk/consensus-otter-tests/build/turtle
157156
retention-days: 7
158157

159158
- name: Upload Fast Otter Tests Container Logs
160159
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
161160
if: ${{ inputs.enable-fast-otter-tests && inputs.enable-network-log-capture && steps.gradle-fast-otter-tests.conclusion == 'failure' && !cancelled() }}
162161
with:
163162
name: Otter Tests Container Logs
164-
path: |
165-
platform-sdk/consensus-otter-tests/build/container/**
163+
path: platform-sdk/consensus-otter-tests/build/container
166164
retention-days: 7
167165

168166
- name: Full Otter Testing
@@ -179,33 +177,23 @@ jobs:
179177
with:
180178
check_name: "Node: Otter Tests Results"
181179
json_thousands_separator: ","
182-
junit_files: "**/consensus-otter-tests/build/test-results/testOtter/TEST-*.xml"
180+
junit_files: "**/consensus-otter-tests/build/test-results/testContainer/TEST-*.xml"
183181
comment_mode: errors # only comment if we could not find or parse the JUnit XML files
184182

185183
- name: Upload Full Otter Tests Report Artifacts
186184
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
187185
if: ${{ inputs.enable-full-otter-tests && steps.gradle-build.conclusion == 'success' && !cancelled() }}
188186
with:
189187
name: Otter Tests Report
190-
path: "**/consensus-otter-tests/build/test-results/testOtter/TEST-*.xml"
191-
retention-days: 7
192-
193-
- name: Upload Full Otter Tests Turtle Logs
194-
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
195-
if: ${{ inputs.enable-full-otter-tests && inputs.enable-network-log-capture && steps.gradle-full-otter-tests.conclusion == 'failure' && !cancelled() }}
196-
with:
197-
name: Otter Tests Turtle Logs
198-
path: |
199-
platform-sdk/consensus-otter-tests/build/turtle/**
188+
path: "**/consensus-otter-tests/build/test-results/testContainer/TEST-*.xml"
200189
retention-days: 7
201190

202191
- name: Upload Full Otter Tests Container Logs
203192
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
204193
if: ${{ inputs.enable-full-otter-tests && inputs.enable-network-log-capture && steps.gradle-full-otter-tests.conclusion == 'failure' && !cancelled() }}
205194
with:
206195
name: Otter Tests Container Logs
207-
path: |
208-
platform-sdk/consensus-otter-tests/build/container/**
196+
path: platform-sdk/consensus-otter-tests/build/container
209197
retention-days: 7
210198

211199
- name: Chaos Otter Testing
@@ -238,17 +226,15 @@ jobs:
238226
if: ${{ inputs.enable-chaos-otter-tests && inputs.enable-network-log-capture && steps.gradle-chaos-otter-tests.conclusion == 'failure' && !cancelled() }}
239227
with:
240228
name: Chaos Otter Tests Turtle Logs
241-
path: |
242-
platform-sdk/consensus-otter-tests/build/turtle/**
229+
path: platform-sdk/consensus-otter-tests/build/turtle
243230
retention-days: 7
244231

245232
- name: Upload Chaos Otter Tests Container Logs
246233
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
247234
if: ${{ inputs.enable-chaos-otter-tests && inputs.enable-network-log-capture && steps.gradle-chaos-otter-tests.conclusion == 'failure' && !cancelled() }}
248235
with:
249236
name: Chaos Otter Tests Container Logs
250-
path: |
251-
platform-sdk/consensus-otter-tests/build/container/**
237+
path: platform-sdk/consensus-otter-tests/build/container
252238
retention-days: 7
253239

254240
- name: Check Results

platform-sdk/consensus-otter-tests/src/testFixtures/java/org/hiero/otter/fixtures/TestEnvironment.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
package org.hiero.otter.fixtures;
33

44
import edu.umd.cs.findbugs.annotations.NonNull;
5+
import java.nio.file.Path;
56
import java.util.Set;
67
import org.hiero.otter.fixtures.chaosbot.ChaosBot;
78
import org.hiero.otter.fixtures.chaosbot.ChaosBotConfiguration;
@@ -55,6 +56,13 @@ public interface TestEnvironment {
5556
@NonNull
5657
ChaosBot createChaosBot(@NonNull ChaosBotConfiguration configuration);
5758

59+
/**
60+
* Get the root output directory for this test environment.
61+
* @return the output directory
62+
*/
63+
@NonNull
64+
Path outputDirectory();
65+
5866
/**
5967
* Destroys the test environment. Once this method is called, the test environment and all its
6068
* components are no longer usable. This method is idempotent, meaning that it is safe to call

platform-sdk/consensus-otter-tests/src/testFixtures/java/org/hiero/otter/fixtures/container/ContainerNode.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import static org.hiero.otter.fixtures.container.utils.ContainerConstants.NODE_COMMUNICATION_PORT;
1212
import static org.hiero.otter.fixtures.container.utils.ContainerConstants.OTTER_LOG_PATH;
1313
import static org.hiero.otter.fixtures.container.utils.ContainerConstants.SWIRLDS_LOG_PATH;
14-
import static org.hiero.otter.fixtures.internal.AbstractNetwork.NODE_IDENTIFIER_FORMAT;
1514
import static org.hiero.otter.fixtures.internal.AbstractNode.LifeCycle.DESTROYED;
1615
import static org.hiero.otter.fixtures.internal.AbstractNode.LifeCycle.INIT;
1716
import static org.hiero.otter.fixtures.internal.AbstractNode.LifeCycle.RUNNING;
@@ -497,8 +496,6 @@ public void stopProfiling() {
497496
void destroy() {
498497
try {
499498
// copy logs from container to the local filesystem
500-
final Path localOutputDirectory =
501-
Path.of("build", "container", NODE_IDENTIFIER_FORMAT.formatted(selfId.id()));
502499
downloadConsensusFiles(localOutputDirectory);
503500
downloadConsistencyServiceFiles(localOutputDirectory);
504501
} catch (final IOException e) {

platform-sdk/consensus-otter-tests/src/testFixtures/java/org/hiero/otter/fixtures/container/ContainerTestEnvironment.java

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import static java.util.Collections.unmodifiableSet;
55
import static org.assertj.core.api.Fail.fail;
6+
import static org.hiero.otter.fixtures.util.EnvironmentUtils.getDefaultOutputDirectory;
67

78
import com.swirlds.common.io.utility.FileUtils;
89
import edu.umd.cs.findbugs.annotations.NonNull;
@@ -28,6 +29,8 @@
2829
*/
2930
public class ContainerTestEnvironment implements TestEnvironment {
3031

32+
private static final String ENV_NAME = "container";
33+
3134
/** Capabilities supported by the container test environment */
3235
private static final Set<Capability> CAPABILITIES = unmodifiableSet(EnumSet.of(
3336
Capability.RECONNECT,
@@ -38,15 +41,16 @@ public class ContainerTestEnvironment implements TestEnvironment {
3841
/** The granularity of time defining how often continuous assertions are checked */
3942
private static final Duration GRANULARITY = Duration.ofMillis(10);
4043

44+
private final Path rootOutputDirectory;
4145
private final ContainerNetwork network;
4246
private final RegularTimeManager timeManager = new RegularTimeManager(GRANULARITY);
4347
private final ContainerTransactionGenerator transactionGenerator = new ContainerTransactionGenerator();
4448

4549
/**
46-
* Constructor with default values for using random node-ids
50+
* Constructor with default values for using random node-ids and default directory for container logs.
4751
*/
4852
public ContainerTestEnvironment() {
49-
this(true);
53+
this(true, getDefaultOutputDirectory(ENV_NAME));
5054
}
5155

5256
/**
@@ -55,10 +59,20 @@ public ContainerTestEnvironment() {
5559
* @param useRandomNodeIds {@code true} if the node IDs should be selected randomly; {@code false} otherwise
5660
*/
5761
public ContainerTestEnvironment(final boolean useRandomNodeIds) {
62+
this(useRandomNodeIds, getDefaultOutputDirectory(ENV_NAME));
63+
}
5864

65+
/**
66+
* Constructor for the {@link ContainerTestEnvironment} class with custom output directory.
67+
*
68+
* @param useRandomNodeIds {@code true} if the node IDs should be selected randomly; {@code false} otherwise
69+
* @param rootOutputDirectory the root directory where container logs will be written per test
70+
*/
71+
public ContainerTestEnvironment(final boolean useRandomNodeIds, @NonNull final Path rootOutputDirectory) {
5972
ContainerLogConfigBuilder.configure();
6073

61-
final Path rootOutputDirectory = Path.of("build", "container");
74+
this.rootOutputDirectory = rootOutputDirectory; // store for later retrieval
75+
6276
try {
6377
if (Files.exists(rootOutputDirectory)) {
6478
FileUtils.deleteDirectory(rootOutputDirectory);
@@ -127,6 +141,15 @@ public ChaosBot createChaosBot(@NonNull final ChaosBotConfiguration configuratio
127141
return new ChaosBotImpl(this, configuration);
128142
}
129143

144+
/**
145+
* {@inheritDoc}
146+
*/
147+
@Override
148+
@NonNull
149+
public Path outputDirectory() {
150+
return rootOutputDirectory;
151+
}
152+
130153
/**
131154
* {@inheritDoc}
132155
*/

platform-sdk/consensus-otter-tests/src/testFixtures/java/org/hiero/otter/fixtures/junit/OtterTestExtension.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.hiero.otter.fixtures.specs.OtterSpecs;
1818
import org.hiero.otter.fixtures.specs.TurtleSpecs;
1919
import org.hiero.otter.fixtures.turtle.TurtleTestEnvironment;
20+
import org.hiero.otter.fixtures.util.EnvironmentUtils;
2021
import org.junit.jupiter.api.RepeatedTest;
2122
import org.junit.jupiter.api.Test;
2223
import org.junit.jupiter.api.TestFactory;
@@ -272,7 +273,8 @@ private TestEnvironment createTurtleTestEnvironment(@NonNull final ExtensionCont
272273
AnnotationSupport.findAnnotation(extensionContext.getElement(), TurtleSpecs.class);
273274
final long randomSeed = turtleSpecs.map(TurtleSpecs::randomSeed).orElse(0L);
274275

275-
return new TurtleTestEnvironment(randomSeed, randomNodeIds);
276+
final var outputDirectory = EnvironmentUtils.getDefaultOutputDirectory("turtle", extensionContext);
277+
return new TurtleTestEnvironment(randomSeed, randomNodeIds, outputDirectory);
276278
}
277279

278280
/**
@@ -288,7 +290,8 @@ private TestEnvironment createContainerTestEnvironment(@NonNull final ExtensionC
288290
AnnotationSupport.findAnnotation(extensionContext.getElement(), OtterSpecs.class);
289291
final boolean randomNodeIds = otterSpecs.map(OtterSpecs::randomNodeIds).orElse(true);
290292

291-
return new ContainerTestEnvironment(randomNodeIds);
293+
final var outputDirectory = EnvironmentUtils.getDefaultOutputDirectory("container", extensionContext);
294+
return new ContainerTestEnvironment(randomNodeIds, outputDirectory);
292295
}
293296

294297
/**

platform-sdk/consensus-otter-tests/src/testFixtures/java/org/hiero/otter/fixtures/turtle/TurtleTestEnvironment.java

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import static com.swirlds.platform.test.fixtures.config.ConfigUtils.CONFIGURATION;
55
import static com.swirlds.platform.test.fixtures.state.TestingAppStateInitializer.registerConstructablesForStorage;
66
import static java.util.Collections.unmodifiableSet;
7+
import static org.hiero.otter.fixtures.util.EnvironmentUtils.getDefaultOutputDirectory;
78

89
import com.swirlds.base.test.fixtures.time.FakeTime;
910
import com.swirlds.common.io.utility.FileUtils;
@@ -48,11 +49,14 @@ public class TurtleTestEnvironment implements TestEnvironment {
4849

4950
private static final Logger log = LogManager.getLogger(TurtleTestEnvironment.class);
5051

52+
private static final String ENV_NAME = "turtle";
53+
5154
/** Capabilities supported by the Turtle test environment */
5255
private static final Set<Capability> CAPABILITIES = unmodifiableSet(EnumSet.of(Capability.DETERMINISTIC_EXECUTION));
5356

5457
static final Duration GRANULARITY = Duration.ofMillis(10);
5558

59+
private final Path rootOutputDirectory;
5660
private final TurtleNetwork network;
5761
private final TurtleTransactionGenerator transactionGenerator;
5862
private final TurtleTimeManager timeManager;
@@ -61,7 +65,7 @@ public class TurtleTestEnvironment implements TestEnvironment {
6165
* Constructor with default values for using a random seed and random node-ids
6266
*/
6367
public TurtleTestEnvironment() {
64-
this(0L, true);
68+
this(0L, true, getDefaultOutputDirectory(ENV_NAME));
6569
}
6670

6771
/**
@@ -71,7 +75,21 @@ public TurtleTestEnvironment() {
7175
* @param useRandomNodeIds {@code true} if the node IDs should be selected randomly; {@code false} otherwise
7276
*/
7377
public TurtleTestEnvironment(final long randomSeed, final boolean useRandomNodeIds) {
74-
final Path rootOutputDirectory = Path.of("build", "turtle");
78+
this(randomSeed, useRandomNodeIds, getDefaultOutputDirectory(ENV_NAME));
79+
}
80+
81+
/**
82+
* Constructor for the {@link TurtleTestEnvironment} class.
83+
*
84+
* @param randomSeed the seed for the PRNG; if {@code 0}, a random seed will be generated
85+
* @param useRandomNodeIds {@code true} if the node IDs should be selected randomly; {@code false} otherwise
86+
* @param rootOutputDirectory the root output directory for Turtle logs
87+
*/
88+
public TurtleTestEnvironment(
89+
final long randomSeed, final boolean useRandomNodeIds, final Path rootOutputDirectory) {
90+
91+
this.rootOutputDirectory = rootOutputDirectory; // set for later retrieval
92+
7593
try {
7694
if (Files.exists(rootOutputDirectory)) {
7795
FileUtils.deleteDirectory(rootOutputDirectory);
@@ -166,6 +184,15 @@ public ChaosBot createChaosBot(@NonNull final ChaosBotConfiguration configuratio
166184
throw new UnsupportedOperationException("ChaosBot is not supported in TurtleTestEnvironment");
167185
}
168186

187+
/**
188+
* {@inheritDoc}
189+
*/
190+
@Override
191+
@NonNull
192+
public Path outputDirectory() {
193+
return rootOutputDirectory;
194+
}
195+
169196
/**
170197
* {@inheritDoc}
171198
*/

0 commit comments

Comments
 (0)