-
Notifications
You must be signed in to change notification settings - Fork 104
Test Framework #121
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
Test Framework #121
Conversation
# Conflicts: # README.md
bdcf2ac
to
2e3e2ef
Compare
affect calls activity code might make to functions on the `temporalio.activity` package. | ||
|
||
* `info` property can be set to customize what is returned from `activity.info()` | ||
* `on_heartbeat` property can be set to handle `activity.heartbeat()` calls |
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.
You might want to mention that when a worker runs an activity it throttles sending out heartbeats to the server so that users don't rely on this function in their tests.
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.
Can document, but can you clarify what you mean by:
users don't rely on this function in their tests
This is the one literally invoked for each heartbeat call unthrottled and I'd expect they can rely on that. Or are you saying so they don't improperly assume every heartbeat is heavy and that people call it quickly a lot so on_heartbeat
should not be assumed to be 1:1 with server heartbeat?
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.
the latter, thanks for clarifying.
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.
Will document when I send in PR for #120
@@ -1,4 +1,25 @@ | |||
""" | |||
@generated by mypy-protobuf. Do not edit manually! | |||
isort:skip_file | |||
The MIT License | |||
|
|||
Copyright (c) 2020 Temporal Technologies Inc. All rights reserved. |
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.
Shouldn't this be 2020-2022?
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.
This is generated code that was added as the result of a mypy-protobuf update. Specifically nipunn1313/mypy-protobuf#385 now writes our license headers. So this is literally from the top of https://github.com/temporalio/api/blob/master/temporal/api/history/v1/message.proto.
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.
We should update there.
""" | ||
|
||
@staticmethod | ||
def from_client(client: temporalio.client.Client) -> WorkflowEnvironment: |
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.
Nice!
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.
Wait until you see a future PR where I will have start_embedded
static function that's gonna download/run Temporalite like it does the test server. I wrestled with myself on whether that's valuable, but considering that I'm gonna do that for my own Python tests, I think it is.
(don't worry, I'm not putting "Temporalite" into the public API anywhere just in case it's folded into another binary later)
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.
Yes please, but please put this in Core so we can have it for TS and newer SDKs.
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.
Love the improvements over TS, I'm considering borrowing some of this.
It'd be great if you could move the download and test server process management logic to core so we can reuse it in other SDKs (not blocking of course).
What was changed
Added test framework. There is a lot here, so see the code and README updates to understand what was added. Ignore the regenerated protos in
temporalio/api
andtemporalio/bridge/proto
.Future changes:
temporalio.testing.WorkflowEnvironment.start_embedded
backed by Temporalite so we can run tests against both test server and real serverChecklist