diff --git a/test/e2e/util/csi/common.go b/test/e2e/util/csi/common.go index 51fb5bc2c..677de4127 100644 --- a/test/e2e/util/csi/common.go +++ b/test/e2e/util/csi/common.go @@ -63,6 +63,7 @@ func GetCsiSnapshotHandle(client TestClient, backupName string) ([]string, error if err1 != nil { return nil, err } + var snapshotHandleList []string for _, i := range vscList.Items { if i.Status == nil { @@ -84,11 +85,9 @@ func GetCsiSnapshotHandle(client TestClient, backupName string) ([]string, error snapshotHandleList = append(snapshotHandleList, tmp[len(tmp)-1]) } } - if err != nil { - return nil, err - } + if len(snapshotHandleList) == 0 { - return snapshotHandleList, errors.New(fmt.Sprintf("No VolumeSnapshotContent from backup %s", backupName)) + fmt.Printf("No VolumeSnapshotContent from backup %s", backupName) } return snapshotHandleList, nil } @@ -132,10 +131,12 @@ func GetVolumeSnapshotContentNameByPod(client TestClient, podName, namespace, ba func CheckVolumeSnapshotCR(client TestClient, backupName string, expectedCount int) ([]string, error) { var err error var snapshotContentNameList []string - if snapshotContentNameList, err = GetCsiSnapshotHandle(client, backupName); err != nil || - len(snapshotContentNameList) != expectedCount { + if snapshotContentNameList, err = GetCsiSnapshotHandle(client, backupName); err != nil { return nil, errors.Wrap(err, "Fail to get Azure CSI snapshot content") } + if len(snapshotContentNameList) != expectedCount { + return nil, errors.New(fmt.Sprintf("Snapshot count %d is not as expect %d", len(snapshotContentNameList), expectedCount)) + } fmt.Println(snapshotContentNameList) return snapshotContentNameList, nil } diff --git a/test/e2e/util/velero/velero_utils.go b/test/e2e/util/velero/velero_utils.go index 500f6cd17..abffafa75 100644 --- a/test/e2e/util/velero/velero_utils.go +++ b/test/e2e/util/velero/velero_utils.go @@ -1197,12 +1197,9 @@ func UpdateVeleroDeployment(ctx context.Context, veleroCfg VeleroConfig) ([]stri Args: []string{"get", "deploy", "-n", veleroCfg.VeleroNamespace, "-ojson"}, } cmds = append(cmds, cmd) - var args string - if veleroCfg.CloudProvider == "vsphere" { - args = fmt.Sprintf("s#\\\"image\\\"\\: \\\"velero\\/velero\\:v[0-9]*.[0-9]*.[0-9]\\\"#\\\"image\\\"\\: \\\"harbor-repo.vmware.com\\/velero_ci\\/velero\\:%s\\\"#g", veleroCfg.VeleroVersion) - } else { - args = fmt.Sprintf("s#\\\"image\\\"\\: \\\"velero\\/velero\\:v[0-9]*.[0-9]*.[0-9]\\\"#\\\"image\\\"\\: \\\"gcr.io\\/velero-gcp\\/nightly\\/velero\\:%s\\\"#g", veleroCfg.VeleroVersion) - } + + args := fmt.Sprintf("s#\\\"image\\\"\\: \\\"velero\\/velero\\:v[0-9]*.[0-9]*.[0-9]\\\"#\\\"image\\\"\\: \\\"gcr.io\\/velero-gcp\\/nightly\\/velero\\:%s\\\"#g", veleroCfg.VeleroVersion) + cmd = &common.OsCommandLine{ Cmd: "sed", Args: []string{args}, @@ -1250,12 +1247,9 @@ func UpdateNodeAgent(ctx context.Context, veleroCfg VeleroConfig, dsjson string) Args: []string{dsjson}, } cmds = append(cmds, cmd) - var args string - if veleroCfg.CloudProvider == "vsphere" { - args = fmt.Sprintf("s#\\\"image\\\"\\: \\\"velero\\/velero\\:v[0-9]*.[0-9]*.[0-9]\\\"#\\\"image\\\"\\: \\\"harbor-repo.vmware.com\\/velero_ci\\/velero\\:%s\\\"#g", veleroCfg.VeleroVersion) - } else { - args = fmt.Sprintf("s#\\\"image\\\"\\: \\\"velero\\/velero\\:v[0-9]*.[0-9]*.[0-9]\\\"#\\\"image\\\"\\: \\\"gcr.io\\/velero-gcp\\/nightly\\/velero\\:%s\\\"#g", veleroCfg.VeleroVersion) - } + + args := fmt.Sprintf("s#\\\"image\\\"\\: \\\"velero\\/velero\\:v[0-9]*.[0-9]*.[0-9]\\\"#\\\"image\\\"\\: \\\"gcr.io\\/velero-gcp\\/nightly\\/velero\\:%s\\\"#g", veleroCfg.VeleroVersion) + cmd = &common.OsCommandLine{ Cmd: "sed", Args: []string{args},