@@ -1065,92 +1065,6 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo
10651065 Expect (serverError .Code ()).To (Equal (codes .InvalidArgument ))
10661066 })
10671067
1068- // CSI spec poses no specific requirements for the cluster/storage setups that a SP MUST support. To perform
1069- // meaningful checks the following test assumes that topology-aware provisioning on a single node setup is supported
1070- It ("should return appropriate values (no optional values added)" , func () {
1071-
1072- By ("getting node information" )
1073- ni , err := n .NodeGetInfo (
1074- context .Background (),
1075- & csi.NodeGetInfoRequest {})
1076- Expect (err ).NotTo (HaveOccurred ())
1077- Expect (ni ).NotTo (BeNil ())
1078- Expect (ni .GetNodeId ()).NotTo (BeEmpty ())
1079-
1080- var accReqs * csi.TopologyRequirement
1081- if ni .AccessibleTopology != nil {
1082- // Topology requirements are honored if provided by the driver
1083- accReqs = & csi.TopologyRequirement {
1084- Requisite : []* csi.Topology {ni .AccessibleTopology },
1085- }
1086- }
1087-
1088- // Create Volume First
1089- By ("creating a single node writer volume" )
1090- name := UniqueString ("sanity-controller-publish" )
1091-
1092- vol , err := c .CreateVolume (
1093- context .Background (),
1094- & csi.CreateVolumeRequest {
1095- Name : name ,
1096- VolumeCapabilities : []* csi.VolumeCapability {
1097- TestVolumeCapabilityWithAccessType (sc , csi .VolumeCapability_AccessMode_SINGLE_NODE_WRITER ),
1098- },
1099- Secrets : sc .Secrets .CreateVolumeSecret ,
1100- Parameters : sc .Config .TestVolumeParameters ,
1101- AccessibilityRequirements : accReqs ,
1102- },
1103- )
1104- Expect (err ).NotTo (HaveOccurred ())
1105- Expect (vol ).NotTo (BeNil ())
1106- Expect (vol .GetVolume ()).NotTo (BeNil ())
1107- Expect (vol .GetVolume ().GetVolumeId ()).NotTo (BeEmpty ())
1108- cl .RegisterVolume (name , VolumeInfo {VolumeID : vol .GetVolume ().GetVolumeId ()})
1109-
1110- // ControllerPublishVolume
1111- By ("calling controllerpublish on that volume" )
1112-
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 ())
1124- cl .RegisterVolume (name , VolumeInfo {VolumeID : vol .GetVolume ().GetVolumeId (), NodeID : ni .GetNodeId ()})
1125- Expect (conpubvol ).NotTo (BeNil ())
1126-
1127- By ("cleaning up unpublishing the volume" )
1128-
1129- conunpubvol , err := c .ControllerUnpublishVolume (
1130- context .Background (),
1131- & csi.ControllerUnpublishVolumeRequest {
1132- VolumeId : vol .GetVolume ().GetVolumeId (),
1133- // NodeID is optional in ControllerUnpublishVolume
1134- NodeId : ni .GetNodeId (),
1135- Secrets : sc .Secrets .ControllerUnpublishVolumeSecret ,
1136- },
1137- )
1138- Expect (err ).NotTo (HaveOccurred ())
1139- Expect (conunpubvol ).NotTo (BeNil ())
1140-
1141- By ("cleaning up deleting the volume" )
1142-
1143- _ , err = c .DeleteVolume (
1144- context .Background (),
1145- & csi.DeleteVolumeRequest {
1146- VolumeId : vol .GetVolume ().GetVolumeId (),
1147- Secrets : sc .Secrets .DeleteVolumeSecret ,
1148- },
1149- )
1150- Expect (err ).NotTo (HaveOccurred ())
1151- cl .UnregisterVolume (name )
1152- })
1153-
11541068 It ("should fail when publishing more volumes than the node max attach limit" , func () {
11551069 if ! sc .Config .TestNodeVolumeAttachLimit {
11561070 Skip ("testnodevolumeattachlimit not enabled" )
@@ -1360,6 +1274,22 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo
13601274 })
13611275 })
13621276
1277+ Describe ("volume lifecycle" , func () {
1278+ BeforeEach (func () {
1279+ if ! isControllerCapabilitySupported (c , csi .ControllerServiceCapability_RPC_PUBLISH_UNPUBLISH_VOLUME ) {
1280+ Skip ("Controller Publish, UnpublishVolume not supported" )
1281+ }
1282+ })
1283+
1284+ It ("should work" , func () {
1285+ VolumeLifecycle (n , c , sc , cl , 1 )
1286+ })
1287+
1288+ It ("should be idempotent" , func () {
1289+ VolumeLifecycle (n , c , sc , cl , sc .Config .IdempotentCount )
1290+ })
1291+ })
1292+
13631293 Describe ("ControllerUnpublishVolume" , func () {
13641294 BeforeEach (func () {
13651295 if ! isControllerCapabilitySupported (c , csi .ControllerServiceCapability_RPC_PUBLISH_UNPUBLISH_VOLUME ) {
@@ -1381,93 +1311,6 @@ var _ = DescribeSanity("Controller Service [Controller Server]", func(sc *TestCo
13811311 Expect (ok ).To (BeTrue ())
13821312 Expect (serverError .Code ()).To (Equal (codes .InvalidArgument ))
13831313 })
1384-
1385- // CSI spec poses no specific requirements for the cluster/storage setups that a SP MUST support. To perform
1386- // meaningful checks the following test assumes that topology-aware provisioning on a single node setup is supported
1387- It ("should return appropriate values (no optional values added)" , func () {
1388-
1389- // Create Volume First
1390- By ("creating a single node writer volume" )
1391- name := UniqueString ("sanity-controller-unpublish" )
1392-
1393- By ("getting node information" )
1394- ni , err := n .NodeGetInfo (
1395- context .Background (),
1396- & csi.NodeGetInfoRequest {})
1397- Expect (err ).NotTo (HaveOccurred ())
1398- Expect (ni ).NotTo (BeNil ())
1399- Expect (ni .GetNodeId ()).NotTo (BeEmpty ())
1400-
1401- var accReqs * csi.TopologyRequirement
1402- if ni .AccessibleTopology != nil {
1403- // Topology requirements are honored if provided by the driver
1404- accReqs = & csi.TopologyRequirement {
1405- Requisite : []* csi.Topology {ni .AccessibleTopology },
1406- }
1407- }
1408-
1409- vol , err := c .CreateVolume (
1410- context .Background (),
1411- & csi.CreateVolumeRequest {
1412- Name : name ,
1413- VolumeCapabilities : []* csi.VolumeCapability {
1414- TestVolumeCapabilityWithAccessType (sc , csi .VolumeCapability_AccessMode_SINGLE_NODE_WRITER ),
1415- },
1416- Secrets : sc .Secrets .CreateVolumeSecret ,
1417- Parameters : sc .Config .TestVolumeParameters ,
1418- AccessibilityRequirements : accReqs ,
1419- },
1420- )
1421- Expect (err ).NotTo (HaveOccurred ())
1422- Expect (vol ).NotTo (BeNil ())
1423- Expect (vol .GetVolume ()).NotTo (BeNil ())
1424- Expect (vol .GetVolume ().GetVolumeId ()).NotTo (BeEmpty ())
1425- cl .RegisterVolume (name , VolumeInfo {VolumeID : vol .GetVolume ().GetVolumeId ()})
1426-
1427- // ControllerPublishVolume
1428- By ("calling controllerpublish on that volume" )
1429-
1430- conpubvol , err := c .ControllerPublishVolume (
1431- context .Background (),
1432- & csi.ControllerPublishVolumeRequest {
1433- VolumeId : vol .GetVolume ().GetVolumeId (),
1434- NodeId : ni .GetNodeId (),
1435- VolumeCapability : TestVolumeCapabilityWithAccessType (sc , csi .VolumeCapability_AccessMode_SINGLE_NODE_WRITER ),
1436- Readonly : false ,
1437- Secrets : sc .Secrets .ControllerPublishVolumeSecret ,
1438- },
1439- )
1440- Expect (err ).NotTo (HaveOccurred ())
1441- cl .RegisterVolume (name , VolumeInfo {VolumeID : vol .GetVolume ().GetVolumeId (), NodeID : ni .GetNodeId ()})
1442- Expect (conpubvol ).NotTo (BeNil ())
1443-
1444- // ControllerUnpublishVolume
1445- By ("calling controllerunpublish on that volume" )
1446-
1447- conunpubvol , err := c .ControllerUnpublishVolume (
1448- context .Background (),
1449- & csi.ControllerUnpublishVolumeRequest {
1450- VolumeId : vol .GetVolume ().GetVolumeId (),
1451- // NodeID is optional in ControllerUnpublishVolume
1452- NodeId : ni .GetNodeId (),
1453- Secrets : sc .Secrets .ControllerUnpublishVolumeSecret ,
1454- },
1455- )
1456- Expect (err ).NotTo (HaveOccurred ())
1457- Expect (conunpubvol ).NotTo (BeNil ())
1458-
1459- By ("cleaning up deleting the volume" )
1460-
1461- _ , err = c .DeleteVolume (
1462- context .Background (),
1463- & csi.DeleteVolumeRequest {
1464- VolumeId : vol .GetVolume ().GetVolumeId (),
1465- Secrets : sc .Secrets .DeleteVolumeSecret ,
1466- },
1467- )
1468- Expect (err ).NotTo (HaveOccurred ())
1469- cl .UnregisterVolume (name )
1470- })
14711314 })
14721315})
14731316
@@ -2152,3 +1995,92 @@ func ControllerUnpublishAndDeleteVolume(sc *TestContext, c csi.ControllerClient,
21521995 Expect (err ).NotTo (HaveOccurred ())
21531996 return err
21541997}
1998+
1999+ // VolumeLifecycle performs Create-Publish-Unpublish-Delete, with optional repeat count to test idempotency.
2000+ func VolumeLifecycle (n csi.NodeClient , c csi.ControllerClient , sc * TestContext , cl * Cleanup , count int ) {
2001+ // CSI spec poses no specific requirements for the cluster/storage setups that a SP MUST support. To perform
2002+ // meaningful checks the following test assumes that topology-aware provisioning on a single node setup is supported
2003+ By ("getting node information" )
2004+ ni , err := n .NodeGetInfo (
2005+ context .Background (),
2006+ & csi.NodeGetInfoRequest {})
2007+ Expect (err ).NotTo (HaveOccurred ())
2008+ Expect (ni ).NotTo (BeNil ())
2009+ Expect (ni .GetNodeId ()).NotTo (BeEmpty ())
2010+
2011+ var accReqs * csi.TopologyRequirement
2012+ if ni .AccessibleTopology != nil {
2013+ // Topology requirements are honored if provided by the driver
2014+ accReqs = & csi.TopologyRequirement {
2015+ Requisite : []* csi.Topology {ni .AccessibleTopology },
2016+ }
2017+ }
2018+
2019+ // Create Volume First
2020+ By ("creating a single node writer volume" )
2021+ name := UniqueString ("sanity-controller-publish" )
2022+
2023+ vol , err := c .CreateVolume (
2024+ context .Background (),
2025+ & csi.CreateVolumeRequest {
2026+ Name : name ,
2027+ VolumeCapabilities : []* csi.VolumeCapability {
2028+ TestVolumeCapabilityWithAccessType (sc , csi .VolumeCapability_AccessMode_SINGLE_NODE_WRITER ),
2029+ },
2030+ Secrets : sc .Secrets .CreateVolumeSecret ,
2031+ Parameters : sc .Config .TestVolumeParameters ,
2032+ AccessibilityRequirements : accReqs ,
2033+ },
2034+ )
2035+ Expect (err ).NotTo (HaveOccurred ())
2036+ Expect (vol ).NotTo (BeNil ())
2037+ Expect (vol .GetVolume ()).NotTo (BeNil ())
2038+ Expect (vol .GetVolume ().GetVolumeId ()).NotTo (BeEmpty ())
2039+ cl .RegisterVolume (name , VolumeInfo {VolumeID : vol .GetVolume ().GetVolumeId ()})
2040+
2041+ // ControllerPublishVolume
2042+ for i := 0 ; i < count ; i ++ {
2043+ By ("calling controllerpublish on that volume" )
2044+ conpubvol , err := c .ControllerPublishVolume (
2045+ context .Background (),
2046+ & csi.ControllerPublishVolumeRequest {
2047+ VolumeId : vol .GetVolume ().GetVolumeId (),
2048+ NodeId : ni .GetNodeId (),
2049+ VolumeCapability : TestVolumeCapabilityWithAccessType (sc , csi .VolumeCapability_AccessMode_SINGLE_NODE_WRITER ),
2050+ Readonly : false ,
2051+ Secrets : sc .Secrets .ControllerPublishVolumeSecret ,
2052+ },
2053+ )
2054+ Expect (err ).NotTo (HaveOccurred ())
2055+ Expect (conpubvol ).NotTo (BeNil ())
2056+ }
2057+ cl .RegisterVolume (name , VolumeInfo {VolumeID : vol .GetVolume ().GetVolumeId (), NodeID : ni .GetNodeId ()})
2058+
2059+ for i := 0 ; i < count ; i ++ {
2060+ By ("cleaning up unpublishing the volume" )
2061+ conunpubvol , err := c .ControllerUnpublishVolume (
2062+ context .Background (),
2063+ & csi.ControllerUnpublishVolumeRequest {
2064+ VolumeId : vol .GetVolume ().GetVolumeId (),
2065+ // NodeID is optional in ControllerUnpublishVolume
2066+ NodeId : ni .GetNodeId (),
2067+ Secrets : sc .Secrets .ControllerUnpublishVolumeSecret ,
2068+ },
2069+ )
2070+ Expect (err ).NotTo (HaveOccurred ())
2071+ Expect (conunpubvol ).NotTo (BeNil ())
2072+ }
2073+
2074+ for i := 0 ; i < count ; i ++ {
2075+ By ("cleaning up deleting the volume" )
2076+ _ , err = c .DeleteVolume (
2077+ context .Background (),
2078+ & csi.DeleteVolumeRequest {
2079+ VolumeId : vol .GetVolume ().GetVolumeId (),
2080+ Secrets : sc .Secrets .DeleteVolumeSecret ,
2081+ },
2082+ )
2083+ Expect (err ).NotTo (HaveOccurred ())
2084+ }
2085+ cl .UnregisterVolume (name )
2086+ }
0 commit comments