Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Batch rate limit #551

Merged
merged 2 commits into from
May 8, 2024
Merged

Conversation

stephanos
Copy link
Contributor

@stephanos stephanos commented May 6, 2024

What was changed

Added support for passing --rps flag to batch operations.

ℹ️ FYI I've only added a single test for TerminateWorkflow, even though there are 3 batch APIs. Reason being that the API is the same and the only difference is the "operation". Let me know if I should add it to the others as well.

❓ Note sure why I'm seeing the CLA request on my PR.

Checklist

  1. Closes

  2. How was this tested: Added new tests.

  3. Any docs updates needed?

@stephanos stephanos force-pushed the batch-rate-limit branch from 2b31be5 to 8c9470c Compare May 6, 2024 17:20
@temporalio temporalio deleted a comment from CLAassistant May 6, 2024
@temporalio temporalio deleted a comment from CLAassistant May 6, 2024
@CLAassistant
Copy link

CLAassistant commented May 6, 2024

CLA assistant check
All committers have signed the CLA.

@stephanos stephanos force-pushed the batch-rate-limit branch 3 times, most recently from 35423f1 to ffd2c01 Compare May 6, 2024 17:30
@temporalio temporalio deleted a comment from CLAassistant May 6, 2024
func (s *SharedServerSuite) TestWorkflow_Terminate_BatchWorkflowSuccess_Ratelimit() {
events, _ := s.testTerminateBatchWorkflow(2, 1, false)
delay := events[1].EventTime.AsTime().Sub(events[0].EventTime.AsTime()).Abs()
s.InDelta(delay, 1*time.Second, float64(100*time.Millisecond))
Copy link
Contributor Author

@stephanos stephanos May 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my tests it hasn't always been 1s or greater, so I added a delta here.

Copy link
Member

@cretz cretz May 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the kind of test that grows flaky with Go runner slowness I've found. Expecting this margin of error is a bit rough. I think for this you may only need to test that it's set on the outbound request (e.g. w/ gRPC interceptor maybe), you don't need to test server behavior for something like this IMO (that's for the server to test).

@@ -308,6 +324,7 @@ func (s *SharedServerSuite) testTerminateBatchWorkflow(json bool) *CommandResult
// Send batch terminate with a "y" for non-json or "--yes" for json
args := []string{
"workflow", "terminate",
"--rps", fmt.Sprint(rps),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduces a delay in the test suite of up to 1s. Not sure how to avoid that while still testing the Server end-to-end.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may have to accept some things cannot reasonably tested in CLI without slowing all tests down.

@stephanos stephanos marked this pull request as ready for review May 6, 2024 17:56
@tlalfano tlalfano requested a review from cretz May 7, 2024 18:41
Copy link
Member

@cretz cretz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. One minor suggestion and concerns about using time-based expectations in tests

@@ -911,6 +911,7 @@ Use the options listed below to change reset behavior.
* `--build-id` (string) - Only used if type is BuildId. Reset the first workflow task processed by this build id. Note that by default, this reset is allowed to be to a prior run in a chain of continue-as-new.
* `--query`, `-q` (string) - Start a batch reset to operate on Workflow Executions with given List Filter.
* `--yes`, `-y` (bool) - Confirm prompt to perform batch. Only allowed if query is present.
* `--rps` (float) - Limit batch's requests per second. Only allowed if query is present.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update the top of this file to include this new data type in the bullet that lists the data types supported? It's our admittedly-informal "spec".

@@ -308,6 +324,7 @@ func (s *SharedServerSuite) testTerminateBatchWorkflow(json bool) *CommandResult
// Send batch terminate with a "y" for non-json or "--yes" for json
args := []string{
"workflow", "terminate",
"--rps", fmt.Sprint(rps),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may have to accept some things cannot reasonably tested in CLI without slowing all tests down.

func (s *SharedServerSuite) TestWorkflow_Terminate_BatchWorkflowSuccess_Ratelimit() {
events, _ := s.testTerminateBatchWorkflow(2, 1, false)
delay := events[1].EventTime.AsTime().Sub(events[0].EventTime.AsTime()).Abs()
s.InDelta(delay, 1*time.Second, float64(100*time.Millisecond))
Copy link
Member

@cretz cretz May 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the kind of test that grows flaky with Go runner slowness I've found. Expecting this margin of error is a bit rough. I think for this you may only need to test that it's set on the outbound request (e.g. w/ gRPC interceptor maybe), you don't need to test server behavior for something like this IMO (that's for the server to test).

Copy link
Member

@cretz cretz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@stephanos stephanos force-pushed the batch-rate-limit branch from f7e612c to 096a1b7 Compare May 8, 2024 17:58
@stephanos stephanos force-pushed the batch-rate-limit branch from 096a1b7 to 422c835 Compare May 8, 2024 18:00
@stephanos stephanos merged commit 4234de0 into temporalio:cli-rewrite May 8, 2024
5 of 6 checks passed
@stephanos stephanos deleted the batch-rate-limit branch May 8, 2024 18:09
@tlalfano
Copy link

tlalfano commented May 9, 2024

Let's make sure this is in the next CLI release.

@antlai-temporal
Copy link
Contributor

@stephanos I think the cli-rewrite branch is dead, main becoming the new target branch for the last two weeks, you may want to merge in main instead... @cretz Can you confirm?
I'm going to use your float changes for one of my flags, thanks for doing that!

@stephanos stephanos restored the batch-rate-limit branch September 23, 2024 14:34
@stephanos stephanos mentioned this pull request Sep 23, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants