-
Notifications
You must be signed in to change notification settings - Fork 545
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
Conversation
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>
[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 |
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" |
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.
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) |
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.
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 |
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.
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 { |
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.
👍
func SetUpGeneratedTestNamespace(name string) (string, corev1.Namespace) { | ||
generatedNamespace := genName(name) | ||
ns := corev1.Namespace{ | ||
ObjectMeta: metav1.ObjectMeta{ |
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.
Mainly curious on when this is necessary: do we need to specify TypeMeta here as well?
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.
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.
The commit is included in #2438 which is merged. |
@dinhxuanvu: Closed this PR. In response to this:
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. |
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
/doc