Documentation
¶
Index ¶
- func AssertNRateLimitedResponses(t *testing.T, n int, method, url string, headers map[string]string)
- func AssertNSuccessfulResponses(t *testing.T, n int, method, url string, headers map[string]string)
- func AssertNSuccessfulResponsesWithRetries(t *testing.T, n, maxRetries int, method, url string, headers map[string]string)
- func AssertRateLimitResponseHeaders(t *testing.T, method, url string, headers map[string]string, ...)
- func MatchingPodCount(t *testing.T, rateLimitName, namespace string) int
- func SetupAPIRule(t *testing.T, apiRuleYAML string, templateValues map[string]any, ...)
- func SetupRateLimit(t *testing.T, rateLimitYAML string, templateValues map[string]any, ...)
- func WaitUntilDeleted(t *testing.T, name, namespace string)
- func WaitUntilReady(t *testing.T, name, namespace string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertNRateLimitedResponses ¶
func AssertNRateLimitedResponses(t *testing.T, n int, method, url string, headers map[string]string)
AssertNRateLimitedResponses sends n requests in total and asserts that each response is 429 TooManyRequests. In dualstack mode, requests are distributed per family.
func AssertNSuccessfulResponses ¶
AssertNSuccessfulResponses sends n requests in total and asserts that each response is 200 OK. In dualstack mode, requests are distributed per family.
func AssertNSuccessfulResponsesWithRetries ¶
func AssertNSuccessfulResponsesWithRetries(t *testing.T, n, maxRetries int, method, url string, headers map[string]string)
AssertNSuccessfulResponsesWithRetries sends up to maxRetries requests and asserts that at least n 200 OK responses are received. 429 responses are ignored. The function logs the total requests sent and how many were successful.
Use this instead of AssertNSuccessfulResponses when there are multiple pods: each pod has an independent token bucket, so requests must be distributed across all pods to drain their combined capacity. maxRetries provides a budget to account for uneven LB distribution.
func AssertRateLimitResponseHeaders ¶
func AssertRateLimitResponseHeaders(t *testing.T, method, url string, headers map[string]string, expectedLimit, expectedRemaining int)
AssertRateLimitResponseHeaders asserts that the response contains the x-ratelimit-limit and x-ratelimit-remaining headers with the expected values, which are set by Envoy when enableResponseHeaders is true.
func MatchingPodCount ¶
MatchingPodCount returns the number of running pods in namespace whose labels match the selectorLabels of the named RateLimit. Returns 1 if none are found.
func SetupAPIRule ¶
func SetupAPIRule(t *testing.T, apiRuleYAML string, templateValues map[string]any, namespace string)
SetupAPIRule creates an APIRule from the given template and waits until it is ready.
func SetupRateLimit ¶
func SetupRateLimit(t *testing.T, rateLimitYAML string, templateValues map[string]any, namespace string)
SetupRateLimit creates a RateLimit resource from the given template and waits until it is ready. It also registers a cleanup that waits for the resource to be fully deleted, so that sequential tests sharing the same ingressgateway do not observe stale Envoy state.
func WaitUntilDeleted ¶
func WaitUntilReady ¶
Types ¶
This section is empty.