Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for Unicode names #111

Closed
wants to merge 1 commit into from
Closed
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
76 changes: 76 additions & 0 deletions pkg/sanity/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,52 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
Expect(err).NotTo(HaveOccurred())
cl.UnregisterVolume(name)
})

It("should not fail when creating volume with a unicode name", func() {

name := "sanity-unicode-\xF0\x9F\x92\xA9-name"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think this is part of the spec. Although a good test, I do not feel we should be pressing this as it is not a point of the spec.

By("creating a volume")
size := TestVolumeSize(sc)

vol, err := c.CreateVolume(
context.Background(),
&csi.CreateVolumeRequest{
Name: name,
VolumeCapabilities: []*csi.VolumeCapability{
{
AccessType: &csi.VolumeCapability_Mount{
Mount: &csi.VolumeCapability_MountVolume{},
},
AccessMode: &csi.VolumeCapability_AccessMode{
Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER,
},
},
},
CapacityRange: &csi.CapacityRange{
RequiredBytes: size,
},
ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret,
},
)
Expect(err).NotTo(HaveOccurred())
Expect(vol).NotTo(BeNil())
Expect(vol.GetVolume()).NotTo(BeNil())
Expect(vol.GetVolume().GetId()).NotTo(BeEmpty())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetId()})
Expect(vol.GetVolume().GetCapacityBytes()).To(BeNumerically(">=", size))

By("cleaning up deleting the volume")

_, err = c.DeleteVolume(
context.Background(),
&csi.DeleteVolumeRequest{
VolumeId: vol.GetVolume().GetId(),
ControllerDeleteSecrets: sc.Secrets.DeleteVolumeSecret,
},
)
Expect(err).NotTo(HaveOccurred())
cl.UnregisterVolume(name)
})
})

Describe("DeleteVolume", func() {
Expand Down Expand Up @@ -1557,6 +1603,36 @@ var _ = DescribeSanity("CreateSnapshot [Controller Server]", func(sc *SanityCont
_, err = c.DeleteVolume(context.Background(), delVolReq)
Expect(err).NotTo(HaveOccurred())
})

It("should not fail when creating snapshot with unicode name", func() {

By("creating a volume")
volReq := MakeCreateVolumeReq(sc, "CreateSnapshot-volume-4")
volume, err := c.CreateVolume(context.Background(), volReq)
Expect(err).NotTo(HaveOccurred())

By("creating a snapshot")
snapReq1 := MakeCreateSnapshotReq(sc, "CreateSnapshot-snapshot-4-\xF0\x9F\x92\xA9", volume.GetVolume().GetId(), nil)
snap1, err := c.CreateSnapshot(context.Background(), snapReq1)
Expect(err).NotTo(HaveOccurred())
Expect(snap1).NotTo(BeNil())
verifySnapshotInfo(snap1.GetSnapshot())

snap2, err := c.CreateSnapshot(context.Background(), snapReq1)
Expect(err).NotTo(HaveOccurred())
Expect(snap2).NotTo(BeNil())
verifySnapshotInfo(snap2.GetSnapshot())

By("cleaning up deleting the snapshot")
delSnapReq := MakeDeleteSnapshotReq(sc, snap1.GetSnapshot().GetId())
_, err = c.DeleteSnapshot(context.Background(), delSnapReq)
Expect(err).NotTo(HaveOccurred())

By("cleaning up deleting the volume")
delVolReq := MakeDeleteVolumeReq(sc, volume.GetVolume().GetId())
_, err = c.DeleteVolume(context.Background(), delVolReq)
Expect(err).NotTo(HaveOccurred())
})
})

func MakeCreateVolumeReq(sc *SanityContext, name string) *csi.CreateVolumeRequest {
Expand Down