@@ -73,6 +73,12 @@ func TestInferencePoolConvertTo(t *testing.T) {
7373						{
7474							GatewayRef : ParentGatewayReference {Name : "my-gateway" },
7575							Conditions : []metav1.Condition {
76+ 								{ // v1alpha2 default condition is skipped from conversion. 
77+ 									Type :               string (v1 .InferencePoolConditionAccepted ),
78+ 									Status :             metav1 .ConditionUnknown ,
79+ 									Reason :             string (InferencePoolReasonPending ),
80+ 									LastTransitionTime : timestamp ,
81+ 								},
7682								{
7783									Type :               string (InferencePoolConditionAccepted ),
7884									Status :             metav1 .ConditionTrue ,
@@ -127,7 +133,7 @@ func TestInferencePoolConvertTo(t *testing.T) {
127133			wantErr : false ,
128134		},
129135		{
130- 			name : "conversion from v1alpha2 to v1 with empty extensionRef" ,
136+ 			name : "conversion from v1alpha2 to v1 with empty extensionRef and default v1alpha2 status condition " ,
131137			src : & InferencePool {
132138				TypeMeta : metav1.TypeMeta {
133139					Kind :       "InferencePool" ,
@@ -149,9 +155,9 @@ func TestInferencePoolConvertTo(t *testing.T) {
149155							GatewayRef : ParentGatewayReference {Name : "my-gateway" },
150156							Conditions : []metav1.Condition {
151157								{
152- 									Type :               string (InferencePoolConditionAccepted ),
153- 									Status :             metav1 .ConditionTrue ,
154- 									Reason :             string (InferencePoolReasonAccepted ),
158+ 									Type :               string (v1 . InferencePoolConditionAccepted ),
159+ 									Status :             metav1 .ConditionUnknown ,
160+ 									Reason :             string (InferencePoolReasonPending ),
155161									LastTransitionTime : timestamp ,
156162								},
157163							},
@@ -180,14 +186,6 @@ func TestInferencePoolConvertTo(t *testing.T) {
180186					Parents : []v1.ParentStatus {
181187						{
182188							ParentRef : v1.ParentReference {Name : "my-gateway" },
183- 							Conditions : []metav1.Condition {
184- 								{
185- 									Type :               string (v1 .InferencePoolConditionAccepted ),
186- 									Status :             metav1 .ConditionTrue ,
187- 									Reason :             string (v1 .InferencePoolReasonAccepted ),
188- 									LastTransitionTime : timestamp ,
189- 								},
190- 							},
191189						},
192190					},
193191				},
@@ -300,7 +298,7 @@ func TestInferencePoolConvertFrom(t *testing.T) {
300298			wantErr : false ,
301299		},
302300		{
303- 			name : "conversion from v1 to v1alpha2 with empty extensionRef" ,
301+ 			name : "conversion from v1 to v1alpha2 with empty extensionRef and nil status condition " ,
304302			src : & v1.InferencePool {
305303				TypeMeta : metav1.TypeMeta {
306304					Kind :       "InferencePool" ,
@@ -322,14 +320,6 @@ func TestInferencePoolConvertFrom(t *testing.T) {
322320					Parents : []v1.ParentStatus {
323321						{
324322							ParentRef : v1.ParentReference {Name : "my-gateway" },
325- 							Conditions : []metav1.Condition {
326- 								{
327- 									Type :               string (v1 .InferencePoolConditionAccepted ),
328- 									Status :             metav1 .ConditionTrue ,
329- 									Reason :             string (v1 .InferencePoolReasonAccepted ),
330- 									LastTransitionTime : timestamp ,
331- 								},
332- 							},
333323						},
334324					},
335325				},
@@ -353,14 +343,60 @@ func TestInferencePoolConvertFrom(t *testing.T) {
353343					Parents : []PoolStatus {
354344						{
355345							GatewayRef : ParentGatewayReference {Name : "my-gateway" },
356- 							Conditions : []metav1.Condition {
357- 								{
358- 									Type :               string (InferencePoolConditionAccepted ),
359- 									Status :             metav1 .ConditionTrue ,
360- 									Reason :             string (InferencePoolReasonAccepted ),
361- 									LastTransitionTime : timestamp ,
362- 								},
363- 							},
346+ 						},
347+ 					},
348+ 				},
349+ 			},
350+ 			wantErr : false ,
351+ 		},
352+ 		{
353+ 			name : "conversion from v1 to v1alpha2 with empty extensionRef and empty status condition" ,
354+ 			src : & v1.InferencePool {
355+ 				TypeMeta : metav1.TypeMeta {
356+ 					Kind :       "InferencePool" ,
357+ 					APIVersion : v1 .GroupVersion .String (),
358+ 				},
359+ 				ObjectMeta : metav1.ObjectMeta {
360+ 					Name :      "test-pool" ,
361+ 					Namespace : "test-ns" ,
362+ 				},
363+ 				Spec : v1.InferencePoolSpec {
364+ 					Selector : v1.LabelSelector {
365+ 						MatchLabels : map [v1.LabelKey ]v1.LabelValue {
366+ 							"app" : "my-model-server" ,
367+ 						},
368+ 					},
369+ 					TargetPorts : []v1.Port {{Number : v1 .PortNumber (int32 (8080 ))}},
370+ 				},
371+ 				Status : v1.InferencePoolStatus {
372+ 					Parents : []v1.ParentStatus {
373+ 						{
374+ 							ParentRef :  v1.ParentReference {Name : "my-gateway" },
375+ 							Conditions : []metav1.Condition {},
376+ 						},
377+ 					},
378+ 				},
379+ 			},
380+ 			want : & InferencePool {
381+ 				TypeMeta : metav1.TypeMeta {
382+ 					Kind :       "InferencePool" ,
383+ 					APIVersion : GroupVersion .String (),
384+ 				},
385+ 				ObjectMeta : metav1.ObjectMeta {
386+ 					Name :      "test-pool" ,
387+ 					Namespace : "test-ns" ,
388+ 				},
389+ 				Spec : InferencePoolSpec {
390+ 					Selector : map [LabelKey ]LabelValue {
391+ 						"app" : "my-model-server" ,
392+ 					},
393+ 					TargetPortNumber : 8080 ,
394+ 				},
395+ 				Status : InferencePoolStatus {
396+ 					Parents : []PoolStatus {
397+ 						{
398+ 							GatewayRef : ParentGatewayReference {Name : "my-gateway" },
399+ 							Conditions : []metav1.Condition {},
364400						},
365401					},
366402				},
0 commit comments