diff --git a/packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/jvm-kotlin-spring-server.test.ts b/packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/jvm-kotlin-spring-server.test.ts index 6d66d8c4db8..235f91b558c 100644 --- a/packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/jvm-kotlin-spring-server.test.ts +++ b/packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/jvm-kotlin-spring-server.test.ts @@ -36,21 +36,8 @@ test(testCase, async (t: Test) => { t.ok(ledger, "CordaTestLedger instantaited OK"); test.onFinish(async () => { - try { - const logBuffer = ((await ledgerContainer.logs({ - follow: false, - stdout: true, - stderr: true, - })) as unknown) as Buffer; - const logs = logBuffer.toString("utf-8"); - t.comment(`[CordaAllInOne] ${logs}`); - } finally { - try { - await ledger.stop(); - } finally { - await ledger.destroy(); - } - } + await ledger.stop(); + await ledger.destroy(); }); const ledgerContainer = await ledger.start(); t.ok(ledgerContainer, "CordaTestLedger container truthy post-start() OK"); diff --git a/packages/cactus-test-tooling/src/main/typescript/corda/corda-test-ledger.ts b/packages/cactus-test-tooling/src/main/typescript/corda/corda-test-ledger.ts index 374f37eb129..ce31edc1dda 100644 --- a/packages/cactus-test-tooling/src/main/typescript/corda/corda-test-ledger.ts +++ b/packages/cactus-test-tooling/src/main/typescript/corda/corda-test-ledger.ts @@ -13,6 +13,7 @@ import { Logger, LoggerProvider, Checks, + Bools, } from "@hyperledger/cactus-common"; import { Base64File } from "../common/base64-file"; import { @@ -32,6 +33,7 @@ export interface ICordaTestLedgerConstructorOptions { rpcPortC?: number; logLevel?: LogLevelDesc; envVars?: string[]; + emitContainerLogs?: boolean; } /* @@ -81,6 +83,7 @@ export class CordaTestLedger implements ITestLedger { public readonly rpcPortA: number; public readonly rpcPortB: number; public readonly rpcPortC: number; + public readonly emitContainerLogs: boolean; private container: Container | undefined; private containerId: string | undefined; @@ -96,6 +99,9 @@ export class CordaTestLedger implements ITestLedger { this.rpcPortB = opts.rpcPortB || DEFAULTS.rpcPortB; this.rpcPortC = opts.rpcPortC || DEFAULTS.rpcPortC; this.rpcPortNotary = opts.rpcPortNotary || DEFAULTS.rpcPortNotary; + this.emitContainerLogs = Bools.isBooleanStrict(opts.emitContainerLogs) + ? (opts.emitContainerLogs as boolean) + : true; this.envVars = opts.envVars ? opts.envVars : DEFAULTS.envVars; Checks.truthy(Array.isArray(this.envVars), `${fnTag}:envVars not an array`); @@ -168,6 +174,14 @@ export class CordaTestLedger implements ITestLedger { eventEmitter.once("start", async (container: Container) => { this.container = container; this.containerId = container.id; + if (this.emitContainerLogs) { + const logOptions = { follow: true, stderr: true, stdout: true }; + const logStream = await container.logs(logOptions); + logStream.on("data", (data: Buffer) => { + const fnTag = `[${this.getContainerImageName()}]`; + this.log.debug(`${fnTag} %o`, data.toString("utf-8")); + }); + } try { let isHealthy = false; do {