From ea01caa02de04f034efdb887a13f92af771af87a Mon Sep 17 00:00:00 2001 From: Max Cao Date: Thu, 24 Oct 2024 13:03:25 -0700 Subject: [PATCH] Fix broken tests Signed-off-by: Max Cao --- controllers/keda/suite_test.go | 12 ++++++++---- pkg/scaling/scale_handler_test.go | 4 ++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/controllers/keda/suite_test.go b/controllers/keda/suite_test.go index 482a45b135c..fec3acd241b 100644 --- a/controllers/keda/suite_test.go +++ b/controllers/keda/suite_test.go @@ -36,6 +36,7 @@ import ( kedav1alpha1 "github.com/kedacore/keda/v2/apis/keda/v1alpha1" "github.com/kedacore/keda/v2/pkg/eventemitter" "github.com/kedacore/keda/v2/pkg/k8s" + "github.com/kedacore/keda/v2/pkg/scalers/authentication" "github.com/kedacore/keda/v2/pkg/scaling" //+kubebuilder:scaffold:imports ) @@ -91,19 +92,22 @@ var _ = BeforeSuite(func() { scaleClient, _, err := k8s.InitScaleClient(k8sManager) Expect(err).ToNot(HaveOccurred()) + authClientSet := &authentication.AuthClientSet{} + err = (&ScaledObjectReconciler{ Client: k8sManager.GetClient(), Scheme: k8sManager.GetScheme(), - ScaleHandler: scaling.NewScaleHandler(k8sManager.GetClient(), scaleClient, k8sManager.GetScheme(), time.Duration(10), k8sManager.GetEventRecorderFor("keda-operator"), nil), + ScaleHandler: scaling.NewScaleHandler(k8sManager.GetClient(), scaleClient, k8sManager.GetScheme(), time.Duration(10), k8sManager.GetEventRecorderFor("keda-operator"), authClientSet), ScaleClient: scaleClient, EventEmitter: eventemitter.NewEventEmitter(k8sManager.GetClient(), k8sManager.GetEventRecorderFor("keda-operator"), "kubernetes-default", nil), }).SetupWithManager(k8sManager, controller.Options{}) Expect(err).ToNot(HaveOccurred()) err = (&ScaledJobReconciler{ - Client: k8sManager.GetClient(), - Scheme: k8sManager.GetScheme(), - EventEmitter: eventemitter.NewEventEmitter(k8sManager.GetClient(), k8sManager.GetEventRecorderFor("keda-operator"), "kubernetes-default", nil), + Client: k8sManager.GetClient(), + Scheme: k8sManager.GetScheme(), + EventEmitter: eventemitter.NewEventEmitter(k8sManager.GetClient(), k8sManager.GetEventRecorderFor("keda-operator"), "kubernetes-default", nil), + AuthClientSet: authClientSet, }).SetupWithManager(k8sManager, controller.Options{}) Expect(err).ToNot(HaveOccurred()) diff --git a/pkg/scaling/scale_handler_test.go b/pkg/scaling/scale_handler_test.go index 1dd00da0fcc..cca23893f2a 100644 --- a/pkg/scaling/scale_handler_test.go +++ b/pkg/scaling/scale_handler_test.go @@ -43,6 +43,7 @@ import ( mock_scalers "github.com/kedacore/keda/v2/pkg/mock/mock_scaler" "github.com/kedacore/keda/v2/pkg/mock/mock_scaling/mock_executor" "github.com/kedacore/keda/v2/pkg/scalers" + "github.com/kedacore/keda/v2/pkg/scalers/authentication" "github.com/kedacore/keda/v2/pkg/scalers/scalersconfig" "github.com/kedacore/keda/v2/pkg/scaling/cache" "github.com/kedacore/keda/v2/pkg/scaling/cache/metricscache" @@ -538,6 +539,9 @@ func TestCheckScaledObjectScalersWithTriggerAuthError(t *testing.T) { scalerCaches: map[string]*cache.ScalersCache{}, scalerCachesLock: &sync.RWMutex{}, scaledObjectsMetricCache: metricscache.NewMetricsCache(), + authClientSet: &authentication.AuthClientSet{ + SecretLister: nil, + }, } isActive, isError, _, activeTriggers, _ := sh.getScaledObjectState(context.TODO(), &scaledObject)