Skip to content
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

Merged
merged 2 commits into from
Sep 12, 2023

Conversation

cthain
Copy link
Contributor

@cthain cthain commented Sep 8, 2023

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:

  • Successfully ran the acceptance tests locally

How I expect reviewers to test this PR:
👀

Checklist:

@cthain cthain added pr/no-changelog PR does not need a corresponding .changelog entry pr/no-backport signals that a PR will not contain a backport label labels Sep 8, 2023
@cthain cthain self-assigned this Sep 8, 2023
Copy link
Contributor

@wilkermichael wilkermichael left a 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)
Copy link
Contributor

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

Copy link
Contributor Author

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.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// 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",
Copy link
Contributor

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

Copy link
Contributor Author

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:

"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) {
Copy link
Contributor

@wilkermichael wilkermichael Sep 8, 2023

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?

Copy link
Contributor Author

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 🤔

Copy link
Contributor

@kisunji kisunji left a 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.

@cthain cthain merged commit 869b097 into main Sep 12, 2023
3 checks passed
@cthain cthain deleted the cthain/net-5472/rate-limit-testing branch September 12, 2023 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr/no-backport signals that a PR will not contain a backport label pr/no-changelog PR does not need a corresponding .changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants