func teardownMayastor() {
	// The correct sequence for a reusable  cluster is
	// Delete all pods in the default namespace
	// Delete all pvcs
	// Then uninstall mayastor
	podsDeleted, podCount := common.DeleteAllPods()
	pvcsDeleted, pvcsFound := common.DeleteAllVolumeResources()

	logf.Log.Info("Cleanup done, Uninstalling mayastor")
	// Deletes can stall indefinitely, try to mitigate this
	// by running the deletes in different threads
	go deleteDeployYaml("csi-daemonset.yaml")
	time.Sleep(10 * time.Second)
	go deleteDeployYaml("mayastor-daemonset.yaml")
	time.Sleep(5 * time.Second)
	go deleteDeployYaml("moac-deployment.yaml")
	time.Sleep(5 * time.Second)
	go deleteDeployYaml("nats-deployment.yaml")
	time.Sleep(5 * time.Second)

	{
		iters := 18
		logf.Log.Info("Waiting for Mayastor pods to be deleted", "timeout seconds", iters*10)
		numMayastorPods := common.MayastorUndeletedPodCount()
		for attempts := 0; attempts < iters && numMayastorPods != 0; attempts++ {
			time.Sleep(10 * time.Second)
			numMayastorPods = common.MayastorUndeletedPodCount()
			logf.Log.Info("", "numMayastorPods", numMayastorPods)
		}
	}

	// The focus is on trying to make the cluster reusable, so we try to delete everything.
	// TODO: When we start using a cluster for a single test run  move these set of deletes to after all checks.
	deleteDeployYaml("mayastorpoolcrd.yaml")
	deleteDeployYaml("moac-rbac.yaml")
	deleteDeployYaml("storage-class.yaml")
	deleteCRD("mayastornodes.openebs.io")
	deleteCRD("mayastorvolumes.openebs.io")
	// Attempt to forcefully delete pods
	// TODO replace this function call when a single cluster is used for a single test run, with a check.
	forceDeleted := common.ForceDeleteMayastorPods()
	deleteDeployYaml("namespace.yaml")
	Expect(forceDeleted).To(BeFalse())

	Expect(podsDeleted).To(BeTrue())
	Expect(podCount).To(BeZero())
	Expect(pvcsFound).To(BeFalse())
	Expect(pvcsDeleted).To(BeTrue())
	Expect(common.MayastorUndeletedPodCount()).To(Equal(0))
}
// Teardown mayastor on the cluster under test.
// We deliberately call out to kubectl, rather than constructing the client-go
// objects, so that we can verfiy the local deploy yamls are correct.
Teardown mayastor on the cluster under test.
We deliberately call out to kubectl, rather than constructing the client-go
objects, so that we can verfiy the local deploy yamls are correct.
// Teardown mayastor on the cluster under test . // We deliberately call out to kubectl rather than constructing the client - go // objects so that we can verfiy the local deploy yamls are correct .
func teardownMayastor() {
	podsDeleted, podCount := common.DeleteAllPods()
	pvcsDeleted, pvcsFound := common.DeleteAllVolumeResources()
	logf.Log.Info("Cleanup done, Uninstalling mayastor")
	go deleteDeployYaml("csi-daemonset.yaml")
	time.Sleep(10 * time.Second)
	go deleteDeployYaml("mayastor-daemonset.yaml")
	time.Sleep(5 * time.Second)
	go deleteDeployYaml("moac-deployment.yaml")
	time.Sleep(5 * time.Second)
	go deleteDeployYaml("nats-deployment.yaml")
	time.Sleep(5 * time.Second)
	{
		iters := 18
		logf.Log.Info("Waiting for Mayastor pods to be deleted", "timeout seconds", iters*10)
		numMayastorPods := common.MayastorUndeletedPodCount()
		for attempts := 0; attempts < iters && numMayastorPods != 0; attempts++ {
			time.Sleep(10 * time.Second)
			numMayastorPods = common.MayastorUndeletedPodCount()
			logf.Log.Info("", "numMayastorPods", numMayastorPods)
		}
	}
	deleteDeployYaml("mayastorpoolcrd.yaml")
	deleteDeployYaml("moac-rbac.yaml")
	deleteDeployYaml("storage-class.yaml")
	deleteCRD("mayastornodes.openebs.io")
	deleteCRD("mayastorvolumes.openebs.io")
	forceDeleted := common.ForceDeleteMayastorPods()
	deleteDeployYaml("namespace.yaml")
	Expect(forceDeleted).To(BeFalse())
	Expect(podsDeleted).To(BeTrue())
	Expect(podCount).To(BeZero())
	Expect(pvcsFound).To(BeFalse())
	Expect(pvcsDeleted).To(BeTrue())
	Expect(common.MayastorUndeletedPodCount()).To(Equal(0))
}
func teardownMayastor ( ) { podsDeleted , podCount := common . DeleteAllPods ( ) pvcsDeleted , pvcsFound := common . DeleteAllVolumeResources ( ) logf . Log . Info ( " " ) go deleteDeployYaml ( " " ) time . Sleep ( 10 * time . Second ) go deleteDeployYaml ( " " ) time . Sleep ( 5 * time . Second ) go deleteDeployYaml ( " " ) time . Sleep ( 5 * time . Second ) go deleteDeployYaml ( " " ) time . Sleep ( 5 * time . Second ) { iters := 18 logf . Log . Info ( " " , " " , iters * 10 ) numMayastorPods := common . MayastorUndeletedPodCount ( ) for attempts := 0 ; attempts < iters && numMayastorPods != 0 ; attempts ++ { time . Sleep ( 10 * time . Second ) numMayastorPods = common . MayastorUndeletedPodCount ( ) logf . Log . Info ( " " , " " , numMayastorPods ) } } deleteDeployYaml ( " " ) deleteDeployYaml ( " " ) deleteDeployYaml ( " " ) deleteCRD ( " " ) deleteCRD ( " " ) forceDeleted := common . ForceDeleteMayastorPods ( ) deleteDeployYaml ( " " ) Expect ( forceDeleted ) . To ( BeFalse ( ) ) Expect ( podsDeleted ) . To ( BeTrue ( ) ) Expect ( podCount ) . To ( BeZero ( ) ) Expect ( pvcsFound ) . To ( BeFalse ( ) ) Expect ( pvcsDeleted ) . To ( BeTrue ( ) ) Expect ( common . MayastorUndeletedPodCount ( ) ) . To ( Equal ( 0 ) ) }
Teardown mayastor on the cluster under test.
Teardown mayastor on the cluster under test .
// The correct sequence for a reusable  cluster is // Delete all pods in the default namespace // Delete all pvcs // Then uninstall mayastor // Deletes can stall indefinitely, try to mitigate this // by running the deletes in different threads // The focus is on trying to make the cluster reusable, so we try to delete everything. // TODO: When we start using a cluster for a single test run  move these set of deletes to after all checks. // Attempt to forcefully delete pods // TODO replace this function call when a single cluster is used for a single test run, with a check.