@@ -23,8 +23,7 @@ import (
23
23
"regexp"
24
24
"testing"
25
25
26
- v1 "k8s.io/api/core/v1"
27
- storagev1 "k8s.io/api/storage/v1"
26
+ "k8s.io/api/core/v1"
28
27
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
29
28
"k8s.io/apimachinery/pkg/runtime"
30
29
"k8s.io/apimachinery/pkg/types"
@@ -49,7 +48,6 @@ func TestSyncHandler(t *testing.T) {
49
48
tests := []struct {
50
49
name string
51
50
csiMigrationEnabled bool
52
- storageClass * storagev1.StorageClass
53
51
pvcKey string
54
52
pv * v1.PersistentVolume
55
53
pvc * v1.PersistentVolumeClaim
@@ -59,27 +57,14 @@ func TestSyncHandler(t *testing.T) {
59
57
}{
60
58
{
61
59
name : "when pvc has no PV binding" ,
62
- pvc : getFakePersistentVolumeClaim ("no-pv-pvc" , "" , "" , "" ),
60
+ pvc : getFakePersistentVolumeClaim ("no-pv-pvc" , "" , "" ),
63
61
pvcKey : "default/no-pv-pvc" ,
64
62
hasError : true ,
65
63
},
66
- {
67
- name : "when pvc has no storageclass" ,
68
- pv : getFakePersistentVolume ("vol-1" , csitranslationplugins .AWSEBSInTreePluginName , "no-sc-pvc-vol-1" ),
69
- pvc : getFakePersistentVolumeClaim ("no-sc-pvc" , "vol-1" , "" , "no-sc-pvc-vol-1" ),
70
- pvcKey : "default/no-sc-pvc" ,
71
- },
72
- {
73
- name : "when pvc storageclass is missing" ,
74
- pv : getFakePersistentVolume ("vol-2" , csitranslationplugins .AWSEBSInTreePluginName , "missing-sc-pvc-vol-2" ),
75
- pvc : getFakePersistentVolumeClaim ("missing-sc-pvc" , "vol-2" , "resizable" , "missing-sc-pvc-vol-2" ),
76
- pvcKey : "default/missing-sc-pvc" ,
77
- },
78
64
{
79
65
name : "when pvc and pv has everything for in-tree plugin" ,
80
66
pv : getFakePersistentVolume ("vol-3" , csitranslationplugins .AWSEBSInTreePluginName , "good-pvc-vol-3" ),
81
- pvc : getFakePersistentVolumeClaim ("good-pvc" , "vol-3" , "resizable2" , "good-pvc-vol-3" ),
82
- storageClass : getFakeStorageClass ("resizable2" , csitranslationplugins .AWSEBSInTreePluginName ),
67
+ pvc : getFakePersistentVolumeClaim ("good-pvc" , "vol-3" , "good-pvc-vol-3" ),
83
68
pvcKey : "default/good-pvc" ,
84
69
expansionCalled : true ,
85
70
expectedAnnotation : map [string ]string {volumetypes .VolumeResizerKey : csitranslationplugins .AWSEBSInTreePluginName },
@@ -88,16 +73,14 @@ func TestSyncHandler(t *testing.T) {
88
73
name : "when csi migration is enabled for a in-tree plugin" ,
89
74
csiMigrationEnabled : true ,
90
75
pv : getFakePersistentVolume ("vol-4" , csitranslationplugins .AWSEBSInTreePluginName , "csi-pvc-vol-4" ),
91
- pvc : getFakePersistentVolumeClaim ("csi-pvc" , "vol-4" , "resizable3" , "csi-pvc-vol-4" ),
92
- storageClass : getFakeStorageClass ("resizable3" , csitranslationplugins .AWSEBSInTreePluginName ),
76
+ pvc : getFakePersistentVolumeClaim ("csi-pvc" , "vol-4" , "csi-pvc-vol-4" ),
93
77
pvcKey : "default/csi-pvc" ,
94
78
expectedAnnotation : map [string ]string {volumetypes .VolumeResizerKey : csitranslationplugins .AWSEBSDriverName },
95
79
},
96
80
{
97
81
name : "for csi plugin without migration path" ,
98
82
pv : getFakePersistentVolume ("vol-5" , "com.csi.ceph" , "ceph-csi-pvc-vol-5" ),
99
- pvc : getFakePersistentVolumeClaim ("ceph-csi-pvc" , "vol-5" , "resizable4" , "ceph-csi-pvc-vol-5" ),
100
- storageClass : getFakeStorageClass ("resizable4" , "com.csi.ceph" ),
83
+ pvc : getFakePersistentVolumeClaim ("ceph-csi-pvc" , "vol-5" , "ceph-csi-pvc-vol-5" ),
101
84
pvcKey : "default/ceph-csi-pvc" ,
102
85
expansionCalled : false ,
103
86
hasError : false ,
@@ -110,7 +93,6 @@ func TestSyncHandler(t *testing.T) {
110
93
informerFactory := informers .NewSharedInformerFactory (fakeKubeClient , controller .NoResyncPeriodFunc ())
111
94
pvcInformer := informerFactory .Core ().V1 ().PersistentVolumeClaims ()
112
95
pvInformer := informerFactory .Core ().V1 ().PersistentVolumes ()
113
- storageClassInformer := informerFactory .Storage ().V1 ().StorageClasses ()
114
96
115
97
pvc := test .pvc
116
98
if tc .pv != nil {
@@ -122,11 +104,8 @@ func TestSyncHandler(t *testing.T) {
122
104
}
123
105
allPlugins := []volume.VolumePlugin {}
124
106
allPlugins = append (allPlugins , awsebs .ProbeVolumePlugins ()... )
125
- if tc .storageClass != nil {
126
- informerFactory .Storage ().V1 ().StorageClasses ().Informer ().GetIndexer ().Add (tc .storageClass )
127
- }
128
107
translator := csitrans .New ()
129
- expc , err := NewExpandController (fakeKubeClient , pvcInformer , pvInformer , storageClassInformer , nil , allPlugins , translator , csimigration .NewPluginManager (translator ), nil )
108
+ expc , err := NewExpandController (fakeKubeClient , pvcInformer , pvInformer , nil , allPlugins , translator , csimigration .NewPluginManager (translator ), nil )
130
109
if err != nil {
131
110
t .Fatalf ("error creating expand controller : %v" , err )
132
111
}
@@ -226,7 +205,7 @@ func getFakePersistentVolume(volumeName, pluginName string, pvcUID types.UID) *v
226
205
return pv
227
206
}
228
207
229
- func getFakePersistentVolumeClaim (pvcName , volumeName , scName string , uid types.UID ) * v1.PersistentVolumeClaim {
208
+ func getFakePersistentVolumeClaim (pvcName , volumeName string , uid types.UID ) * v1.PersistentVolumeClaim {
230
209
pvc := & v1.PersistentVolumeClaim {
231
210
ObjectMeta : metav1.ObjectMeta {Name : pvcName , Namespace : "default" , UID : uid },
232
211
Spec : v1.PersistentVolumeClaimSpec {},
@@ -235,15 +214,5 @@ func getFakePersistentVolumeClaim(pvcName, volumeName, scName string, uid types.
235
214
pvc .Spec .VolumeName = volumeName
236
215
}
237
216
238
- if scName != "" {
239
- pvc .Spec .StorageClassName = & scName
240
- }
241
217
return pvc
242
218
}
243
-
244
- func getFakeStorageClass (scName , pluginName string ) * storagev1.StorageClass {
245
- return & storagev1.StorageClass {
246
- ObjectMeta : metav1.ObjectMeta {Name : scName },
247
- Provisioner : pluginName ,
248
- }
249
- }
0 commit comments