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

fix: Label handling #248

Merged
merged 1 commit into from
Apr 27, 2023
Merged

fix: Label handling #248

merged 1 commit into from
Apr 27, 2023

Conversation

embano1
Copy link
Contributor

@embano1 embano1 commented Apr 20, 2023

Follow-up on #194 where the logic was still not correct in all cases. The behavior is now as expected: if --labels is specified all keys and values specified must match a feature. This allows for arbitrary and complex combinations of multiple features within one suite.

For example:

f1 := features.New("label demo 1").
		WithLabel("a", "1").
		WithLabel("all", "true").
		Feature()

f2 := features.New("label demo 2").
		WithLabel("all", "true").
		Feature()

f3 := features.New("label demo 3").
		WithLabel("a", "2").
		WithLabel("all", "true").
		Feature()

f4 := features.New("label demo 4").
		WithLabel("a", "1").
		WithLabel("b", "1").
		WithLabel("all", "true").
		Feature()

Leads to the following outcomes with different --labels:

go test -race -v ./e2e -args -v 4 --labels=some=value
--- PASS: TestDemoE2E (0.07s)
    --- SKIP: TestDemoE2E/label_demo_1 (0.00s)
    --- SKIP: TestDemoE2E/label_demo_2 (0.00s)
    --- SKIP: TestDemoE2E/label_demo_3 (0.00s)
    --- SKIP: TestDemoE2E/label_demo_4 (0.00s)
PASS
go test -race -v ./e2e -args -v 4 --labels=a=1
--- PASS: TestDemoE2E (0.06s)
    --- PASS: TestDemoE2E/label_demo_1 (0.00s)
    --- SKIP: TestDemoE2E/label_demo_2 (0.00s)
    --- SKIP: TestDemoE2E/label_demo_3 (0.00s)
    --- PASS: TestDemoE2E/label_demo_4 (0.00s)
PASS
go test -race -v ./e2e -args -v 4 --labels=all=true
--- PASS: TestDemoE2E (0.05s)
    --- PASS: TestDemoE2E/label_demo_1 (0.00s)
    --- PASS: TestDemoE2E/label_demo_2 (0.00s)
    --- PASS: TestDemoE2E/label_demo_3 (0.00s)
    --- PASS: TestDemoE2E/label_demo_4 (0.00s)
PASS
go test -race -v ./e2e -args -v 4 --labels=all=true,a=1
--- PASS: TestDemoE2E (0.04s)
    --- PASS: TestDemoE2E/label_demo_1 (0.00s)
    --- SKIP: TestDemoE2E/label_demo_2 (0.00s)
    --- SKIP: TestDemoE2E/label_demo_3 (0.00s)
    --- PASS: TestDemoE2E/label_demo_4 (0.00s)
PASS

Passing no --labels of course works as expected

go test -race -v ./e2e -args -v 4
--- PASS: TestDemoE2E (0.06s)
    --- PASS: TestDemoE2E/label_demo_1 (0.00s)
    --- PASS: TestDemoE2E/label_demo_2 (0.00s)
    --- PASS: TestDemoE2E/label_demo_3 (0.00s)
    --- PASS: TestDemoE2E/label_demo_4 (0.00s)
PASS

Also works in combination with --skip-labels

go test -race -v ./e2e -args -v 4 --labels=a=1 --skip-labels=all=true
--- PASS: TestDemoE2E (0.05s)
    --- SKIP: TestDemoE2E/label_demo_1 (0.00s)
    --- SKIP: TestDemoE2E/label_demo_2 (0.00s)
    --- SKIP: TestDemoE2E/label_demo_3 (0.00s)
    --- SKIP: TestDemoE2E/label_demo_4 (0.00s)
PASS

@k8s-ci-robot k8s-ci-robot added the sig/testing Categorizes an issue or PR as relevant to SIG Testing. label Apr 20, 2023
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 20, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @embano1. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Apr 20, 2023
Copy link
Contributor

@vladimirvivien vladimirvivien left a comment

Choose a reason for hiding this comment

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

@embano1 This looks great. Thanks for the awesome work.

I will ask for one favor though:
Can you update examples/skip_flags/README.md with the examples you have on the PR that shows the complex combination that is now supported!

Signed-off-by: Michael Gasch <15986659+embano1@users.noreply.github.com>
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 23, 2023
@embano1
Copy link
Contributor Author

embano1 commented Apr 23, 2023

@vladimirvivien done! Formatted and added more details to the README for clarity. Also updated the test examples to show how multiple labels can be used.

@ShwethaKumbla
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 23, 2023
Copy link
Contributor

@vladimirvivien vladimirvivien left a comment

Choose a reason for hiding this comment

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

Thanks a lot for this and the doc update.
Leaving it as comment for now so you can see my comment on the review.

/lgtm


There are several supported flags (for more accurate list, see package `pkg/flag`):
Copy link
Contributor

Choose a reason for hiding this comment

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

I support this removal.
But we probably need to put it in its own doc (i.e. docs/supported_flags.md).
Maybe for now, open a new issue to have proper argument documentations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason I removed it as we have this already covered in the flags example and this one is focused on labels. But will add tracking issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, if already documented, no need for the tracking issue.

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

embano1 commented Apr 25, 2023

@vladimirvivien tide is still pending?

@embano1 embano1 mentioned this pull request Apr 25, 2023
@vladimirvivien
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: embano1, vladimirvivien

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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 27, 2023
@k8s-ci-robot k8s-ci-robot merged commit 64d85de into kubernetes-sigs:main Apr 27, 2023
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. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants