@@ -187,6 +187,7 @@ func TestReconcileEstimatorConnection(t *testing.T) {
187
187
key util.QueueKey
188
188
disableSchedulerEstimatorInPullMode bool
189
189
expectedError bool
190
+ expectEstablishConnection bool
190
191
}{
191
192
{
192
193
name : "Invalid key" ,
@@ -203,22 +204,32 @@ func TestReconcileEstimatorConnection(t *testing.T) {
203
204
key : clusterName ,
204
205
disableSchedulerEstimatorInPullMode : true ,
205
206
expectedError : false ,
207
+ expectEstablishConnection : false ,
206
208
},
207
209
{
208
210
name : "Cluster in pull mode, estimator enabled" ,
209
211
key : clusterName ,
210
212
disableSchedulerEstimatorInPullMode : false ,
211
213
expectedError : false ,
214
+ expectEstablishConnection : true ,
212
215
},
213
216
}
214
217
215
218
for _ , tt := range tests {
216
219
t .Run (tt .name , func (t * testing.T ) {
217
220
scheduler .disableSchedulerEstimatorInPullMode = tt .disableSchedulerEstimatorInPullMode
221
+
218
222
err := scheduler .reconcileEstimatorConnection (tt .key )
219
223
if (err != nil ) != tt .expectedError {
220
224
t .Errorf ("reconcileEstimatorConnection() error = %v, expectedError %v" , err , tt .expectedError )
221
225
}
226
+
227
+ // We can't directly assert whether EstablishConnection is called.
228
+ // Instead, we'll check for conditions around its invocation.
229
+ // If EstablishConnection should be called, the error should be nil, and no early returns should have occurred.
230
+ if tt .expectEstablishConnection && err != nil {
231
+ t .Errorf ("Expected EstablishConnection to be called, but got error: %v" , err )
232
+ }
222
233
})
223
234
}
224
235
}
0 commit comments