Skip to content

Commit c13ddf0

Browse files
author
Daniel Vaseekaran
committed
Add Uninstall Contour CRDs
1 parent 3f99b3e commit c13ddf0

File tree

4 files changed

+57
-0
lines changed

4 files changed

+57
-0
lines changed

tests/e2e/const.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ func apiGroupKoperatorDependencies() map[string]string {
7575
"cert-manager": "cert-manager.io",
7676
"zookeeper": "zookeeper.pravega.io",
7777
"prometheus": "monitoring.coreos.com",
78+
"contour": "projectcontour.io",
7879
}
7980
}
8081

tests/e2e/test_uninstall.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,10 @@ func testUninstall() bool {
5757
ConfigPath: kubectlOptions.ConfigPath,
5858
Namespace: certManagerHelmDescriptor.Namespace,
5959
})
60+
requireUninstallingContour(k8s.KubectlOptions{
61+
ContextName: kubectlOptions.ContextName,
62+
ConfigPath: kubectlOptions.ConfigPath,
63+
Namespace: contourIngressControllerHelmDescriptor.Namespace,
64+
})
6065
})
6166
}

tests/e2e/types.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type dependencyCRDsType struct {
2424
zookeeper []string
2525
prometheus []string
2626
certManager []string
27+
contour []string
2728
}
2829

2930
func (c *dependencyCRDsType) Zookeeper() []string {
@@ -35,13 +36,20 @@ func (c *dependencyCRDsType) Prometheus() []string {
3536
func (c *dependencyCRDsType) CertManager() []string {
3637
return c.certManager
3738
}
39+
func (c *dependencyCRDsType) Contour() []string {
40+
return c.contour
41+
}
3842

3943
func (c *dependencyCRDsType) Initialize(kubectlOptions k8s.KubectlOptions) error {
4044
var err error
4145
c.certManager, err = listK8sResourceKinds(kubectlOptions, apiGroupKoperatorDependencies()["cert-manager"])
4246
if err != nil {
4347
return fmt.Errorf("initialize Cert-manager CRDs error: %w", err)
4448
}
49+
c.contour, err = listK8sResourceKinds(kubectlOptions, apiGroupKoperatorDependencies()["contour"])
50+
if err != nil {
51+
return fmt.Errorf("initialize Contour Ingress Controller CRDs error: %w", err)
52+
}
4553
c.prometheus, err = listK8sResourceKinds(kubectlOptions, apiGroupKoperatorDependencies()["prometheus"])
4654
if err != nil {
4755
return fmt.Errorf("initialize Prometheus CRDs error: %w", err)

tests/e2e/uninstall.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,49 @@ func requireRemoveCertManagerCRDs(kubectlOptions k8s.KubectlOptions) {
206206
}
207207
})
208208
}
209+
func requireUninstallingContour(kubectlOptions k8s.KubectlOptions) {
210+
When("Uninstalling zookeeper-operator", func() {
211+
requireUninstallingContourHelmChart(kubectlOptions)
212+
requireRemoveContourCRDs(kubectlOptions)
213+
requireRemoveNamespace(kubectlOptions, contourIngressControllerHelmDescriptor.Namespace)
214+
})
215+
}
216+
217+
// requireUninstallingCertManagerHelmChart uninstalls cert-manager helm chart
218+
// and checks the success of that operation.
219+
func requireUninstallingContourHelmChart(kubectlOptions k8s.KubectlOptions) {
220+
It("Uninstalling Project Contour Helm chart", func() {
221+
err := contourIngressControllerHelmDescriptor.uninstallHelmChart(kubectlOptions, true)
222+
Expect(err).NotTo(HaveOccurred())
223+
224+
By("Verifying Project Contour helm chart resources cleanup")
225+
226+
k8sResourceKinds, err := listK8sResourceKinds(kubectlOptions, "")
227+
Expect(err).ShouldNot(HaveOccurred())
228+
229+
contourAvailableResourceKinds := stringSlicesInstersect(dependencyCRDs.Contour(), k8sResourceKinds)
230+
contourAvailableResourceKinds = append(contourAvailableResourceKinds, basicK8sResourceKinds()...)
231+
232+
remainedResources, err := getK8sResources(kubectlOptions,
233+
contourAvailableResourceKinds,
234+
fmt.Sprintf(managedByHelmLabelTemplate, contourIngressControllerHelmDescriptor.ReleaseName),
235+
"",
236+
kubectlArgGoTemplateKindNameNamespace,
237+
"--all-namespaces")
238+
Expect(err).ShouldNot(HaveOccurred())
239+
240+
Expect(remainedResources).Should(BeEmpty())
241+
})
242+
}
243+
244+
func requireRemoveContourCRDs(kubectlOptions k8s.KubectlOptions) {
245+
It("Removing Contour Ingress Controller CRDs", func() {
246+
for _, crd := range dependencyCRDs.Contour() {
247+
err := deleteK8sResourceNoErrNotFound(kubectlOptions, defaultDeletionTimeout, crdKind, crd)
248+
Expect(err).ShouldNot(HaveOccurred())
249+
}
250+
})
251+
}
209252

210253
// requireRemoveNamespace deletes the indicated namespace object
211254
func requireRemoveNamespace(kubectlOptions k8s.KubectlOptions, namespace string) {

0 commit comments

Comments
 (0)