From 5e16a31085c530bc3e6f5c67468ff89639b8f0f6 Mon Sep 17 00:00:00 2001 From: Vyatcheslav Suharnikov Date: Mon, 28 Oct 2024 15:11:14 +0400 Subject: [PATCH] Node number in logs --- .../src/test/scala/units/BaseItTestSuite.scala | 7 ++++++- .../src/test/scala/units/docker/EcContainer.scala | 10 ++++++++-- .../test/scala/units/docker/WavesNodeContainer.scala | 7 ++++++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/consensus-client-it/src/test/scala/units/BaseItTestSuite.scala b/consensus-client-it/src/test/scala/units/BaseItTestSuite.scala index 3288b814..3aa9c8a4 100644 --- a/consensus-client-it/src/test/scala/units/BaseItTestSuite.scala +++ b/consensus-client-it/src/test/scala/units/BaseItTestSuite.scala @@ -39,7 +39,12 @@ trait BaseItTestSuite protected lazy val network = Networks.network - protected lazy val ec1: EcContainer = new EcContainer(network, "ec-1", Networks.ipForNode(2)) // ipForNode(1) is assigned to Ryuk + protected lazy val ec1: EcContainer = new EcContainer( + network = network, + number = 1, + ip = Networks.ipForNode(2) // ipForNode(1) is assigned to Ryuk + ) + protected lazy val waves1: WavesNodeContainer = new WavesNodeContainer( network = network, number = 1, diff --git a/consensus-client-it/src/test/scala/units/docker/EcContainer.scala b/consensus-client-it/src/test/scala/units/docker/EcContainer.scala index 15736a96..98573a7e 100644 --- a/consensus-client-it/src/test/scala/units/docker/EcContainer.scala +++ b/consensus-client-it/src/test/scala/units/docker/EcContainer.scala @@ -1,5 +1,6 @@ package units.docker +import com.google.common.io.Files import com.typesafe.config.{ConfigFactory, ConfigValueFactory} import net.ceedubs.ficus.Ficus.toFicusConfig import org.testcontainers.containers.BindMode @@ -16,7 +17,12 @@ import units.el.ElBridgeClient import units.eth.EthAddress import units.http.OkHttpLogger -class EcContainer(network: NetworkImpl, hostName: String, ip: String) extends BaseContainer(hostName) { +import java.io.File + +class EcContainer(network: NetworkImpl, number: Int, ip: String) extends BaseContainer(s"ec-$number") { + private val logFile = new File(s"$DefaultLogsDir/besu-$number.log") + Files.touch(logFile) + protected override val container = new GenericContainer(DockerImageName.parse("hyperledger/besu:latest")) .withNetwork(network) .withExposedPorts(RpcPort, EnginePort) @@ -25,7 +31,7 @@ class EcContainer(network: NetworkImpl, hostName: String, ip: String) extends Ba .withFileSystemBind(s"$ConfigsDir/besu", "/config", BindMode.READ_ONLY) .withFileSystemBind(s"$ConfigsDir/besu/run-besu.sh", "/tmp/run.sh", BindMode.READ_ONLY) .withFileSystemBind(s"$ConfigsDir/ec-common/p2p-key-1.hex", "/etc/secrets/p2p-key", BindMode.READ_ONLY) - .withFileSystemBind(s"$DefaultLogsDir", "/opt/besu/logs", BindMode.READ_WRITE) + .withFileSystemBind(s"$logFile", "/opt/besu/logs/besu.log", BindMode.READ_WRITE) .withCreateContainerCmdModifier { cmd => cmd .withName(s"${network.getName}-$hostName") diff --git a/consensus-client-it/src/test/scala/units/docker/WavesNodeContainer.scala b/consensus-client-it/src/test/scala/units/docker/WavesNodeContainer.scala index 0ac5d9b4..6b7978d1 100644 --- a/consensus-client-it/src/test/scala/units/docker/WavesNodeContainer.scala +++ b/consensus-client-it/src/test/scala/units/docker/WavesNodeContainer.scala @@ -1,5 +1,6 @@ package units.docker +import com.google.common.io.Files import com.wavesplatform.account.Address import com.wavesplatform.api.NodeHttpApi import com.wavesplatform.common.utils.Base58 @@ -11,6 +12,7 @@ import units.client.HttpChainContractClient import units.docker.BaseContainer.{ConfigsDir, DefaultLogsDir} import units.docker.WavesNodeContainer.ApiPort +import java.io.File import java.nio.charset.StandardCharsets import scala.jdk.CollectionConverters.MapHasAsJava @@ -22,6 +24,9 @@ class WavesNodeContainer( chainContractAddress: Address, ecEngineApiUrl: String ) extends BaseContainer(s"wavesnode-$number") { + private val logFile = new File(s"$DefaultLogsDir/waves-$number.log") + Files.touch(logFile) + protected override val container = new GenericContainer(DockerImageName.parse(System.getProperty("cc.it.docker.image"))) .withNetwork(network) .withExposedPorts(ApiPort) @@ -41,7 +46,7 @@ class WavesNodeContainer( ) .withFileSystemBind(s"$ConfigsDir/wavesnode", "/etc/waves", BindMode.READ_ONLY) .withFileSystemBind(s"$ConfigsDir/ec-common", "/etc/secrets", BindMode.READ_ONLY) - .withFileSystemBind(s"$DefaultLogsDir", "/var/log/waves", BindMode.READ_WRITE) + .withFileSystemBind(s"$logFile", "/var/log/waves/waves.log", BindMode.READ_WRITE) .withCreateContainerCmdModifier { cmd => cmd .withName(s"${network.getName}-$hostName")