From 1330b49f720823262a33451e6421331ac41b79e5 Mon Sep 17 00:00:00 2001 From: Peter Somogyvari Date: Sun, 8 Sep 2024 13:47:49 -0700 Subject: [PATCH] test(test-tooling): add new besu AIO image builder utility 1. This will help author test cases for the Besu connector that are designed to be testing the latest version of the image instead of a pinned one that we pull from the registry as part of the test case. 2. We need tests for both latest and pinned image versions if we want to make sure that the connector is backward compatible with older ledger versions. Signed-off-by: Peter Somogyvari --- .cspell.json | 1 + .../build-image-besu-all-in-one-latest.ts | 49 +++++++++++++++++++ .../build-image-corda-all-in-one-v4-12.ts | 2 +- .../src/main/typescript/public-api.ts | 6 +++ 4 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 packages/cactus-test-tooling/src/main/typescript/corda/build-image-besu-all-in-one-latest.ts diff --git a/.cspell.json b/.cspell.json index 37c4569943..1854dea439 100644 --- a/.cspell.json +++ b/.cspell.json @@ -18,6 +18,7 @@ "Authz", "authzn", "AWSSM", + "baio", "benchmarkjs", "Besu", "Bools", diff --git a/packages/cactus-test-tooling/src/main/typescript/corda/build-image-besu-all-in-one-latest.ts b/packages/cactus-test-tooling/src/main/typescript/corda/build-image-besu-all-in-one-latest.ts new file mode 100644 index 0000000000..82ca16eb2a --- /dev/null +++ b/packages/cactus-test-tooling/src/main/typescript/corda/build-image-besu-all-in-one-latest.ts @@ -0,0 +1,49 @@ +import path from "node:path"; +import { buildContainerImage } from "../public-api"; +import { LoggerProvider, LogLevelDesc } from "@hyperledger/cactus-common"; + +export interface IBuildImageBesuAllInOneLatestResponse { + readonly imageName: Readonly; + readonly imageVersion: Readonly; + /** + * The concatenation of `imageName` a colon character and `imageVersion`. + */ + readonly imageTag: Readonly; +} + +export interface IBuildImageBesuAllInOneLatestRequest { + readonly logLevel?: Readonly; +} + +export async function buildImageBesuAllInOneLatest( + req: IBuildImageBesuAllInOneLatestRequest, +): Promise { + if (!req) { + throw new Error("Expected arg req to be truthy."); + } + const logLevel: LogLevelDesc = req.logLevel || "WARN"; + const log = LoggerProvider.getOrCreate({ + level: logLevel, + label: "build-image-besu-all-in-one-latest.ts", + }); + const projectRoot = path.join(__dirname, "../../../../../../../"); + + const buildDirRel = "./tools/docker/besu-all-in-one/"; + + const buildDirAbs = path.join(projectRoot, buildDirRel); + + log.info("Invoking container build with build dir: %s", buildDirAbs); + + const imageName = "baio"; + const imageVersion = "latest"; + const imageTag = `${imageName}:${imageVersion}`; + + await buildContainerImage({ + buildDir: buildDirAbs, + imageFile: "Dockerfile", + imageTag, + logLevel: logLevel, + }); + + return { imageName, imageVersion, imageTag }; +} diff --git a/packages/cactus-test-tooling/src/main/typescript/corda/build-image-corda-all-in-one-v4-12.ts b/packages/cactus-test-tooling/src/main/typescript/corda/build-image-corda-all-in-one-v4-12.ts index 55226c427b..82f2ce4d6f 100644 --- a/packages/cactus-test-tooling/src/main/typescript/corda/build-image-corda-all-in-one-v4-12.ts +++ b/packages/cactus-test-tooling/src/main/typescript/corda/build-image-corda-all-in-one-v4-12.ts @@ -24,7 +24,7 @@ export async function buildImageCordaAllInOneV412( const logLevel: LogLevelDesc = req.logLevel || "WARN"; const log = LoggerProvider.getOrCreate({ level: logLevel, - label: "build-image-connector-corda-server.ts", + label: "build-image-corda-all-in-one-v4-12.ts", }); const projectRoot = path.join(__dirname, "../../../../../../../"); diff --git a/packages/cactus-test-tooling/src/main/typescript/public-api.ts b/packages/cactus-test-tooling/src/main/typescript/public-api.ts index ec19ee7324..25b85a43c9 100755 --- a/packages/cactus-test-tooling/src/main/typescript/public-api.ts +++ b/packages/cactus-test-tooling/src/main/typescript/public-api.ts @@ -218,3 +218,9 @@ export { IBuildImageCordaAllInOneV412Response, buildImageCordaAllInOneV412, } from "./corda/build-image-corda-all-in-one-v4-12"; + +export { + IBuildImageBesuAllInOneLatestRequest, + IBuildImageBesuAllInOneLatestResponse, + buildImageBesuAllInOneLatest, +} from "./corda/build-image-besu-all-in-one-latest";