-
Notifications
You must be signed in to change notification settings - Fork 18
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 tests for D&O merge strategy #638
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: averevki <[email protected]>
raise TypeError("Strategy can only be set on defaults or overrides") | ||
|
||
self.spec_section["strategy"] = strategy.value | ||
self.spec_section = None |
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.
what is the purpose of setting it to None here?
@@ -0,0 +1,27 @@ | |||
"""Test defaults policy aimed at the same resoure uses oldested policy.""" |
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.
resoure / oldested - typos?
@@ -0,0 +1,27 @@ | |||
"""Test defaults policy aimed at the same resoure uses oldested policy.""" |
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.
Typos here too
@@ -0,0 +1,51 @@ | |||
"""Test gateway level default merging with and being patrially overriden by another policy.""" |
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.
*partially overridden
raise TypeError("Strategy can only be set on defaults or overrides") | ||
|
||
self.spec_section["strategy"] = strategy.value | ||
self.spec_section = None |
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.
Same again, unclear to me why there is this "None" assignment
|
||
def test_multiple_policies_merge_default_ab(client): | ||
"""Test RateLimitPolicy with merge defaults being ignored due to age""" | ||
responses = client.get_many("/get", MERGE_LIMIT.limit) |
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.
To be honest I think that the comments need to be swapped between test_ab_strategy and test_ba_strategy. If I got it right "a" means standard policy and "b" means policy with merge defaults.
So in "ab" the "a" policy is created first, and once "b" is created the "a" gets overridden - you can see it in test that "MERGE_LIMIT" is used for both get_many
calls. However, the comment in "ab" suggests that "b" is ignored which is not true - it is true in the "ba" test where the policies are created in different order.
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 decrypted the policy names.
dmp
means policy with defauls section and merge strategy (defaults merge policy)
sp
means standard policy === policy without both defaults and overrides sections
omp
means policy with overrides section and merge strategy (overrides merge policy)
|
||
|
||
def test_multiple_policies_merge_default_ab(client): | ||
"""Test RateLimitPolicy with merge overrides being ignored due to age""" |
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.
The RateLimitPolicy with merge overrides is not ignored. On the contrary it is fully enforced
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.
What is also weird is the fact that "ab" and "ba" strategy are the same, ie the order of creation of the polices does not matter, in both cases the "b" (one with overrides section and merge strategy) is fully enforced and "a" is overridden.
Not sure if this is expected behavior or not.
I don't like two additional things:
|
Refined part of #608 with merge strategy tests only
Closes #566