Skip to content

Commit

Permalink
ci: fix the namespace in test
Browse files Browse the repository at this point in the history
fixed the namespace in the vsg
test

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
  • Loading branch information
Madhu-1 committed Sep 11, 2024
1 parent 97ef0f5 commit e93e1f5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion e2e/cephfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ var _ = Describe(cephfsType, func() {
framework.Failf("failed to create CephFS storageclass: %v", err)
}
scName := "csi-cephfs-sc"
base, err := newVolumeGroupSnapshotBase(f, scName, f.UniqueName, false, deployTimeout, 3)
base, err := newVolumeGroupSnapshotBase(f, f.UniqueName, scName, false, deployTimeout, 3)
if err != nil {
framework.Failf("failed to create volumeGroupSnapshot Base: %v", err)
}
Expand Down
5 changes: 3 additions & 2 deletions e2e/volumegroupsnapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func (c *cephFS) GetVolumeGroupSnapshotClass() (*groupsnapapi.VolumeGroupSnapsho
}

func (c *cephFS) ValidateResourcesForCreate(vgs *groupsnapapi.VolumeGroupSnapshot) error {
ctx := context.TODO()
metadataPool, err := getCephFSMetadataPoolName(c.framework, fileSystemName)
if err != nil {
return fmt.Errorf("failed getting cephFS metadata pool name: %w", err)
Expand All @@ -72,14 +73,14 @@ func (c *cephFS) ValidateResourcesForCreate(vgs *groupsnapapi.VolumeGroupSnapsho

// we are creating 1 snapshot for each source PVC, validate the snapshot count
for _, pvcSnap := range vgs.Status.PVCVolumeSnapshotRefList {
pvc, err := c.framework.ClientSet.CoreV1().PersistentVolumeClaims(vgs.Namespace).Get(context.TODO(),
pvc, err := c.framework.ClientSet.CoreV1().PersistentVolumeClaims(vgs.Namespace).Get(ctx,
pvcSnap.PersistentVolumeClaimRef.Name,
metav1.GetOptions{})
if err != nil {
return fmt.Errorf("failed to get PVC: %w", err)
}
pv := pvc.Spec.VolumeName
pvObj, err := c.framework.ClientSet.CoreV1().PersistentVolumes().Get(context.TODO(), pv, metav1.GetOptions{})
pvObj, err := c.framework.ClientSet.CoreV1().PersistentVolumes().Get(ctx, pv, metav1.GetOptions{})
if err != nil {
return fmt.Errorf("failed to get PV: %w", err)
}
Expand Down
23 changes: 17 additions & 6 deletions e2e/volumegroupsnapshot_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ func (v *volumeGroupSnapshotterBase) CreatePVCClones(vgs *groupsnapapi.VolumeGro
return nil, fmt.Errorf("failed to get PVC: %w", err)
}
pvcs[i] = pvc.DeepCopy()

pvcs[i].Name = fmt.Sprintf("%s-clone-%d", pvc.Name, i)
snap := pvcSnap.VolumeSnapshotRef
apiGroup := snapapi.GroupName
Expand All @@ -178,8 +179,11 @@ func (v *volumeGroupSnapshotterBase) CreatePVCClones(vgs *groupsnapapi.VolumeGro
Name: snap.Name,
}
pvcs[i].Spec.StorageClassName = &scName
// cleanup the VolumeName and Resource version in pvc object
pvcs[i].Spec.VolumeName = ""
pvcs[i].ResourceVersion = ""

err = createPVCAndvalidatePV(v.framework.ClientSet, pvc, v.timeout)
err = createPVCAndvalidatePV(v.framework.ClientSet, pvcs[i], v.timeout)
if err != nil {
return nil, fmt.Errorf("failed to create PVC: %w", err)
}
Expand All @@ -194,7 +198,7 @@ func (v volumeGroupSnapshotterBase) CreateVolumeGroupSnapshotClass(
return wait.PollUntilContextTimeout(
context.TODO(),
poll,
time.Duration(v.timeout),
time.Duration(v.timeout)*time.Minute,
true,
func(ctx context.Context) (bool, error) {
_, err := v.groupclient.VolumeGroupSnapshotClasses().Create(ctx, groupSnapshotClass, metav1.CreateOptions{})
Expand Down Expand Up @@ -259,11 +263,18 @@ func (v volumeGroupSnapshotterBase) CreateVolumeGroupSnapshot(name,
if groupSnapshot.Status == nil || groupSnapshot.Status.ReadyToUse == nil {
return false, nil
}

if *groupSnapshot.Status.ReadyToUse {
return true, nil
}

framework.Logf("VolumeGroupSnapshot %s status %+v", groupSnapshot.Name, *groupSnapshot.Status)
readyToUse := groupSnapshot.Status.ReadyToUse
errMsg := ""
if groupSnapshot.Status.Error != nil {
errMsg = *groupSnapshot.Status.Error.Message
}

framework.Logf("VolumeGroupSnapshot %s is not ready to use. ReadyToUse: %v, Error: %s", name, readyToUse, errMsg)

return false, nil
})
Expand All @@ -275,8 +286,9 @@ func (v volumeGroupSnapshotterBase) CreateVolumeGroupSnapshot(name,
}

func (v volumeGroupSnapshotterBase) DeleteVolumeGroupSnapshot(volumeGroupSnapshotName, namespace string) error {
ctx := context.TODO()
err := v.groupclient.VolumeGroupSnapshots(namespace).Delete(
context.TODO(),
ctx,
volumeGroupSnapshotName,
metav1.DeleteOptions{})
if err != nil {
Expand All @@ -285,7 +297,6 @@ func (v volumeGroupSnapshotterBase) DeleteVolumeGroupSnapshot(volumeGroupSnapsho
start := time.Now()
framework.Logf("Waiting for VolumeGroupSnapshot %v to be deleted", volumeGroupSnapshotName)
timeout := time.Duration(v.timeout) * time.Minute
ctx := context.TODO()

return wait.PollUntilContextTimeout(
ctx,
Expand Down Expand Up @@ -375,7 +386,7 @@ func (v *volumeGroupSnapshotterBase) testVolumeGroupSnapshot(vol volumeGroupSnap

clonePVCs, err := v.CreatePVCClones(volumeGroupSnapshot, v.storageClassName)
if err != nil {
return fmt.Errorf("failed to create clones and pods: %w", err)
return fmt.Errorf("failed to create clones: %w", err)
}
// validate the resources in the backend
err = vol.ValidateResourcesForCreate(volumeGroupSnapshot)
Expand Down

0 comments on commit e93e1f5

Please sign in to comment.