@@ -18,15 +18,15 @@ var (
18
18
func TestUpdateDatastore_EndpointSliceReconciler (t * testing.T ) {
19
19
tests := []struct {
20
20
name string
21
- datastore K8sDatastore
21
+ datastore * K8sDatastore
22
22
incomingSlice * discoveryv1.EndpointSlice
23
- want K8sDatastore
23
+ wantPods * sync. Map
24
24
}{
25
25
{
26
26
name : "Add new pod" ,
27
- datastore : K8sDatastore {
28
- Pods : populateMap (basePod1 , basePod2 ),
29
- LLMServerPool : & v1alpha1.LLMServerPool {
27
+ datastore : & K8sDatastore {
28
+ pods : populateMap (basePod1 , basePod2 ),
29
+ llmServerPool : & v1alpha1.LLMServerPool {
30
30
Spec : v1alpha1.LLMServerPoolSpec {
31
31
TargetPort : int32 (8000 ),
32
32
},
@@ -66,15 +66,13 @@ func TestUpdateDatastore_EndpointSliceReconciler(t *testing.T) {
66
66
},
67
67
},
68
68
},
69
- want : K8sDatastore {
70
- Pods : populateMap (basePod1 , basePod2 , basePod3 ),
71
- },
69
+ wantPods : populateMap (basePod1 , basePod2 , basePod3 ),
72
70
},
73
71
{
74
72
name : "New pod, but its not ready yet. Do not add." ,
75
- datastore : K8sDatastore {
76
- Pods : populateMap (basePod1 , basePod2 ),
77
- LLMServerPool : & v1alpha1.LLMServerPool {
73
+ datastore : & K8sDatastore {
74
+ pods : populateMap (basePod1 , basePod2 ),
75
+ llmServerPool : & v1alpha1.LLMServerPool {
78
76
Spec : v1alpha1.LLMServerPoolSpec {
79
77
TargetPort : int32 (8000 ),
80
78
},
@@ -114,15 +112,13 @@ func TestUpdateDatastore_EndpointSliceReconciler(t *testing.T) {
114
112
},
115
113
},
116
114
},
117
- want : K8sDatastore {
118
- Pods : populateMap (basePod1 , basePod2 ),
119
- },
115
+ wantPods : populateMap (basePod1 , basePod2 ),
120
116
},
121
117
{
122
118
name : "Existing pod not ready, new pod added, and is ready" ,
123
- datastore : K8sDatastore {
124
- Pods : populateMap (basePod1 , basePod2 ),
125
- LLMServerPool : & v1alpha1.LLMServerPool {
119
+ datastore : & K8sDatastore {
120
+ pods : populateMap (basePod1 , basePod2 ),
121
+ llmServerPool : & v1alpha1.LLMServerPool {
126
122
Spec : v1alpha1.LLMServerPoolSpec {
127
123
TargetPort : int32 (8000 ),
128
124
},
@@ -162,18 +158,16 @@ func TestUpdateDatastore_EndpointSliceReconciler(t *testing.T) {
162
158
},
163
159
},
164
160
},
165
- want : K8sDatastore {
166
- Pods : populateMap (basePod3 , basePod2 ),
167
- },
161
+ wantPods : populateMap (basePod3 , basePod2 ),
168
162
},
169
163
}
170
164
for _ , test := range tests {
171
165
t .Run (test .name , func (t * testing.T ) {
172
- endpointSliceReconciler := & EndpointSliceReconciler {Datastore : & test .datastore , Zone : "" }
166
+ endpointSliceReconciler := & EndpointSliceReconciler {Datastore : test .datastore , Zone : "" }
173
167
endpointSliceReconciler .updateDatastore (test .incomingSlice )
174
168
175
- if mapsEqual (endpointSliceReconciler .Datastore .Pods , test .want . Pods ) {
176
- t .Errorf ("Unexpected output pod mismatch. \n Got %v \n Want: %v \n " , endpointSliceReconciler .Datastore .Pods , test .want . Pods )
169
+ if mapsEqual (endpointSliceReconciler .Datastore .pods , test .wantPods ) {
170
+ t .Errorf ("Unexpected output pod mismatch. \n Got %v \n Want: %v \n " , endpointSliceReconciler .Datastore .pods , test .wantPods )
177
171
}
178
172
})
179
173
}
0 commit comments