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(e2e): Run each test in subscription in different namespace #2433

Closed

Conversation

dinhxuanvu
Copy link
Member

All test cases in subscription suite shares the same test namespace.
In some cases, the resource cleanup which doesn't work properly from
previous test causes failure on subsequent test.

This commit will create new namespace for each test so it can be run
in insolation.

Signed-off-by: Vu Dinh vudinh@outlook.com

Description of the change:

Motivation for the change:

Reviewer Checklist

  • Implementation matches the proposed design, or proposal is updated to match implementation
  • Sufficient unit test coverage
  • Sufficient end-to-end test coverage
  • Docs updated or added to /doc
  • Commit messages sensible and descriptive

All test cases in subscription suite shares the same test namespace.
In some cases, the resource cleanup which doesn't work properly from
previous test causes failure on subsequent test.

This commit will create new namespace for each test so it can be run
in insolation.

Signed-off-by: Vu Dinh <vudinh@outlook.com>
@openshift-ci
Copy link

openshift-ci bot commented Nov 3, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dinhxuanvu

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 3, 2021
Comment on lines +39 to 41
v1 "github.com/operator-framework/api/pkg/operators/v1"
"github.com/operator-framework/api/pkg/operators/v1alpha1"
operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1"
Copy link
Contributor

Choose a reason for hiding this comment

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

Feel free to complete ignore this: v1 -> operatorsv1? It also looks like there's duplicate v1alpha1 imports here too.

@@ -918,3 +919,30 @@ func HaveMessage(goal string) gtypes.GomegaMatcher {
return plan.Status.Message
}, ContainSubstring(goal))
}

func SetUpGeneratedTestNamespace(name string) (string, corev1.Namespace) {
generatedNamespace := genName(name)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd expect this to happen at the call site, but this is fine for now.

return ctx.Ctx().Client().Create(context.Background(), &og)
}).Should(Succeed())

return generatedNamespace, ns
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, not opposed to this function signature, but you can access the generated namespace's name through ns.GetName() type operations (or indexing into the metadata.Name field directly).

TargetNamespaces: []string{ns.GetName()},
},
}
Eventually(func() error {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

func SetUpGeneratedTestNamespace(name string) (string, corev1.Namespace) {
generatedNamespace := genName(name)
ns := corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Copy link
Contributor

Choose a reason for hiding this comment

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

Mainly curious on when this is necessary: do we need to specify TypeMeta here as well?

Copy link
Contributor

@timflannagan timflannagan left a comment

Choose a reason for hiding this comment

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

Thanks, this should be help reduce many of the existing subscription-related e2e failures that are due to test pollution affect unrelated tests, and making debugging those failures less difficult. I only had one real comment: any reason we need to supply both a generatedNamespace and a corev1.Namespace as output variables from the SetUpGeneratedTestNamespace function? We should be able to infer the generated namespace by indexing into the corev1.Namespace's fields.

@dinhxuanvu
Copy link
Member Author

The commit is included in #2438 which is merged.
/close

@openshift-ci openshift-ci bot closed this Nov 10, 2021
@openshift-ci
Copy link

openshift-ci bot commented Nov 10, 2021

@dinhxuanvu: Closed this PR.

In response to this:

The commit is included in #2438 which is merged.
/close

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.

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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants