timeout for tests
This commit is contained in:
parent
c0904936e4
commit
aefc3f26b6
@ -44,11 +44,12 @@
|
||||
"typescript": "^4.1.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@gnu-taler/taler-wallet-core": "workspace:*",
|
||||
"@types/minimatch": "^3.0.3",
|
||||
"axios": "^0.21.1",
|
||||
"cancellationtoken": "^2.2.0",
|
||||
"minimatch": "^3.0.4",
|
||||
"source-map-support": "^0.5.19",
|
||||
"@gnu-taler/taler-wallet-core": "workspace:*",
|
||||
"tslib": "^2.1.0"
|
||||
}
|
||||
}
|
||||
|
@ -98,10 +98,14 @@ import {
|
||||
import { ApplyRefundResponse } from "@gnu-taler/taler-wallet-core";
|
||||
import { PendingOperationsResponse } from "@gnu-taler/taler-wallet-core";
|
||||
import { CoinConfig } from "./denomStructures";
|
||||
import CancellationToken from "cancellationtoken";
|
||||
|
||||
const exec = util.promisify(require("child_process").exec);
|
||||
|
||||
export async function delayMs(ms: number): Promise<void> {
|
||||
export async function delayMs(
|
||||
ms: number,
|
||||
cancellationToken?: CancellationToken,
|
||||
): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
setTimeout(() => resolve(), ms);
|
||||
});
|
||||
@ -1486,6 +1490,8 @@ export interface TestRunResult {
|
||||
timeSec: number;
|
||||
|
||||
status: TestStatus;
|
||||
|
||||
reason?: string;
|
||||
}
|
||||
|
||||
export async function runTestWithState(
|
||||
|
@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
import {
|
||||
delayMs,
|
||||
GlobalTestState,
|
||||
runTestWithState,
|
||||
shouldLingerInTest,
|
||||
@ -56,6 +57,7 @@ import { runMerchantExchangeConfusionTest } from "./test-merchant-exchange-confu
|
||||
import { runLibeufinBasicTest } from "./test-libeufin-basic";
|
||||
import { runLibeufinTutorialTest } from "./test-libeufin-tutorial";
|
||||
import { runDepositTest } from "./test-deposit";
|
||||
import CancellationToken from "cancellationtoken";
|
||||
|
||||
/**
|
||||
* Test runner.
|
||||
@ -201,30 +203,64 @@ export async function runTests(spec: TestRunSpec) {
|
||||
currentChild.stdout?.pipe(harnessLogStream);
|
||||
currentChild.stderr?.pipe(harnessLogStream);
|
||||
|
||||
const result: TestRunResult = await new Promise((resolve, reject) => {
|
||||
let msg: TestRunResult | undefined;
|
||||
currentChild!.on("message", (m) => {
|
||||
msg = m as TestRunResult;
|
||||
});
|
||||
currentChild!.on("exit", (code, signal) => {
|
||||
if (signal) {
|
||||
reject(new Error(`test worker exited with signal ${signal}`));
|
||||
} else if (code != 0) {
|
||||
reject(new Error(`test worker exited with code ${code}`));
|
||||
} else if (!msg) {
|
||||
reject(
|
||||
new Error(
|
||||
`test worker exited without giving back the test results`,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
resolve(msg);
|
||||
}
|
||||
});
|
||||
currentChild!.on("error", (err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
const testTimeoutMs = 60000;
|
||||
|
||||
const { token } = CancellationToken.timeout(60000);
|
||||
|
||||
const resultPromise: Promise<TestRunResult> = new Promise(
|
||||
(resolve, reject) => {
|
||||
let msg: TestRunResult | undefined;
|
||||
currentChild!.on("message", (m) => {
|
||||
if (token.isCancelled) {
|
||||
return;
|
||||
}
|
||||
msg = m as TestRunResult;
|
||||
});
|
||||
currentChild!.on("exit", (code, signal) => {
|
||||
if (token.isCancelled) {
|
||||
return;
|
||||
}
|
||||
if (signal) {
|
||||
reject(new Error(`test worker exited with signal ${signal}`));
|
||||
} else if (code != 0) {
|
||||
reject(new Error(`test worker exited with code ${code}`));
|
||||
} else if (!msg) {
|
||||
reject(
|
||||
new Error(
|
||||
`test worker exited without giving back the test results`,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
resolve(msg);
|
||||
}
|
||||
});
|
||||
currentChild!.on("error", (err) => {
|
||||
if (token.isCancelled) {
|
||||
return;
|
||||
}
|
||||
reject(err);
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
let result: TestRunResult;
|
||||
|
||||
try {
|
||||
result = await token.racePromise(resultPromise);
|
||||
} catch (e) {
|
||||
console.error(`test ${testName} timed out`);
|
||||
if (token.isCancelled) {
|
||||
result = {
|
||||
status: "fail",
|
||||
reason: "timeout",
|
||||
timeSec: testTimeoutMs / 1000,
|
||||
name: testName,
|
||||
};
|
||||
currentChild.kill("SIGTERM");
|
||||
} else {
|
||||
throw Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
harnessLogStream.close();
|
||||
|
||||
|
@ -48,6 +48,7 @@ importers:
|
||||
rollup-plugin-terser: 7.0.2_rollup@2.37.1
|
||||
typescript: 4.1.3
|
||||
specifiers:
|
||||
'@gnu-taler/taler-wallet-core': workspace:*
|
||||
'@rollup/plugin-commonjs': ^17.0.0
|
||||
'@rollup/plugin-json': ^4.1.0
|
||||
'@rollup/plugin-node-resolve': ^11.1.0
|
||||
@ -58,16 +59,16 @@ importers:
|
||||
rollup: ^2.37.1
|
||||
rollup-plugin-sourcemaps: ^0.6.3
|
||||
rollup-plugin-terser: ^7.0.2
|
||||
'@gnu-taler/taler-wallet-core': workspace:*
|
||||
tslib: ^2.1.0
|
||||
typescript: ^4.1.3
|
||||
packages/taler-wallet-cli:
|
||||
dependencies:
|
||||
'@gnu-taler/taler-wallet-core': link:../taler-wallet-core
|
||||
'@types/minimatch': 3.0.3
|
||||
axios: 0.21.1
|
||||
cancellationtoken: 2.2.0
|
||||
minimatch: 3.0.4
|
||||
source-map-support: 0.5.19
|
||||
'@gnu-taler/taler-wallet-core': link:../taler-wallet-core
|
||||
tslib: 2.1.0
|
||||
devDependencies:
|
||||
'@rollup/plugin-commonjs': 17.0.0_rollup@2.37.1
|
||||
@ -83,6 +84,7 @@ importers:
|
||||
typedoc: 0.20.16_typescript@4.1.3
|
||||
typescript: 4.1.3
|
||||
specifiers:
|
||||
'@gnu-taler/taler-wallet-core': workspace:*
|
||||
'@rollup/plugin-commonjs': ^17.0.0
|
||||
'@rollup/plugin-json': ^4.1.0
|
||||
'@rollup/plugin-node-resolve': ^11.1.0
|
||||
@ -90,6 +92,7 @@ importers:
|
||||
'@types/minimatch': ^3.0.3
|
||||
'@types/node': ^14.14.22
|
||||
axios: ^0.21.1
|
||||
cancellationtoken: ^2.2.0
|
||||
minimatch: ^3.0.4
|
||||
prettier: ^2.2.1
|
||||
rimraf: ^3.0.2
|
||||
@ -97,21 +100,21 @@ importers:
|
||||
rollup-plugin-sourcemaps: ^0.6.3
|
||||
rollup-plugin-terser: ^7.0.2
|
||||
source-map-support: ^0.5.19
|
||||
'@gnu-taler/taler-wallet-core': workspace:*
|
||||
tslib: ^2.1.0
|
||||
typedoc: ^0.20.16
|
||||
typescript: ^4.1.3
|
||||
packages/taler-wallet-core:
|
||||
dependencies:
|
||||
'@gnu-taler/idb-bridge': link:../idb-bridge
|
||||
'@types/node': 14.14.22
|
||||
axios: 0.21.1
|
||||
big-integer: 1.6.48
|
||||
fflate: 0.6.0
|
||||
'@gnu-taler/idb-bridge': link:../idb-bridge
|
||||
source-map-support: 0.5.19
|
||||
tslib: 2.1.0
|
||||
devDependencies:
|
||||
'@ava/typescript': 1.1.1
|
||||
'@gnu-taler/pogen': link:../pogen
|
||||
'@microsoft/api-extractor': 7.13.0
|
||||
'@typescript-eslint/eslint-plugin': 4.14.0_980e7d90d2d08155204a38366bd3b934
|
||||
'@typescript-eslint/parser': 4.14.0_eslint@7.18.0+typescript@4.1.3
|
||||
@ -126,7 +129,6 @@ importers:
|
||||
jed: 1.1.1
|
||||
nyc: 15.1.0
|
||||
po2json: 0.4.5
|
||||
'@gnu-taler/pogen': link:../pogen
|
||||
prettier: 2.2.1
|
||||
rimraf: 3.0.2
|
||||
rollup: 2.37.1
|
||||
@ -136,6 +138,8 @@ importers:
|
||||
typescript: 4.1.3
|
||||
specifiers:
|
||||
'@ava/typescript': ^1.1.1
|
||||
'@gnu-taler/idb-bridge': workspace:*
|
||||
'@gnu-taler/pogen': workspace:*
|
||||
'@microsoft/api-extractor': ^7.13.0
|
||||
'@types/node': ^14.14.22
|
||||
'@typescript-eslint/eslint-plugin': ^4.14.0
|
||||
@ -151,11 +155,9 @@ importers:
|
||||
eslint-plugin-react-hooks: ^4.2.0
|
||||
esm: ^3.2.25
|
||||
fflate: ^0.6.0
|
||||
'@gnu-taler/idb-bridge': workspace:*
|
||||
jed: ^1.1.1
|
||||
nyc: ^15.1.0
|
||||
po2json: ^0.4.5
|
||||
'@gnu-taler/pogen': workspace:*
|
||||
prettier: ^2.2.1
|
||||
rimraf: ^3.0.2
|
||||
rollup: ^2.37.1
|
||||
@ -167,8 +169,8 @@ importers:
|
||||
typescript: ^4.1.3
|
||||
packages/taler-wallet-webextension:
|
||||
dependencies:
|
||||
moment: 2.29.1
|
||||
'@gnu-taler/taler-wallet-core': link:../taler-wallet-core
|
||||
moment: 2.29.1
|
||||
tslib: 2.1.0
|
||||
devDependencies:
|
||||
'@rollup/plugin-commonjs': 17.0.0_rollup@2.37.1
|
||||
@ -192,6 +194,7 @@ importers:
|
||||
rollup-plugin-terser: 7.0.2_rollup@2.37.1
|
||||
typescript: 4.1.3
|
||||
specifiers:
|
||||
'@gnu-taler/taler-wallet-core': workspace:*
|
||||
'@rollup/plugin-commonjs': ^17.0.0
|
||||
'@rollup/plugin-json': ^4.1.0
|
||||
'@rollup/plugin-node-resolve': ^11.1.0
|
||||
@ -212,7 +215,6 @@ importers:
|
||||
rollup-plugin-ignore: ^1.0.9
|
||||
rollup-plugin-sourcemaps: ^0.6.3
|
||||
rollup-plugin-terser: ^7.0.2
|
||||
'@gnu-taler/taler-wallet-core': workspace:*
|
||||
tslib: ^2.1.0
|
||||
typescript: ^4.1.3
|
||||
lockfileVersion: 5.2
|
||||
@ -1314,6 +1316,10 @@ packages:
|
||||
node: '>=6'
|
||||
resolution:
|
||||
integrity: sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==
|
||||
/cancellationtoken/2.2.0:
|
||||
dev: false
|
||||
resolution:
|
||||
integrity: sha512-uF4sHE5uh2VdEZtIRJKGoXAD9jm7bFY0tDRCzH4iLp262TOJ2lrtNHjMG2zc8H+GICOpELIpM7CGW5JeWnb3Hg==
|
||||
/chalk/0.4.0:
|
||||
dependencies:
|
||||
ansi-styles: 1.0.0
|
||||
|
Loading…
Reference in New Issue
Block a user