Skip to content

Commit c420158

Browse files
committed
test/e2e: Replace context.TODO references with context.Background in the catalog e2e package
Signed-off-by: timflannagan <[email protected]>
1 parent e29a8d7 commit c420158

File tree

1 file changed

+38
-38
lines changed

1 file changed

+38
-38
lines changed

Diff for: test/e2e/catalog_e2e_test.go

+38-38
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
104104

105105
// Determine which namespace is global. Should be `openshift-marketplace` for OCP 4.2+.
106106
// Locally it is `olm`
107-
namespaces, _ := c.KubernetesInterface().CoreV1().Namespaces().List(context.TODO(), metav1.ListOptions{})
107+
namespaces, _ := c.KubernetesInterface().CoreV1().Namespaces().List(context.Background(), metav1.ListOptions{})
108108
for _, ns := range namespaces.Items {
109109
if ns.GetName() == "openshift-marketplace" {
110110
globalNS = "openshift-marketplace"
@@ -165,7 +165,7 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
165165
Expect(err).ShouldNot(HaveOccurred())
166166

167167
fetchedInstallPlan.Spec.Approved = true
168-
_, err = crc.OperatorsV1alpha1().InstallPlans(testNamespace).Update(context.TODO(), fetchedInstallPlan, metav1.UpdateOptions{})
168+
_, err = crc.OperatorsV1alpha1().InstallPlans(testNamespace).Update(context.Background(), fetchedInstallPlan, metav1.UpdateOptions{})
169169
Expect(err).ShouldNot(HaveOccurred())
170170

171171
_, err = awaitCSV(crc, testNamespace, mainCSV.GetName(), csvSucceededChecker)
@@ -244,19 +244,19 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
244244
Expect(err).ShouldNot(HaveOccurred())
245245

246246
// Get initial configmap
247-
configMap, err := c.KubernetesInterface().CoreV1().ConfigMaps(testNamespace).Get(context.TODO(), fetchedInitialCatalog.Spec.ConfigMap, metav1.GetOptions{})
247+
configMap, err := c.KubernetesInterface().CoreV1().ConfigMaps(testNamespace).Get(context.Background(), fetchedInitialCatalog.Spec.ConfigMap, metav1.GetOptions{})
248248
Expect(err).ShouldNot(HaveOccurred())
249249

250250
// Check pod created
251-
initialPods, err := c.KubernetesInterface().CoreV1().Pods(testNamespace).List(context.TODO(), metav1.ListOptions{LabelSelector: "olm.configMapResourceVersion=" + configMap.ResourceVersion})
251+
initialPods, err := c.KubernetesInterface().CoreV1().Pods(testNamespace).List(context.Background(), metav1.ListOptions{LabelSelector: "olm.configMapResourceVersion=" + configMap.ResourceVersion})
252252
Expect(err).ShouldNot(HaveOccurred())
253253
Expect(initialPods.Items).To(HaveLen(1))
254254

255255
// Update catalog configmap
256256
updateInternalCatalog(GinkgoT(), c, crc, mainCatalogName, testNamespace, []apiextensions.CustomResourceDefinition{dependentCRD}, []v1alpha1.ClusterServiceVersion{mainCSV, dependentCSV}, append(mainManifests, dependentManifests...))
257257

258258
// Get updated configmap
259-
updatedConfigMap, err := c.KubernetesInterface().CoreV1().ConfigMaps(testNamespace).Get(context.TODO(), fetchedInitialCatalog.Spec.ConfigMap, metav1.GetOptions{})
259+
updatedConfigMap, err := c.KubernetesInterface().CoreV1().ConfigMaps(testNamespace).Get(context.Background(), fetchedInitialCatalog.Spec.ConfigMap, metav1.GetOptions{})
260260
Expect(err).ShouldNot(HaveOccurred())
261261

262262
fetchedUpdatedCatalog, err := fetchCatalogSourceOnStatus(crc, mainCatalogName, testNamespace, func(catalog *v1alpha1.CatalogSource) bool {
@@ -299,7 +299,7 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
299299
_, err = fetchCSV(crc, subscription.Status.CurrentCSV, testNamespace, buildCSVConditionChecker(v1alpha1.CSVPhaseSucceeded))
300300
Expect(err).ShouldNot(HaveOccurred())
301301

302-
ipList, err := crc.OperatorsV1alpha1().InstallPlans(testNamespace).List(context.TODO(), metav1.ListOptions{})
302+
ipList, err := crc.OperatorsV1alpha1().InstallPlans(testNamespace).List(context.Background(), metav1.ListOptions{})
303303
ipCount := 0
304304
for _, ip := range ipList.Items {
305305
if ownerutil.IsOwnedBy(&ip, subscription) {
@@ -354,11 +354,11 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
354354
fetchedInitialCatalog, err := fetchCatalogSourceOnStatus(crc, mainCatalogName, testNamespace, catalogSourceRegistryPodSynced)
355355
Expect(err).ShouldNot(HaveOccurred())
356356
// Get initial configmap
357-
configMap, err := c.KubernetesInterface().CoreV1().ConfigMaps(testNamespace).Get(context.TODO(), fetchedInitialCatalog.Spec.ConfigMap, metav1.GetOptions{})
357+
configMap, err := c.KubernetesInterface().CoreV1().ConfigMaps(testNamespace).Get(context.Background(), fetchedInitialCatalog.Spec.ConfigMap, metav1.GetOptions{})
358358
Expect(err).ShouldNot(HaveOccurred())
359359

360360
// Check pod created
361-
initialPods, err := c.KubernetesInterface().CoreV1().Pods(testNamespace).List(context.TODO(), metav1.ListOptions{LabelSelector: "olm.configMapResourceVersion=" + configMap.ResourceVersion})
361+
initialPods, err := c.KubernetesInterface().CoreV1().Pods(testNamespace).List(context.Background(), metav1.ListOptions{LabelSelector: "olm.configMapResourceVersion=" + configMap.ResourceVersion})
362362
Expect(err).ShouldNot(HaveOccurred())
363363
Expect(initialPods.Items).To(HaveLen(1))
364364

@@ -474,10 +474,10 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
474474
},
475475
}
476476

477-
addressSource, err = crc.OperatorsV1alpha1().CatalogSources(testNamespace).Create(context.TODO(), addressSource, metav1.CreateOptions{})
477+
addressSource, err = crc.OperatorsV1alpha1().CatalogSources(testNamespace).Create(context.Background(), addressSource, metav1.CreateOptions{})
478478
Expect(err).ShouldNot(HaveOccurred())
479479
defer func() {
480-
err := crc.OperatorsV1alpha1().CatalogSources(testNamespace).Delete(context.TODO(), addressSourceName, metav1.DeleteOptions{})
480+
err := crc.OperatorsV1alpha1().CatalogSources(testNamespace).Delete(context.Background(), addressSourceName, metav1.DeleteOptions{})
481481
Expect(err).ShouldNot(HaveOccurred())
482482
}()
483483

@@ -486,9 +486,9 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
486486
Expect(err).ToNot(HaveOccurred(), "catalog source did not become ready")
487487

488488
// Delete CatalogSources
489-
err = crc.OperatorsV1alpha1().CatalogSources(testNamespace).Delete(context.TODO(), mainSourceName, metav1.DeleteOptions{})
489+
err = crc.OperatorsV1alpha1().CatalogSources(testNamespace).Delete(context.Background(), mainSourceName, metav1.DeleteOptions{})
490490
Expect(err).ShouldNot(HaveOccurred())
491-
err = crc.OperatorsV1alpha1().CatalogSources(testNamespace).Delete(context.TODO(), replacementSourceName, metav1.DeleteOptions{})
491+
err = crc.OperatorsV1alpha1().CatalogSources(testNamespace).Delete(context.Background(), replacementSourceName, metav1.DeleteOptions{})
492492
Expect(err).ShouldNot(HaveOccurred())
493493

494494
// Create Subscription
@@ -503,10 +503,10 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
503503
Expect(err).ShouldNot(HaveOccurred())
504504

505505
// Update the catalog's address to point at the other registry pod's cluster ip
506-
addressSource, err = crc.OperatorsV1alpha1().CatalogSources(testNamespace).Get(context.TODO(), addressSourceName, metav1.GetOptions{})
506+
addressSource, err = crc.OperatorsV1alpha1().CatalogSources(testNamespace).Get(context.Background(), addressSourceName, metav1.GetOptions{})
507507
Expect(err).ShouldNot(HaveOccurred())
508508
addressSource.Spec.Address = net.JoinHostPort(replacementCopy.Status.PodIP, "50051")
509-
_, err = crc.OperatorsV1alpha1().CatalogSources(testNamespace).Update(context.TODO(), addressSource, metav1.UpdateOptions{})
509+
_, err = crc.OperatorsV1alpha1().CatalogSources(testNamespace).Update(context.Background(), addressSource, metav1.UpdateOptions{})
510510
Expect(err).ShouldNot(HaveOccurred())
511511

512512
// Wait for the replacement CSV to be installed
@@ -555,7 +555,7 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
555555
// Delete the registry pod
556556
Eventually(func() error {
557557
backgroundDeletion := metav1.DeletePropagationBackground
558-
return c.KubernetesInterface().CoreV1().Pods(testNamespace).DeleteCollection(context.TODO(), metav1.DeleteOptions{PropagationPolicy: &backgroundDeletion}, metav1.ListOptions{LabelSelector: selector.String()})
558+
return c.KubernetesInterface().CoreV1().Pods(testNamespace).DeleteCollection(context.Background(), metav1.DeleteOptions{PropagationPolicy: &backgroundDeletion}, metav1.ListOptions{LabelSelector: selector.String()})
559559
}).Should(Succeed())
560560

561561
// Wait for a new registry pod to be created
@@ -600,7 +600,7 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
600600
},
601601
}
602602

603-
source, err := crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Create(context.TODO(), source, metav1.CreateOptions{})
603+
source, err := crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Create(context.Background(), source, metav1.CreateOptions{})
604604
Expect(err).ShouldNot(HaveOccurred())
605605

606606
// Wait for a new registry pod to be created
@@ -617,7 +617,7 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
617617
// Delete the registry pod
618618
Eventually(func() error {
619619
backgroundDeletion := metav1.DeletePropagationBackground
620-
return c.KubernetesInterface().CoreV1().Pods(testNamespace).DeleteCollection(context.TODO(), metav1.DeleteOptions{PropagationPolicy: &backgroundDeletion}, metav1.ListOptions{LabelSelector: selector.String()})
620+
return c.KubernetesInterface().CoreV1().Pods(testNamespace).DeleteCollection(context.Background(), metav1.DeleteOptions{PropagationPolicy: &backgroundDeletion}, metav1.ListOptions{LabelSelector: selector.String()})
621621
}).Should(Succeed())
622622

623623
// Wait for a new registry pod to be created
@@ -733,10 +733,10 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
733733
},
734734
}
735735

