@@ -190,6 +190,18 @@ void configuringRateAndRetryViaAnnotationsShouldWork() {
190
190
assertEquals (Duration .ofSeconds (3 ), rateLimiter .getRefreshPeriod ());
191
191
}
192
192
193
+ @ Test
194
+ void configuringRateLimitAndGradualRetryViaSuperClassShouldWork () {
195
+ var config = configFor (new GradualRetryAndRateLimitedOnSuperClass ());
196
+ final var retry = config .getRetry ();
197
+ final var testRetry = assertInstanceOf (GenericRetry .class , retry );
198
+ assertEquals (BaseClassWithGradualRetryAndRateLimited .RETRY_MAX_ATTEMPTS , testRetry .getMaxAttempts ());
199
+
200
+ final var rateLimiter = assertInstanceOf (LinearRateLimiter .class , config .getRateLimiter ());
201
+ assertEquals (BaseClassWithGradualRetryAndRateLimited .RATE_LIMITED_MAX_RECONCILIATIONS , rateLimiter .getLimitForPeriod ());
202
+ assertEquals (Duration .ofSeconds (BaseClassWithGradualRetryAndRateLimited .RATE_LIMITED_WITHIN_SECONDS ), rateLimiter .getRefreshPeriod ());
203
+ }
204
+
193
205
@ Test
194
206
void checkingRetryingGraduallyWorks () {
195
207
var config = configFor (new CheckRetryingGraduallyConfiguration ());
@@ -382,6 +394,29 @@ public UpdateControl<ConfigMap> reconcile(ConfigMap resource, Context<ConfigMap>
382
394
}
383
395
}
384
396
397
+ @ ControllerConfiguration
398
+ private static class GradualRetryAndRateLimitedOnSuperClass
399
+ extends BaseClassWithGradualRetryAndRateLimited
400
+ implements Reconciler <ConfigMap > {
401
+
402
+ @ Override
403
+ public UpdateControl <ConfigMap > reconcile (ConfigMap resource , Context <ConfigMap > context ) throws Exception {
404
+ return null ;
405
+ }
406
+ }
407
+
408
+ @ RateLimited (
409
+ maxReconciliations = BaseClassWithGradualRetryAndRateLimited .RATE_LIMITED_MAX_RECONCILIATIONS ,
410
+ within = BaseClassWithGradualRetryAndRateLimited .RATE_LIMITED_WITHIN_SECONDS
411
+ )
412
+ @ GradualRetry (maxAttempts = BaseClassWithGradualRetryAndRateLimited .RETRY_MAX_ATTEMPTS )
413
+ private static class BaseClassWithGradualRetryAndRateLimited {
414
+
415
+ public static final int RATE_LIMITED_MAX_RECONCILIATIONS = 7 ;
416
+ public static final int RATE_LIMITED_WITHIN_SECONDS = 3 ;
417
+ public static final int RETRY_MAX_ATTEMPTS = 3 ;
418
+ }
419
+
385
420
private static class ControllerConfigurationOnSuperClass extends BaseClass {
386
421
}
387
422
0 commit comments