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 all-features flag to add ability to enable all supported feature conformance tests. #1642

Merged

Conversation

gyohuangxin
Copy link
Member

What type of PR is this?

/kind feature

What this PR does / why we need it:

It adds all-features flag to add ability to enable all supported feature conformance tests. For example:

go test ./conformance --gateway-class istio --debug --all-features

Which issue(s) this PR fixes:

Fixes #1638

Does this PR introduce a user-facing change?:

1. Add `all-features` flag to enable all supported feature conformance tests.

@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Jan 11, 2023
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jan 11, 2023
@gyohuangxin
Copy link
Member Author

@robscott @arkodg Could you review this PR? Thanks.

CleanupBaseResources = flag.Bool("cleanup-base-resources", true, "Whether to cleanup base test resources after the run")
SupportedFeatures = flag.String("supported-features", "", "Supported features included in conformance tests suites")
ExemptFeatures = flag.String("exempt-features", "", "Exempt Features excluded from conformance tests suites")
EnableAllSupportedFeatures = flag.Bool("all-features", false, "Whether to enable all supported feature conformance tests")
Copy link
Contributor

Choose a reason for hiding this comment

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

flag name lgtm !

@@ -77,6 +77,23 @@ var StandardCoreFeatures = map[SupportedFeature]bool{
SupportReferenceGrant: true,
}

