@@ -2372,18 +2372,53 @@ func TestReconcileInClusterSAToken(t *testing.T) {
23722372
23732373 for _ , tc := range testCases {
23742374 t .Run (tc .name , func (t * testing.T ) {
2375- ctrl := & promClientController {
2376- currentPrometheusAuthToken : tc .currentAuthToken ,
2377- metricsProviders : map [api.MetricsSource ]* api.MetricsProvider {
2378- api .PrometheusMetrics : {
2379- Source : api .PrometheusMetrics ,
2380- Prometheus : & api.Prometheus {
2381- URL : prometheusURL ,
2375+ for _ , setupMode := range []struct {
2376+ name string
2377+ init func (t * testing.T ) * promClientController
2378+ }{
2379+ {
2380+ name : "running with prom reconciler directly" ,
2381+ init : func (t * testing.T ) * promClientController {
2382+ return & promClientController {
2383+ currentPrometheusAuthToken : tc .currentAuthToken ,
2384+ metricsProviders : map [api.MetricsSource ]* api.MetricsProvider {
2385+ api .PrometheusMetrics : {
2386+ Source : api .PrometheusMetrics ,
2387+ Prometheus : & api.Prometheus {
2388+ URL : prometheusURL ,
2389+ },
23822390 },
23832391 },
2384- },
2385- inClusterConfig : tc .inClusterConfigFunc ,
2386- }
2392+ inClusterConfig : tc .inClusterConfigFunc ,
2393+ }
2394+ },
2395+ },
2396+ {
2397+ name : "running with full descheduler" ,
2398+ init : func (t * testing.T ) * promClientController {
2399+ ctx := context .Background ()
2400+ prometheusConfig := & api.Prometheus {
2401+ URL : prometheusURL ,
2402+ }
2403+ deschedulerPolicy := & api.DeschedulerPolicy {
2404+ MetricsProviders : []api.MetricsProvider {
2405+ {
2406+ Source : api .PrometheusMetrics ,
2407+ Prometheus : prometheusConfig ,
2408+ },
2409+ },
2410+ }
2411+ _ , descheduler , _ , _ := initDescheduler (t , ctx , initFeatureGates (), deschedulerPolicy , nil , false )
2412+
2413+ // Override the fields needed for this test
2414+ descheduler .promClientCtrl .currentPrometheusAuthToken = tc .currentAuthToken
2415+ descheduler .promClientCtrl .inClusterConfig = tc .inClusterConfigFunc
2416+ return descheduler .promClientCtrl
2417+ },
2418+ },
2419+ } {
2420+ t .Run (setupMode .name , func (t * testing.T ) {
2421+ ctrl := setupMode .init (t )
23872422
23882423 // Set previous transport and client if test expects them to be cleared
23892424 if tc .expectPreviousTransportCleared {
@@ -2455,6 +2490,8 @@ func TestReconcileInClusterSAToken(t *testing.T) {
24552490 t .Error ("Expected promClient to be cleared, but it was set" )
24562491 }
24572492 }
2493+ })
2494+ }
24582495 })
24592496 }
24602497}
0 commit comments