@@ -75,8 +75,17 @@ const (
7575
7676var (
7777 noResyncPeriodFunc = func () time.Duration { return 0 }
78+ testNodeSpec = v1.NodeSpec {
79+ ProviderID : "gce://test-project/us-central1-b/test" ,
80+ }
7881)
7982
83+ func testNodeSpecWithProviderID (providerID string ) v1.NodeSpec {
84+ return v1.NodeSpec {
85+ ProviderID : providerID ,
86+ }
87+ }
88+
8089func hasNodeInProcessing (ca * cloudCIDRAllocator , name string ) bool {
8190 if ca .queue .Len () > 0 {
8291 val , _ := ca .queue .Get ()
@@ -102,6 +111,7 @@ func TestBoundedRetries(t *testing.T) {
102111 ObjectMeta : metav1.ObjectMeta {
103112 Name : nodeName ,
104113 },
114+ Spec : testNodeSpecWithProviderID ("gce://test-project/us-central1-b/testNode" ),
105115 })
106116 for hasNodeInProcessing (ca , nodeName ) {
107117 // wait for node to finish processing (should terminate and not time out)
@@ -122,6 +132,9 @@ func TestNodeTopologyQueuePeriodicSync(t *testing.T) {
122132 ObjectMeta : metav1.ObjectMeta {
123133 Name : "testNodeTopologyLifecycle" ,
124134 },
135+ Spec : v1.NodeSpec {
136+ ProviderID : "gce://test-project/us-central1-b/testNodeTopologyLifecycle" ,
137+ },
125138 }
126139 mscnode := & v1.Node {
127140 ObjectMeta : metav1.ObjectMeta {
@@ -130,6 +143,9 @@ func TestNodeTopologyQueuePeriodicSync(t *testing.T) {
130143 testNodePoolSubnetLabelPrefix : "subnet1" ,
131144 },
132145 },
146+ Spec : v1.NodeSpec {
147+ ProviderID : "gce://test-project/us-central1-b/testNode" ,
148+ },
133149 }
134150 fakeClient := fake .NewSimpleClientset (defaultnode , mscnode )
135151 fakeInformerFactory := informers .NewSharedInformerFactory (fakeClient , time .Second )
@@ -180,6 +196,9 @@ func TestNodeTopologyQueuePeriodicSync(t *testing.T) {
180196 testNodePoolSubnetLabelPrefix : "subnet2" ,
181197 },
182198 },
199+ Spec : v1.NodeSpec {
200+ ProviderID : "gce://test-project/us-central1-b/testNode2" ,
201+ },
183202 }
184203 fakeClient .Tracker ().Add (mscnode2 )
185204 time .Sleep (time .Second * 1 )
@@ -202,6 +221,9 @@ func TestNodeTopologyCR_AddOrUpdateNode(t *testing.T) {
202221 ObjectMeta : metav1.ObjectMeta {
203222 Name : "testNodeTopologyLifecycle" ,
204223 },
224+ Spec : v1.NodeSpec {
225+ ProviderID : "gce://test-project/us-central1-b/testNodeTopologyLifecycle" ,
226+ },
205227 }
206228 mscnode := & v1.Node {
207229 ObjectMeta : metav1.ObjectMeta {
@@ -210,6 +232,9 @@ func TestNodeTopologyCR_AddOrUpdateNode(t *testing.T) {
210232 testNodePoolSubnetLabelPrefix : "subnet1" ,
211233 },
212234 },
235+ Spec : v1.NodeSpec {
236+ ProviderID : "gce://test-project/us-central1-b/testNode" ,
237+ },
213238 }
214239 fakeClient := fake .NewSimpleClientset (defaultnode )
215240 fakeInformerFactory := informers .NewSharedInformerFactory (fakeClient , time .Second )
@@ -254,6 +279,9 @@ func TestNodeTopologyCR_AddOrUpdateNode(t *testing.T) {
254279 testNodePoolSubnetLabelPrefix : "subnet2" ,
255280 },
256281 },
282+ Spec : v1.NodeSpec {
283+ ProviderID : "gce://test-project/us-central1-b/testNode2" ,
284+ },
257285 }
258286 fakeClient .Tracker ().Add (mscnode2 )
259287 expectedSubnets = []string {"subnet-def" , "subnet1" , "subnet2" }
@@ -316,6 +344,7 @@ func TestNodeTopologyCR_DeleteNode(t *testing.T) {
316344 ObjectMeta : metav1.ObjectMeta {
317345 Name : "nodeTopologyDefautNode" ,
318346 },
347+ Spec : testNodeSpecWithProviderID ("gce://test-project/us-central1-b/nodeTopologyDefautNode" ),
319348 }
320349 fakeClient := fake .NewSimpleClientset (defaultnode )
321350 fakeInformerFactory := informers .NewSharedInformerFactory (fakeClient , time .Second )
@@ -343,6 +372,9 @@ func TestNodeTopologyCR_DeleteNode(t *testing.T) {
343372 testNodePoolSubnetLabelPrefix : "subnet1" ,
344373 },
345374 },
375+ Spec : v1.NodeSpec {
376+ ProviderID : "gce://test-project/us-central1-b/testNode" ,
377+ },
346378 }
347379 fakeClient .Tracker ().Add (mscnode )
348380
@@ -555,9 +587,7 @@ func TestUpdateCIDRAllocation(t *testing.T) {
555587 ObjectMeta : metav1.ObjectMeta {
556588 Name : "test" ,
557589 },
558- Spec : v1.NodeSpec {
559- ProviderID : "test" ,
560- },
590+ Spec : testNodeSpec ,
561591 },
562592 },
563593 Clientset : fake .NewSimpleClientset (),
@@ -579,9 +609,7 @@ func TestUpdateCIDRAllocation(t *testing.T) {
579609 ObjectMeta : metav1.ObjectMeta {
580610 Name : "test" ,
581611 },
582- Spec : v1.NodeSpec {
583- ProviderID : "gce://test-project/us-central1-b/test" ,
584- },
612+ Spec : testNodeSpec ,
585613 },
586614 },
587615 Clientset : fake .NewSimpleClientset (),
@@ -603,9 +631,7 @@ func TestUpdateCIDRAllocation(t *testing.T) {
603631 ObjectMeta : metav1.ObjectMeta {
604632 Name : "test" ,
605633 },
606- Spec : v1.NodeSpec {
607- ProviderID : "gce://test-project/us-central1-b/test" ,
608- },
634+ Spec : testNodeSpec ,
609635 },
610636 },
611637 Clientset : fake .NewSimpleClientset (),
@@ -646,9 +672,7 @@ func TestUpdateCIDRAllocation(t *testing.T) {
646672 ObjectMeta : metav1.ObjectMeta {
647673 Name : "test" ,
648674 },
649- Spec : v1.NodeSpec {
650- ProviderID : "gce://test-project/us-central1-b/test" ,
651- },
675+ Spec : testNodeSpec ,
652676 },
653677 },
654678 Clientset : fake .NewSimpleClientset (),
@@ -690,9 +714,7 @@ func TestUpdateCIDRAllocation(t *testing.T) {
690714 ObjectMeta : metav1.ObjectMeta {
691715 Name : "test" ,
692716 },
693- Spec : v1.NodeSpec {
694- ProviderID : "gce://test-project/us-central1-b/test" ,
695- },
717+ Spec : testNodeSpec ,
696718 },
697719 },
698720 Clientset : fake .NewSimpleClientset (),
@@ -735,9 +757,7 @@ func TestUpdateCIDRAllocation(t *testing.T) {
735757 ObjectMeta : metav1.ObjectMeta {
736758 Name : "test" ,
737759 },
738- Spec : v1.NodeSpec {
739- ProviderID : "gce://test-project/us-central1-b/test" ,
740- },
760+ Spec : testNodeSpec ,
741761 },
742762 },
743763 Clientset : fake .NewSimpleClientset (),
@@ -780,9 +800,7 @@ func TestUpdateCIDRAllocation(t *testing.T) {
780800 ObjectMeta : metav1.ObjectMeta {
781801 Name : "test" ,
782802 },
783- Spec : v1.NodeSpec {
784- ProviderID : "gce://test-project/us-central1-b/test" ,
785- },
803+ Spec : testNodeSpec ,
786804 },
787805 },
788806 Clientset : fake .NewSimpleClientset (),
@@ -820,9 +838,7 @@ func TestUpdateCIDRAllocation(t *testing.T) {
820838 ObjectMeta : metav1.ObjectMeta {
821839 Name : "test" ,
822840 },
823- Spec : v1.NodeSpec {
824- ProviderID : "gce://test-project/us-central1-b/test" ,
825- },
841+ Spec : testNodeSpec ,
826842 },
827843 },
828844 Clientset : fake .NewSimpleClientset (),
@@ -855,9 +871,7 @@ func TestUpdateCIDRAllocation(t *testing.T) {
855871 ObjectMeta : metav1.ObjectMeta {
856872 Name : "test" ,
857873 },
858- Spec : v1.NodeSpec {
859- ProviderID : "gce://test-project/us-central1-b/test" ,
860- },
874+ Spec : testNodeSpec ,
861875 },
862876 },
863877 Clientset : fake .NewSimpleClientset (),
@@ -979,9 +993,7 @@ func TestUpdateCIDRAllocation(t *testing.T) {
979993 ObjectMeta : metav1.ObjectMeta {
980994 Name : "test" ,
981995 },
982- Spec : v1.NodeSpec {
983- ProviderID : "gce://test-project/us-central1-b/test" ,
984- },
996+ Spec : testNodeSpec ,
985997 },
986998 },
987999 Clientset : fake .NewSimpleClientset (),
@@ -1033,9 +1045,7 @@ func TestUpdateCIDRAllocation(t *testing.T) {
10331045 ObjectMeta : metav1.ObjectMeta {
10341046 Name : "test" ,
10351047 },
1036- Spec : v1.NodeSpec {
1037- ProviderID : "gce://test-project/us-central1-b/test" ,
1038- },
1048+ Spec : testNodeSpec ,
10391049 },
10401050 },
10411051 Clientset : fake .NewSimpleClientset (),
@@ -1093,9 +1103,7 @@ func TestUpdateCIDRAllocation(t *testing.T) {
10931103 ObjectMeta : metav1.ObjectMeta {
10941104 Name : "test" ,
10951105 },
1096- Spec : v1.NodeSpec {
1097- ProviderID : "gce://test-project/us-central1-b/test" ,
1098- },
1106+ Spec : testNodeSpec ,
10991107 Status : v1.NodeStatus {
11001108 Capacity : v1.ResourceList {},
11011109 },
@@ -1152,9 +1160,7 @@ func TestUpdateCIDRAllocation(t *testing.T) {
11521160 utilnode .NodePoolPodRangeLabelPrefix : defaultSecondaryRangeA ,
11531161 },
11541162 },
1155- Spec : v1.NodeSpec {
1156- ProviderID : "gce://test-project/us-central1-b/test" ,
1157- },
1163+ Spec : testNodeSpec ,
11581164 Status : v1.NodeStatus {
11591165 Capacity : v1.ResourceList {},
11601166 },
@@ -1212,9 +1218,7 @@ func TestUpdateCIDRAllocation(t *testing.T) {
12121218 networkv1 .NodeNetworkAnnotationKey : fmt .Sprintf ("[{\" name\" :\" %s\" },{\" name\" :\" %s\" }]" , networkv1 .DefaultPodNetworkName , redNetworkName ),
12131219 },
12141220 },
1215- Spec : v1.NodeSpec {
1216- ProviderID : "gce://test-project/us-central1-b/test" ,
1217- },
1221+ Spec : testNodeSpec ,
12181222 Status : v1.NodeStatus {
12191223 Capacity : v1.ResourceList {},
12201224 },
@@ -1277,9 +1281,7 @@ func TestUpdateCIDRAllocation(t *testing.T) {
12771281 networkv1 .NodeNetworkAnnotationKey : fmt .Sprintf ("[{\" name\" :\" %s\" },{\" name\" :\" %s\" }]" , networkv1 .DefaultPodNetworkName , redNetworkName ),
12781282 },
12791283 },
1280- Spec : v1.NodeSpec {
1281- ProviderID : "gce://test-project/us-central1-b/test" ,
1282- },
1284+ Spec : testNodeSpec ,
12831285 Status : v1.NodeStatus {
12841286 Capacity : v1.ResourceList {},
12851287 },
@@ -2297,9 +2299,7 @@ func TestUpdateCIDRAllocation(t *testing.T) {
22972299 networkv1 .NodeNetworkAnnotationKey : fmt .Sprintf ("[{\" name\" :\" %s\" },{\" name\" :\" %s\" }]" , networkv1 .DefaultPodNetworkName , redNetworkName ),
22982300 },
22992301 },
2300- Spec : v1.NodeSpec {
2301- ProviderID : "gce://test-project/us-central1-b/test" ,
2302- },
2302+ Spec : testNodeSpec ,
23032303 Status : v1.NodeStatus {
23042304 Capacity : v1.ResourceList {},
23052305 },
0 commit comments