@@ -44,8 +44,8 @@ func init() {
4444func TestCreateVolume (t * testing.T ) {
4545 // mock OpenStack
4646 properties := map [string ]string {"cinder.csi.openstack.org/cluster" : FakeCluster }
47- // CreateVolume(name string, size int, vtype, availability string, snapshotID string, tags * map[string]string) (string, string, int, error)
48- osmock .On ("CreateVolume" , FakeVolName , mock .AnythingOfType ("int" ), FakeVolType , FakeAvailability , "" , "" , & properties ).Return (& FakeVol , nil )
47+ // CreateVolume(name string, size int, vtype, availability string, snapshotID string, sourceVolID string, sourceBackupID string, tags map[string]string) (string, string, int, error)
48+ osmock .On ("CreateVolume" , FakeVolName , mock .AnythingOfType ("int" ), FakeVolType , FakeAvailability , "" , "" , "" , properties ).Return (& FakeVol , nil )
4949
5050 osmock .On ("GetVolumesByName" , FakeVolName ).Return (FakeVolListEmpty , nil )
5151 // Init assert
@@ -90,9 +90,9 @@ func TestCreateVolume(t *testing.T) {
9090func TestCreateVolumeWithParam (t * testing.T ) {
9191 // mock OpenStack
9292 properties := map [string ]string {"cinder.csi.openstack.org/cluster" : FakeCluster }
93- // CreateVolume(name string, size int, vtype, availability string, snapshotID string, tags * map[string]string) (string, string, int, error)
93+ // CreateVolume(name string, size int, vtype, availability string, snapshotID string, sourceVolID string, sourceBackupID string, tags map[string]string) (string, string, int, error)
9494 // Vol type and availability comes from CreateVolumeRequest.Parameters
95- osmock .On ("CreateVolume" , FakeVolName , mock .AnythingOfType ("int" ), "dummyVolType" , "cinder" , "" , "" , & properties ).Return (& FakeVol , nil )
95+ osmock .On ("CreateVolume" , FakeVolName , mock .AnythingOfType ("int" ), "dummyVolType" , "cinder" , "" , "" , "" , properties ).Return (& FakeVol , nil )
9696
9797 osmock .On ("GetVolumesByName" , FakeVolName ).Return (FakeVolListEmpty , nil )
9898 // Init assert
@@ -146,8 +146,8 @@ func TestCreateVolumeWithExtraMetadata(t *testing.T) {
146146 "csi.storage.k8s.io/pvc/name" : FakePVCName ,
147147 "csi.storage.k8s.io/pvc/namespace" : FakePVCNamespace ,
148148 }
149- // CreateVolume(name string, size int, vtype, availability string, snapshotID string, tags * map[string]string) (string, string, int, error)
150- osmock .On ("CreateVolume" , FakeVolName , mock .AnythingOfType ("int" ), FakeVolType , FakeAvailability , "" , "" , & properties ).Return (& FakeVol , nil )
149+ // CreateVolume(name string, size int, vtype, availability string, snapshotID string, sourceVolID string, sourceBackupID string, tags map[string]string) (string, string, int, error)
150+ osmock .On ("CreateVolume" , FakeVolName , mock .AnythingOfType ("int" ), FakeVolType , FakeAvailability , "" , "" , "" , properties ).Return (& FakeVol , nil )
151151
152152 osmock .On ("GetVolumesByName" , FakeVolName ).Return (FakeVolListEmpty , nil )
153153
@@ -186,8 +186,8 @@ func TestCreateVolumeWithExtraMetadata(t *testing.T) {
186186
187187func TestCreateVolumeFromSnapshot (t * testing.T ) {
188188 properties := map [string ]string {"cinder.csi.openstack.org/cluster" : FakeCluster }
189- // CreateVolume(name string, size int, vtype, availability string, snapshotID string, tags * map[string]string) (string, string, int, error)
190- osmock .On ("CreateVolume" , FakeVolName , mock .AnythingOfType ("int" ), FakeVolType , "" , FakeSnapshotID , "" , & properties ).Return (& FakeVolFromSnapshot , nil )
189+ // CreateVolume(name string, size int, vtype, availability string, snapshotID string, sourceVolID string, sourceBackupID string, tags map[string]string) (string, string, int, error)
190+ osmock .On ("CreateVolume" , FakeVolName , mock .AnythingOfType ("int" ), FakeVolType , "" , FakeSnapshotID , "" , "" , properties ).Return (& FakeVolFromSnapshot , nil )
191191 osmock .On ("GetVolumesByName" , FakeVolName ).Return (FakeVolListEmpty , nil )
192192
193193 // Init assert
@@ -233,8 +233,8 @@ func TestCreateVolumeFromSnapshot(t *testing.T) {
233233
234234func TestCreateVolumeFromSourceVolume (t * testing.T ) {
235235 properties := map [string ]string {"cinder.csi.openstack.org/cluster" : FakeCluster }
236- // CreateVolume(name string, size int, vtype, availability string, snapshotID string, tags * map[string]string) (string, string, int, error)
237- osmock .On ("CreateVolume" , FakeVolName , mock .AnythingOfType ("int" ), FakeVolType , "" , "" , FakeVolID , & properties ).Return (& FakeVolFromSourceVolume , nil )
236+ // CreateVolume(name string, size int, vtype, availability string, snapshotID string, sourceVolID string, sourceBackupID string, tags map[string]string) (string, string, int, error)
237+ osmock .On ("CreateVolume" , FakeVolName , mock .AnythingOfType ("int" ), FakeVolType , "" , "" , FakeVolID , "" , properties ).Return (& FakeVolFromSourceVolume , nil )
238238 osmock .On ("GetVolumesByName" , FakeVolName ).Return (FakeVolListEmpty , nil )
239239
240240 // Init assert
@@ -451,10 +451,12 @@ func TestListVolumes(t *testing.T) {
451451
452452// Test CreateSnapshot
453453func TestCreateSnapshot (t * testing.T ) {
454- osmock .On ("CreateSnapshot" , FakeSnapshotName , FakeVolID , & map [string ]string {cinderCSIClusterIDKey : "cluster" }).Return (& FakeSnapshotRes , nil )
455- osmock .On ("ListSnapshots" , map [string ]string {"Name" : FakeSnapshotName }).Return (FakeSnapshotListEmpty , "" , nil )
456- osmock .On ("WaitSnapshotReady" , FakeSnapshotID ).Return (nil )
457454
455+ osmock .On ("CreateSnapshot" , FakeSnapshotName , FakeVolID , map [string ]string {cinderCSIClusterIDKey : "cluster" }).Return (& FakeSnapshotRes , nil )
456+ osmock .On ("ListSnapshots" , map [string ]string {"Name" : FakeSnapshotName }).Return (FakeSnapshotListEmpty , "" , nil )
457+ osmock .On ("WaitSnapshotReady" , FakeSnapshotID ).Return (FakeSnapshotRes .Status , nil )
458+ osmock .On ("ListBackups" , map [string ]string {"Name" : FakeSnapshotName }).Return (FakeBackupListEmpty , nil )
459+ osmock .On ("GetSnapshotByID" , FakeVolID ).Return (& FakeSnapshotRes , nil )
458460 // Init assert
459461 assert := assert .New (t )
460462
@@ -487,7 +489,7 @@ func TestCreateSnapshotWithExtraMetadata(t *testing.T) {
487489 openstack .SnapshotForceCreate : "true" ,
488490 }
489491
490- osmock .On ("CreateSnapshot" , FakeSnapshotName , FakeVolID , & properties ).Return (& FakeSnapshotRes , nil )
492+ osmock .On ("CreateSnapshot" , FakeSnapshotName , FakeVolID , properties ).Return (& FakeSnapshotRes , nil )
491493 osmock .On ("ListSnapshots" , map [string ]string {"Name" : FakeSnapshotName }).Return (FakeSnapshotListEmpty , "" , nil )
492494 osmock .On ("WaitSnapshotReady" , FakeSnapshotID ).Return (nil )
493495
@@ -522,6 +524,7 @@ func TestCreateSnapshotWithExtraMetadata(t *testing.T) {
522524func TestDeleteSnapshot (t * testing.T ) {
523525 // DeleteSnapshot(volumeID string) error
524526 osmock .On ("DeleteSnapshot" , FakeSnapshotID ).Return (nil )
527+ osmock .On ("DeleteBackup" , FakeSnapshotID ).Return (nil )
525528
526529 // Init assert
527530 assert := assert .New (t )
0 commit comments