Skip to content

Commit

Permalink
fix(ci): disk full issues on GitHub Action Workflow runner #698
Browse files Browse the repository at this point in the history
Updates the test cases that use ledger containers to clean up
after themselves not just by stopping and deleting the containers
but by also doing a docker prune of the containers, images, networks
and volumes as well.
What we hope to accomplish here is that the GHA CI will stop
failing with disk full errors.

Fixes #698

Signed-off-by: Peter Somogyvari <peter.somogyvari@accenture.com>
  • Loading branch information
petermetz committed Mar 23, 2021
1 parent 2784ceb commit 61e3f76
Show file tree
Hide file tree
Showing 9 changed files with 176 additions and 39 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import test, { Test } from "tape";
import test, { Test } from "tape-promise/tape";
import { v4 as uuidv4 } from "uuid";
import { PluginRegistry } from "@hyperledger/cactus-core";
import {
Expand All @@ -9,14 +9,25 @@ import {
Web3SigningCredentialCactusKeychainRef,
} from "../../../../../main/typescript/public-api";
import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory";
import { BesuTestLedger } from "@hyperledger/cactus-test-tooling";
import {
BesuTestLedger,
pruneDockerAllIfGithubAction,
} from "@hyperledger/cactus-test-tooling";
import { LogLevelDesc } from "@hyperledger/cactus-common";
import HelloWorldContractJson from "../../../../solidity/hello-world-contract/HelloWorld.json";
import Web3 from "web3";
import { PluginImportType } from "@hyperledger/cactus-core-api";

test("deploys contract via .json file", async (t: Test) => {
const logLevel: LogLevelDesc = "TRACE";
const testCase = "deploys contract via .json file";
const logLevel: LogLevelDesc = "TRACE";

test("BEFORE " + testCase, async (t: Test) => {
const pruning = pruneDockerAllIfGithubAction({ logLevel });
await t.doesNotReject(pruning, "Pruning didnt throw OK");
t.end();
});

test(testCase, async (t: Test) => {
const besuTestLedger = new BesuTestLedger();
await besuTestLedger.start();

Expand Down Expand Up @@ -359,3 +370,9 @@ test("deploys contract via .json file", async (t: Test) => {

t.end();
});

test("AFTER " + testCase, async (t: Test) => {
const pruning = pruneDockerAllIfGithubAction({ logLevel });
await t.doesNotReject(pruning, "Pruning didnt throw OK");
t.end();
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import test, { Test } from "tape-promise/tape";
import { v4 as internalIpV4 } from "internal-ip";

import { CordaTestLedger } from "@hyperledger/cactus-test-tooling";
import {
CordaTestLedger,
pruneDockerAllIfGithubAction,
} from "@hyperledger/cactus-test-tooling";
import { LogLevelDesc } from "@hyperledger/cactus-common";
import {
SampleCordappEnum,
Expand All @@ -15,9 +18,16 @@ import {
JvmTypeKind,
} from "../../../main/typescript/generated/openapi/typescript-axios/index";

const testCase = "Tests are passing on the JVM side";
const logLevel: LogLevelDesc = "TRACE";

test("Tests are passing on the JVM side", async (t: Test) => {
test("BEFORE " + testCase, async (t: Test) => {
const pruning = pruneDockerAllIfGithubAction({ logLevel });
await t.doesNotReject(pruning, "Pruning didnt throw OK");
t.end();
});

test(testCase, async (t: Test) => {
const ledger = new CordaTestLedger({
imageName: "petermetz/cactus-corda-4-6-all-in-one-obligation",
imageVersion: "2021-03-04-ac0d32a",
Expand Down Expand Up @@ -414,3 +424,9 @@ test("Tests are passing on the JVM side", async (t: Test) => {

t.end();
});

test("AFTER " + testCase, async (t: Test) => {
const pruning = pruneDockerAllIfGithubAction({ logLevel });
await t.doesNotReject(pruning, "Pruning didnt throw OK");
t.end();
});
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { AddressInfo } from "net";
import http from "http";

import test, { Test } from "tape";
import test, { Test } from "tape-promise/tape";
import { v4 as uuidv4 } from "uuid";

import express from "express";
import bodyParser from "body-parser";

import { FabricTestLedgerV1 } from "@hyperledger/cactus-test-tooling";
import {
FabricTestLedgerV1,
pruneDockerAllIfGithubAction,
} from "@hyperledger/cactus-test-tooling";

import {
IListenOptions,
Expand All @@ -34,9 +37,16 @@ import { IPluginLedgerConnectorFabricOptions } from "../../../../../main/typescr
import { DiscoveryOptions } from "fabric-network";
import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory";

const testCase = "deploys contract from go source";
const logLevel: LogLevelDesc = "TRACE";

test("deploys contract from go source", async (t: Test) => {
test("BEFORE " + testCase, async (t: Test) => {
const pruning = pruneDockerAllIfGithubAction({ logLevel });
await t.doesNotReject(pruning, "Pruning didnt throw OK");
t.end();
});

test(testCase, async (t: Test) => {
const ledger = new FabricTestLedgerV1({
emitContainerLogs: true,
publishAllPorts: true,
Expand Down Expand Up @@ -208,3 +218,9 @@ test("deploys contract from go source", async (t: Test) => {
t.equal(getRes.data.functionOutput, testValue, "get returns UUID OK");
t.end();
});

test("AFTER " + testCase, async (t: Test) => {
const pruning = pruneDockerAllIfGithubAction({ logLevel });
await t.doesNotReject(pruning, "Pruning didnt throw OK");
t.end();
});
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import http from "http";
import { AddressInfo } from "net";

import test, { Test } from "tape";
import test, { Test } from "tape-promise/tape";
import { v4 as uuidv4 } from "uuid";

import bodyParser from "body-parser";
import express from "express";

import { FabricTestLedgerV1 } from "@hyperledger/cactus-test-tooling";
import {
FabricTestLedgerV1,
pruneDockerAllIfGithubAction,
} from "@hyperledger/cactus-test-tooling";
import { PluginRegistry } from "@hyperledger/cactus-core";

import {
Expand Down Expand Up @@ -38,9 +41,16 @@ import { K_CACTUS_FABRIC_TOTAL_TX_COUNT } from "../../../../main/typescript/prom
* ```
*/

test("runs tx on a Fabric v1.4.8 ledger", async (t: Test) => {
const logLevel: LogLevelDesc = "TRACE";
const testCase = "runs tx on a Fabric v1.4.8 ledger";
const logLevel: LogLevelDesc = "TRACE";

test("BEFORE " + testCase, async (t: Test) => {
const pruning = pruneDockerAllIfGithubAction({ logLevel });
await t.doesNotReject(pruning, "Pruning didnt throw OK");
t.end();
});

test(testCase, async (t: Test) => {
const ledger = new FabricTestLedgerV1({
publishAllPorts: true,
emitContainerLogs: false,
Expand Down Expand Up @@ -203,3 +213,9 @@ test("runs tx on a Fabric v1.4.8 ledger", async (t: Test) => {
}
t.end();
});

test("AFTER " + testCase, async (t: Test) => {
const pruning = pruneDockerAllIfGithubAction({ logLevel });
await t.doesNotReject(pruning, "Pruning didnt throw OK");
t.end();
});
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import http from "http";
import { AddressInfo } from "net";

import test, { Test } from "tape";
import test, { Test } from "tape-promise/tape";
import { v4 as uuidv4 } from "uuid";

import bodyParser from "body-parser";
import express from "express";

import {
Containers,
FabricTestLedgerV1,
pruneDockerAllIfGithubAction,
} from "@hyperledger/cactus-test-tooling";
import { PluginRegistry } from "@hyperledger/cactus-core";

Expand Down Expand Up @@ -42,17 +42,16 @@ import { DiscoveryOptions } from "fabric-network";
* ```
*/

test("runs tx on a Fabric v2.2.0 ledger", async (t: Test) => {
// Always set to true when GitHub Actions is running the workflow.
// You can use this variable to differentiate when tests are being run locally or by GitHub Actions.
// @see https://docs.github.com/en/actions/reference/environment-variables
if (process.env.GITHUB_ACTIONS === "true") {
// Github Actions started to run out of disk space recently so we have this
// hack here to attempt to free up disk space when running inside a VM of
// the CI system.
await Containers.pruneDockerResources();
}
const testCase = "runs tx on a Fabric v2.2.0 ledger";
const logLevel: LogLevelDesc = "TRACE";

test("BEFORE " + testCase, async (t: Test) => {
const pruning = pruneDockerAllIfGithubAction({ logLevel });
await t.doesNotReject(pruning, "Pruning didnt throw OK");
t.end();
});

test(testCase, async (t: Test) => {
const logLevel: LogLevelDesc = "TRACE";

const ledger = new FabricTestLedgerV1({
Expand Down Expand Up @@ -220,3 +219,9 @@ test("runs tx on a Fabric v2.2.0 ledger", async (t: Test) => {
}
t.end();
});

test("AFTER " + testCase, async (t: Test) => {
const pruning = pruneDockerAllIfGithubAction({ logLevel });
await t.doesNotReject(pruning, "Pruning didnt throw OK");
t.end();
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import test, { Test } from "tape";
import test, { Test } from "tape-promise/tape";
import Web3 from "web3";
import { v4 as uuidV4 } from "uuid";

Expand All @@ -19,12 +19,20 @@ import {
QuorumTestLedger,
IQuorumGenesisOptions,
IAccount,
pruneDockerAllIfGithubAction,
} from "@hyperledger/cactus-test-tooling";
import { PluginRegistry } from "@hyperledger/cactus-core";

const testCase = "Quorum Ledger Connector Plugin";
const logLevel: LogLevelDesc = "INFO";

test("Quorum Ledger Connector Plugin", async (t: Test) => {
test("BEFORE " + testCase, async (t: Test) => {
const pruning = pruneDockerAllIfGithubAction({ logLevel });
await t.doesNotReject(pruning, "Pruning didnt throw OK");
t.end();
});

test(testCase, async (t: Test) => {
const ledger = new QuorumTestLedger();
await ledger.start();

Expand Down Expand Up @@ -389,3 +397,9 @@ test("Quorum Ledger Connector Plugin", async (t: Test) => {

t.end();
});

test("AFTER " + testCase, async (t: Test) => {
const pruning = pruneDockerAllIfGithubAction({ logLevel });
await t.doesNotReject(pruning, "Pruning didnt throw OK");
t.end();
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AddressInfo } from "net";

import test, { Test } from "tape";
import test, { Test } from "tape-promise/tape";
import { v4 as uuidV4 } from "uuid";
import { JWK } from "jose";
import Web3 from "web3";
Expand All @@ -21,17 +21,27 @@ import {
PluginLedgerConnectorQuorum,
Web3SigningCredentialType,
} from "@hyperledger/cactus-plugin-ledger-connector-quorum";
import { QuorumTestLedger } from "@hyperledger/cactus-test-tooling";
import {
pruneDockerAllIfGithubAction,
QuorumTestLedger,
} from "@hyperledger/cactus-test-tooling";
import { LogLevelDesc, Servers } from "@hyperledger/cactus-common";

import {
IPluginConsortiumManualOptions,
PluginConsortiumManual,
} from "@hyperledger/cactus-plugin-consortium-manual";

test("Routes to correct node based on ledger ID", async (t: Test) => {
const logLevel: LogLevelDesc = "TRACE";
const logLevel: LogLevelDesc = "TRACE";
const testCase = "Routes to correct node based on ledger ID";

test("BEFORE " + testCase, async (t: Test) => {
const pruning = pruneDockerAllIfGithubAction({ logLevel });
await t.doesNotReject(pruning, "Pruning didnt throw OK");
t.end();
});

test(testCase, async (t: Test) => {
const ledger1: Ledger = {
id: "my_cool_ledger_that_i_want_to_transact_on",
ledgerType: LedgerType.QUORUM2X,
Expand Down Expand Up @@ -276,3 +286,9 @@ test("Routes to correct node based on ledger ID", async (t: Test) => {

t.end();
});

test("AFTER " + testCase, async (t: Test) => {
const pruning = pruneDockerAllIfGithubAction({ logLevel });
await t.doesNotReject(pruning, "Pruning didnt throw OK");
t.end();
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import test, { Test } from "tape";
import test, { Test } from "tape-promise/tape";

import { v4 as uuidv4 } from "uuid";
import { createServer } from "http";
Expand All @@ -16,7 +16,10 @@ import {
LogLevelDesc,
} from "@hyperledger/cactus-common";

import { BesuTestLedger } from "@hyperledger/cactus-test-tooling";
import {
BesuTestLedger,
pruneDockerAllIfGithubAction,
} from "@hyperledger/cactus-test-tooling";

import {
Configuration,
Expand All @@ -30,8 +33,16 @@ import { PluginRegistry } from "@hyperledger/cactus-core";

import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory";

test("Test sign transaction endpoint", async (t: Test) => {
const logLevel: LogLevelDesc = "TRACE";
const testCase = "Test sign transaction endpoint";
const logLevel: LogLevelDesc = "TRACE";

test("BEFORE " + testCase, async (t: Test) => {
const pruning = pruneDockerAllIfGithubAction({ logLevel });
await t.doesNotReject(pruning, "Pruning didnt throw OK");
t.end();
});

test(testCase, async (t: Test) => {
const keyEncoder: KeyEncoder = new KeyEncoder("secp256k1");
const keychainId = uuidv4();
const keychainRef = uuidv4();
Expand Down Expand Up @@ -174,3 +185,9 @@ test("Test sign transaction endpoint", async (t: Test) => {
);
}
});

test("AFTER " + testCase, async (t: Test) => {
const pruning = pruneDockerAllIfGithubAction({ logLevel });
await t.doesNotReject(pruning, "Pruning didnt throw OK");
t.end();
});

0 comments on commit 61e3f76

Please sign in to comment.