@@ -156,7 +156,7 @@ void addingDuplicatedDependentsWithNameShouldWork() {
156
156
assertEquals (2 , dependents .size ());
157
157
assertTrue (findByNameOptional (dependents , NamedDuplicatedDepReconciler .NAME ).isPresent ()
158
158
&& findByNameOptional (dependents , DependentResource .defaultNameFor (ReadOnlyDependent .class ))
159
- .isPresent ());
159
+ .isPresent ());
160
160
}
161
161
162
162
@ Test
@@ -190,6 +190,24 @@ 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 (
199
+ BaseClassWithGradualRetryAndRateLimited .RETRY_MAX_ATTEMPTS ,
200
+ testRetry .getMaxAttempts ());
201
+
202
+ final var rateLimiter = assertInstanceOf (LinearRateLimiter .class , config .getRateLimiter ());
203
+ assertEquals (
204
+ BaseClassWithGradualRetryAndRateLimited .RATE_LIMITED_MAX_RECONCILIATIONS ,
205
+ rateLimiter .getLimitForPeriod ());
206
+ assertEquals (
207
+ Duration .ofSeconds (BaseClassWithGradualRetryAndRateLimited .RATE_LIMITED_WITHIN_SECONDS ),
208
+ rateLimiter .getRefreshPeriod ());
209
+ }
210
+
193
211
@ Test
194
212
void checkingRetryingGraduallyWorks () {
195
213
var config = configFor (new CheckRetryingGraduallyConfiguration ());
@@ -250,6 +268,7 @@ public UpdateControl<ConfigMap> reconcile(ConfigMap resource, Context<ConfigMap>
250
268
@ ControllerConfiguration (
251
269
dependents = @ Dependent (type = ReadOnlyDependent .class , name = NamedDepReconciler .NAME ))
252
270
private static class NamedDepReconciler implements Reconciler <ConfigMap > {
271
+
253
272
private static final String NAME = "foo" ;
254
273
255
274
@ Override
@@ -325,9 +344,11 @@ public UpdateControl<ConfigMap> reconcile(ConfigMap resource, Context<ConfigMap>
325
344
}
326
345
327
346
public static class TestRetry implements Retry , AnnotationConfigurable <TestRetryConfiguration > {
347
+
328
348
private int value ;
329
349
330
- public TestRetry () {}
350
+ public TestRetry () {
351
+ }
331
352
332
353
@ Override
333
354
public RetryExecution initExecution () {
@@ -347,6 +368,7 @@ public void initFrom(TestRetryConfiguration configuration) {
347
368
@ Target (ElementType .TYPE )
348
369
@ Retention (RetentionPolicy .RUNTIME )
349
370
private @interface TestRetryConfiguration {
371
+
350
372
int value () default 42 ;
351
373
}
352
374
@@ -382,7 +404,31 @@ public UpdateControl<ConfigMap> reconcile(ConfigMap resource, Context<ConfigMap>
382
404
}
383
405
}
384
406
407
+ @ ControllerConfiguration
408
+ private static class GradualRetryAndRateLimitedOnSuperClass
409
+ extends BaseClassWithGradualRetryAndRateLimited
410
+ implements Reconciler <ConfigMap > {
411
+
412
+ @ Override
413
+ public UpdateControl <ConfigMap > reconcile (ConfigMap resource , Context <ConfigMap > context ) {
414
+ return null ;
415
+ }
416
+ }
417
+
418
+ @ RateLimited (
419
+ maxReconciliations = BaseClassWithGradualRetryAndRateLimited .RATE_LIMITED_MAX_RECONCILIATIONS ,
420
+ within = BaseClassWithGradualRetryAndRateLimited .RATE_LIMITED_WITHIN_SECONDS
421
+ )
422
+ @ GradualRetry (maxAttempts = BaseClassWithGradualRetryAndRateLimited .RETRY_MAX_ATTEMPTS )
423
+ private static class BaseClassWithGradualRetryAndRateLimited {
424
+
425
+ public static final int RATE_LIMITED_MAX_RECONCILIATIONS = 7 ;
426
+ public static final int RATE_LIMITED_WITHIN_SECONDS = 3 ;
427
+ public static final int RETRY_MAX_ATTEMPTS = 3 ;
428
+ }
429
+
385
430
private static class ControllerConfigurationOnSuperClass extends BaseClass {
431
+
386
432
}
387
433
388
434
@ ControllerConfiguration
@@ -443,10 +489,12 @@ private static class ChildCustomAnnotatedDep extends CustomAnnotatedDep {
443
489
444
490
@ Retention (RetentionPolicy .RUNTIME )
445
491
private @interface CustomAnnotation {
492
+
446
493
int value ();
447
494
}
448
495
449
496
private static class CustomConfig {
497
+
450
498
private final int value ;
451
499
452
500
private CustomConfig (int value ) {
@@ -460,6 +508,7 @@ public int getValue() {
460
508
461
509
private static class CustomConfigConverter
462
510
implements ConfigurationConverter <CustomAnnotation , CustomConfig , CustomAnnotatedDep > {
511
+
463
512
static final int CONVERTER_PROVIDED_DEFAULT = 7 ;
464
513
465
514
@ Override
0 commit comments