736-
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Create(context.TODO(), source, metav1.CreateOptions{})
736+
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Create(context.Background(), source, metav1.CreateOptions{})
737737
Expect(err).ShouldNot(HaveOccurred())
738738
defer func() {
739-
err := crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Delete(context.TODO(), source.GetName(), metav1.DeleteOptions{})
739+
err := crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Delete(context.Background(), source.GetName(), metav1.DeleteOptions{})
740740
Expect(err).ShouldNot(HaveOccurred())
741741
}()
742742

@@ -792,11 +792,11 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
792792
}
793793

794794
// update catalog source with annotation (to kick resync)
795-
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Get(context.TODO(), source.GetName(), metav1.GetOptions{})
795+
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Get(context.Background(), source.GetName(), metav1.GetOptions{})
796796
Expect(err).ShouldNot(HaveOccurred(), "error awaiting registry pod")
797797
source.Annotations = make(map[string]string)
798798
source.Annotations["testKey"] = "testValue"
799-
_, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Update(context.TODO(), source, metav1.UpdateOptions{})
799+
_, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Update(context.Background(), source, metav1.UpdateOptions{})
800800
Expect(err).ShouldNot(HaveOccurred(), "error awaiting registry pod")
801801

802802
time.Sleep(11 * time.Second)
@@ -816,10 +816,10 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
816816
}
817817
}
818818
// update catalog source with annotation (to kick resync)
819-
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Get(context.TODO(), source.GetName(), metav1.GetOptions{})
819+
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Get(context.Background(), source.GetName(), metav1.GetOptions{})
820820
Expect(err).ShouldNot(HaveOccurred(), "error getting catalog source pod")
821821
source.Annotations["testKey"] = genName("newValue")
822-
_, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Update(context.TODO(), source, metav1.UpdateOptions{})
822+
_, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Update(context.Background(), source, metav1.UpdateOptions{})
823823
Expect(err).ShouldNot(HaveOccurred(), "error updating catalog source pod with test annotation")
824824
return false
825825
}
@@ -830,10 +830,10 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
830830
Expect(registryPods.Items).To(HaveLen(1), "unexpected number of registry pods found")
831831

