Skip to content

Commit a04d1cd

Browse files
authored
Merge pull request #475 from fluxcd/test-reconciler-ratelimiter
Set rate limiter option in test reconcilers
2 parents 3abab5b + 3d6578a commit a04d1cd

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

controllers/controllers_fuzzer_test.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,27 @@ import (
3838
"github.com/fluxcd/go-git/v5/plumbing"
3939
"github.com/fluxcd/go-git/v5/plumbing/object"
4040
"github.com/fluxcd/go-git/v5/storage/memory"
41-
"github.com/fluxcd/image-automation-controller/pkg/update"
42-
"github.com/fluxcd/pkg/gittestserver"
43-
"github.com/fluxcd/pkg/runtime/testenv"
4441
"github.com/go-git/go-billy/v5/memfs"
4542
"github.com/go-logr/logr"
43+
corev1 "k8s.io/api/core/v1"
44+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
4645
"k8s.io/apimachinery/pkg/types"
4746
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
4847
"k8s.io/client-go/kubernetes/scheme"
49-
5048
"k8s.io/client-go/rest"
5149
ctrl "sigs.k8s.io/controller-runtime"
5250
"sigs.k8s.io/controller-runtime/pkg/client"
5351
"sigs.k8s.io/controller-runtime/pkg/envtest"
5452
"sigs.k8s.io/controller-runtime/pkg/manager"
5553

56-
image_automationv1 "github.com/fluxcd/image-automation-controller/api/v1beta1"
5754
image_reflectv1 "github.com/fluxcd/image-reflector-controller/api/v1beta1"
55+
"github.com/fluxcd/pkg/gittestserver"
56+
"github.com/fluxcd/pkg/runtime/controller"
57+
"github.com/fluxcd/pkg/runtime/testenv"
5858
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
59-
corev1 "k8s.io/api/core/v1"
60-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
59+
60+
image_automationv1 "github.com/fluxcd/image-automation-controller/api/v1beta1"
61+
"github.com/fluxcd/image-automation-controller/pkg/update"
6162
)
6263

6364
var (
@@ -84,7 +85,10 @@ func Fuzz_ImageUpdateReconciler(f *testing.F) {
8485
utilruntime.Must(ensureDependencies(func(m manager.Manager) {
8586
utilruntime.Must((&ImageUpdateAutomationReconciler{
8687
Client: m.GetClient(),
87-
}).SetupWithManager(m, ImageUpdateAutomationReconcilerOptions{MaxConcurrentReconciles: 4}))
88+
}).SetupWithManager(m, ImageUpdateAutomationReconcilerOptions{
89+
MaxConcurrentReconciles: 4,
90+
RateLimiter: controller.GetDefaultRateLimiter(),
91+
}))
8892
}))
8993
})
9094

controllers/suite_test.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
ctrl "sigs.k8s.io/controller-runtime"
3030

3131
imagev1_reflect "github.com/fluxcd/image-reflector-controller/api/v1beta1"
32+
"github.com/fluxcd/pkg/runtime/controller"
3233
"github.com/fluxcd/pkg/runtime/testenv"
3334
sourcev1 "github.com/fluxcd/source-controller/api/v1beta2"
3435

@@ -75,7 +76,9 @@ func runTestsWithFeatures(m *testing.M, feats map[string]bool) int {
7576
Client: testEnv,
7677
EventRecorder: testEnv.GetEventRecorderFor(controllerName),
7778
features: feats,
78-
}).SetupWithManager(testEnv, ImageUpdateAutomationReconcilerOptions{}); err != nil {
79+
}).SetupWithManager(testEnv, ImageUpdateAutomationReconcilerOptions{
80+
RateLimiter: controller.GetDefaultRateLimiter(),
81+
}); err != nil {
7982
panic(fmt.Sprintf("failed to start ImageUpdateAutomationReconciler: %v", err))
8083
}
8184

0 commit comments

Comments
 (0)