From c667df9bec28b65c5e31e9ccd9ef81d9bb9ad77d Mon Sep 17 00:00:00 2001 From: Shams Asari Date: Fri, 1 Feb 2019 18:10:10 +0000 Subject: [PATCH] Port over ENT changes (#4706) Port of commit https://github.com/corda/enterprise/commit/9b55ad2680aa41b07d66de4208443d3095fe62a2 --- .../flows/FlowCheckpointVersionNodeStartupCheckTest.kt | 9 +++++---- .../net/corda/testing/node/internal/ProcessUtilities.kt | 9 +++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/node/src/integration-test/kotlin/net/corda/node/flows/FlowCheckpointVersionNodeStartupCheckTest.kt b/node/src/integration-test/kotlin/net/corda/node/flows/FlowCheckpointVersionNodeStartupCheckTest.kt index 55a8c0de63..73f2127631 100644 --- a/node/src/integration-test/kotlin/net/corda/node/flows/FlowCheckpointVersionNodeStartupCheckTest.kt +++ b/node/src/integration-test/kotlin/net/corda/node/flows/FlowCheckpointVersionNodeStartupCheckTest.kt @@ -22,6 +22,7 @@ import net.corda.testing.node.internal.enclosedCordapp import org.assertj.core.api.Assertions.assertThat import org.junit.Test import java.nio.file.Path +import kotlin.streams.toList import kotlin.test.assertFailsWith // TraderDemoTest already has a test which checks the node can resume a flow from a checkpoint @@ -48,9 +49,6 @@ class FlowCheckpointVersionNodeStartupCheckTest { CheckpointIncompatibleException.CordappNotInstalledException(ReceiverFlow::class.java.name).message ) - // Clean-up - stdOutLogFile(BOB_NAME).let { it.renameTo("${it.fileName}-no-cordapp") } - // Now test the scenerio where the CorDapp's hash is different but the flow exists within the jar val modifiedCordapp = defaultCordapp.copy(name = "${defaultCordapp.name}-modified") assertThat(defaultCordapp.jarFile.hash).isNotEqualTo(modifiedCordapp.jarFile.hash) // Just double-check the hashes are different @@ -90,7 +88,10 @@ class FlowCheckpointVersionNodeStartupCheckTest { } private fun DriverDSL.stdOutLogFile(name: CordaX500Name): Path { - return baseDirectory(name).list { it.filter { it.toString().endsWith("stdout.log") }.findAny().get() } + return baseDirectory(name) + .list { it.filter { it.toString().endsWith("stdout.log") }.toList() } + .sortedBy { it.attributes().creationTime() } + .last() } @InitiatingFlow diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/ProcessUtilities.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/ProcessUtilities.kt index 50a4961588..224d525ca4 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/ProcessUtilities.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/ProcessUtilities.kt @@ -3,6 +3,8 @@ package net.corda.testing.node.internal import net.corda.core.internal.div import java.io.File import java.nio.file.Path +import java.time.ZonedDateTime +import java.time.format.DateTimeFormatter object ProcessUtilities { inline fun startJavaProcess( @@ -38,8 +40,11 @@ object ProcessUtilities { inheritIO() environment()["CLASSPATH"] = classPath.joinToString(File.pathSeparator) if (workingDirectory != null) { - redirectError((workingDirectory / "$className.stderr.log").toFile()) - redirectOutput((workingDirectory / "$className.stdout.log").toFile()) + // Timestamp may be handy if the same process started, killed and then re-started. Without timestamp + // StdOut and StdErr will be overwritten. + val timestamp = ZonedDateTime.now().format(DateTimeFormatter.ofPattern("HHmmss.SSS")) + redirectError((workingDirectory / "$className.$timestamp.stderr.log").toFile()) + redirectOutput((workingDirectory / "$className.$timestamp.stdout.log").toFile()) directory(workingDirectory.toFile()) } }.start()