@@ -2908,6 +2908,113 @@ func TestNVMeDeleteSnapshot_Error(t *testing.T) {
29082908 assert .Error (t , err )
29092909}
29102910
2911+ func TestNVMeCreateVolumeGroupSnapshot (t * testing.T ) {
2912+ ctx := context .Background ()
2913+
2914+ driver , mockAPI := newNVMeDriverAndMockApi (t )
2915+ mockAPI .EXPECT ().SVMName ().AnyTimes ().Return ("SVM1" )
2916+ mockAPI .EXPECT ().IsDisaggregated ().AnyTimes ().Return (false )
2917+
2918+ groupSnapshotConfig := & storage.GroupSnapshotConfig {
2919+ Name : "groupsnapshot-1234" ,
2920+ InternalName : "groupsnapshot-1234" ,
2921+ VolumeNames : []string {"vol1" , "vol2" },
2922+ }
2923+ storageVols := storage.GroupSnapshotTargetVolumes {
2924+ "trident_vol1" : {
2925+ "vol1" : & storage.VolumeConfig {Name : "vol1" },
2926+ },
2927+ "trident_vol2" : {
2928+ "vol2" : & storage.VolumeConfig {Name : "vol2" },
2929+ },
2930+ }
2931+ targetInfo := & storage.GroupSnapshotTargetInfo {
2932+ StorageType : "unified" ,
2933+ StorageUUID : "12345" ,
2934+ StorageVolumes : storageVols ,
2935+ }
2936+ storageVolNames := []string {"trident_vol1" , "trident_vol2" }
2937+ snapName , _ := storage .ConvertGroupSnapshotID (groupSnapshotConfig .Name )
2938+
2939+ mockAPI .EXPECT ().ConsistencyGroupSnapshot (ctx , snapName , gomock .InAnyOrder (storageVolNames )).Return (nil ).Times (1 )
2940+
2941+ err := driver .CreateGroupSnapshot (ctx , groupSnapshotConfig , targetInfo )
2942+ assert .NoError (t , err , "Group snapshot creation failed" )
2943+ }
2944+
2945+ func TestNVMeProcessVolumeGroupSnapshot (t * testing.T ) {
2946+ ctx := context .Background ()
2947+
2948+ driver , mockAPI := newNVMeDriverAndMockApi (t )
2949+ mockAPI .EXPECT ().SVMName ().AnyTimes ().Return ("SVM1" )
2950+ mockAPI .EXPECT ().IsDisaggregated ().AnyTimes ().Return (false )
2951+
2952+ groupSnapshotConfig := & storage.GroupSnapshotConfig {
2953+ Name : "groupsnapshot-1234" ,
2954+ InternalName : "groupsnapshot-1234" ,
2955+ VolumeNames : []string {"vol1" , "vol2" },
2956+ }
2957+ storageVols := []* storage.VolumeConfig {
2958+ {Name : "vol1" },
2959+ {Name : "vol2" },
2960+ }
2961+ snapName , _ := storage .ConvertGroupSnapshotID (groupSnapshotConfig .Name )
2962+ snapInfoResult := api.Snapshot {CreateTime : "1" }
2963+ size := 1073741824
2964+
2965+ mockAPI .EXPECT ().VolumeSnapshotInfo (ctx , snapName , gomock .Any ()).Return (snapInfoResult , nil ).Times (2 )
2966+ mockAPI .EXPECT ().NVMeNamespaceGetSize (ctx , gomock .Any ()).Return (1073741824 , nil ).Times (2 )
2967+
2968+ snaps , err := driver .ProcessGroupSnapshot (ctx , groupSnapshotConfig , storageVols )
2969+ assert .NoError (t , err , "Group snapshot processing failed" )
2970+ assert .NotNil (t , snaps , "Grouped snapshot extraction failed" )
2971+ for _ , snap := range snaps {
2972+ assert .Equal (t , snapName , snap .Config .Name )
2973+ assert .Equal (t , int64 (size ), snap .SizeBytes )
2974+ }
2975+ }
2976+
2977+ func TestNVMeGetGroupSnapshotTarget (t * testing.T ) {
2978+ ctx := context .Background ()
2979+
2980+ driver , mockAPI := newNVMeDriverAndMockApi (t )
2981+ mockAPI .EXPECT ().SVMName ().AnyTimes ().Return ("SVM1" )
2982+ mockAPI .EXPECT ().IsDisaggregated ().AnyTimes ().Return (false )
2983+
2984+ volumeConfigs := []* storage.VolumeConfig {
2985+ {
2986+ Name : "vol1" ,
2987+ InternalName : "trident_vol1" ,
2988+ },
2989+ {
2990+ Name : "vol2" ,
2991+ InternalName : "trident_vol2" ,
2992+ },
2993+ }
2994+
2995+ storageVols := storage.GroupSnapshotTargetVolumes {
2996+ "trident_vol1" : {
2997+ "vol1" : & storage.VolumeConfig {Name : "vol1" , InternalName : "trident_vol1" },
2998+ },
2999+ "trident_vol2" : {
3000+ "vol2" : & storage.VolumeConfig {Name : "vol2" , InternalName : "trident_vol2" },
3001+ },
3002+ }
3003+ expectedTargetInfo := & storage.GroupSnapshotTargetInfo {
3004+ StorageType : "Unified" ,
3005+ StorageUUID : "12345" ,
3006+ StorageVolumes : storageVols ,
3007+ }
3008+
3009+ mockAPI .EXPECT ().GetSVMUUID ().Return ("12345" ).Times (1 )
3010+ mockAPI .EXPECT ().VolumeExists (ctx , gomock .Any ()).Return (true , nil ).Times (2 )
3011+
3012+ targetInfo , err := driver .GetGroupSnapshotTarget (ctx , volumeConfigs )
3013+
3014+ assert .Equal (t , targetInfo , expectedTargetInfo )
3015+ assert .NoError (t , err , "Volume group target failed" )
3016+ }
3017+
29113018// Phase 3: Volume Management Tests
29123019func TestNVMeGet_Success (t * testing.T ) {
29133020 d , mAPI := newNVMeDriverAndMockApi (t )
0 commit comments