@@ -510,6 +510,69 @@ func testSmartVolumeAutoDistributeDisperse(t *testing.T) {
510510 checkZeroLvs (r )
511511}
512512
513+ func testSmartVolumeWhenCloneExists (t * testing.T ) {
514+ r := require .New (t )
515+
516+ smartvolname := "svol1"
517+
518+ createReq := api.VolCreateReq {
519+ Name : smartvolname ,
520+ Size : 20 * gutils .MiB ,
521+ ReplicaCount : 3 ,
522+ }
523+ volinfo , err := client .VolumeCreate (createReq )
524+ r .Nil (err )
525+
526+ r .Len (volinfo .Subvols , 1 )
527+ r .Equal ("Replicate" , volinfo .Type .String ())
528+ r .Len (volinfo .Subvols [0 ].Bricks , 3 )
529+
530+ err = client .VolumeStart (smartvolname , false )
531+ r .Nil (err )
532+
533+ // Snapshot Create, Activate, Clone and delete Snapshot
534+ snapshotCreateReq := api.SnapCreateReq {
535+ VolName : smartvolname ,
536+ SnapName : smartvolname + "-s1" ,
537+ }
538+ _ , err = client .SnapshotCreate (snapshotCreateReq )
539+ r .Nil (err , "snapshot create failed" )
540+
541+ var snapshotActivateReq api.SnapActivateReq
542+
543+ err = client .SnapshotActivate (snapshotActivateReq , smartvolname + "-s1" )
544+ r .Nil (err )
545+
546+ snapshotCloneReq := api.SnapCloneReq {
547+ CloneName : smartvolname + "-c1" ,
548+ }
549+ _ , err = client .SnapshotClone (smartvolname + "-s1" , snapshotCloneReq )
550+ r .Nil (err , "snapshot clone failed" )
551+
552+ err = client .SnapshotDelete (smartvolname + "-s1" )
553+ r .Nil (err )
554+
555+ // Check number of Lvs
556+ nlv , err := numberOfLvs ("gluster-dev-gluster_loop1" )
557+ r .Nil (err )
558+ // Thinpool + brick + Clone volume's brick
559+ r .Equal (3 , nlv )
560+
561+ r .Nil (client .VolumeStop (smartvolname ))
562+
563+ r .Nil (client .VolumeDelete (smartvolname ))
564+
565+ nlv , err = numberOfLvs ("gluster-dev-gluster_loop1" )
566+ r .Nil (err )
567+ // Thinpool + brick + Clone volume's brick
568+ r .Equal (2 , nlv )
569+
570+ // Delete Clone Volume
571+ r .Nil (client .VolumeDelete (smartvolname + "-c1" ))
572+
573+ checkZeroLvs (r )
574+ }
575+
513576func editDevice (t * testing.T ) {
514577 r := require .New (t )
515578 peerList , err := client .Peers ()
@@ -632,6 +695,8 @@ func TestSmartVolume(t *testing.T) {
632695 t .Run ("Smartvol Distributed-Disperse Volume" , testSmartVolumeDistributeDisperse )
633696 t .Run ("Smartvol Auto Distributed-Replicate Volume" , testSmartVolumeAutoDistributeReplicate )
634697 t .Run ("Smartvol Auto Distributed-Disperse Volume" , testSmartVolumeAutoDistributeDisperse )
698+ // Test dependent lvs in thinpool cases
699+ t .Run ("Smartvol delete when clone exists" , testSmartVolumeWhenCloneExists )
635700 t .Run ("Replace Brick" , testReplaceBrick )
636701 t .Run ("Edit device" , editDevice )
637702
0 commit comments