Skip to content
Open
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
4 changes: 2 additions & 2 deletions pkg/sanity/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo
volReq.VolumeContentSource = &csi.VolumeContentSource{
Type: &csi.VolumeContentSource_Snapshot{
Snapshot: &csi.VolumeContentSource_SnapshotSource{
SnapshotId: "non-existing-snapshot-id",
SnapshotId: sc.Config.IDGen.GenerateUniqueValidSnapshotID(),
},
},
}
Expand Down Expand Up @@ -1220,7 +1220,7 @@ var _ = DescribeSanity("DeleteSnapshot [Controller Server]", func(sc *TestContex

It("should succeed when an invalid snapshot id is used", func() {

req := MakeDeleteSnapshotReq(sc, "reallyfakesnapshotid")
req := MakeDeleteSnapshotReq(sc, sc.Config.IDGen.GenerateInvalidSnapshotID())
_, err := r.DeleteSnapshot(context.Background(), req)
Expect(err).NotTo(HaveOccurred())
})
Expand Down
17 changes: 17 additions & 0 deletions pkg/sanity/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ type IDGenerator interface {
// case this method should output any non-empty ID
GenerateInvalidVolumeID() string

// GenerateUniqueValidSnapshotID must generate a unique Snapshot ID that the CSI
// Driver considers in valid form
GenerateUniqueValidSnapshotID() string

// GenerateInvalidSnapshotID must output a Snapshot ID that the CSI Driver MAY
// consider invalid. Some drivers may not have requirements on IDs in which
// case this method should output any non-empty ID
GenerateInvalidSnapshotID() string

// GenerateUniqueValidNodeID must generate a unique Node ID that the CSI
// Driver considers in valid form
GenerateUniqueValidNodeID() string
Expand All @@ -60,6 +69,14 @@ func (d DefaultIDGenerator) GenerateInvalidVolumeID() string {
return "fake-vol-id"
}

func (d DefaultIDGenerator) GenerateUniqueValidSnapshotID() string {
return fmt.Sprintf("fake-snap-id-%s", uuid.New().String()[:10])
}

func (d DefaultIDGenerator) GenerateInvalidSnapshotID() string {
return "fake-snap-id"
}

func (d DefaultIDGenerator) GenerateUniqueValidNodeID() string {
return fmt.Sprintf("fake-node-id-%s", uuid.New().String()[:10])
}
Expand Down