Skip to content

Commit

Permalink
updates from comments
Browse files Browse the repository at this point in the history
Signed-off-by: Wesley Hayutin <[email protected]>
  • Loading branch information
weshayutin committed Sep 30, 2024
1 parent fc395fa commit 58dbb8c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tests/e2e/backup_restore_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func runApplicationBackupAndRestore(brCase ApplicationBackupRestoreCase, expecte
backupName, restoreName := prepareBackupAndRestore(brCase.BackupRestoreCase, updateLastInstallTime)

// Ensure that an existing backup repository is deleted
brerr := lib.DeleteBackupRepositoryByRegex(runTimeClientForSuiteRun, namespace)
brerr := lib.DeleteBackupRepositories(runTimeClientForSuiteRun, namespace)
gomega.Expect(brerr).ToNot(gomega.HaveOccurred())

// install app
Expand Down
15 changes: 11 additions & 4 deletions tests/e2e/lib/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ func GetBackupRepositoryList(c client.Client, namespace string) (*velero.BackupR
// if there is an error, just print, don't return the error
if err != nil {
log.Printf("error getting BackupRepository list: %v", err)
return nil, err
}
return backupRepositoryList, nil
}
Expand All @@ -172,20 +173,26 @@ func DeleteBackupRepository(c client.Client, namespace string, name string) erro
return nil
}

// DeleteBackupRepositoryByRegex deletes a BackupRepository instance that matches the given regex pattern.
func DeleteBackupRepositoryByRegex(c client.Client, namespace string) error {
// DeleteBackupRepositories deletes all BackupRepositories n.
func DeleteBackupRepositories(c client.Client, namespace string) error {
log.Printf("Checking if backuprepository's exist in %s", namespace)

backupRepos, err := GetBackupRepositoryList(c, namespace)
if err != nil {
return fmt.Errorf("failed to get BackupRepository list: %v", err)
}
// Get a list of the BackupRepositories and delete the one that matches the regex
if len(backupRepos.Items) == 0 {
log.Printf("No BackupRepositories found in namespace %s", namespace)
return nil
}

// Get a list of the BackupRepositories and delete all of them.
for _, repo := range backupRepos.Items {
log.Printf("backuprepository name is %s", repo.Name)
err := DeleteBackupRepository(c, namespace, repo.Name)
if err != nil {
return fmt.Errorf("failed to delete BackupRepository %s: %v", repo.Name, err)
log.Printf("failed to delete BackupRepository %s: ", repo.Name)
return err
}
log.Printf("Successfully deleted BackupRepository: %s", repo.Name)
}
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/virt_backup_restore_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ var _ = ginkgo.Describe("VM backup and restore tests", ginkgo.Ordered, func() {
gomega.Expect(err).To(gomega.BeNil())
err = v.CreateWaitForFirstConsumerStorageClass("test-sc-wffc")
gomega.Expect(err).To(gomega.BeNil())
lib.DeleteBackupRepositoryByRegex(runTimeClientForSuiteRun, namespace)
err = lib.DeleteBackupRepositories(runTimeClientForSuiteRun, namespace)
gomega.Expect(err).To(gomega.BeNil())
})

Expand Down

0 comments on commit 58dbb8c

Please sign in to comment.