-
Notifications
You must be signed in to change notification settings - Fork 14
Worker: use real runtime in unit tests #496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
|
||
| // 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) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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 .