Skip to content

Commit 26a394a

Browse files
petermetzJordi Giron
authored and
Jordi Giron
committed
fix(ci): disk full issues on GitHub Action Workflow runner hyperledger-cacti#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 hyperledger-cacti#698 Signed-off-by: Peter Somogyvari <[email protected]>
1 parent 7744d14 commit 26a394a

File tree

9 files changed

+176
-39
lines changed

9 files changed

+176
-39
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/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,
@@ -15,9 +18,16 @@ import {
1518
JvmTypeKind,
1619
} from "../../../main/typescript/generated/openapi/typescript-axios/index";
1720

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

20-
test("Tests are passing on the JVM side", async (t: Test) => {
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) => {
2131
const ledger = new CordaTestLedger({
2232
imageName: "petermetz/cactus-corda-4-6-all-in-one-obligation",
2333
imageVersion: "2021-03-04-ac0d32a",
@@ -414,3 +424,9 @@ test("Tests are passing on the JVM side", async (t: Test) => {
414424

415425
t.end();
416426
});
427+
428+
test("AFTER " + testCase, async (t: Test) => {
429+
const pruning = pruneDockerAllIfGithubAction({ logLevel });
430+
await t.doesNotReject(pruning, "Pruning didnt throw OK");
431+
t.end();
432+
});

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,
@@ -34,9 +37,16 @@ import { IPluginLedgerConnectorFabricOptions } from "../../../../../main/typescr
3437
import { DiscoveryOptions } from "fabric-network";
3538
import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory";
3639

40+
const testCase = "deploys contract from go source";
3741
const logLevel: LogLevelDesc = "TRACE";
3842

39-
test("deploys contract from go source", async (t: Test) => {
43+
test("BEFORE " + testCase, async (t: Test) => {
44+
const pruning = pruneDockerAllIfGithubAction({ logLevel });
45+
await t.doesNotReject(pruning, "Pruning didnt throw OK");
46+
t.end();
47+
});
48+
49+
test(testCase, async (t: Test) => {
4050
const ledger = new FabricTestLedgerV1({
4151
emitContainerLogs: true,
4252
publishAllPorts: true,
@@ -208,3 +218,9 @@ test("deploys contract from go source", async (t: Test) => {
208218
t.equal(getRes.data.functionOutput, testValue, "get returns UUID OK");
209219
t.end();
210220
});
221+
222+
test("AFTER " + testCase, async (t: Test) => {
223+
const pruning = pruneDockerAllIfGithubAction({ logLevel });
224+
await t.doesNotReject(pruning, "Pruning didnt throw OK");
225+
t.end();
226+
});

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 {
@@ -38,9 +41,16 @@ import { K_CACTUS_FABRIC_TOTAL_TX_COUNT } from "../../../../main/typescript/prom
3841
* ```
3942
*/
4043

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

53+
test(testCase, async (t: Test) => {
4454
const ledger = new FabricTestLedgerV1({
4555
publishAllPorts: true,
4656
emitContainerLogs: false,
@@ -203,3 +213,9 @@ test("runs tx on a Fabric v1.4.8 ledger", async (t: Test) => {
203213
}
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-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

@@ -42,17 +42,16 @@ import { DiscoveryOptions } from "fabric-network";
4242
* ```
4343
*/
4444

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

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

5857
const ledger = new FabricTestLedgerV1({
@@ -220,3 +219,9 @@ test("runs tx on a Fabric v2.2.0 ledger", async (t: Test) => {
220219
}
221220
t.end();
222221
});
222+
223+
test("AFTER " + testCase, async (t: Test) => {
224+
const pruning = pruneDockerAllIfGithubAction({ logLevel });
225+
await t.doesNotReject(pruning, "Pruning didnt throw OK");
226+
t.end();
227+
});

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+
});

packages/cactus-test-plugin-ledger-connector-besu/src/test/typescript/integration/plugin-validator-besu/sign-transaction-endpoint.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

33
import { v4 as uuidv4 } from "uuid";
44
import { createServer } from "http";
@@ -16,7 +16,10 @@ import {
1616
LogLevelDesc,
1717
} from "@hyperledger/cactus-common";
1818

19-
import { BesuTestLedger } from "@hyperledger/cactus-test-tooling";
19+
import {
20+
BesuTestLedger,
21+
pruneDockerAllIfGithubAction,
22+
} from "@hyperledger/cactus-test-tooling";
2023

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

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

33-
test("Test sign transaction endpoint", async (t: Test) => {
34-
const logLevel: LogLevelDesc = "TRACE";
36+
const testCase = "Test sign transaction endpoint";
37+
const logLevel: LogLevelDesc = "TRACE";
38+
39+
test("BEFORE " + testCase, async (t: Test) => {
40+
const pruning = pruneDockerAllIfGithubAction({ logLevel });
41+
await t.doesNotReject(pruning, "Pruning didnt throw OK");
42+
t.end();
43+
});
44+
45+
test(testCase, async (t: Test) => {
3546
const keyEncoder: KeyEncoder = new KeyEncoder("secp256k1");
3647
const keychainId = uuidv4();
3748
const keychainRef = uuidv4();
@@ -174,3 +185,9 @@ test("Test sign transaction endpoint", async (t: Test) => {
174185
);
175186
}
176187
});
188+
189+
test("AFTER " + testCase, async (t: Test) => {
190+
const pruning = pruneDockerAllIfGithubAction({ logLevel });
191+
await t.doesNotReject(pruning, "Pruning didnt throw OK");
192+
t.end();
193+
});

0 commit comments

Comments
 (0)