Skip to content

Commit 3431d8e

Browse files
committed
fix(ci): disk full issues on GitHub Action Workflow runner #698
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 <[email protected]>
1 parent b89dfa7 commit 3431d8e

File tree

10 files changed

+194
-43
lines changed

10 files changed

+194
-43
lines changed

packages/cactus-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-ledger-connector-besu/deploy-contract/deploy-contract-from-json.test.ts

+21-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import test, { Test } from "tape";
1+
import test, { Test } from "tape-promise/tape";
22
import { v4 as uuidv4 } from "uuid";
33
import { PluginRegistry } from "@hyperledger/cactus-core";
44
import {
@@ -9,14 +9,25 @@ import {
99
Web3SigningCredentialCactusKeychainRef,
1010
} from "../../../../../main/typescript/public-api";
1111
import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory";
12-
import { BesuTestLedger } from "@hyperledger/cactus-test-tooling";
12+
import {
13+
BesuTestLedger,
14+
pruneDockerAllIfGithubAction,
15+
} from "@hyperledger/cactus-test-tooling";
1316
import { LogLevelDesc } from "@hyperledger/cactus-common";
1417
import HelloWorldContractJson from "../../../../solidity/hello-world-contract/HelloWorld.json";
1518
import Web3 from "web3";
1619
import { PluginImportType } from "@hyperledger/cactus-core-api";
1720

18-
test("deploys contract via .json file", async (t: Test) => {
19-
const logLevel: LogLevelDesc = "TRACE";
21+
const testCase = "deploys contract via .json file";
22+
const logLevel: LogLevelDesc = "TRACE";
23+
24+
test("BEFORE " + testCase, async (t: Test) => {
25+
const pruning = pruneDockerAllIfGithubAction({ logLevel });
26+
await t.doesNotReject(pruning, "Pruning didnt throw OK");
27+
t.end();
28+
});
29+
30+
test(testCase, async (t: Test) => {
2031
const besuTestLedger = new BesuTestLedger();
2132
await besuTestLedger.start();
2233

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

360371
t.end();
361372
});
373+
374+
test("AFTER " + testCase, async (t: Test) => {
375+
const pruning = pruneDockerAllIfGithubAction({ logLevel });
376+
await t.doesNotReject(pruning, "Pruning didnt throw OK");
377+
t.end();
378+
});

packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/deploy-cordapp-jars-to-nodes.test.ts

+18-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import test, { Test } from "tape-promise/tape";
22
import { v4 as internalIpV4 } from "internal-ip";
33

4-
import { CordaTestLedger } from "@hyperledger/cactus-test-tooling";
4+
import {
5+
CordaTestLedger,
6+
pruneDockerAllIfGithubAction,
7+
} from "@hyperledger/cactus-test-tooling";
58
import { LogLevelDesc } from "@hyperledger/cactus-common";
69
import {
710
SampleCordappEnum,
@@ -17,14 +20,19 @@ import {
1720
JvmTypeKind,
1821
} from "../../../main/typescript/generated/openapi/typescript-axios/index";
1922

23+
const testCase = "Invocation of uploaded cordapps to nodes via SSH+SCP works";
2024
const logLevel: LogLevelDesc = "TRACE";
2125

22-
test("Tests are passing on the JVM side", async (t: Test) => {
26+
test("BEFORE " + testCase, async (t: Test) => {
27+
const pruning = pruneDockerAllIfGithubAction({ logLevel });
28+
await t.doesNotReject(pruning, "Pruning didnt throw OK");
29+
t.end();
30+
});
31+
32+
test(testCase, async (t: Test) => {
2333
const ledger = new CordaTestLedger({
2434
imageName: "hyperledger/cactus-corda-4-6-all-in-one-obligation",
2535
imageVersion: "2021-03-19-feat-686",
26-
// imageName: "caio",
27-
// imageVersion: "latest",
2836
logLevel,
2937
});
3038
t.ok(ledger, "CordaTestLedger instantaited OK");
@@ -311,3 +319,9 @@ test("Tests are passing on the JVM side", async (t: Test) => {
311319

312320
t.end();
313321
});
322+
323+
test("AFTER " + testCase, async (t: Test) => {
324+
const pruning = pruneDockerAllIfGithubAction({ logLevel });
325+
await t.doesNotReject(pruning, "Pruning didnt throw OK");
326+
t.end();
327+
});

packages/cactus-plugin-ledger-connector-corda/src/test/typescript/integration/jvm-kotlin-spring-server.test.ts

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import test, { Test } from "tape-promise/tape";
22
import { v4 as internalIpV4 } from "internal-ip";
33

4-
import { CordaTestLedger } from "@hyperledger/cactus-test-tooling";
4+
import {
5+
CordaTestLedger,
6+
pruneDockerAllIfGithubAction,
7+
} from "@hyperledger/cactus-test-tooling";
58
import { LogLevelDesc } from "@hyperledger/cactus-common";
69
import {
710
SampleCordappEnum,
@@ -17,9 +20,16 @@ import {
1720
JvmTypeKind,
1821
} from "../../../main/typescript/generated/openapi/typescript-axios/index";
1922

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

22-
test("Tests are passing on the JVM side", async (t: Test) => {
26+
test("BEFORE " + testCase, async (t: Test) => {
27+
const pruning = pruneDockerAllIfGithubAction({ logLevel });
28+
await t.doesNotReject(pruning, "Pruning didnt throw OK");
29+
t.end();
30+
});
31+
32+
test(testCase, async (t: Test) => {
2333
const ledger = new CordaTestLedger({
2434
imageName: "hyperledger/cactus-corda-4-6-all-in-one-obligation",
2535
imageVersion: "2021-03-04-ac0d32a",
@@ -429,3 +439,9 @@ test("Tests are passing on the JVM side", async (t: Test) => {
429439

430440
t.end();
431441
});
442+
443+
test("AFTER " + testCase, async (t: Test) => {
444+
const pruning = pruneDockerAllIfGithubAction({ logLevel });
445+
await t.doesNotReject(pruning, "Pruning didnt throw OK");
446+
t.end();
447+
});

packages/cactus-plugin-ledger-connector-fabric/src/test/typescript/integration/deploy-contract-go-bin-endpoint-v1/deploy-contract/deploy-cc-from-golang-source.test.ts

+19-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import { AddressInfo } from "net";
22
import http from "http";
33

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

77
import express from "express";
88
import bodyParser from "body-parser";
99

10-
import { FabricTestLedgerV1 } from "@hyperledger/cactus-test-tooling";
10+
import {
11+
FabricTestLedgerV1,
12+
pruneDockerAllIfGithubAction,
13+
} from "@hyperledger/cactus-test-tooling";
1114

1215
import {
1316
IListenOptions,
@@ -31,9 +34,16 @@ import { IPluginLedgerConnectorFabricOptions } from "../../../../../main/typescr
3134
import { DiscoveryOptions } from "fabric-network";
3235
import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory";
3336

37+
const testCase = "deploys contract from go source";
3438
const logLevel: LogLevelDesc = "TRACE";
3539

36-
test("deploys contract from go source", async (t: Test) => {
40+
test("BEFORE " + testCase, async (t: Test) => {
41+
const pruning = pruneDockerAllIfGithubAction({ logLevel });
42+
await t.doesNotReject(pruning, "Pruning didnt throw OK");
43+
t.end();
44+
});
45+
46+
test(testCase, async (t: Test) => {
3747
const ledger = new FabricTestLedgerV1({
3848
emitContainerLogs: true,
3949
publishAllPorts: true,
@@ -203,3 +213,9 @@ test("deploys contract from go source", async (t: Test) => {
203213
t.equal(getRes.data.functionOutput, testValue, "get returns UUID OK");
204214
t.end();
205215
});
216+
217+
test("AFTER " + testCase, async (t: Test) => {
218+
const pruning = pruneDockerAllIfGithubAction({ logLevel });
219+
await t.doesNotReject(pruning, "Pruning didnt throw OK");
220+
t.end();
221+
});

packages/cactus-plugin-ledger-connector-fabric/src/test/typescript/integration/fabric-v1-4-x/run-transaction-endpoint-v1.test.ts

+20-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import http from "http";
22
import { AddressInfo } from "net";
33

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

77
import bodyParser from "body-parser";
88
import express from "express";
99

10-
import { FabricTestLedgerV1 } from "@hyperledger/cactus-test-tooling";
10+
import {
11+
FabricTestLedgerV1,
12+
pruneDockerAllIfGithubAction,
13+
} from "@hyperledger/cactus-test-tooling";
1114
import { PluginRegistry } from "@hyperledger/cactus-core";
1215

1316
import {
@@ -36,9 +39,16 @@ import { DiscoveryOptions } from "fabric-network";
3639
* ```
3740
*/
3841

39-
test("runs tx on a Fabric v1.4.8 ledger", async (t: Test) => {
40-
const logLevel: LogLevelDesc = "TRACE";
42+
const testCase = "runs tx on a Fabric v1.4.8 ledger";
43+
const logLevel: LogLevelDesc = "TRACE";
44+
45+
test("BEFORE " + testCase, async (t: Test) => {
46+
const pruning = pruneDockerAllIfGithubAction({ logLevel });
47+
await t.doesNotReject(pruning, "Pruning didnt throw OK");
48+
t.end();
49+
});
4150

51+
test(testCase, async (t: Test) => {
4252
const ledger = new FabricTestLedgerV1({
4353
publishAllPorts: true,
4454
emitContainerLogs: false,
@@ -193,3 +203,9 @@ test("runs tx on a Fabric v1.4.8 ledger", async (t: Test) => {
193203
}
194204
t.end();
195205
});
206+
207+
test("AFTER " + testCase, async (t: Test) => {
208+
const pruning = pruneDockerAllIfGithubAction({ logLevel });
209+
await t.doesNotReject(pruning, "Pruning didnt throw OK");
210+
t.end();
211+
});

packages/cactus-plugin-ledger-connector-fabric/src/test/typescript/integration/fabric-v2-2-x/run-transaction-endpoint-v1.test.ts

+17-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import http from "http";
22
import { AddressInfo } from "net";
33

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

77
import bodyParser from "body-parser";
88
import express from "express";
99

1010
import {
11-
Containers,
1211
FabricTestLedgerV1,
12+
pruneDockerAllIfGithubAction,
1313
} from "@hyperledger/cactus-test-tooling";
1414
import { PluginRegistry } from "@hyperledger/cactus-core";
1515

@@ -39,17 +39,16 @@ import { DiscoveryOptions } from "fabric-network";
3939
* ```
4040
*/
4141

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

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

5554
const ledger = new FabricTestLedgerV1({
@@ -209,3 +208,9 @@ test("runs tx on a Fabric v2.2.0 ledger", async (t: Test) => {
209208
}
210209
t.end();
211210
});
211+
212+
test("AFTER " + testCase, async (t: Test) => {
213+
const pruning = pruneDockerAllIfGithubAction({ logLevel });
214+
await t.doesNotReject(pruning, "Pruning didnt throw OK");
215+
t.end();
216+
});

packages/cactus-plugin-ledger-connector-quorum/src/test/typescript/integration/plugin-ledger-connector-quorum/deploy-contract/deploy-contract-from-json.test.ts

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import test, { Test } from "tape";
1+
import test, { Test } from "tape-promise/tape";
22
import Web3 from "web3";
33
import { v4 as uuidV4 } from "uuid";
44

@@ -19,12 +19,20 @@ import {
1919
QuorumTestLedger,
2020
IQuorumGenesisOptions,
2121
IAccount,
22+
pruneDockerAllIfGithubAction,
2223
} from "@hyperledger/cactus-test-tooling";
2324
import { PluginRegistry } from "@hyperledger/cactus-core";
2425

26+
const testCase = "Quorum Ledger Connector Plugin";
2527
const logLevel: LogLevelDesc = "INFO";
2628

27-
test("Quorum Ledger Connector Plugin", async (t: Test) => {
29+
test("BEFORE " + testCase, async (t: Test) => {
30+
const pruning = pruneDockerAllIfGithubAction({ logLevel });
31+
await t.doesNotReject(pruning, "Pruning didnt throw OK");
32+
t.end();
33+
});
34+
35+
test(testCase, async (t: Test) => {
2836
const ledger = new QuorumTestLedger();
2937
await ledger.start();
3038

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

390398
t.end();
391399
});
400+
401+
test("AFTER " + testCase, async (t: Test) => {
402+
const pruning = pruneDockerAllIfGithubAction({ logLevel });
403+
await t.doesNotReject(pruning, "Pruning didnt throw OK");
404+
t.end();
405+
});

packages/cactus-test-api-client/src/test/typescript/integration/api-client-routing-node-to-node.test.ts

+20-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { AddressInfo } from "net";
22

3-
import test, { Test } from "tape";
3+
import test, { Test } from "tape-promise/tape";
44
import { v4 as uuidV4 } from "uuid";
55
import { JWK } from "jose";
66
import Web3 from "web3";
@@ -21,17 +21,27 @@ import {
2121
PluginLedgerConnectorQuorum,
2222
Web3SigningCredentialType,
2323
} from "@hyperledger/cactus-plugin-ledger-connector-quorum";
24-
import { QuorumTestLedger } from "@hyperledger/cactus-test-tooling";
24+
import {
25+
pruneDockerAllIfGithubAction,
26+
QuorumTestLedger,
27+
} from "@hyperledger/cactus-test-tooling";
2528
import { LogLevelDesc, Servers } from "@hyperledger/cactus-common";
2629

2730
import {
2831
IPluginConsortiumManualOptions,
2932
PluginConsortiumManual,
3033
} from "@hyperledger/cactus-plugin-consortium-manual";
3134

32-
test("Routes to correct node based on ledger ID", async (t: Test) => {
33-
const logLevel: LogLevelDesc = "TRACE";
35+
const logLevel: LogLevelDesc = "TRACE";
36+
const testCase = "Routes to correct node based on ledger ID";
37+
38+
test("BEFORE " + testCase, async (t: Test) => {
39+
const pruning = pruneDockerAllIfGithubAction({ logLevel });
40+
await t.doesNotReject(pruning, "Pruning didnt throw OK");
41+
t.end();
42+
});
3443

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

277287
t.end();
278288
});
289+
290+
test("AFTER " + testCase, async (t: Test) => {
291+
const pruning = pruneDockerAllIfGithubAction({ logLevel });
292+
await t.doesNotReject(pruning, "Pruning didnt throw OK");
293+
t.end();
294+
});

0 commit comments

Comments
 (0)