From 16fd3457a495f63b44d09eb84a704c7187216983 Mon Sep 17 00:00:00 2001 From: Peter Somogyvari Date: Tue, 16 Jul 2024 07:23:47 -0700 Subject: [PATCH] test(test-tooling): fix WS identity server port publish configuration 1. The hostconfig portion of the container start configuration was not being set up correctly which made it so that the exposed ports were not published on randomized ports like they were supposed to. 2. This caused the `fabric-v2-2-x/run-transaction-with-ws-ids.test.ts` test to fail because it couldn't map the container port to a host machine port. 3. Setting up the ws-test-server.ts class so that it does map the ports to the host machine solved the issue. Signed-off-by: Peter Somogyvari --- .../run-transaction-with-ws-ids.test.ts | 12 ++++++------ .../main/typescript/ws-test-server/ws-test-server.ts | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/cactus-plugin-ledger-connector-fabric/src/test/typescript/integration/fabric-v2-2-x/run-transaction-with-ws-ids.test.ts b/packages/cactus-plugin-ledger-connector-fabric/src/test/typescript/integration/fabric-v2-2-x/run-transaction-with-ws-ids.test.ts index 9c633dc3e9..def3837058 100644 --- a/packages/cactus-plugin-ledger-connector-fabric/src/test/typescript/integration/fabric-v2-2-x/run-transaction-with-ws-ids.test.ts +++ b/packages/cactus-plugin-ledger-connector-fabric/src/test/typescript/integration/fabric-v2-2-x/run-transaction-with-ws-ids.test.ts @@ -61,21 +61,21 @@ describe("PluginLedgerConnectorFabric", () => { logLevel, }); - await ledger.start({ omitPull: false }); - wsTestContainer = new WsTestServer({}); await wsTestContainer.start(); + const ci = await Containers.getById(wsTestContainer.containerId); + const wsIpAddr = await internalIpV4(); + const hostPort = await Containers.getPublicPort(WS_IDENTITY_HTTP_PORT, ci); + + await ledger.start({ omitPull: false }); + const connectionProfile = await ledger.getConnectionProfileOrg1(); expect(connectionProfile).toBeTruthy(); const keychainInstanceId = uuidv4(); keychainId = uuidv4(); - const ci = await Containers.getById(wsTestContainer.containerId); - const wsIpAddr = await internalIpV4(); - const hostPort = await Containers.getPublicPort(WS_IDENTITY_HTTP_PORT, ci); - const wsUrl = `http://${wsIpAddr}:${hostPort}`; const wsConfig: IWebSocketConfig = { diff --git a/packages/cactus-test-tooling/src/main/typescript/ws-test-server/ws-test-server.ts b/packages/cactus-test-tooling/src/main/typescript/ws-test-server/ws-test-server.ts index f7e0074660..70d95d1738 100644 --- a/packages/cactus-test-tooling/src/main/typescript/ws-test-server/ws-test-server.ts +++ b/packages/cactus-test-tooling/src/main/typescript/ws-test-server/ws-test-server.ts @@ -94,12 +94,12 @@ export class WsTestServer { // to docker container's IP addresses directly... // https://stackoverflow.com/a/39217691 PublishAllPorts: true, - /*Env: [`WS_IDENTITY_PATH=${WS_IDENTITY_PATH}`, ...this.envVars], + /*Env: [`WS_IDENTITY_PATH=${WS_IDENTITY_PATH}`, ...this.envVars],*/ HostConfig: { // NetworkMode: "host", - CapAdd: ["IPC_LOCK"], + // CapAdd: ["IPC_LOCK"], PublishAllPorts: true, - },*/ + }, //Healthcheck: { // Test: ["CMD-SHELL", "wget -O- http://127.0.0.1:8200/v1/sys/health"], // Interval: 100 * 1000000,