-
Notifications
You must be signed in to change notification settings - Fork 154
Add Functional tests for ProxySettingsPolicy #4482
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
base: feat/proxy-settings-policy
Are you sure you want to change the base?
Add Functional tests for ProxySettingsPolicy #4482
Conversation
| // ????????????????????????????????????????????????// ???????????????????????????????? | ||
| // Route policy specifies buffer sizes without setting disable: false (should set PartiallyInvalid condition) | ||
| When("valid disable for Gateway ProxySettingsPolicies is inherited by HTTPRoute", func() { | ||
| var ( | ||
| policies = []string{ | ||
| "proxy-settings-policy/gateway-disabled-coffee-not-enabled-proxy-settings.yaml", | ||
| } | ||
|
|
||
| baseURL string | ||
| ) | ||
|
|
||
| BeforeAll(func() { | ||
| Expect(resourceManager.ApplyFromFiles(policies, namespace)).To(Succeed()) | ||
|
|
||
| port := 80 | ||
| if portFwdPort != 0 { | ||
| port = portFwdPort | ||
| } | ||
|
|
||
| baseURL = fmt.Sprintf("http://cafe.example.com:%d", port) | ||
| }) | ||
|
|
||
| AfterAll(func() { | ||
| Expect(resourceManager.DeleteFromFiles(policies, namespace)).To(Succeed()) | ||
| }) | ||
|
|
||
| Specify("they are accepted by the target resource", func() { | ||
| policyNames := []string{ | ||
| "gateway-proxy-settings", | ||
| "coffee-proxy-settings", | ||
| } | ||
|
|
||
| for _, name := range policyNames { | ||
| nsname := types.NamespacedName{Name: name, Namespace: namespace} | ||
|
|
||
| err := waitForPSPolicyStatus(nsname) | ||
| Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("%s was not accepted", name)) | ||
| } | ||
| }) | ||
|
|
||
| Context("verify working traffic", func() { | ||
| // ???????????????????????????????????????????????? | ||
| It("should return a 200 response only for HTTPRoute tea, and fail for coffee", func() { | ||
| baseCoffeeURL := baseURL + "/coffee" | ||
| baseTeaURL := baseURL + "/tea" | ||
|
|
||
| Eventually( |
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.
In this case reading the design proposal
Important: If a Gateway policy disables buffering (disable: true), and a Route policy specifies buffer size fields (bufferSize, buffers, or busyBuffersSize) without explicitly setting disable: false, the buffer size fields will be ignored since buffering is disabled. A Condition will be set on the Route policy to indicate that these fields are being ignored. To use buffer size settings when the Gateway has disabled buffering, the Route policy must explicitly set disable: false.
If gateway disables proxy buffering and disable: false is not explicitly set which is in the example you are using, the proxy buffer fields are ignored and a proper error message should be communicated on the route saying these fields are ignored. Are you able to see the error message on coffee route about these fields being ignored? That's what needs to be checked here.
But if disable: false was explicitly set on the route proxy settings policy the request would succeed (not your case)
| When("valid disable for HTTPRoute ProxySettingsPolicies overrides enabled Gateway setting", func() { | ||
| var ( | ||
| policies = []string{ | ||
| "proxy-settings-policy/gateway-enabled-coffee-disabled-proxy-settings.yaml", | ||
| } | ||
|
|
||
| baseURL string | ||
| ) | ||
|
|
||
| BeforeAll(func() { | ||
| Expect(resourceManager.ApplyFromFiles(policies, namespace)).To(Succeed()) | ||
|
|
||
| port := 80 | ||
| if portFwdPort != 0 { | ||
| port = portFwdPort | ||
| } | ||
|
|
||
| baseURL = fmt.Sprintf("http://cafe.example.com:%d", port) | ||
| }) | ||
|
|
||
| AfterAll(func() { | ||
| Expect(resourceManager.DeleteFromFiles(policies, namespace)).To(Succeed()) | ||
| }) | ||
|
|
||
| Specify("they are accepted by the target resource", func() { | ||
| policyNames := []string{ | ||
| "gateway-proxy-settings", | ||
| "coffee-proxy-settings", | ||
| } | ||
|
|
||
| for _, name := range policyNames { | ||
| nsname := types.NamespacedName{Name: name, Namespace: namespace} | ||
|
|
||
| err := waitForPSPolicyStatus(nsname) | ||
| Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("%s was not accepted", name)) | ||
| } | ||
| }) | ||
|
|
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.
Looking at the implementation, we set a proxy_buffering off directive on the location block when buffering is disabled at Route level, are you seeing that? We should verify that directive exists and request for coffee should fail,
Whereas tea should pass because it will inherit the settings from the Gateway which has proxy buffering enabled.
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 guess if we didn't explicitly set it off then coffee location would still inherit Gateway settings.
Let me know if you are tests results look off from the desired and I will look deeper.
Problem: As an NGF developer
I want functional tests for the ProxySettingsPolicy
So that I can ensure that nginx behaves properly when defining proxy settings.
Acceptance:
Functional tests are added for ProxySettingsPolicy
https://github.com/nginx/nginx-gateway-fabric/blob/main/docs/proposals/proxy-settings.md#testing
verify nginx config looks correct
Solution: Added next Functional tests that test the attachment and inheritance behavior, including:
Policy attached to Gateway only
Policy attached to Route only
Policy attached to both Gateway and Route
With inheritance and override scenarios:
Validation tests for invalid configurations
Closes #4264
Checklist
Before creating a PR, run through this checklist and mark each as complete.
Release notes