Skip to content

Commit

Permalink
e2e: fixup custom configmaps with labels
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
  • Loading branch information
stevekuznetsov committed Nov 30, 2023
1 parent 8a68d79 commit 7a056b2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
14 changes: 14 additions & 0 deletions test/e2e/subscription_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,21 @@ var _ = Describe("Subscription", func() {
It("creation if not installed", func() {

defer func() {
if env := os.Getenv("SKIP_CLEANUP"); env != "" {
fmt.Printf("Skipping cleanup of subscriptions in namespace %s\n", generatedNamespace.GetName())
return
}
require.NoError(GinkgoT(), crc.OperatorsV1alpha1().Subscriptions(generatedNamespace.GetName()).DeleteCollection(context.Background(), metav1.DeleteOptions{}, metav1.ListOptions{}))
}()

By("creating a catalog")
require.NoError(GinkgoT(), initCatalog(GinkgoT(), generatedNamespace.GetName(), c, crc))

By(fmt.Sprintf("creating a subscription: %s/%s", generatedNamespace.GetName(), testSubscriptionName))
cleanup, _ := createSubscription(GinkgoT(), crc, generatedNamespace.GetName(), testSubscriptionName, testPackageName, betaChannel, operatorsv1alpha1.ApprovalAutomatic)
defer cleanup()

By("waiting for the subscription to have a current CSV and be at latest")
var currentCSV string
Eventually(func() bool {
fetched, err := crc.OperatorsV1alpha1().Subscriptions(generatedNamespace.GetName()).Get(context.Background(), testSubscriptionName, metav1.GetOptions{})
Expand Down Expand Up @@ -3073,6 +3081,9 @@ var (
dummyCatalogConfigMap = &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: catalogConfigMapName,
Labels: map[string]string{
install.OLMManagedLabelKey: install.OLMManagedLabelValue,
},
},
Data: map[string]string{},
}
Expand Down Expand Up @@ -3121,6 +3132,7 @@ func initCatalog(t GinkgoTInterface, namespace string, c operatorclient.ClientIn
}
return err
}
t.Logf("created configmap %s/%s", dummyCatalogConfigMap.Namespace, dummyCatalogConfigMap.Name)

dummyCatalogSource.SetNamespace(namespace)
if _, err := crc.OperatorsV1alpha1().CatalogSources(namespace).Create(context.Background(), &dummyCatalogSource, metav1.CreateOptions{}); err != nil {
Expand All @@ -3129,6 +3141,7 @@ func initCatalog(t GinkgoTInterface, namespace string, c operatorclient.ClientIn
}
return err
}
t.Logf("created catalog source %s/%s", dummyCatalogSource.Namespace, dummyCatalogSource.Name)

fetched, err := fetchCatalogSourceOnStatus(crc, dummyCatalogSource.GetName(), dummyCatalogSource.GetNamespace(), catalogSourceRegistryPodSynced())
require.NoError(t, err)
Expand Down Expand Up @@ -3312,6 +3325,7 @@ func createSubscription(t GinkgoTInterface, crc versioned.Interface, namespace,

subscription, err := crc.OperatorsV1alpha1().Subscriptions(namespace).Create(context.Background(), subscription, metav1.CreateOptions{})
Expect(err).ToNot(HaveOccurred())
t.Logf("created subscription %s/%s", subscription.Namespace, subscription.Name)
return buildSubscriptionCleanupFunc(crc, subscription), subscription
}

Expand Down
4 changes: 3 additions & 1 deletion test/e2e/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -1073,11 +1073,13 @@ func SetupGeneratedTestNamespaceWithOperatorGroup(name string, og operatorsv1.Op
return ctx.Ctx().E2EClient().Create(context.Background(), &ns)
}).Should(Succeed())

ctx.Ctx().Logf("created the %s testing namespace", ns.GetName())

Eventually(func() error {
return ctx.Ctx().E2EClient().Create(context.Background(), &og)
}).Should(Succeed())

ctx.Ctx().Logf("created the %s testing namespace", ns.GetName())
ctx.Ctx().Logf("created the %s/%s operator group", og.Namespace, og.Name)

return ns
}
Expand Down

0 comments on commit 7a056b2

Please sign in to comment.