Skip to content
Closed
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
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/aws/aws-sdk-go v1.28.2
github.com/go-logr/logr v0.4.0
github.com/google/uuid v1.1.2
github.com/kubernetes-csi/external-snapshotter/client/v4 v4.2.0
github.com/onsi/ginkgo v1.16.4
github.com/onsi/ginkgo/v2 v2.1.1
github.com/onsi/gomega v1.17.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,8 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kubernetes-csi/external-snapshotter/client/v4 v4.0.0/go.mod h1:YBCo4DoEeDndqvAn6eeu0vWM7QdXmHEeI9cFWplmBys=
github.com/kubernetes-csi/external-snapshotter/client/v4 v4.2.0 h1:nHHjmvjitIiyPlUHk/ofpgvBcNcawJLtf4PYHORLjAA=
github.com/kubernetes-csi/external-snapshotter/client/v4 v4.2.0/go.mod h1:YBCo4DoEeDndqvAn6eeu0vWM7QdXmHEeI9cFWplmBys=
github.com/kylelemons/godebug v0.0.0-20170820004349-d65d576e9348/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
Expand Down
5 changes: 5 additions & 0 deletions tests/e2e/backup_restore_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ var _ = Describe("AWS backup restore tests", func() {
Expect(succeeded).To(Equal(true))
log.Printf("Backup for case %s succeeded", brCase.Name)

if brCase.BackupRestoreType == CSI {
// wait for volume snapshot to be Ready
Eventually(IsVolumeSnapshotsReady(dpaCR.Client, backupName), timeoutMultiplier*time.Minute*4, time.Second*10).Should(BeTrue())
}

// uninstall app
log.Printf("Uninstalling app for case %s", brCase.Name)
err = UninstallApplication(dpaCR.Client, brCase.ApplicationTemplate)
Expand Down
53 changes: 53 additions & 0 deletions tests/e2e/lib/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import (
"os"
"os/exec"

volumesnapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v4/apis/volumesnapshot/v1"
"github.com/onsi/ginkgo/v2"
ocpappsv1 "github.com/openshift/api/apps/v1"
security "github.com/openshift/api/security/v1"
"github.com/vmware-tanzu/velero/pkg/label"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -109,6 +111,57 @@ func UninstallApplication(ocClient client.Client, file string) error {
// }
// }

func IsVolumeSnapshotsReady(ocClient client.Client, backupName string) wait.ConditionFunc {
return func() (bool, error) {
vList := &volumesnapshotv1.VolumeSnapshotList{}
// vListBeta := &volumesnapshotv1beta1.VolumeSnapshotList{}
err := ocClient.List(context.Background(), vList, &client.ListOptions{LabelSelector: label.NewSelectorForBackup(backupName)})
if err != nil {
// try beta version
// if runtime.IsNotRegisteredError(err) {
// // try v1beta1
// vList = nil // reset
// err = ocClient.List(context.Background(), vList, client.InNamespace(namespace))
// if err!= nil {
// if runtime.IsNotRegisteredError(err) {
// return false, nil
// }
// }
// }
return false, err
}
// if vList != nil {
if len(vList.Items) == 0 {
ginkgo.GinkgoWriter.Println("No VolumeSnapshots found")
return false, nil
}
for _, v := range vList.Items {
if v.Status.ReadyToUse == nil {
ginkgo.GinkgoWriter.Println("VolumeSnapshots Ready status not found for " + v.Name)
ginkgo.GinkgoWriter.Println(fmt.Sprintf("status: %v", v.Status))
return false, nil
}
if !*v.Status.ReadyToUse {
ginkgo.GinkgoWriter.Println("VolumeSnapshots Ready status is false " + v.Name)
return false, nil
}
}
// }
// } else {
// if len(vListBeta.Items) == 0 {
// return false, nil
// }
// for _, v := range vListBeta.Items {
// if v.Status.ReadyToUse == nil || !*v.Status.ReadyToUse {
// return false, nil
// }
// }
// }

return true, nil
}
}

func IsDCReady(ocClient client.Client, namespace, dcName string) wait.ConditionFunc {
return func() (bool, error) {
dc := ocpappsv1.DeploymentConfig{}
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/lib/dpa_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

utils "github.com/openshift/oadp-operator/tests/e2e/utils"

volumesnapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v4/apis/volumesnapshot/v1"
appsv1 "github.com/openshift/api/apps/v1"
security "github.com/openshift/api/security/v1"
oadpv1alpha1 "github.com/openshift/oadp-operator/api/v1alpha1"
Expand Down Expand Up @@ -174,6 +175,7 @@ func (v *DpaCustomResource) SetClient() error {
appsv1.AddToScheme(client.Scheme())
security.AddToScheme(client.Scheme())
operators.AddToScheme(client.Scheme())
volumesnapshotv1.AddToScheme(client.Scheme())

v.Client = client
return nil
Expand Down