Worker: use real runtime in unit tests#496
Merged
josephjclark merged 12 commits intorelease/nextfrom Nov 17, 2023
Merged
Conversation
josephjclark
commented
Nov 17, 2023
|
|
||
| // hmm, i don't even think I can test this in the mock runtime | ||
| test.skip('should pass the right dataclip when running in parallel', () => {}); | ||
| test('should pass the right dataclip when running in parallel', (t) => { |
Collaborator
Author
There was a problem hiding this comment.
As a result of using the new runtime, I can now write really sophisticated tests like this, which deeply test a) how the runtime handles complex Attempts and b) how the worker maps runtime events to Lightning events.
If I had this test two weeks ago, I'd have skipped over a lot of hurt this week!
This proves the value of this work, in the next couple of weeks I'll be building more more complex tests like this.
3 tasks
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #486
The worker at the moment uses a mock runtime engine to test against.
This is quite reasonable because we don't want to be spinning up loads of threads while unit testing worker functions. It's overkill.
Previously the engine mock did include it's own fake little runtime with very limited functionality. But there are two big problems with this:
The mock engine does not autoinstall. It will call the credentials resolver. It will do a sort of fake compilation of jobs - it won't download an adaptor and do real compilation, but it will wrap the
fn()call in anexport default [fn]wrapper for compatability. It also injects some "fake" adaptor functions into the job scope.Globals
To make this work I'm pulling in some old code from #303. This allows us to set globals in the runtime scope.
This functionality is not exposed to the CLI or the Worker. Just the mock worker .