Skip to content

Commit

Permalink
Improve test cleanup and isolation (vmware-tanzu#19)
Browse files Browse the repository at this point in the history
Make sure that backup and restore has unique name for each test,
and that all backups are removed after tests.

Signed-off-by: Bartosz Rybacki <brybacki@redhat.com>
  • Loading branch information
brybacki authored Nov 5, 2021
1 parent a7c6378 commit fee3c6b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions tests/resource_filtering_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ import (
"kubevirt.io/kubevirt-velero-plugin/pkg/util"
)

const (
backupName = "test-backup"
restoreName = "test-restore"
)

var newVMSpecDVTemplate = func(vmName, size string) *kvv1.VirtualMachine {
no := false
var zero int64 = 0
Expand Down Expand Up @@ -217,10 +212,15 @@ var _ = Describe("Resource includes", func() {
var client, _ = util.GetK8sClient()
var timeout context.Context
var cancelFunc context.CancelFunc
var backupName string
var restoreName string
var r = framework.NewKubernetesReporter()

BeforeEach(func() {
timeout, cancelFunc = context.WithTimeout(context.Background(), 5*time.Minute)
t := time.Now().UnixNano()
backupName = fmt.Sprintf("test-backup-%d", t)
restoreName = fmt.Sprintf("test-restore-%d", t)
})

AfterEach(func() {
Expand Down Expand Up @@ -1735,13 +1735,18 @@ var _ = Describe("Resource excludes", func() {
var timeout context.Context
var cancelFunc context.CancelFunc
var namespace *v1.Namespace
var backupName string
var restoreName string
var r = framework.NewKubernetesReporter()

BeforeEach(func() {
var err error
timeout, cancelFunc = context.WithTimeout(context.Background(), 5*time.Minute)
namespace, err = CreateNamespace(client)
Expect(err).ToNot(HaveOccurred())
t := time.Now().UnixNano()
backupName = fmt.Sprintf("test-backup-%d", t)
restoreName = fmt.Sprintf("test-restore-%d", t)
})

AfterEach(func() {
Expand Down

0 comments on commit fee3c6b

Please sign in to comment.