832832
// update catalog source with annotation (to kick resync)
833-
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Get(context.TODO(), source.GetName(), metav1.GetOptions{})
833+
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Get(context.Background(), source.GetName(), metav1.GetOptions{})
834834
Expect(err).ShouldNot(HaveOccurred(), "error awaiting registry pod")
835835
source.Annotations["testKey"] = "newValue"
836-
_, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Update(context.TODO(), source, metav1.UpdateOptions{})
836+
_, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Update(context.Background(), source, metav1.UpdateOptions{})
837837
Expect(err).ShouldNot(HaveOccurred(), "error awaiting registry pod")
838838

839839
subChecker := func(sub *v1alpha1.Subscription) bool {
@@ -890,10 +890,10 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
890890
},
891891
}
892892

893-
source, err := crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Create(context.TODO(), source, metav1.CreateOptions{})
893+
source, err := crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Create(context.Background(), source, metav1.CreateOptions{})
894894
Expect(err).ShouldNot(HaveOccurred())
895895
defer func() {
896-
err := crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Delete(context.TODO(), source.GetName(), metav1.DeleteOptions{})
896+
err := crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Delete(context.Background(), source.GetName(), metav1.DeleteOptions{})
897897
Expect(err).ShouldNot(HaveOccurred())
898898
}()
899899

