-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f92b9a3
commit 0801c28
Showing
4 changed files
with
64 additions
and
3 deletions.
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
integration-tests/worker/dummy-repo/node_modules/@openfn/test-adaptor_1.0.0/index.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
integration-tests/worker/dummy-repo/node_modules/@openfn/test-adaptor_1.0.0/package.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
"private": true, | ||
"version": "1.0.0", | ||
"dependencies": { | ||
"@openfn/stateful-test_1.0.0": "@npm:@openfn/[email protected]" | ||
"@openfn/stateful-test_1.0.0": "@npm:@openfn/[email protected]", | ||
"@openfn/test-adaptor_1.0.0": "@npm:@openfn/[email protected]" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,15 @@ test.after(async () => { | |
await worker.destroy(); | ||
}); | ||
|
||
const createDummyWorker = () => { | ||
const engineArgs = { | ||
repoDir: path.resolve('./dummy-repo'), | ||
maxWorkers: 1, | ||
purge: false, | ||
}; | ||
return initWorker(lightningPort, engineArgs); | ||
}; | ||
|
||
test('should run a simple job with no compilation or adaptor', (t) => { | ||
return new Promise(async (done) => { | ||
lightning.once('run:complete', (evt) => { | ||
|
@@ -148,7 +157,7 @@ test("Don't send job logs to stdout", (t) => { | |
|
||
lightning.once('run:complete', () => { | ||
const jsonLogs = engineLogger._history; | ||
|
||
console.log(jsonLogs); | ||
// The engine logger shouldn't print out any job logs | ||
const jobLog = jsonLogs.find((l) => l.name === 'JOB'); | ||
t.falsy(jobLog); | ||
|
@@ -157,7 +166,44 @@ test("Don't send job logs to stdout", (t) => { | |
|
||
// But it SHOULD log engine stuff | ||
const runtimeLog = jsonLogs.find( | ||
(l) => l.name === 'R/T' && l.message[0].match(/completed step/i) | ||
(l) => l.name === 'R/T' && l.message[0].match(/completed workflow/i) | ||
); | ||
t.truthy(runtimeLog); | ||
done(); | ||
}); | ||
|
||
lightning.enqueueRun(attempt); | ||
}); | ||
}); | ||
|
||
test("Don't send adaptor logs to stdout", (t) => { | ||
return new Promise(async (done) => { | ||
// We have to create a new worker with a different repo for this one | ||
await worker.destroy(); | ||
({ worker, engineLogger } = await createDummyWorker()); | ||
|
||
const message = 've have been expecting you meester bond'; | ||
const attempt = { | ||
id: crypto.randomUUID(), | ||
jobs: [ | ||
{ | ||
adaptor: '@openfn/[email protected]', | ||
body: `import { log } from '@openfn/test-adaptor'; log("${message}")`, | ||
}, | ||
], | ||
}; | ||
|
||
lightning.once('run:complete', (evt) => { | ||
const jsonLogs = engineLogger._history; | ||
// The engine logger shouldn't print out any adaptor logs | ||
const jobLog = jsonLogs.find((l) => l.name === 'ADA'); | ||
t.falsy(jobLog); | ||
const jobLog2 = jsonLogs.find((l) => l.message[0] === message); | ||
t.falsy(jobLog2); | ||
|
||
// But it SHOULD log engine stuff | ||
const runtimeLog = jsonLogs.find( | ||
(l) => l.name === 'R/T' && l.message[0].match(/completed workflow/i) | ||
); | ||
t.truthy(runtimeLog); | ||
done(); | ||
|
@@ -433,6 +479,7 @@ test('stateful adaptor should create a new client for each attempt', (t) => { | |
return new Promise(async (done) => { | ||
// We want to create our own special worker here | ||
await worker.destroy(); | ||
({ worker } = await createDummyWorker()); | ||
|
||
const attempt1 = { | ||
id: crypto.randomUUID(), | ||
|