Skip to content

Commit 07e422d

Browse files
committed
Add idempotency loop for controller operations
Similar to Node operations, add loop for controller operations as well.
1 parent 7541597 commit 07e422d

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

pkg/sanity/controller.go

+21-12
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo
123123
AfterEach(func() {
124124
cl.DeleteVolumes()
125125
})
126+
idempotentcount := sc.Config.IdempotentCount
127+
// Negative value for Idempotency repeat count means "skip idempotency testing"
128+
// We also do not want zero as that would skip as well, so in special cases we
129+
// reset the loop count to 1 to make this happen as regular testing.
130+
if idempotentcount < 1 {
131+
idempotentcount = 1
132+
}
126133

127134
Describe("ControllerGetCapabilities", func() {
128135
It("should return appropriate capabilities", func() {
@@ -1110,19 +1117,21 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo
11101117
// ControllerPublishVolume
11111118
By("calling controllerpublish on that volume")
11121119

1113-
conpubvol, err := c.ControllerPublishVolume(
1114-
context.Background(),
1115-
&csi.ControllerPublishVolumeRequest{
1116-
VolumeId: vol.GetVolume().GetVolumeId(),
1117-
NodeId: ni.GetNodeId(),
1118-
VolumeCapability: TestVolumeCapabilityWithAccessType(sc, csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER),
1119-
Readonly: false,
1120-
Secrets: sc.Secrets.ControllerPublishVolumeSecret,
1121-
},
1122-
)
1123-
Expect(err).NotTo(HaveOccurred())
1120+
for i := 0; i < idempotentcount; i++ {
1121+
conpubvol, err := c.ControllerPublishVolume(
1122+
context.Background(),
1123+
&csi.ControllerPublishVolumeRequest{
1124+
VolumeId: vol.GetVolume().GetVolumeId(),
1125+
NodeId: ni.GetNodeId(),
1126+
VolumeCapability: TestVolumeCapabilityWithAccessType(sc, csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER),
1127+
Readonly: false,
1128+
Secrets: sc.Secrets.ControllerPublishVolumeSecret,
1129+
},
1130+
)
1131+
Expect(err).NotTo(HaveOccurred())
1132+
Expect(conpubvol).NotTo(BeNil())
1133+
}
11241134
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId(), NodeID: ni.GetNodeId()})
1125-
Expect(conpubvol).NotTo(BeNil())
11261135

11271136
By("cleaning up unpublishing the volume")
11281137

0 commit comments

Comments
 (0)