Skip to content
This repository has been archived by the owner on Oct 23, 2024. It is now read-only.

Commit

Permalink
tests: Cleanup ingress even if test fails
Browse files Browse the repository at this point in the history
Signed-off-by: Simão Reis <sreis@mesosphere.io>
  • Loading branch information
Simão Reis authored and sreis committed Jul 1, 2019
1 parent 9594ef2 commit f66aa08
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
13 changes: 9 additions & 4 deletions test/e2e/framework/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ func (f *Framework) DeleteEdgeLBPool(pool *models.V2Pool) {
defer fn()
err := f.EdgeLBManager.DeletePool(ctx, pool.Name)
Expect(err).NotTo(HaveOccurred(), "failed to delete edgelb pool %q", pool.Name)
// Wait for the EdgeLB API server to stop reporting the EdgeLB pool as existing.
err = retry.WithTimeout(DefaultRetryTimeout, DefaultRetryInterval, func() (b bool, e error) {
ctx, fn := context.WithTimeout(context.Background(), DefaultEdgeLBOperationTimeout)
defer fn()
f.WaitEdgeLBPoolDelete(pool)
}

// WaitEdgeLBPoolDelete waits for the EdgeLB API server to stop reporting the
// EdgeLB pool as existing.
func (f *Framework) WaitEdgeLBPoolDelete(pool *models.V2Pool) {
err := retry.WithTimeout(DefaultRetryTimeout, DefaultRetryInterval, func() (b bool, e error) {
ctx, cancel := context.WithTimeout(context.Background(), DefaultEdgeLBOperationTimeout)
defer cancel()
_, err := f.EdgeLBManager.GetPool(ctx, pool.Name)
return dklberrors.IsNotFound(err), nil
})
Expand Down
10 changes: 6 additions & 4 deletions test/e2e/ingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1189,6 +1189,12 @@ hBHIkVstxMO9c4ZCA60QbQ==
}
})
Expect(err).NotTo(HaveOccurred(), "failed to create ingress")
// Manually delete the Ingress resource regardless of test result.
defer func() {
err = f.KubeClient.ExtensionsV1beta1().Ingresses(ingress.Namespace).Delete(ingress.Name, metav1.NewDeleteOptions(0))
Expect(err).NotTo(HaveOccurred(), "failed to delete ingress %q", kubernetes.Key(ingress))
f.WaitEdgeLBPoolDelete(pool)
}()

// Wait for EdgeLB to acknowledge the EdgeLB pool's creation.
err = retry.WithTimeout(framework.DefaultRetryTimeout, framework.DefaultRetryInterval, func() (bool, error) {
Expand Down Expand Up @@ -1246,10 +1252,6 @@ hBHIkVstxMO9c4ZCA60QbQ==
return r.StatusCode == 200, nil
})
Expect(err).NotTo(HaveOccurred(), "timed out while waiting for the ingress to be reachable")

// Manually delete the Ingress resource now so that the target EdgeLB pool isn't left dangling after namespace deletion.
err = f.KubeClient.ExtensionsV1beta1().Ingresses(ingress.Namespace).Delete(ingress.Name, metav1.NewDeleteOptions(0))
Expect(err).NotTo(HaveOccurred(), "failed to delete ingress %q", kubernetes.Key(ingress))
})
})
})
Expand Down

0 comments on commit f66aa08

Please sign in to comment.