Skip to content

Commit 82ab614

Browse files
Merge pull request #1635 from njhale/fix-always-cleanup-e2e
test(e2e): delete all subs, installplans, catalogs, and csvs in test teardown
2 parents 01f2ed0 + e4a8133 commit 82ab614

14 files changed

+174
-206
lines changed

test/e2e/bundle_e2e_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111

1212
. "github.com/onsi/ginkgo"
1313
. "github.com/onsi/gomega"
14-
1514
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1615
"k8s.io/apimachinery/pkg/runtime/schema"
1716
"k8s.io/client-go/dynamic"
@@ -38,7 +37,7 @@ var _ = PDescribe("Installing bundles with new object types", func() {
3837
})
3938

4039
AfterEach(func() {
41-
cleaner.NotifyTestComplete(true)
40+
TearDown(testNamespace)
4241
})
4342

4443
When("a bundle with a pdb, priorityclass, and VPA object is installed", func() {

test/e2e/catalog_e2e_test.go

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,11 @@ import (
3131
)
3232

3333
var _ = Describe("Catalog", func() {
34-
It("loading between restarts", func() {
35-
36-
defer cleaner.NotifyTestComplete(true)
34+
AfterEach(func() {
35+
TearDown(testNamespace)
36+
})
3737

38+
It("loading between restarts", func() {
3839
// create a simple catalogsource
3940
packageName := genName("nginx")
4041
stableChannel := "stable"
@@ -90,8 +91,6 @@ var _ = Describe("Catalog", func() {
9091
})
9192
It("global update triggers subscription sync", func() {
9293

93-
defer cleaner.NotifyTestComplete(true)
94-
9594
globalNS := operatorNamespace
9695
c := newKubeClient()
9796
crc := newCRClient()
@@ -199,8 +198,6 @@ var _ = Describe("Catalog", func() {
199198
})
200199
It("config map update triggers registry pod rollout", func() {
201200

202-
defer cleaner.NotifyTestComplete(true)
203-
204201
mainPackageName := genName("nginx-")
205202
dependentPackageName := genName("nginxdep-")
206203

@@ -318,8 +315,6 @@ var _ = Describe("Catalog", func() {
318315
})
319316
It("config map replace triggers registry pod rollout", func() {
320317

321-
defer cleaner.NotifyTestComplete(true)
322-
323318
mainPackageName := genName("nginx-")
324319
dependentPackageName := genName("nginxdep-")
325320

@@ -408,8 +403,6 @@ var _ = Describe("Catalog", func() {
408403
// Update the "address" CatalogSources's Spec.Address field with the PodIP of the replacement copied pod's PodIP
409404
// Wait for the replacement CSV to be Successful
410405

411-
defer cleaner.NotifyTestComplete(true)
412-
413406
mainPackageName := genName("nginx-")
414407
dependentPackageName := genName("nginxdep-")
415408

@@ -545,8 +538,6 @@ var _ = Describe("Catalog", func() {
545538
// Delete the registry pod
546539
// Wait for a new registry pod to be created
547540

548-
defer cleaner.NotifyTestComplete(true)
549-
550541
// Create internal CatalogSource containing csv in package
551542
packageName := genName("nginx-")
552543
packageStable := fmt.Sprintf("%s-stable", packageName)
@@ -630,8 +621,6 @@ var _ = Describe("Catalog", func() {
630621
// Delete the registry pod
631622
// Wait for a new registry pod to be created
632623

633-
defer cleaner.NotifyTestComplete(true)
634-
635624
sourceName := genName("catalog-")
636625
packageName := "etcd"
637626
channelName := "clusterwide-alpha"
@@ -781,7 +770,6 @@ var _ = Describe("Catalog", func() {
781770
}
782771

783772
// 2. setup catalog source
784-
defer cleaner.NotifyTestComplete(true)
785773

786774
sourceName := genName("catalog-")
787775
packageName := "busybox"
@@ -952,7 +940,6 @@ var _ = Describe("Catalog", func() {
952940
// Update the catalog to point to an image that contains the busybox v2 and busybox-dependency v2 images.
953941
// Wait for the new Subscriptions to succeed and check if they include the new CSVs
954942
// Wait for the CSVs to succeed and confirm that the have the correct Spec.Replaces fields.
955-
defer cleaner.NotifyTestComplete(true)
956943

957944
sourceName := genName("catalog-")
958945
packageName := "busybox"

test/e2e/crd_e2e_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
)
1919

2020
var _ = Describe("CRD Versions", func() {
21-
AfterEach(func() { cleaner.NotifyTestComplete(true) }, float64(10))
21+
AfterEach(func() { TearDown(testNamespace) }, float64(30))
2222

2323
It("creates v1beta1 crds with a v1beta1 schema successfully", func() {
2424
By("This test proves that OLM is able to handle v1beta1 CRDs successfully. Creating v1 CRDs has more " +

test/e2e/csv_e2e_test.go

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ import (
3434
)
3535

3636
var _ = Describe("CSV", func() {
37-
It("create with unmet requirements mini kube version", func() {
37+
AfterEach(func() {
38+
TearDown(testNamespace)
39+
})
3840

39-
defer cleaner.NotifyTestComplete(true)
41+
It("create with unmet requirements mini kube version", func() {
4042

4143
c := newKubeClient()
4244
crc := newCRClient()
@@ -88,8 +90,6 @@ var _ = Describe("CSV", func() {
8890
// TODO: same test but missing serviceaccount instead
8991
It("create with unmet requirements CRD", func() {
9092

91-
defer cleaner.NotifyTestComplete(true)
92-
9393
c := newKubeClient()
9494
crc := newCRClient()
9595

@@ -150,8 +150,6 @@ var _ = Describe("CSV", func() {
150150
})
151151
It("create with unmet permissions CRD", func() {
152152

153-
defer cleaner.NotifyTestComplete(true)
154-
155153
c := newKubeClient()
156154
crc := newCRClient()
157155

@@ -260,8 +258,6 @@ var _ = Describe("CSV", func() {
260258
})
261259
It("create with unmet requirements API service", func() {
262260

263-
defer cleaner.NotifyTestComplete(true)
264-
265261
c := newKubeClient()
266262
crc := newCRClient()
267263

@@ -322,8 +318,6 @@ var _ = Describe("CSV", func() {
322318
})
323319
It("create with unmet permissions API service", func() {
324320

325-
defer cleaner.NotifyTestComplete(true)
326-
327321
c := newKubeClient()
328322
crc := newCRClient()
329323

@@ -412,8 +406,6 @@ var _ = Describe("CSV", func() {
412406
})
413407
It("create with unmet requirements native API", func() {
414408

415-
defer cleaner.NotifyTestComplete(true)
416-
417409
c := newKubeClient()
418410
crc := newCRClient()
419411

@@ -465,8 +457,6 @@ var _ = Describe("CSV", func() {
465457
// TODO: same test but create serviceaccount instead
466458
It("create requirements met CRD", func() {
467459

468-
defer cleaner.NotifyTestComplete(true)
469-
470460
c := newKubeClient()
471461
crc := newCRClient()
472462

@@ -727,8 +717,6 @@ var _ = Describe("CSV", func() {
727717
})
728718
It("create requirements met API service", func() {
729719

730-
defer cleaner.NotifyTestComplete(true)
731-
732720
c := newKubeClient()
733721
crc := newCRClient()
734722

@@ -890,8 +878,6 @@ var _ = Describe("CSV", func() {
890878
})
891879
It("create with owned API service", func() {
892880

893-
defer cleaner.NotifyTestComplete(true)
894-
895881
c := newKubeClient()
896882
crc := newCRClient()
897883

@@ -1081,8 +1067,6 @@ var _ = Describe("CSV", func() {
10811067
})
10821068
It("update with owned API service", func() {
10831069

1084-
defer cleaner.NotifyTestComplete(true)
1085-
10861070
c := newKubeClient()
10871071
crc := newCRClient()
10881072

@@ -1284,8 +1268,6 @@ var _ = Describe("CSV", func() {
12841268
})
12851269
It("create same CSV with owned API service multi namespace", func() {
12861270

1287-
defer cleaner.NotifyTestComplete(true)
1288-
12891271
c := newKubeClient()
12901272
crc := newCRClient()
12911273

@@ -1489,8 +1471,6 @@ var _ = Describe("CSV", func() {
14891471
})
14901472
It("orphaned API service clean up", func() {
14911473

1492-
defer cleaner.NotifyTestComplete(true)
1493-
14941474
c := newKubeClient()
14951475

14961476
mockGroup := fmt.Sprintf("hats.%s.redhat.com", genName(""))
@@ -1556,8 +1536,6 @@ var _ = Describe("CSV", func() {
15561536
})
15571537
It("update same deployment name", func() {
15581538

1559-
defer cleaner.NotifyTestComplete(true)
1560-
15611539
c := newKubeClient()
15621540
crc := newCRClient()
15631541

@@ -1740,8 +1718,6 @@ var _ = Describe("CSV", func() {
17401718
})
17411719
It("update different deployment name", func() {
17421720

1743-
defer cleaner.NotifyTestComplete(true)
1744-
17451721
c := newKubeClient()
17461722
crc := newCRClient()
17471723

@@ -1922,8 +1898,6 @@ var _ = Describe("CSV", func() {
19221898
})
19231899
It("update multiple intermediates", func() {
19241900

1925-
defer cleaner.NotifyTestComplete(true)
1926-
19271901
c := newKubeClient()
19281902
crc := newCRClient()
19291903

@@ -2110,8 +2084,6 @@ var _ = Describe("CSV", func() {
21102084
})
21112085
It("update in place", func() {
21122086

2113-
defer cleaner.NotifyTestComplete(true)
2114-
21152087
c := newKubeClient()
21162088
crc := newCRClient()
21172089

@@ -2264,8 +2236,6 @@ var _ = Describe("CSV", func() {
22642236
})
22652237
It("update multiple version CRD", func() {
22662238

2267-
defer cleaner.NotifyTestComplete(true)
2268-
22692239
c := newKubeClient()
22702240
crc := newCRClient()
22712241

@@ -2545,8 +2515,6 @@ var _ = Describe("CSV", func() {
25452515
})
25462516
It("update modify deployment name", func() {
25472517

2548-
defer cleaner.NotifyTestComplete(true)
2549-
25502518
c := newKubeClient()
25512519
crc := newCRClient()
25522520

@@ -2697,7 +2665,6 @@ var _ = Describe("CSV", func() {
26972665
})
26982666

26992667
It("emits CSV requirement events", func() {
2700-
defer cleaner.NotifyTestComplete(true)
27012668

27022669
c := ctx.Ctx().KubeClient()
27032670
crc := ctx.Ctx().OperatorClient()
@@ -2785,8 +2752,6 @@ var _ = Describe("CSV", func() {
27852752
// TODO: test behavior when replaces field doesn't point to existing CSV
27862753
It("status invalid CSV", func() {
27872754

2788-
defer cleaner.NotifyTestComplete(true)
2789-
27902755
c := newKubeClient()
27912756
crc := newCRClient()
27922757

@@ -2899,7 +2864,6 @@ var _ = Describe("CSV", func() {
28992864
})
29002865

29012866
It("api service resource migrated if adoptable", func() {
2902-
defer cleaner.NotifyTestComplete(true)
29032867

29042868
c := newKubeClient()
29052869
crc := newCRClient()
@@ -2983,7 +2947,6 @@ var _ = Describe("CSV", func() {
29832947
})
29842948

29852949
It("API service resource not migrated if not adoptable", func() {
2986-
defer cleaner.NotifyTestComplete(true)
29872950

29882951
c := newKubeClient()
29892952
crc := newCRClient()
@@ -3070,7 +3033,6 @@ var _ = Describe("CSV", func() {
30703033
})
30713034

30723035
It("multiple API services on a single pod", func() {
3073-
defer cleaner.NotifyTestComplete(true)
30743036

30753037
c := newKubeClient()
30763038
crc := newCRClient()

test/e2e/ctx/ctx.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ func setDerivedFields(ctx *TestContext) error {
115115

116116
ctx.scheme = runtime.NewScheme()
117117
localSchemeBuilder := runtime.NewSchemeBuilder(
118+
apiextensionsv1.AddToScheme,
118119
kscheme.AddToScheme,
119120
operatorsv1alpha1.AddToScheme,
120121
operatorsv1.AddToScheme,

test/e2e/dynamic_resource_e2e_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ var _ = Describe("Subscriptions create required objects from Catalogs", func() {
3636
})
3737

3838
AfterEach(func() {
39-
cleaner.NotifyTestComplete(true)
39+
TearDown(testNamespace)
4040
})
4141

4242
Context("Given a Namespace", func() {

test/e2e/e2e_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,6 @@ var _ = BeforeSuite(func() {
6969
testNamespace = *namespace
7070
operatorNamespace = *olmNamespace
7171
communityOperatorsImage = *communityOperators
72-
73-
cleaner = newNamespaceCleaner(testNamespace)
74-
7572
deprovision = ctx.MustProvision(ctx.Ctx())
7673
ctx.MustInstall(ctx.Ctx())
7774

test/e2e/gc_e2e_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var _ = Describe("Garbage collection for dependent resources", func() {
3535
})
3636

3737
AfterEach(func() {
38-
cleaner.NotifyTestComplete(true)
38+
TearDown(testNamespace)
3939
})
4040

4141
Context("Given a ClusterRole owned by a CustomResourceDefinition", func() {

0 commit comments

Comments
 (0)