-
Notifications
You must be signed in to change notification settings - Fork 129
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
feat: support scoping plugins to consumer-groups #959
Conversation
cf552c4
to
0a896f6
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #959 +/- ##
==========================================
- Coverage 33.98% 33.59% -0.40%
==========================================
Files 101 101
Lines 12201 12364 +163
==========================================
+ Hits 4147 4154 +7
- Misses 7651 7801 +150
- Partials 403 409 +6
☔ View full report in Codecov by Sentry. |
1123668
to
bc50703
Compare
Can we please ensure that we have integration test coverage for Konnect Runtime Group API as well? |
Some have already been added here: 16e0a24 |
Is there any reason to not run the ones added in this PR against Konnect (and in general, do that for every integration test we add)? As we're aware Konnect API is not always fully compatible with Kong, I think we should be very careful assuming they will work the same (that is a lesson I learned from #978). I think it would be ideal to have the same coverage for Konnect as for the regular Gateway and write the tests in a way so they're not specific to any of those. |
The one test added here against the Gateway that is not mapped to a Konnect test is the one testing the Consumer Groups functionality in the runtime (e.g. deploying CGs and checking that proxy requests are limited as expected). This sort of e2e with Konnect is not covered in this repo (it would require spinning up a real DP and connect it to Konnect), but it's covered elsewhere.
Totally agree with that and any deficiency should be fixed.
For the most part that's already the case. Again, any deficiency of this is an overlook and it should be fixed. Also agree that the testing framework needs some love indeed. |
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 one test added here against the Gateway that is not mapped to a Konnect test is the one testing the Consumer Groups functionality in the runtime (e.g. deploying CGs and checking that proxy requests are limited as expected). This sort of e2e with Konnect is not covered in this repo (it would require spinning up a real DP and connect it to Konnect), but it's covered elsewhere.
Yeah, thanks for the explanation. That makes sense. That for sure is something that couldn't be easily done in this PR (testing DP behavior with Konnect).
I left comments on tests that I believe could be run against Konnect, please correct me if I'm wrong about them. 🙇
19f7fe1
to
40eb7b2
Compare
40eb7b2
to
9f68186
Compare
e2d635f
to
f7222bc
Compare
// Otherwise, a plugin with name and the supplied foreign references is | ||
// searched. | ||
// name is required. | ||
func (k *PluginsCollection) GetByProp(name, serviceID, | ||
routeID string, consumerID string, | ||
func (k *PluginsCollection) GetByProp( |
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.
Nothing actionable for now but given that GetByProp
has grown to have 5 params now, it became hard to understand which parameter is used for what. Especially since all of those are of type string
.
It's also "easy to misuse": e.g. use argument in different order than expected.
@@ -444,7 +444,6 @@ | |||
}, | |||
"groups": { | |||
"items": { | |||
"$schema": "http://json-schema.org/draft-04/schema#", |
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.
Is this change related to Consumer Groups work? 🤔
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 file is auto-generated from the go-kong update.
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 that case: #991, let's mark it as generated to prevent folks from reviewing this.
file/builder.go
Outdated
return errors.New("a rate-limiting-advanced plugin with config.consumer_groups\n" + | ||
"and/or config.enforce_consumer_groups was found. Please use Consumer Groups scoped\n" + | ||
"Plugins when running against Kong Enterprise 3.4.0 and above.\n\n" + | ||
"Check DOC_LINK for more information") |
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.
Perhaps we could put this error in a variable which could then be compared against at the call site?
cmd/common_konnect.go
Outdated
@@ -129,6 +129,7 @@ func resetKonnectV2(ctx context.Context) error { | |||
if err != nil { | |||
return err | |||
} | |||
dumpConfig.IsConsumerGroupScopedPluginSupported = true |
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.
Why is this true only in resetKonnectV2
function while in the others (e.g. dumpKonnectV2
) it's not? How does it correspond with the fact that Konnect support for CG-scoped plugins was not released yet?
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.
Actually we don't need this flag set here. We only need when reading from a configuration file (so when running sync
) as opposite of reset
and dump
. I'll remove it.
tests/integration/dump_test.go
Outdated
} | ||
} | ||
|
||
func Test_Dump_SkipConsumers_34x(t *testing.T) { |
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.
Nit: we could avoid test code duplication if we extended the testcase struct in the original Test_Dump_SkipConsumers
test like so:
func Test_Dump_SkipConsumers(t *testing.T) {
tests := []struct {
name string
stateFile string
expectedFile string
skipConsumers bool
runWhen func(t *testing.T)
}{
...
{
name: "3.4 dump with skip-consumers",
stateFile: "testdata/dump/002-skip-consumers/kong34.yaml",
expectedFile: "testdata/dump/002-skip-consumers/expected.yaml",
skipConsumers: true,
runWhen: func(t *testing.T) { runWhen(t, "enterprise", ">=3.4.0 <3.5.0") },
},
{
name: "3.4 dump with no skip-consumers",
stateFile: "testdata/dump/002-skip-consumers/kong34.yaml",
expectedFile: "testdata/dump/002-skip-consumers/expected-no-skip-34.yaml",
skipConsumers: false,
runWhen: func(t *testing.T) { runWhen(t, "enterprise", ">=3.4.0 <3.5.0") },
},
{
name: "3.5 dump with skip-consumers",
stateFile: "testdata/dump/002-skip-consumers/kong34.yaml",
expectedFile: "testdata/dump/002-skip-consumers/expected.yaml",
skipConsumers: true,
runWhen: func(t *testing.T) { runWhen(t, "enterprise", ">=3.5.0") },
},
{
name: "3.5 dump with no skip-consumers",
stateFile: "testdata/dump/002-skip-consumers/kong34.yaml",
expectedFile: "testdata/dump/002-skip-consumers/expected-no-skip-35.yaml",
skipConsumers: false,
runWhen: func(t *testing.T) { runWhen(t, "enterprise", ">=3.5.0") },
},
...
}
...
t.Run(tc.name, func(t *testing.T) {
tc.runWhen(t)
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.
nice!
f97ffbb
to
bbef9fb
Compare
bbef9fb
to
ef83a97
Compare
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.
LGTM 👍
No description provided.