Skip to content

Commit 1c4e452

Browse files
authored
chore: Make CSV metric files available after container run (#21314)
Signed-off-by: Timo Brandstätter <[email protected]>
1 parent 2349820 commit 1c4e452

File tree

3 files changed

+32
-10
lines changed

3 files changed

+32
-10
lines changed

platform-sdk/consensus-otter-docker-app/src/testFixtures/java/org/hiero/consensus/otter/docker/app/DockerManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ public final class DockerManager extends ContainerControlServiceGrpc.ContainerCo
4242
private static final Logger log = LogManager.getLogger(DockerManager.class);
4343

4444
/** The string location of the docker application jar */
45-
private static final String DOCKER_APP_JAR = CONTAINER_APP_WORKING_DIR + "/apps/DockerApp.jar";
45+
private static final String DOCKER_APP_JAR = CONTAINER_APP_WORKING_DIR + "apps/DockerApp.jar";
4646

4747
/** The string location of the docker application libraries */
48-
private static final String DOCKER_APP_LIBS = CONTAINER_APP_WORKING_DIR + "/lib/*";
48+
private static final String DOCKER_APP_LIBS = CONTAINER_APP_WORKING_DIR + "lib/*";
4949

5050
/**
5151
* The main class in the docker application jar that starts the

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

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
import static java.util.Objects.requireNonNull;
66
import static org.hiero.otter.fixtures.container.utils.ContainerConstants.CONTAINER_APP_WORKING_DIR;
77
import static org.hiero.otter.fixtures.container.utils.ContainerConstants.CONTAINER_CONTROL_PORT;
8+
import static org.hiero.otter.fixtures.container.utils.ContainerConstants.HASHSTREAM_LOG_PATH;
9+
import static org.hiero.otter.fixtures.container.utils.ContainerConstants.METRICS_PATH;
810
import static org.hiero.otter.fixtures.container.utils.ContainerConstants.NODE_COMMUNICATION_PORT;
11+
import static org.hiero.otter.fixtures.container.utils.ContainerConstants.SWIRLDS_LOG_PATH;
912
import static org.hiero.otter.fixtures.internal.AbstractNetwork.NODE_IDENTIFIER_FORMAT;
1013
import static org.hiero.otter.fixtures.internal.AbstractNode.LifeCycle.DESTROYED;
1114
import static org.hiero.otter.fixtures.internal.AbstractNode.LifeCycle.INIT;
@@ -372,17 +375,21 @@ public SingleNodeMarkerFileResult newMarkerFileResult() {
372375
void destroy() {
373376
try {
374377
// copy logs from container to the local filesystem
375-
final Path logPath = Path.of("build", "container", NODE_IDENTIFIER_FORMAT.formatted(selfId.id()), "output");
376-
Files.createDirectories(logPath.resolve("swirlds-hashstream"));
378+
final Path outputPath = Path.of("build", "container", NODE_IDENTIFIER_FORMAT.formatted(selfId.id()));
379+
Files.createDirectories(outputPath.resolve("output/swirlds-hashstream"));
380+
Files.createDirectories(outputPath.resolve("data/stats"));
377381

378382
container.copyFileFromContainer(
379-
CONTAINER_APP_WORKING_DIR + "/output/swirlds.log",
380-
logPath.resolve("swirlds.log").toString());
383+
CONTAINER_APP_WORKING_DIR + SWIRLDS_LOG_PATH,
384+
outputPath.resolve(SWIRLDS_LOG_PATH).toString());
381385
container.copyFileFromContainer(
382-
CONTAINER_APP_WORKING_DIR + "/output/swirlds-hashstream/swirlds-hashstream.log",
383-
logPath.resolve("swirlds-hashstream/swirlds-hashstream.log").toString());
386+
CONTAINER_APP_WORKING_DIR + HASHSTREAM_LOG_PATH,
387+
outputPath.resolve(HASHSTREAM_LOG_PATH).toString());
388+
container.copyFileFromContainer(
389+
CONTAINER_APP_WORKING_DIR + METRICS_PATH.formatted(selfId.id()),
390+
outputPath.resolve(METRICS_PATH.formatted(selfId.id())).toString());
384391
} catch (final IOException e) {
385-
throw new UncheckedIOException("Failed to copy logs from container", e);
392+
throw new UncheckedIOException("Failed to copy files from container", e);
386393
}
387394

388395
if (lifeCycle == RUNNING) {

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,22 @@ public class ContainerConstants {
1212
/**
1313
* Working directory of the container
1414
*/
15-
public static final String CONTAINER_APP_WORKING_DIR = "/opt/DockerApp";
15+
public static final String CONTAINER_APP_WORKING_DIR = "/opt/DockerApp/";
16+
17+
/**
18+
* Path to {@code swirdls.log} file
19+
*/
20+
public static final String SWIRLDS_LOG_PATH = "output/swirlds.log";
21+
22+
/**
23+
* Path to {@code swirlds-hashstream.log} file
24+
*/
25+
public static final String HASHSTREAM_LOG_PATH = "output/swirlds-hashstream/swirlds-hashstream.log";
26+
27+
/**
28+
* Path to {@code MainNetStats{nodeId}.csv} file
29+
*/
30+
public static final String METRICS_PATH = "data/stats/MainNetStats%d.csv";
1631

1732
/**
1833
* The port to open to allow connections to the

0 commit comments

Comments
 (0)