Skip to content

Commit

Permalink
Delete left over resources
Browse files Browse the repository at this point in the history
Signed-off-by: Sridhar Gaddam <[email protected]>
  • Loading branch information
sridhargaddam committed Dec 27, 2024
1 parent e281e30 commit 93fbc74
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/e2e/ambient/ambient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,11 @@ spec:

By("Cleaning up the ZTunnel namespace")
Expect(cl.Delete(ctx, &corev1.Namespace{ObjectMeta: metav1.ObjectMeta{Name: ztunnelNamespace}})).To(Succeed(), "ZTunnel Namespace failed to be deleted")

By("Deleting any left-over Istio and IstioRevision resources")
Expect(forceDeleteIstioResources()).To(Succeed())
Success("Resources deleted")
Success("Cleanup done")
})
})

Expand Down Expand Up @@ -357,6 +362,27 @@ func getEnvVars(container corev1.Container) []corev1.EnvVar {
return container.Env
}

func forceDeleteIstioResources() error {
// This is a workaround to delete the Istio CRs that are left in the cluster
// This will be improved by splitting the tests into different Nodes with their independent setups and cleanups
err := k.ForceDelete("istio", istioName)
if err != nil && !strings.Contains(err.Error(), "not found") {
return fmt.Errorf("failed to delete %s CR: %w", "istio", err)
}

err = k.ForceDelete("istiorevision", "default")
if err != nil && !strings.Contains(err.Error(), "not found") {
return fmt.Errorf("failed to delete %s CR: %w", "istiorevision", err)
}

err = k.Delete("istiocni", istioCniName)
if err != nil && !strings.Contains(err.Error(), "not found") {
return fmt.Errorf("failed to delete %s CR: %w", "istiocni", err)
}

return nil
}

func checkPodConnectivity(podName, srcNamespace, destNamespace string) {
command := fmt.Sprintf(`curl -o /dev/null -s -w "%%{http_code}\n" httpbin.%s.svc.cluster.local:8000/get`, destNamespace)
response, err := k.WithNamespace(srcNamespace).Exec(podName, srcNamespace, command)
Expand Down

0 comments on commit 93fbc74

Please sign in to comment.