@@ -28,7 +28,7 @@ import (
2828 "sigs.k8s.io/controller-runtime/pkg/client"
2929)
3030
31- var _ = PDescribe ("Weave GitOps Profiles API" , func () {
31+ var _ = Describe ("Weave GitOps Profiles API" , func () {
3232 var (
3333 namespace = "test-namespace"
3434 clusterName string
@@ -58,12 +58,9 @@ var _ = PDescribe("Weave GitOps Profiles API", func() {
5858 })
5959
6060 AfterEach (func () {
61- session := runCommandAndReturnSessionOutput (fmt .Sprintf ("kubectl -n %s delete kustomizations --all" , namespace ))
62- Eventually (session , "20s" , "1s" ).Should (gexec .Exit (0 ))
63- session = runCommandAndReturnSessionOutput (fmt .Sprintf ("kubectl -n %s delete gitrepositories --all" , namespace ))
64- Eventually (session , "20s" , "1s" ).Should (gexec .Exit (0 ))
65- deleteWorkload (profileName , namespace )
61+ cleanupFinalizers (clusterName , namespace )
6662 deleteRepo (tip .appRepoName , gitproviders .GitProviderGitHub , githubOrg )
63+ deleteNamespace (namespace )
6764 })
6865
6966 It ("gets deployed and is accessible via the service" , func () {
@@ -154,6 +151,19 @@ Namespace: %s`, clusterName, namespace)))
154151 })
155152})
156153
154+ func cleanupFinalizers (clusterName , namespace string ) {
155+ session := runCommandAndReturnSessionOutput (fmt .Sprintf ("%s flux suspend kustomization -n %s %s-system" , gitopsBinaryPath , namespace , clusterName ))
156+ Eventually (session , "60s" , "1s" ).Should (gexec .Exit (0 ))
157+ session = runCommandAndReturnSessionOutput (fmt .Sprintf ("kubectl -n %s delete helmreleases --all --wait" , namespace ))
158+ Eventually (session , "60s" , "1s" ).Should (gexec .Exit (0 ))
159+ session = runCommandAndReturnSessionOutput (fmt .Sprintf ("kubectl -n %s delete helmrepositories --all --wait" , namespace ))
160+ Eventually (session , "60s" , "1s" ).Should (gexec .Exit (0 ))
161+ session = runCommandAndReturnSessionOutput (fmt .Sprintf ("kubectl -n %s delete kustomizations --all --wait" , namespace ))
162+ Eventually (session , "60s" , "1s" ).Should (gexec .Exit (0 ))
163+ session = runCommandAndReturnSessionOutput (fmt .Sprintf ("kubectl -n %s delete gitrepositories --all --wait" , namespace ))
164+ Eventually (session , "60s" , "1s" ).Should (gexec .Exit (0 ))
165+ }
166+
157167func buildKubernetesClients () (* kubernetes.Clientset , client.Client ) {
158168 config , err := clientcmd .BuildConfigFromFlags ("" , filepath .Join (homedir .HomeDir (), ".kube" , "config" ))
159169 Expect (err ).NotTo (HaveOccurred ())
0 commit comments