Skip to content

fix disable copied csv e2e test failure #2543

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 40 additions & 46 deletions test/e2e/csv_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4175,58 +4175,52 @@ var _ = Describe("ClusterServiceVersion", func() {
})

var _ = Describe("Disabling copied CSVs", func() {
// Define namespace, operatorGroup, and csv upfront
ns := &corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: genName("csv-toggle-test-"),
},
}
var (
ns corev1.Namespace
csv operatorsv1alpha1.ClusterServiceVersion
)

operatorGroup := operatorsv1.OperatorGroup{
ObjectMeta: metav1.ObjectMeta{
Name: genName("csv-toggle-test-"),
Namespace: ns.GetName(),
},
}
BeforeEach(func() {
nsname := genName("csv-toggle-test-")
og := operatorsv1.OperatorGroup{
ObjectMeta: metav1.ObjectMeta{
Name: fmt.Sprintf("%s-operatorgroup", nsname),
Namespace: nsname,
},
}
ns = SetupGeneratedTestNamespaceWithOperatorGroup(nsname, og)

csv := operatorsv1alpha1.ClusterServiceVersion{
ObjectMeta: metav1.ObjectMeta{
Name: genName("csv-toggle-test-"),
Namespace: ns.GetName(),
},
Spec: operatorsv1alpha1.ClusterServiceVersionSpec{
InstallStrategy: newNginxInstallStrategy(genName("csv-toggle-test-"), nil, nil),
InstallModes: []operatorsv1alpha1.InstallMode{
{
Type: operatorsv1alpha1.InstallModeTypeAllNamespaces,
Supported: true,
csv = operatorsv1alpha1.ClusterServiceVersion{
ObjectMeta: metav1.ObjectMeta{
Name: genName("csv-toggle-test-"),
Namespace: nsname,
},
Spec: operatorsv1alpha1.ClusterServiceVersionSpec{
InstallStrategy: newNginxInstallStrategy(genName("csv-toggle-test-"), nil, nil),
InstallModes: []operatorsv1alpha1.InstallMode{
{
Type: operatorsv1alpha1.InstallModeTypeAllNamespaces,
Supported: true,
},
},
},
},
}

When("an operator is installed in AllNamespace mode", func() {
BeforeEach(func() {
Eventually(func() error {
if err := ctx.Ctx().Client().Create(context.TODO(), ns); err != nil && !k8serrors.IsAlreadyExists(err) {
ctx.Ctx().Logf("Unable to create ns: %v", err)
return err
}

if err := ctx.Ctx().Client().Create(context.TODO(), &operatorGroup); err != nil && !k8serrors.IsAlreadyExists(err) {
ctx.Ctx().Logf("Unable to create og: %v", err)
return err
}

if err := ctx.Ctx().Client().Create(context.TODO(), &csv); err != nil && !k8serrors.IsAlreadyExists(err) {
ctx.Ctx().Logf("Unable to create csv: %v", err)
return err
}
}
err := ctx.Ctx().Client().Create(context.Background(), &csv)
Expect(err).ShouldNot(HaveOccurred())
})
AfterEach(func() {
Eventually(func() error {
err := ctx.Ctx().Client().Delete(context.Background(), &csv)
if err != nil && k8serrors.IsNotFound(err) {
return err
}

return nil
}).Should(Succeed())
})
return nil
}).Should(Succeed())
TeardownNamespace(ns.GetName())
})

When("an operator is installed in AllNamespace mode", func() {
It("should have Copied CSVs in all other namespaces", func() {
Eventually(func() error {
requirement, err := k8slabels.NewRequirement(operatorsv1alpha1.CopiedLabelKey, selection.Equals, []string{csv.GetNamespace()})
Expand Down
25 changes: 15 additions & 10 deletions test/e2e/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ func HaveMessage(goal string) gtypes.GomegaMatcher {
}, ContainSubstring(goal))
}

func SetupGeneratedTestNamespace(name string) corev1.Namespace {
func SetupGeneratedTestNamespaceWithOperatorGroup(name string, og operatorsv1.OperatorGroup) corev1.Namespace {
ns := corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Expand All @@ -961,15 +961,6 @@ func SetupGeneratedTestNamespace(name string) corev1.Namespace {
return ctx.Ctx().Client().Create(context.Background(), &ns)
}).Should(Succeed())

og := operatorsv1.OperatorGroup{
ObjectMeta: metav1.ObjectMeta{
Name: fmt.Sprintf("%s-operatorgroup", ns.GetName()),
Namespace: ns.GetName(),
},
Spec: operatorsv1.OperatorGroupSpec{
TargetNamespaces: []string{ns.GetName()},
},
}
Eventually(func() error {
return ctx.Ctx().Client().Create(context.Background(), &og)
}).Should(Succeed())
Expand All @@ -979,6 +970,20 @@ func SetupGeneratedTestNamespace(name string) corev1.Namespace {
return ns
}

func SetupGeneratedTestNamespace(name string) corev1.Namespace {
og := operatorsv1.OperatorGroup{
ObjectMeta: metav1.ObjectMeta{
Name: fmt.Sprintf("%s-operatorgroup", name),
Namespace: name,
},
Spec: operatorsv1.OperatorGroupSpec{
TargetNamespaces: []string{name},
},
}

return SetupGeneratedTestNamespaceWithOperatorGroup(name, og)
}

func TeardownNamespace(ns string) {
log := ctx.Ctx().Logf

Expand Down