Merge branch 'release/os/4.5' into jamesh/os-4.5-4.6-merge-11062020

This commit is contained in:
James Higgs 2020-06-11 09:40:39 +01:00
commit ab023d0b07
3 changed files with 22 additions and 4 deletions

View File

@ -333,8 +333,7 @@ open class NodeStartup : NodeStartupLogging {
if (devMode) return true if (devMode) return true
if (!certDirectory.isDirectory()) { if (!certDirectory.isDirectory()) {
printError("Unable to access certificates directory ${certDirectory}. This could be because the node has not been registered with the Identity Operator.") logger.error("Unable to access certificates directory ${certDirectory}. This could be because the node has not been registered with the Identity Operator. Node will now shutdown")
printError("Node will now shutdown.")
return false return false
} }
return true return true
@ -504,6 +503,7 @@ interface NodeStartupLogging {
fun CliWrapperBase.initLogging(baseDirectory: Path): Boolean { fun CliWrapperBase.initLogging(baseDirectory: Path): Boolean {
System.setProperty("defaultLogLevel", specifiedLogLevel) // These properties are referenced from the XML config file. System.setProperty("defaultLogLevel", specifiedLogLevel) // These properties are referenced from the XML config file.
System.setProperty("log-path", (baseDirectory / NodeCliCommand.LOGS_DIRECTORY_NAME).toString())
if (verbose) { if (verbose) {
System.setProperty("consoleLoggingEnabled", "true") System.setProperty("consoleLoggingEnabled", "true")
System.setProperty("consoleLogLevel", specifiedLogLevel) System.setProperty("consoleLogLevel", specifiedLogLevel)
@ -526,7 +526,6 @@ fun CliWrapperBase.initLogging(baseDirectory: Path): Boolean {
return false return false
} }
System.setProperty("log-path", (baseDirectory / NodeCliCommand.LOGS_DIRECTORY_NAME).toString())
SLF4JBridgeHandler.removeHandlersForRootLogger() // The default j.u.l config adds a ConsoleHandler. SLF4JBridgeHandler.removeHandlersForRootLogger() // The default j.u.l config adds a ConsoleHandler.
SLF4JBridgeHandler.install() SLF4JBridgeHandler.install()
return true return true

View File

@ -2,14 +2,19 @@ package net.corda.node.internal
import net.corda.cliutils.CommonCliConstants import net.corda.cliutils.CommonCliConstants
import net.corda.core.internal.div import net.corda.core.internal.div
import net.corda.core.internal.exists
import net.corda.nodeapi.internal.config.UnknownConfigKeysPolicy import net.corda.nodeapi.internal.config.UnknownConfigKeysPolicy
import org.assertj.core.api.Assertions import org.assertj.core.api.Assertions
import org.junit.BeforeClass import org.junit.BeforeClass
import org.junit.Test import org.junit.Test
import org.slf4j.LoggerFactory
import org.slf4j.event.Level import org.slf4j.event.Level
import picocli.CommandLine import picocli.CommandLine
import java.nio.file.Files
import java.nio.file.Path import java.nio.file.Path
import java.nio.file.Paths import java.nio.file.Paths
import kotlin.test.assertFalse
import kotlin.test.assertTrue
class NodeStartupCliTest { class NodeStartupCliTest {
private val startup = NodeStartupCli() private val startup = NodeStartupCli()
@ -49,4 +54,17 @@ class NodeStartupCliTest {
Assertions.assertThat(startup.cmdLineOptions.configFile).isEqualTo(workingDirectory / "another-base-dir" / "node.conf") Assertions.assertThat(startup.cmdLineOptions.configFile).isEqualTo(workingDirectory / "another-base-dir" / "node.conf")
Assertions.assertThat(startup.cmdLineOptions.networkRootTrustStorePathParameter).isEqualTo(null) Assertions.assertThat(startup.cmdLineOptions.networkRootTrustStorePathParameter).isEqualTo(null)
} }
@Test(timeout=3_000)
fun `test logs are written to correct location correctly if verbose flag set`() {
val node = NodeStartupCli()
val dir = Files.createTempDirectory("verboseLoggingTest")
node.verbose = true
// With verbose set, initLogging can accidentally attempt to access a logger before all required system properties are set. This
// causes the logging config to be parsed too early, resulting in logs being written to the wrong directory
node.initLogging(dir)
LoggerFactory.getLogger("").debug("Test message")
assertTrue(dir.resolve("logs").exists())
assertFalse(Paths.get("./logs").exists())
}
} }

View File

@ -27,6 +27,7 @@ object UpdateBusinessDayFlow {
override fun call() { override fun call() {
val message = otherPartySession.receive<UpdateBusinessDayMessage>().unwrap { it } val message = otherPartySession.receive<UpdateBusinessDayMessage>().unwrap { it }
(serviceHub.clock as DemoClock).updateDate(message.date) (serviceHub.clock as DemoClock).updateDate(message.date)
otherPartySession.send(true) // Let's Broadcast know we've updated the clock
} }
} }
@ -64,7 +65,7 @@ object UpdateBusinessDayFlow {
@Suspendable @Suspendable
private fun doNextRecipient(recipient: Party) { private fun doNextRecipient(recipient: Party) {
initiateFlow(recipient).send(UpdateBusinessDayMessage(date)) initiateFlow(recipient).sendAndReceive<Boolean>(UpdateBusinessDayMessage(date))
} }
} }
} }