-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* worker: allow a limit on payload size * changeset * worker: ensure server default payload limit is set * tests: worker tests for payload limit * tests: add test for log limits * worker: dont log data which exceeds the payload limit * update changeset * worker: log the payload limit at the start of a run * worker: add output_dataclip_error * fix tests * worker: rename payload_memory_limit_mb to payload_limit_mb * versions: [email protected] * worker: WORKER_MAX_PAYLPAD_MEMORY_MB -> WORKER_MAX_PAYLOAD_MB * lexicon: fix typing * tests: update
- Loading branch information
1 parent
5c72cb6
commit 7f14570
Showing
18 changed files
with
408 additions
and
40 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"name": "@openfn/integration-tests-worker", | ||
"private": true, | ||
"version": "1.0.52", | ||
"version": "1.0.53", | ||
"description": "Lightning WOrker integration tests", | ||
"author": "Open Function Group <[email protected]>", | ||
"license": "ISC", | ||
|
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 |
---|---|---|
|
@@ -787,5 +787,127 @@ test.serial('set a timeout on a run', (t) => { | |
}); | ||
}); | ||
|
||
test.serial('set a default payload limit on the worker', (t) => { | ||
return new Promise(async (done) => { | ||
if (!worker.destroyed) { | ||
await worker.destroy(); | ||
} | ||
|
||
({ worker } = await initWorker( | ||
lightningPort, | ||
{ | ||
maxWorkers: 1, | ||
// use the dummy repo to remove autoinstall | ||
repoDir: path.resolve('./dummy-repo'), | ||
}, | ||
{ | ||
payloadLimitMb: 0, | ||
} | ||
)); | ||
|
||
const run = { | ||
id: crypto.randomUUID(), | ||
jobs: [ | ||
{ | ||
adaptor: '@openfn/[email protected]', | ||
body: `fn((s) => ({ data: 'aaaa' }))`, | ||
}, | ||
], | ||
}; | ||
|
||
lightning.once('step:complete', (evt) => { | ||
const { reason, output_dataclip_id, output_dataclip } = evt.payload; | ||
t.is(reason, 'success'); | ||
t.falsy(output_dataclip_id); | ||
t.falsy(output_dataclip); | ||
|
||
done(); | ||
}); | ||
|
||
lightning.enqueueRun(run); | ||
}); | ||
}); | ||
|
||
test.serial('override the worker payload through run options', (t) => { | ||
return new Promise(async (done) => { | ||
if (!worker.destroyed) { | ||
await worker.destroy(); | ||
} | ||
|
||
({ worker } = await initWorker( | ||
lightningPort, | ||
{ | ||
maxWorkers: 1, | ||
// use the dummy repo to remove autoinstall | ||
repoDir: path.resolve('./dummy-repo'), | ||
}, | ||
{ payloadLimitMb: 0 } | ||
)); | ||
|
||
const run = { | ||
id: crypto.randomUUID(), | ||
jobs: [ | ||
{ | ||
adaptor: '@openfn/[email protected]', | ||
body: `fn((s) => ({ data: 'aaaa' }))`, | ||
}, | ||
], | ||
options: { | ||
payload_limit_mb: 100, | ||
}, | ||
}; | ||
|
||
lightning.once('step:complete', (evt) => { | ||
const { reason, output_dataclip_id, output_dataclip } = evt.payload; | ||
t.is(reason, 'success'); | ||
t.truthy(output_dataclip_id); | ||
t.deepEqual(output_dataclip, JSON.stringify({ data: 'aaaa' })); | ||
|
||
done(); | ||
}); | ||
|
||
lightning.enqueueRun(run); | ||
}); | ||
}); | ||
|
||
test.serial('Redact logs which exceed the payload limit', (t) => { | ||
return new Promise(async (done) => { | ||
if (!worker.destroyed) { | ||
await worker.destroy(); | ||
} | ||
|
||
({ worker } = await initWorker(lightningPort, { | ||
maxWorkers: 1, | ||
// use the dummy repo to remove autoinstall | ||
repoDir: path.resolve('./dummy-repo'), | ||
})); | ||
|
||
const run = { | ||
id: crypto.randomUUID(), | ||
jobs: [ | ||
{ | ||
adaptor: '@openfn/[email protected]', | ||
body: `fn((s) => { console.log('a'); return s;})`, | ||
}, | ||
], | ||
options: { | ||
payload_limit_mb: 0, | ||
}, | ||
}; | ||
|
||
lightning.on('run:log', (evt) => { | ||
if (evt.payload.source === 'JOB') { | ||
t.regex(evt.payload.message[0], /redacted/i); | ||
} | ||
}); | ||
|
||
lightning.enqueueRun(run); | ||
|
||
lightning.once('run:complete', () => { | ||
done(); | ||
}); | ||
}); | ||
}); | ||
|
||
// REMEMBER the default worker was destroyed at this point! | ||
// If you want to use a worker, you'll have to create your own |
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
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
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
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
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
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
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
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
Oops, something went wrong.