Change ReadyToUse in Snapshot based on caller input

ReadyToUse in Snapshot will be updated based on ReadyToUse in Content.
ReadytoUse in Snapshot will also be updated when caller indicates it should
be changed to false when an error occurrs.
This commit is contained in:
xing-yang
2020-12-02 15:54:01 +00:00
parent 29b01ac7ff
commit 2a7c550b18
4 changed files with 44 additions and 26 deletions

View File

@@ -57,7 +57,7 @@ func TestUpdateSnapshotClass(t *testing.T) {
name: "1-3 - snapshot class name not found",
initialContents: nocontents,
initialSnapshots: newSnapshotArray("snap1-3", "snapuid1-3", "claim1-3", "", "missing-class", "", &True, nil, nil, nil, false, true, nil),
expectedSnapshots: newSnapshotArray("snap1-3", "snapuid1-3", "claim1-3", "", "missing-class", "", &False, nil, nil, newVolumeError("Failed to get snapshot class with error volumesnapshotclass.snapshot.storage.k8s.io \"missing-class\" not found"), false, true, nil),
expectedSnapshots: newSnapshotArray("snap1-3", "snapuid1-3", "claim1-3", "", "missing-class", "", &True, nil, nil, newVolumeError("Failed to get snapshot class with error volumesnapshotclass.snapshot.storage.k8s.io \"missing-class\" not found"), false, true, nil),
initialClaims: newClaimArray("claim1-3", "pvc-uid1-3", "1Gi", "volume1-3", v1.ClaimBound, &sameDriver),
initialVolumes: newVolumeArray("volume1-3", "pv-uid1-3", "pv-handle1-3", "1Gi", "pvc-uid1-3", "claim1-3", v1.VolumeBound, v1.PersistentVolumeReclaimDelete, sameDriver),
expectedEvents: []string{"Warning GetSnapshotClassFailed"},
@@ -69,7 +69,7 @@ func TestUpdateSnapshotClass(t *testing.T) {
name: "1-5 - snapshot update with default class name failed because PVC was not found",
initialContents: nocontents,
initialSnapshots: newSnapshotArray("snap1-5", "snapuid1-5", "claim1-5", "", "", "", &True, nil, nil, nil, false, true, nil),
expectedSnapshots: newSnapshotArray("snap1-5", "snapuid1-5", "claim1-5", "", "", "", &False, nil, nil, newVolumeError("Failed to set default snapshot class with error failed to retrieve PVC claim1-5 from the lister: \"persistentvolumeclaim \\\"claim1-5\\\" not found\""), false, true, nil),
expectedSnapshots: newSnapshotArray("snap1-5", "snapuid1-5", "claim1-5", "", "", "", &True, nil, nil, newVolumeError("Failed to set default snapshot class with error failed to retrieve PVC claim1-5 from the lister: \"persistentvolumeclaim \\\"claim1-5\\\" not found\""), false, true, nil),
initialClaims: nil,
initialVolumes: nil,
expectedEvents: []string{"Warning SetDefaultSnapshotClassFailed"},