@@ -913,7 +913,7 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
913913
Expect(subscription.Status.InstalledCSV).To(Equal("busybox.v1.0.0"))
914914

915915
// Confirm that a subscription was created for busybox-dependency
916-
subscriptionList, err := crc.OperatorsV1alpha1().Subscriptions(source.GetNamespace()).List(context.TODO(), metav1.ListOptions{})
916+
subscriptionList, err := crc.OperatorsV1alpha1().Subscriptions(source.GetNamespace()).List(context.Background(), metav1.ListOptions{})
917917
Expect(err).ShouldNot(HaveOccurred())
918918
dependencySubscriptionName := ""
919919
for _, sub := range subscriptionList.Items {
@@ -931,13 +931,13 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
931931

932932
// Update the catalog image
933933
Eventually(func() (bool, error) {
934-
existingSource, err := crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Get(context.TODO(), sourceName, metav1.GetOptions{})
934+
existingSource, err := crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Get(context.Background(), sourceName, metav1.GetOptions{})
935935
if err != nil {
936936
return false, err
937937
}
938938
existingSource.Spec.Image = catSrcImage + ":2.0.0-with-ListBundles-method"
939939

940-
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Update(context.TODO(), existingSource, metav1.UpdateOptions{})
940+
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Update(context.Background(), existingSource, metav1.UpdateOptions{})
941941
if err == nil {
942942
return true, nil
943943
}
@@ -1006,7 +1006,7 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
10061006
},
10071007
}
10081008

1009-
source, err := crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Create(context.TODO(), source, metav1.CreateOptions{})
1009+
source, err := crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Create(context.Background(), source, metav1.CreateOptions{})
10101010
Expect(err).ToNot(HaveOccurred())
10111011

10121012
// wait for new catalog source pod to be created and report ready
@@ -1017,7 +1017,7 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
10171017
Expect(catalogPods).ToNot(BeNil())
10181018

10191019
Eventually(func() (bool, error) {
1020-
podList, err := c.KubernetesInterface().CoreV1().Pods(source.GetNamespace()).List(context.TODO(), metav1.ListOptions{LabelSelector: selector.String()})
1020+
podList, err := c.KubernetesInterface().CoreV1().Pods(source.GetNamespace()).List(context.Background(), metav1.ListOptions{LabelSelector: selector.String()})
10211021
if err != nil {
10221022
return false, err
10231023
}
@@ -1071,14 +1071,14 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
10711071

10721072
var err error
10731073
Eventually(func() error {
1074-
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Create(context.TODO(), source, metav1.CreateOptions{})
1074+
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Create(context.Background(), source, metav1.CreateOptions{})
10751075
return err
10761076
}).Should(Succeed())
10771077

10781078
By("updating the catalog source with template annotation")
10791079

10801080
Eventually(func() error {
1081-
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Get(context.TODO(), source.GetName(), metav1.GetOptions{})
1081+
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Get(context.Background(), source.GetName(), metav1.GetOptions{})
10821082
if err != nil {
10831083
return err
10841084
}
@@ -1088,13 +1088,13 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
10881088
})
10891089

10901090
// Update the catalog image
1091-
_, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Update(context.TODO(), source, metav1.UpdateOptions{})
1091+
_, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Update(context.Background(), source, metav1.UpdateOptions{})
10921092
return err
10931093
}).Should(Succeed())
10941094

10951095
// wait for status condition to show up
10961096
Eventually(func() (bool, error) {
1097-
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Get(context.TODO(), sourceName, metav1.GetOptions{})
1097+
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Get(context.Background(), sourceName, metav1.GetOptions{})
10981098
if err != nil {
10991099
return false, err
11001100
}
@@ -1184,7 +1184,7 @@ func rescaleDeployment(c operatorclient.ClientInterface, deployment *appsv1.Depl
11841184
}
11851185

11861186
func replicateCatalogPod(c operatorclient.ClientInterface, catalog *v1alpha1.CatalogSource) *corev1.Pod {
1187-
initialPods, err := c.KubernetesInterface().CoreV1().Pods(catalog.GetNamespace()).List(context.TODO(), metav1.ListOptions{LabelSelector: "olm.catalogSource=" + catalog.GetName()})
1187+
initialPods, err := c.KubernetesInterface().CoreV1().Pods(catalog.GetNamespace()).List(context.Background(), metav1.ListOptions{LabelSelector: "olm.catalogSource=" + catalog.GetName()})
11881188
Expect(err).ToNot(HaveOccurred())
11891189
Expect(initialPods.Items).To(HaveLen(1))
11901190

@@ -1197,7 +1197,7 @@ func replicateCatalogPod(c operatorclient.ClientInterface, catalog *v1alpha1.Cat
11971197
Spec: pod.Spec,
11981198
}
11991199

1200-
copied, err = c.KubernetesInterface().CoreV1().Pods(catalog.GetNamespace()).Create(context.TODO(), copied, metav1.CreateOptions{})
1200+
copied, err = c.KubernetesInterface().CoreV1().Pods(catalog.GetNamespace()).Create(context.Background(), copied, metav1.CreateOptions{})
12011201
Expect(err).ToNot(HaveOccurred())
12021202

12031203
return copied

0 commit comments

Comments
 (0)