// AllFeatures contains all the supported features and can be used to run all
// conformance tests with `all-features` flag.
var AllFeatures = map[SupportedFeature]bool{
Copy link
Contributor

@arkodg arkodg Jan 11, 2023

Choose a reason for hiding this comment

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

is there any way a contributor defines the suite name once ? I fear the contributor will add it the constant w/o adding it to this map, and the burden to ensure its in sync will fall on the maintainer/ code reviewer

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, you are right, developers need to modify two places after the constant changes. But I can't find a simple way to define the suite name once in this codebase. Or I can add a comment to notice developer/code reviewer to ensure they are in sync?
@robscott Can you help with some advice?

Copy link
Contributor

Choose a reason for hiding this comment

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

I can't think of a better solution rn, can you add a comment to ensure they are in sync, TIA !

@gyohuangxin
Copy link
Member Author

@robscott Could you review it? Thanks

conformance/utils/flags/flags.go Outdated Show resolved Hide resolved
@@ -77,6 +77,23 @@ var StandardCoreFeatures = map[SupportedFeature]bool{
SupportReferenceGrant: true,
}

// AllFeatures contains all the supported features and can be used to run all
// conformance tests with `all-features` flag.
var AllFeatures = map[SupportedFeature]bool{
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps we should consider using a set for this instead of a map?

Copy link
Member Author

@gyohuangxin gyohuangxin Jan 19, 2023

Choose a reason for hiding this comment

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

IMO, there is no native set structure in golang, do you mean the map[SupportedFeature]struct{}? Also we should pass AllFeatures to suite's SupportedFeatures, so we should make them the same type.

Copy link
Member

Choose a reason for hiding this comment

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

Sets are available in apimachinery:

https://github.com/kubernetes/apimachinery/tree/master/pkg/util/sets

e.g.:

import "k8s.io/apimachinery/pkg/utils/sets"

var AllFeatures = sets.NewString(
	SupportReferenceGrant,
	SupportTLSRoute,
	SupportHTTPRouteQueryParamMatching,
	SupportHTTPRouteMethodMatching,
	SupportHTTPResponseHeaderModification,
	SupportRouteDestinationPortMatching,
	SupportGatewayClassObservedGenerationBump,
	SupportHTTPRoutePortRedirect,
	SupportHTTPRouteSchemeRedirect,
	SupportHTTPRoutePathRedirect,
	SupportHTTPRouteHostRewrite,
	SupportHTTPRoutePathRewrite,
)
if AllFeatures.Has(SupportReferenceGrant) {

Copy link
Member Author

Choose a reason for hiding this comment

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

@shaneutt Thank you for providing this example, it does provide an easy way to use set.
However, var AllFeatures = map[SupportedFeature]bool is also equivalent to a set, and I think it's better to keep AllFeatures declared in the same way as StandardCoreFeatures unless we also change the declaration method of StandardCoreFeatures. What do you think? Please correct me if I was wrong.

Copy link
Member

Choose a reason for hiding this comment

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

Yes the implementation ultimately uses a map, so the benefit here is for the developers which I think is a fair thing to trade for, however I don't consider this suggestion a blocker I'll let others weigh in.

Copy link
Member Author

Choose a reason for hiding this comment

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

Understood, if others also want the benefit, I can implement it.

Copy link
Member

Choose a reason for hiding this comment

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

Now that the k8s sets util supports generics, I think it would be best to move both this and AllFeatures over to use that approach.

Copy link
Member Author

Choose a reason for hiding this comment

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

Now that the k8s sets util supports generics, I think it would be best to move both this and AllFeatures over to use that approach.

@robscott @shaneutt I tried to move it to K8s sets utils: b85174a, can you review if it is correct?

@shaneutt shaneutt requested a review from robscott January 20, 2023 10:27
Copy link
Member

@robscott robscott left a comment

Choose a reason for hiding this comment

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

Thanks @gyohuangxin! Agree with moving to k8s sets util, but otherwise this LGTM.

@@ -77,6 +77,23 @@ var StandardCoreFeatures = map[SupportedFeature]bool{
SupportReferenceGrant: true,
}

// AllFeatures contains all the supported features and can be used to run all
// conformance tests with `all-features` flag.
var AllFeatures = map[SupportedFeature]bool{
Copy link
Member

Choose a reason for hiding this comment

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

Now that the k8s sets util supports generics, I think it would be best to move both this and AllFeatures over to use that approach.

Copy link
Contributor

@arkodg arkodg left a comment

Choose a reason for hiding this comment

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

lgtm, thanks for adding this !

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 26, 2023
Signed-off-by: Huang Xin <[email protected]>
Signed-off-by: Huang Xin <[email protected]>
…features when feature constants change.

Signed-off-by: Huang Xin <[email protected]>
@gyohuangxin gyohuangxin force-pushed the all-features-conformance-flag branch from 173f08e to 2cc158b Compare January 28, 2023 01:40
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 28, 2023
Signed-off-by: Huang Xin <[email protected]>
@gyohuangxin gyohuangxin force-pushed the all-features-conformance-flag branch 2 times, most recently from d4a4440 to b85174a Compare January 28, 2023 07:00
Signed-off-by: Huang Xin <[email protected]>
Signed-off-by: Huang Xin <[email protected]>
@gyohuangxin gyohuangxin removed the request for review from robscott January 31, 2023 12:27
@gyohuangxin gyohuangxin requested review from shaneutt and removed request for howardjohn, bowei and arkodg January 31, 2023 12:27
@shaneutt shaneutt requested a review from robscott January 31, 2023 13:38
Copy link
Member

@shaneutt shaneutt left a comment

Choose a reason for hiding this comment

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

Would like @robscott to give the final LGTM since he's been reviewing this too, but does LGTM.

conformance/utils/suite/suite.go Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 31, 2023
@gyohuangxin
Copy link
Member Author

@robscott Can you review it?

@shaneutt shaneutt added this to the v0.6.1 milestone Feb 3, 2023
Copy link
Member

@robscott robscott left a comment

Choose a reason for hiding this comment

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

Thanks @gyohuangxin!

conformance/utils/suite/suite.go Outdated Show resolved Hide resolved
Copy link
Member

@shaneutt shaneutt left a comment

Choose a reason for hiding this comment

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

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 6, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: arkodg, gyohuangxin, shaneutt

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit d8b8994 into kubernetes-sigs:main Feb 6, 2023
shaneutt pushed a commit that referenced this pull request Feb 7, 2023
Add `all-features` flag to add ability to enable all supported feature conformance tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ability to enable all Supported Feature Conformance tests
5 participants