Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Remove velero pkg generated #1492

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/e2e/backup_restore_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func runBackup(brCase BackupRestoreCase, backupName string) bool {
// wait for backup to not be running
gomega.Eventually(lib.IsBackupDone(dpaCR.Client, namespace, backupName), brCase.BackupTimeout, time.Second*10).Should(gomega.BeTrue())
// TODO only log on fail?
describeBackup := lib.DescribeBackup(veleroClientForSuiteRun, dpaCR.Client, namespace, backupName)
describeBackup := lib.DescribeBackup(dpaCR.Client, namespace, backupName)
ginkgo.GinkgoWriter.Println(describeBackup)

backupLogs := lib.BackupLogs(kubernetesClientForSuiteRun, dpaCR.Client, namespace, backupName)
Expand Down Expand Up @@ -204,7 +204,7 @@ func runRestore(brCase BackupRestoreCase, backupName, restoreName string, nsRequ
gomega.Expect(err).ToNot(gomega.HaveOccurred())
gomega.Eventually(lib.IsRestoreDone(dpaCR.Client, namespace, restoreName), time.Minute*60, time.Second*10).Should(gomega.BeTrue())
// TODO only log on fail?
describeRestore := lib.DescribeRestore(veleroClientForSuiteRun, dpaCR.Client, namespace, restoreName)
describeRestore := lib.DescribeRestore(dpaCR.Client, namespace, restoreName)
ginkgo.GinkgoWriter.Println(describeRestore)

restoreLogs := lib.RestoreLogs(kubernetesClientForSuiteRun, dpaCR.Client, namespace, restoreName)
Expand Down
7 changes: 2 additions & 5 deletions tests/e2e/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import (
"github.com/onsi/gomega"
openshiftappsv1 "github.com/openshift/api/apps/v1"
openshiftbuildv1 "github.com/openshift/api/build/v1"
openshiftroutev1 "github.com/openshift/api/route/v1"
openshiftsecurityv1 "github.com/openshift/api/security/v1"
openshifttemplatev1 "github.com/openshift/api/template/v1"
operatorsv1 "github.com/operator-framework/api/pkg/operators/v1"
operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1"
velerov1 "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
veleroclientset "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/client-go/dynamic"
Expand All @@ -38,7 +38,6 @@ var (

kubernetesClientForSuiteRun *kubernetes.Clientset
runTimeClientForSuiteRun client.Client
veleroClientForSuiteRun veleroclientset.Interface
dynamicClientForSuiteRun dynamic.Interface

dpaCR *lib.DpaCustomResource
Expand Down Expand Up @@ -126,14 +125,12 @@ func TestOADPE2E(t *testing.T) {
openshiftbuildv1.AddToScheme(runTimeClientForSuiteRun.Scheme())
openshiftsecurityv1.AddToScheme(runTimeClientForSuiteRun.Scheme())
openshifttemplatev1.AddToScheme(runTimeClientForSuiteRun.Scheme())
openshiftroutev1.AddToScheme(runTimeClientForSuiteRun.Scheme())
corev1.AddToScheme(runTimeClientForSuiteRun.Scheme())
volumesnapshotv1.AddToScheme(runTimeClientForSuiteRun.Scheme())
operatorsv1alpha1.AddToScheme(runTimeClientForSuiteRun.Scheme())
operatorsv1.AddToScheme(runTimeClientForSuiteRun.Scheme())

veleroClientForSuiteRun, err = veleroclientset.NewForConfig(kubeConfig)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

dynamicClientForSuiteRun, err = dynamic.NewForConfig(kubeConfig)
gomega.Expect(err).NotTo(gomega.HaveOccurred())

Expand Down
9 changes: 5 additions & 4 deletions tests/e2e/lib/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
pkgbackup "github.com/vmware-tanzu/velero/pkg/backup"
"github.com/vmware-tanzu/velero/pkg/cmd/util/downloadrequest"
"github.com/vmware-tanzu/velero/pkg/cmd/util/output"
veleroclientset "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned"
"github.com/vmware-tanzu/velero/pkg/label"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
Expand Down Expand Up @@ -90,7 +89,7 @@ func IsBackupCompletedSuccessfully(c *kubernetes.Clientset, ocClient client.Clie
}

// https://github.com/vmware-tanzu/velero/blob/11bfe82342c9f54c63f40d3e97313ce763b446f2/pkg/cmd/cli/backup/describe.go#L77-L111
func DescribeBackup(veleroClient veleroclientset.Interface, ocClient client.Client, namespace string, name string) (backupDescription string) {
func DescribeBackup(ocClient client.Client, namespace string, name string) (backupDescription string) {
backup, err := GetBackup(ocClient, namespace, name)
if err != nil {
return "could not get provided backup: " + err.Error()
Expand All @@ -100,13 +99,15 @@ func DescribeBackup(veleroClient veleroclientset.Interface, ocClient client.Clie
caCertFile := ""

deleteRequestListOptions := pkgbackup.NewDeleteBackupRequestListOptions(backup.Name, string(backup.UID))
deleteRequestList, err := veleroClient.VeleroV1().DeleteBackupRequests(backup.Namespace).List(context.Background(), deleteRequestListOptions)
deleteRequestList := &velero.DeleteBackupRequestList{}
err = ocClient.List(context.Background(), deleteRequestList, client.InNamespace(backup.Namespace), &client.ListOptions{Raw: &deleteRequestListOptions})
if err != nil {
log.Printf("error getting DeleteBackupRequests for backup %s: %v\n", backup.Name, err)
}

opts := label.NewListOptionsForBackup(backup.Name)
podVolumeBackupList, err := veleroClient.VeleroV1().PodVolumeBackups(backup.Namespace).List(context.Background(), opts)
podVolumeBackupList := &velero.PodVolumeBackupList{}
err = ocClient.List(context.Background(), podVolumeBackupList, client.InNamespace(backup.Namespace), &client.ListOptions{Raw: &opts})
if err != nil {
log.Printf("error getting PodVolumeBackups for backup %s: %v\n", backup.Name, err)
}
Expand Down
1 change: 0 additions & 1 deletion tests/e2e/lib/ocp_common_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
func GetRouteEndpointURL(ocClient client.Client, namespace, routeName string) (string, error) {
log.Println("Verifying if the service is accessible via route")
route := &routev1.Route{}
routev1.AddToScheme(ocClient.Scheme())
err := ocClient.Get(context.Background(), client.ObjectKey{Namespace: namespace, Name: routeName}, route)
if err != nil {
if apierrors.IsNotFound(err) {
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/lib/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
velero "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
"github.com/vmware-tanzu/velero/pkg/cmd/util/downloadrequest"
"github.com/vmware-tanzu/velero/pkg/cmd/util/output"
veleroclientset "github.com/vmware-tanzu/velero/pkg/generated/clientset/versioned"
"github.com/vmware-tanzu/velero/pkg/label"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
Expand Down Expand Up @@ -87,7 +86,7 @@ func IsRestoreCompletedSuccessfully(c *kubernetes.Clientset, ocClient client.Cli
}

// https://github.com/vmware-tanzu/velero/blob/11bfe82342c9f54c63f40d3e97313ce763b446f2/pkg/cmd/cli/restore/describe.go#L72-L78
func DescribeRestore(veleroClient veleroclientset.Interface, ocClient client.Client, namespace string, name string) string {
func DescribeRestore(ocClient client.Client, namespace string, name string) string {
restore, err := GetRestore(ocClient, namespace, name)
if err != nil {
return "could not get provided backup: " + err.Error()
Expand All @@ -96,7 +95,8 @@ func DescribeRestore(veleroClient veleroclientset.Interface, ocClient client.Cli
insecureSkipTLSVerify := true
caCertFile := ""
opts := metav1.ListOptions{LabelSelector: fmt.Sprintf("%s=%s", velero.RestoreNameLabel, label.GetValidName(restore.Name))}
podvolumeRestoreList, err := veleroClient.VeleroV1().PodVolumeRestores(restore.Namespace).List(context.Background(), opts)
podvolumeRestoreList := &velero.PodVolumeRestoreList{}
err = ocClient.List(context.Background(), podvolumeRestoreList, client.InNamespace(restore.Namespace), &client.ListOptions{Raw: &opts})
if err != nil {
log.Printf("error getting PodVolumeRestores for restore %s: %v\n", restore.Name, err)
}
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 @@ -269,7 +269,7 @@ func runVmRestore(brCase VmBackupRestoreCase, backupName, restoreName string, ns
gomega.Expect(err).ToNot(gomega.HaveOccurred())
gomega.Eventually(lib.IsRestoreDone(dpaCR.Client, namespace, restoreName), time.Minute*60, time.Second*10).Should(gomega.BeTrue())
// TODO only log on fail?
describeRestore := lib.DescribeRestore(veleroClientForSuiteRun, dpaCR.Client, namespace, restoreName)
describeRestore := lib.DescribeRestore(dpaCR.Client, namespace, restoreName)
ginkgo.GinkgoWriter.Println(describeRestore)

restoreLogs := lib.RestoreLogs(kubernetesClientForSuiteRun, dpaCR.Client, namespace, restoreName)
Expand Down