@@ -90,4 +90,54 @@ func lvmClusterTest() {
9090 VerifyLVMSSetup (ctx , cluster )
9191 })
9292 })
93+
94+ Describe ("Device Removal" , Serial , func () {
95+ It ("should remove devices from volume group successfully" , func (ctx SpecContext ) {
96+ // Configure cluster with multiple devices for removal testing
97+ cluster .Spec .Storage .DeviceClasses [0 ].DeviceSelector = & v1alpha1.DeviceSelector {
98+ Paths : []v1alpha1.DevicePath {"/dev/sdg" , "/dev/sdh" },
99+ }
100+
101+ By ("Creating cluster with multiple devices" )
102+ CreateResource (ctx , cluster )
103+ VerifyLVMSSetup (ctx , cluster )
104+
105+ By ("Removing one device from the volume group" )
106+ // Update cluster to remove /dev/sdi
107+ cluster .Spec .Storage .DeviceClasses [0 ].DeviceSelector .Paths = []v1alpha1.DevicePath {
108+ "/dev/sdg" ,
109+ }
110+
111+ err := crClient .Update (ctx , cluster )
112+ Expect (err ).NotTo (HaveOccurred ())
113+
114+ By ("Verifying device removal completed successfully" )
115+ Eventually (func (ctx SpecContext ) bool {
116+ return validateDeviceRemovalSuccess (ctx , cluster , 1 )
117+ }, 5 * timeout , interval ).WithContext (ctx ).Should (BeTrue ())
118+ })
119+
120+ It ("should handle optional device removal" , func (ctx SpecContext ) {
121+ // Configure cluster with both required and optional devices
122+ cluster .Spec .Storage .DeviceClasses [0 ].DeviceSelector = & v1alpha1.DeviceSelector {
123+ Paths : []v1alpha1.DevicePath {"/dev/sdh" },
124+ OptionalPaths : []v1alpha1.DevicePath {"/dev/sdl" , "/dev/sdm" },
125+ }
126+
127+ By ("Creating cluster with required and optional devices" )
128+ CreateResource (ctx , cluster )
129+ VerifyLVMSSetup (ctx , cluster )
130+
131+ By ("Removing optional devices" )
132+ cluster .Spec .Storage .DeviceClasses [0 ].DeviceSelector .OptionalPaths = []v1alpha1.DevicePath {}
133+
134+ err := crClient .Update (ctx , cluster )
135+ Expect (err ).NotTo (HaveOccurred (), "Should allow removal of optional devices" )
136+
137+ By ("Verifying cluster remains Ready with required device only" )
138+ Eventually (func (ctx SpecContext ) bool {
139+ return validateClusterReady (ctx , cluster )
140+ }, timeout , interval ).WithContext (ctx ).Should (BeTrue ())
141+ })
142+ })
93143}
0 commit comments