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 every_test_custom_ns test example #253

Merged
merged 1 commit into from
May 10, 2023

Conversation

maruina
Copy link
Contributor

@maruina maruina commented May 2, 2023

The current example doesn't tell us how to use the namespace after we pass it to the context. This PR fixes it with a working example, while addressing a couple of go static-check fixes.

Tested with

❯ go test -v ./...
=== RUN   TestListPods
    main_test.go:91: Creating NS ns-d-903b2 for test TestListPods
=== RUN   TestListPods/pod_list
=== RUN   TestListPods/pod_list/pods_from_namespace
    k8s_test.go:37: found 0 pods in namespace ns-d-903b2
=== NAME  TestListPods
    main_test.go:100: Deleting NS ns-d-903b2 for test TestListPods
--- PASS: TestListPods (0.07s)
    --- PASS: TestListPods/pod_list (0.00s)
        --- PASS: TestListPods/pod_list/pods_from_namespace (0.00s)
PASS
ok  	sigs.k8s.io/e2e-framework/examples/every_test_custom_ns	31.204s

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels May 2, 2023
@k8s-ci-robot k8s-ci-robot added sig/testing Categorizes an issue or PR as relevant to SIG Testing. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 2, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @maruina. 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/M Denotes a PR that changes 30-99 lines, ignoring generated files. label May 2, 2023
Comment on lines +108 to +112
if strings.Contains(t.Name(), "/") {
return NamespaceCtxKey(strings.Split(t.Name(), "/")[0])
}
Copy link
Contributor Author

@maruina maruina May 2, 2023

Choose a reason for hiding this comment

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

This is needed because when we call t.Name() from inside an Assess the name is TestName/Features/Assess.

When we call if from inside testenv.BeforeEachTest the name is just TestName

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @maruina make sure to add a comment to function GetNamespaceKey with your explanation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this better?

@maruina maruina marked this pull request as ready for review May 2, 2023 15:29
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 2, 2023
@maruina maruina changed the title Fix every_test_custom_ns test Fix every_test_custom_ns test example May 2, 2023
@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 May 5, 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 for adding to the example!!

Comment on lines +108 to +112
if strings.Contains(t.Name(), "/") {
return NamespaceCtxKey(strings.Split(t.Name(), "/")[0])
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @maruina make sure to add a comment to function GetNamespaceKey with your explanation.

Copy link
Member

@ShwethaKumbla ShwethaKumbla 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 May 10, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: maruina, ShwethaKumbla

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 May 10, 2023
@k8s-ci-robot k8s-ci-robot merged commit e2613da into kubernetes-sigs:main May 10, 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/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.

4 participants