diff --git a/tests/e2e/backup_restore_suite_test.go b/tests/e2e/backup_restore_suite_test.go index ced57de019..bd0c4b780f 100644 --- a/tests/e2e/backup_restore_suite_test.go +++ b/tests/e2e/backup_restore_suite_test.go @@ -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) @@ -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) diff --git a/tests/e2e/e2e_suite_test.go b/tests/e2e/e2e_suite_test.go index eb584fab9d..cdd2203ff3 100644 --- a/tests/e2e/e2e_suite_test.go +++ b/tests/e2e/e2e_suite_test.go @@ -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" @@ -38,7 +38,6 @@ var ( kubernetesClientForSuiteRun *kubernetes.Clientset runTimeClientForSuiteRun client.Client - veleroClientForSuiteRun veleroclientset.Interface dynamicClientForSuiteRun dynamic.Interface dpaCR *lib.DpaCustomResource @@ -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()) diff --git a/tests/e2e/lib/backup.go b/tests/e2e/lib/backup.go index 08cc460884..7885b621be 100755 --- a/tests/e2e/lib/backup.go +++ b/tests/e2e/lib/backup.go @@ -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" @@ -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() @@ -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) } diff --git a/tests/e2e/lib/ocp_common_helpers.go b/tests/e2e/lib/ocp_common_helpers.go index dae47ce26d..b9883cd0d9 100644 --- a/tests/e2e/lib/ocp_common_helpers.go +++ b/tests/e2e/lib/ocp_common_helpers.go @@ -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) { diff --git a/tests/e2e/lib/restore.go b/tests/e2e/lib/restore.go index 8ac584c21f..b3a80bcaf9 100755 --- a/tests/e2e/lib/restore.go +++ b/tests/e2e/lib/restore.go @@ -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" @@ -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() @@ -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) } diff --git a/tests/e2e/virt_backup_restore_suite_test.go b/tests/e2e/virt_backup_restore_suite_test.go index 6e15756db1..4735a39012 100644 --- a/tests/e2e/virt_backup_restore_suite_test.go +++ b/tests/e2e/virt_backup_restore_suite_test.go @@ -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)