Skip to content

Commit 98dce27

Browse files
authored
increase timeout in CLI command tests (#1042)
1 parent fb6d110 commit 98dce27

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

packages/cli/test/commands.test.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,18 @@ import { cmd } from '../src/cli';
1212
import commandParser from '../src/commands';
1313
import type { Opts } from '../src/options';
1414

15+
// These CLI tests take quite a while to run, mostly I think
16+
// because of all the FS mocking
17+
// To make them more robust in CI, all the tests in this file need
18+
// an increased timeout
19+
const TIMEOUT = 1000 * 20;
20+
1521
const logger = createMockLogger('', { level: 'debug' });
1622

1723
const port = 8967;
1824

1925
let server;
26+
2027
const endpoint = `http://localhost:${port}`;
2128

2229
test.before(async () => {
@@ -148,6 +155,7 @@ test.after(async () => {
148155
});
149156

150157
test.serial('run an execution plan', async (t) => {
158+
t.timeout(TIMEOUT);
151159
const plan = {
152160
workflow: {
153161
steps: [
@@ -175,6 +183,7 @@ test.serial('run an execution plan', async (t) => {
175183
});
176184

177185
test.serial('run an execution plan with start', async (t) => {
186+
t.timeout(TIMEOUT);
178187
const state = JSON.stringify({ data: { x: 0 } });
179188
const plan = {
180189
workflow: {
@@ -207,6 +216,7 @@ test.serial('run an execution plan with start', async (t) => {
207216
});
208217

209218
test.serial('print version information with version', async (t) => {
219+
t.timeout(TIMEOUT);
210220
await run('version', '');
211221

212222
const last = logger._parse(logger._last);
@@ -217,13 +227,15 @@ test.serial('print version information with version', async (t) => {
217227
});
218228

219229
test.serial('run test job with default state', async (t) => {
230+
t.timeout(TIMEOUT);
220231
await run('test', '');
221232

222233
const { message } = logger._parse(logger._last);
223234
t.assert(message === 'Result: 42');
224235
});
225236

226237
test.serial('run test job with custom state', async (t) => {
238+
t.timeout(TIMEOUT);
227239
const state = JSON.stringify({ data: { answer: 1 } });
228240

229241
await run(`test -S ${state}`, '');
@@ -232,17 +244,20 @@ test.serial('run test job with custom state', async (t) => {
232244
});
233245

234246
test.serial('run a job with defaults: openfn job.js', async (t) => {
247+
t.timeout(TIMEOUT);
235248
const result = await run('openfn job.js', EXPR_EXPORT_42);
236249
t.assert(result.data.count === 42);
237250
});
238251

239252
test.serial('run a job which does not return state', async (t) => {
253+
t.timeout(TIMEOUT);
240254
const result = await run('openfn job.js', 'export default [s => {}]');
241255

242256
t.falsy(result);
243257
});
244258

245259
test.serial('run a workflow', async (t) => {
260+
t.timeout(TIMEOUT);
246261
const workflow = {
247262
jobs: [
248263
{
@@ -268,6 +283,7 @@ test.serial('run a workflow', async (t) => {
268283
});
269284

270285
test.serial('run a workflow with config as an object', async (t) => {
286+
t.timeout(TIMEOUT);
271287
const workflow = {
272288
jobs: [
273289
{
@@ -290,6 +306,7 @@ test.serial('run a workflow with config as an object', async (t) => {
290306
});
291307

292308
test.serial('run a workflow with config as a path', async (t) => {
309+
t.timeout(TIMEOUT);
293310
const workflow = {
294311
jobs: [
295312
{
@@ -319,6 +336,7 @@ test.serial('run a workflow with config as a path', async (t) => {
319336
test.serial.skip(
320337
'run a trivial job from a folder: openfn ~/openfn/jobs/the-question',
321338
async (t) => {
339+
t.timeout(TIMEOUT);
322340
const options = {
323341
// set up the file system
324342
expressionPath:
@@ -345,6 +363,7 @@ test.serial.skip(
345363
test.serial(
346364
'output to file: openfn job.js --output-path=/tmp/my-output.json',
347365
async (t) => {
366+
t.timeout(TIMEOUT);
348367
const options = {
349368
outputPath: '/tmp/my-output.json',
350369
};
@@ -364,6 +383,7 @@ test.serial(
364383
test.serial(
365384
'output to file with alias: openfn job.js -o=/tmp/my-output.json',
366385
async (t) => {
386+
t.timeout(TIMEOUT);
367387
const options = {
368388
outputPath: '/tmp/my-output.json',
369389
};
@@ -383,6 +403,7 @@ test.serial(
383403
test.serial(
384404
'output to file removing configuration: openfn job.js --output-path=/tmp/my-output.json',
385405
async (t) => {
406+
t.timeout(TIMEOUT);
386407
const options = {
387408
outputPath: '/tmp/my-output.json',
388409
};
@@ -407,6 +428,7 @@ test.serial(
407428
test.serial(
408429
'read state from file: openfn job.js --state-path=/tmp/my-state.json',
409430
async (t) => {
431+
t.timeout(TIMEOUT);
410432
const options = {
411433
statePath: '/tmp/my-state.json',
412434
state: { data: { count: 33 } },
@@ -423,6 +445,7 @@ test.serial(
423445
test.serial(
424446
'read state from file with alias: openfn job.js -s /tmp/my-state.json',
425447
async (t) => {
448+
t.timeout(TIMEOUT);
426449
const options = {
427450
statePath: '/tmp/my-state.json',
428451
state: { data: { count: 33 } },
@@ -439,6 +462,7 @@ test.serial(
439462
test.serial(
440463
'read state from stdin: openfn job.js --state-stdin=<obj>',
441464
async (t) => {
465+
t.timeout(TIMEOUT);
442466
const state = JSON.stringify({ data: { count: 11 } });
443467
const result = await run(
444468
`openfn job.js --state-stdin=${state}`,
@@ -451,6 +475,7 @@ test.serial(
451475
test.serial(
452476
'read state from stdin with alias: openfn job.js -S <obj>',
453477
async (t) => {
478+
t.timeout(TIMEOUT);
454479
const state = JSON.stringify({ data: { count: 44 } });
455480
const result = await run(`openfn job.js -S ${state}`, EXPR_TIMES_2);
456481
t.assert(result.data.count === 88);
@@ -460,6 +485,7 @@ test.serial(
460485
test.serial(
461486
'override an adaptor: openfn --no-expand-adaptors -S <obj> --adaptor times-two=<path-to-module>',
462487
async (t) => {
488+
t.timeout(TIMEOUT);
463489
const state = JSON.stringify({ data: { count: 49.5 } });
464490

465491
await resMock.generateJob(EXPR_MOCK_ADAPTOR);
@@ -477,6 +503,7 @@ test.serial(
477503
test.serial(
478504
'override adaptors: openfn --no-expand-adaptors -S <obj> --adaptors times-two=<path-to-module>',
479505
async (t) => {
506+
t.timeout(TIMEOUT);
480507
const state = JSON.stringify({ data: { count: 49.5 } });
481508

482509
await resMock.generateJob(EXPR_MOCK_ADAPTOR);
@@ -492,6 +519,7 @@ test.serial(
492519
test.serial(
493520
'override adaptors: openfn --no-expand-adaptors -S <obj> -a times-two=<path-to-module>',
494521
async (t) => {
522+
t.timeout(TIMEOUT);
495523
const state = JSON.stringify({ data: { count: 49.5 } });
496524

497525
// mock module with real filesystem
@@ -508,6 +536,7 @@ test.serial(
508536
test.serial(
509537
'auto-import from test module with repoDir: openfn job.js -S <obj> -a times-two',
510538
async (t) => {
539+
t.timeout(TIMEOUT);
511540
const state = JSON.stringify({ data: { count: 11 } });
512541
const job = 'export default [byTwo]';
513542
await resMock.generateJob(job);
@@ -527,6 +556,7 @@ test.serial(
527556
test.serial(
528557
'auto-import from test module with path: openfn job.js -S <obj> -a times-two',
529558
async (t) => {
559+
t.timeout(TIMEOUT);
530560
const state = JSON.stringify({ data: { count: 22 } });
531561
const job = 'export default [byTwo]';
532562
await resMock.generateJob(job);
@@ -542,6 +572,7 @@ test.serial(
542572
test.serial(
543573
'auto-import from language-common (job): openfn job.js -a @openfn/language-common@0.0.1',
544574
async (t) => {
575+
t.timeout(TIMEOUT);
545576
const job = 'fn((state) => { state.data.done = true; return state; });';
546577
await resMock.generateJob(job);
547578
const result = await run(
@@ -560,6 +591,7 @@ test.serial(
560591
test.serial(
561592
'run a workflow using language-common: openfn wf.json',
562593
async (t) => {
594+
t.timeout(TIMEOUT);
563595
const workflow = {
564596
jobs: [
565597
{
@@ -590,6 +622,7 @@ test.serial(
590622
test.serial(
591623
'use execute from language-postgres: openfn job.js -a @openfn/language-postgres',
592624
async (t) => {
625+
t.timeout(TIMEOUT);
593626
const job =
594627
'alterState((state) => { /* function isn\t actually called by the mock adaptor */ throw new Error("fake adaptor") });';
595628

@@ -610,6 +643,7 @@ test.serial(
610643
test.serial(
611644
'load an adaptor from the monorepo env var: openfn job.js -m -a common',
612645
async (t) => {
646+
t.timeout(TIMEOUT);
613647
process.env.OPENFN_ADAPTORS_REPO = resMock.monorepoPath;
614648
const job = 'export default [alterState(() => 39)]';
615649
await resMock.generateJob(job);
@@ -628,6 +662,7 @@ test.serial(
628662
// controlling that from here
629663
// I'll have to leave this as an integration test for now
630664
test.serial.skip('sanitize output', async (t) => {
665+
t.timeout(TIMEOUT);
631666
const job = 'export default [() => {console.log({}); return 22}]';
632667

633668
const result = await run('job.js -a common --sanitize=obfuscate', job);
@@ -643,6 +678,7 @@ test.serial.skip('sanitize output', async (t) => {
643678
test.serial(
644679
'load a workflow adaptor from the monorepo: openfn workflow.json -m',
645680
async (t) => {
681+
t.timeout(TIMEOUT);
646682
process.env.OPENFN_ADAPTORS_REPO = resMock.monorepoPath;
647683

648684
const workflow = JSON.stringify({
@@ -668,6 +704,7 @@ test.serial(
668704
);
669705

670706
test.serial('compile a job: openfn compile job.js to stdout', async (t) => {
707+
t.timeout(TIMEOUT);
671708
const options = {};
672709
await run('compile job.js', 'fn(42);', options);
673710

@@ -676,6 +713,7 @@ test.serial('compile a job: openfn compile job.js to stdout', async (t) => {
676713
});
677714

678715
test.serial('compile a job: openfn compile job.js to file', async (t) => {
716+
t.timeout(TIMEOUT);
679717
const options = {
680718
outputPath: 'out.js',
681719
};
@@ -686,6 +724,7 @@ test.serial('compile a job: openfn compile job.js to file', async (t) => {
686724
});
687725

688726
test.serial('compile a workflow: openfn compile wf.json to file', async (t) => {
727+
t.timeout(TIMEOUT);
689728
const options = {
690729
outputPath: 'out.json',
691730
expressionPath: 'wf.json', // just to fool the test
@@ -704,6 +743,7 @@ test.serial('compile a workflow: openfn compile wf.json to file', async (t) => {
704743
});
705744

706745
test.serial('docs should print documentation with full names', async (t) => {
746+
t.timeout(TIMEOUT);
707747
mock({
708748
'/repo/docs/@openfn/language-common@1.0.0.json': JSON.stringify({
709749
name: 'test',
@@ -734,6 +774,7 @@ test.serial('docs should print documentation with full names', async (t) => {
734774
});
735775

736776
test.serial('docs adaptor should list operations', async (t) => {
777+
t.timeout(TIMEOUT);
737778
const pkgPath = path.resolve('./package.json');
738779
mock({
739780
[pkgPath]: mock.load(pkgPath),
@@ -764,6 +805,7 @@ test.serial('docs adaptor should list operations', async (t) => {
764805
test.serial(
765806
'docs adaptor + operation should print documentation with shorthand names',
766807
async (t) => {
808+
t.timeout(TIMEOUT);
767809
mock({
768810
'/repo/docs/@openfn/language-common@1.0.0.json': JSON.stringify({
769811
name: 'test',
@@ -795,6 +837,7 @@ test.serial(
795837
);
796838

797839
test.serial('pull: should pull a simple project', async (t) => {
840+
t.timeout(TIMEOUT);
798841
mock({
799842
'./state.json': '',
800843
'./project.yaml': '',

0 commit comments

Comments
 (0)