Skip to content

Commit

Permalink
test(test-tooling): add new besu AIO image builder utility
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
petermetz committed Sep 10, 2024
1 parent 7b32791 commit 72fda32
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
1 change: 1 addition & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"Authz",
"authzn",
"AWSSM",
"baio",
"benchmarkjs",
"Besu",
"Bools",
Expand Down
Original file line number Diff line number Diff line change
@@ -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<string>;
readonly imageVersion: Readonly<string>;
/**
* The concatenation of `imageName` a colon character and `imageVersion`.
*/
readonly imageTag: Readonly<string>;
}

export interface IBuildImageBesuAllInOneLatestRequest {
readonly logLevel?: Readonly<LogLevelDesc>;
}

export async function buildImageBesuAllInOneLatest(
req: IBuildImageBesuAllInOneLatestRequest,
): Promise<IBuildImageBesuAllInOneLatestResponse> {
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 };
}
Original file line number Diff line number Diff line change
Expand Up @@ -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, "../../../../../../../");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

0 comments on commit 72fda32

Please sign in to comment.