From eb24de91572ba57eca5258766ff9abce89b1a009 Mon Sep 17 00:00:00 2001 From: Sunny Date: Tue, 17 Jan 2023 22:15:08 +0000 Subject: [PATCH] Set rate limiter option in test reconcilers Set the default rate limiter configuration used in main.go in the test reconcilers as well. Signed-off-by: Sunny --- controllers/suite_test.go | 20 +++++++++++++------- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/controllers/suite_test.go b/controllers/suite_test.go index 7f7458a7d..4ab956a5c 100644 --- a/controllers/suite_test.go +++ b/controllers/suite_test.go @@ -26,9 +26,6 @@ import ( "strings" "testing" - "github.com/fluxcd/pkg/runtime/controller" - "github.com/fluxcd/pkg/runtime/testenv" - "github.com/fluxcd/pkg/ssa" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" @@ -39,6 +36,10 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/apiutil" + "github.com/fluxcd/pkg/runtime/controller" + "github.com/fluxcd/pkg/runtime/testenv" + "github.com/fluxcd/pkg/ssa" + apiv1 "github.com/fluxcd/notification-controller/api/v1beta2" // +kubebuilder:scaffold:imports ) @@ -53,7 +54,6 @@ var ( func TestMain(m *testing.M) { var err error utilruntime.Must(apiv1.AddToScheme(scheme.Scheme)) - //utilruntime.Must(sourcev1.AddToScheme(scheme.Scheme)) testEnv = testenv.New(testenv.WithCRDPath( filepath.Join("..", "config", "crd", "bases"), @@ -72,7 +72,9 @@ func TestMain(m *testing.M) { Metrics: testMetricsH, ControllerName: controllerName, EventRecorder: testEnv.GetEventRecorderFor(controllerName), - }).SetupWithManager(testEnv); err != nil { + }).SetupWithManagerAndOptions(testEnv, AlertReconcilerOptions{ + RateLimiter: controller.GetDefaultRateLimiter(), + }); err != nil { panic(fmt.Sprintf("Failed to start AlerReconciler: %v", err)) } @@ -81,7 +83,9 @@ func TestMain(m *testing.M) { Metrics: testMetricsH, ControllerName: controllerName, EventRecorder: testEnv.GetEventRecorderFor(controllerName), - }).SetupWithManager(testEnv); err != nil { + }).SetupWithManagerAndOptions(testEnv, ProviderReconcilerOptions{ + RateLimiter: controller.GetDefaultRateLimiter(), + }); err != nil { panic(fmt.Sprintf("Failed to start ProviderReconciler: %v", err)) } @@ -90,7 +94,9 @@ func TestMain(m *testing.M) { Metrics: testMetricsH, ControllerName: controllerName, EventRecorder: testEnv.GetEventRecorderFor(controllerName), - }).SetupWithManager(testEnv); err != nil { + }).SetupWithManagerAndOptions(testEnv, ReceiverReconcilerOptions{ + RateLimiter: controller.GetDefaultRateLimiter(), + }); err != nil { panic(fmt.Sprintf("Failed to start ReceiverReconciler: %v", err)) } diff --git a/go.mod b/go.mod index 9d7718b1a..6d7a1d751 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/fluxcd/pkg/apis/event v0.2.0 github.com/fluxcd/pkg/apis/meta v0.18.0 github.com/fluxcd/pkg/masktoken v0.2.0 - github.com/fluxcd/pkg/runtime v0.24.0 + github.com/fluxcd/pkg/runtime v0.26.0 github.com/fluxcd/pkg/ssa v0.22.0 github.com/getsentry/sentry-go v0.15.0 github.com/go-logr/logr v1.2.3 diff --git a/go.sum b/go.sum index 9037c3f93..8a03c1fae 100644 --- a/go.sum +++ b/go.sum @@ -188,8 +188,8 @@ github.com/fluxcd/pkg/apis/meta v0.18.0 h1:s0LeulWcQ4DxVX6805vgDTxlA6bAYk+Lq1QHS github.com/fluxcd/pkg/apis/meta v0.18.0/go.mod h1:pYvXRFi1UKNNrGR34jw3uqOnMXw9X6dTkML8j5Z7tis= github.com/fluxcd/pkg/masktoken v0.2.0 h1:HoSPTk4l1fz5Fevs2vVRvZGru33blfMwWSZKsHdfG/0= github.com/fluxcd/pkg/masktoken v0.2.0/go.mod h1:EA7GleAHL33kN6kTW06m5R3/Q26IyuGO7Ef/0CtpDI0= -github.com/fluxcd/pkg/runtime v0.24.0 h1:rQmm5Xq8K7f8xcPj1oNOInM1x4YwmgTucZJOP51Xmr4= -github.com/fluxcd/pkg/runtime v0.24.0/go.mod h1:I2T+HWVNzX0cxm9TgH+SVNHTwqlmEDiSke43JXsq9iY= +github.com/fluxcd/pkg/runtime v0.26.0 h1:j78f52xzpbR8xOvvemGwbGt4BLxpn9FOzim5tngOYvo= +github.com/fluxcd/pkg/runtime v0.26.0/go.mod h1:I2T+HWVNzX0cxm9TgH+SVNHTwqlmEDiSke43JXsq9iY= github.com/fluxcd/pkg/ssa v0.22.0 h1:HvJTuiYLZMxCjin7bAqBgnc2RjSqEfYrMbV5yINoM64= github.com/fluxcd/pkg/ssa v0.22.0/go.mod h1:QND0ZNOQ5EzFxoNKfjUxE9J46AbRK3WKF8YkURwbVg0= github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=