Skip to content

Commit f4734bf

Browse files
robinschneiderDuciwuci
authored andcommitted
Fix cinder controller server tests
1 parent ae27218 commit f4734bf

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/csi/cinder/controllerserver_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ func TestCreateVolume(t *testing.T) {
6262
// mock OpenStack
6363
properties := map[string]string{cinderCSIClusterIDKey: FakeCluster}
6464
osmock.On("CreateVolume", FakeVolName, mock.AnythingOfType("int"), FakeVolType, FakeAvailability, "", "", "", properties).Return(&FakeVol, nil)
65+
osmock.On("WaitVolumeTargetStatusWithCustomBackoff", FakeVol.ID, []string{openstack.VolumeAvailableStatus}, mock.AnythingOfType("*wait.Backoff")).Return(nil)
66+
6567
osmock.On("GetVolumesByName", FakeVolName).Return(FakeVolListEmpty, nil)
6668
osmock.On("GetBlockStorageOpts").Return(openstack.BlockStorageOpts{})
6769

@@ -156,6 +158,8 @@ func TestCreateVolumeWithParam(t *testing.T) {
156158
// mock OpenStack
157159
properties := map[string]string{cinderCSIClusterIDKey: FakeCluster}
158160
osmock.On("CreateVolume", FakeVolName, mock.AnythingOfType("int"), "dummyVolType", "cinder", "", "", "", properties).Return(&FakeVol, nil)
161+
osmock.On("WaitVolumeTargetStatusWithCustomBackoff", FakeVol.ID, []string{openstack.VolumeAvailableStatus}, mock.AnythingOfType("*wait.Backoff")).Return(nil)
162+
159163
osmock.On("GetVolumesByName", FakeVolName).Return(FakeVolListEmpty, nil)
160164
osmock.On("GetBlockStorageOpts").Return(openstack.BlockStorageOpts{})
161165

@@ -206,6 +210,7 @@ func TestCreateVolumeWithIgnoreVolumeAZ(t *testing.T) {
206210

207211
properties := map[string]string{cinderCSIClusterIDKey: FakeCluster}
208212
osmock.On("CreateVolume", FakeVolName, mock.AnythingOfType("int"), FakeVolType, "cinder", "", "", "", properties).Return(&FakeVol, nil)
213+
osmock.On("WaitVolumeTargetStatusWithCustomBackoff", FakeVol.ID, []string{openstack.VolumeAvailableStatus}, mock.AnythingOfType("*wait.Backoff")).Return(nil)
209214
osmock.On("GetVolumesByName", FakeVolName).Return(FakeVolListEmpty, nil)
210215
osmock.On("GetBlockStorageOpts").Return(openstack.BlockStorageOpts{IgnoreVolumeAZ: true})
211216

@@ -289,6 +294,7 @@ func TestCreateVolumeWithTopologyDisabled(t *testing.T) {
289294

290295
properties := map[string]string{cinderCSIClusterIDKey: FakeCluster}
291296
osmock.On("CreateVolume", FakeVolName, mock.AnythingOfType("int"), FakeVolType, tt.expectedVolumeAZ, "", "", "", properties).Return(&FakeVol, nil)
297+
osmock.On("WaitVolumeTargetStatusWithCustomBackoff", FakeVol.ID, []string{openstack.VolumeAvailableStatus}, mock.AnythingOfType("*wait.Backoff")).Return(nil)
292298
osmock.On("GetVolumesByName", FakeVolName).Return(FakeVolListEmpty, nil)
293299
osmock.On("GetBlockStorageOpts").Return(openstack.BlockStorageOpts{})
294300

@@ -335,6 +341,7 @@ func TestCreateVolumeWithExtraMetadata(t *testing.T) {
335341
sharedcsi.PvcNamespaceKey: FakePVCNamespace,
336342
}
337343
osmock.On("CreateVolume", FakeVolName, mock.AnythingOfType("int"), FakeVolType, FakeAvailability, "", "", "", properties).Return(&FakeVol, nil)
344+
osmock.On("WaitVolumeTargetStatusWithCustomBackoff", FakeVol.ID, []string{openstack.VolumeAvailableStatus}, mock.AnythingOfType("*wait.Backoff")).Return(nil)
338345
osmock.On("GetVolumesByName", FakeVolName).Return(FakeVolListEmpty, nil)
339346
osmock.On("GetBlockStorageOpts").Return(openstack.BlockStorageOpts{})
340347

@@ -375,6 +382,7 @@ func TestCreateVolumeFromSnapshot(t *testing.T) {
375382

376383
properties := map[string]string{cinderCSIClusterIDKey: FakeCluster}
377384
osmock.On("CreateVolume", FakeVolName, mock.AnythingOfType("int"), FakeVolType, "", FakeSnapshotID, "", "", properties).Return(&FakeVolFromSnapshot, nil)
385+
osmock.On("WaitVolumeTargetStatusWithCustomBackoff", FakeVolFromSnapshot.ID, []string{openstack.VolumeAvailableStatus}, mock.AnythingOfType("*wait.Backoff")).Return(nil)
378386
osmock.On("GetVolumesByName", FakeVolName).Return(FakeVolListEmpty, nil)
379387
osmock.On("GetBlockStorageOpts").Return(openstack.BlockStorageOpts{})
380388

@@ -422,6 +430,7 @@ func TestCreateVolumeFromSourceVolume(t *testing.T) {
422430

423431
properties := map[string]string{cinderCSIClusterIDKey: FakeCluster}
424432
osmock.On("CreateVolume", FakeVolName, mock.AnythingOfType("int"), FakeVolType, "", "", FakeVolID, "", properties).Return(&FakeVolFromSourceVolume, nil)
433+
osmock.On("WaitVolumeTargetStatusWithCustomBackoff", FakeVolFromSourceVolume.ID, []string{openstack.VolumeAvailableStatus}, mock.AnythingOfType("*wait.Backoff")).Return(nil)
425434
osmock.On("GetVolumesByName", FakeVolName).Return(FakeVolListEmpty, nil)
426435
osmock.On("GetBlockStorageOpts").Return(openstack.BlockStorageOpts{})
427436

0 commit comments

Comments
 (0)