Skip to content

Commit

Permalink
Delete persistent storage at end of tests
Browse files Browse the repository at this point in the history
Signed-off-by: Lorenzo Manacorda <lorenzo@kinvolk.io>
  • Loading branch information
Lorenzo Manacorda committed Mar 6, 2018
1 parent a923e0a commit a2142bf
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/e2e/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
utils "github.com/kinvolk/habitat-operator/test/e2e/framework"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
)

const (
Expand Down Expand Up @@ -206,6 +207,24 @@ func TestHabitatPersistence(t *testing.T) {
t.Fatal(err)
}

// Delete all PVCs at the end of the test.
// For dynamically provisioned PVs (as is the case on minikube), this will
// also delete the PVs.
defer (func(name string) {
ls := labels.SelectorFromSet(labels.Set(map[string]string{
habv1beta1.HabitatNameLabel: name,
}))

lo := metav1.ListOptions{
LabelSelector: ls.String(),
}

err := framework.KubeClient.CoreV1().PersistentVolumeClaims(utils.TestNs).DeleteCollection(&metav1.DeleteOptions{}, lo)
if err != nil {
t.Fatal(err)
}
})(persisted.Name)

if err := framework.WaitForResources(habv1beta1.HabitatLabel, persisted.Name, 1); err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit a2142bf

Please sign in to comment.