-
Notifications
You must be signed in to change notification settings - Fork 326
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
Add local rate limiting acceptance test #2932
Conversation
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.
Thanks for adding this Chris! Looks great!
Mostly just some observations, nothing critical here.
"http://localhost:1234/regex": 5, | ||
} | ||
|
||
opts := newRateLimitOptions(t, ctx) |
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.
Just a thought, but maybe it would be more straightforward to create an array of opts and add the addr/rate limit to each one? Would keep the configuration all in one place.
Then you could just loop on the opts
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.
Yeah that might be a nice update. My only concern with that is we would still have to do bits of the opts
setup in the loop. I think I'll stick with the host/rps map for now.
|
||
opts := newRateLimitOptions(t, ctx) | ||
|
||
// Ensure that all requests from static-client to static-server succeed. |
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.
// Ensure that all requests from static-client to static-server succeed. | |
// Ensure that all requests from static-client to static-server succeed (no rate limiting set) |
return &assertRateLimitOptions{ | ||
resourceType: "deploy/", | ||
successOutput: "hello world", | ||
rateLimitOutput: "curl: (22) The requested URL returned error: 429", |
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.
I might even consider changing this to just contain 429
in case any part of this string were to change in the future, 429 would be the most likely part to stay consistent
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.
It's possible that this could change but I think it's unlikely 🤷. If curl changes its output format/messages we'll likely have to change things elsewhere. I followed what was used in the connhelper
pkg for testing failed connections:
consul-k8s/acceptance/framework/connhelper/connect_helper.go
Lines 417 to 419 in 3d3bd70
"curl: (56) Recv failure: Connection reset by peer", | |
"curl: (52) Empty reply from server", | |
"curl: (7) Failed to connect to static-server port 80: Connection refused", |
} | ||
} | ||
|
||
func assertRateLimits(t *testing.T, opts *assertRateLimitOptions, curlArgs ...string) { |
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.
Just an observation that I think this mostly just tests requestMaxBursts
right? Do we want to add tests for throttling based on requestsPerSecond
?
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 this test is bursty. It was pretty difficult to setup a reliable burst test and with the current framework I think it would be even more difficult to reliably test throttling. We're using curl
via kubectl exec
and everything has to happen in under 1 second because we don't allow tweaking the fill_interval
.
I'm open to ideas if you have thoughts on how we could do this 🤔
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 great! Love your assertion that the bursts happened in 1s.
Changes proposed in this PR:
This PR adds a local rate limiting acceptance test to the
connect
folder. It is a follow on to #2844.How I've tested this PR:
How I expect reviewers to test this PR:
👀
Checklist: