|
28 | 28 | import org.junit.jupiter.api.DisplayName;
|
29 | 29 | import org.junit.jupiter.api.RepeatedTest;
|
30 | 30 | import org.junit.jupiter.api.Test;
|
| 31 | +import org.junit.jupiter.params.ParameterizedTest; |
| 32 | +import org.junit.jupiter.params.provider.MethodSource; |
31 | 33 | import reactor.core.publisher.Flux;
|
32 | 34 | import reactor.core.scheduler.Schedulers;
|
33 | 35 |
|
34 | 36 | import java.time.Duration;
|
35 | 37 | import java.util.HashMap;
|
| 38 | +import java.util.List; |
36 | 39 | import java.util.Map;
|
37 | 40 | import java.util.concurrent.CountDownLatch;
|
38 | 41 | import java.util.concurrent.ExecutorService;
|
39 | 42 | import java.util.concurrent.Executors;
|
40 | 43 | import java.util.concurrent.TimeUnit;
|
41 | 44 | import java.util.concurrent.atomic.AtomicInteger;
|
| 45 | +import java.util.stream.Stream; |
42 | 46 |
|
| 47 | +import static java.util.Arrays.asList; |
43 | 48 | import static java.util.Collections.emptyList;
|
44 | 49 | import static java.util.Collections.singletonList;
|
45 | 50 | import static org.assertj.core.api.Assertions.assertThat;
|
@@ -493,4 +498,31 @@ void meterRemovalPropagatesToChildRegistryWithModifyingFilter() {
|
493 | 498 | assertThat(this.simple.getMeters()).isEmpty();
|
494 | 499 | }
|
495 | 500 |
|
| 501 | + @Issue("#1441") |
| 502 | + @ParameterizedTest |
| 503 | + @MethodSource("registriesProvider") |
| 504 | + void whenMetersArePolledNoopChildrenShouldBeIgnored(List<MeterRegistry> registries) { |
| 505 | + // this means that firstChild() practically should be firstNonNoopChild() |
| 506 | + CompositeMeterRegistry composite = new CompositeMeterRegistry(Clock.SYSTEM, registries); |
| 507 | + Counter counter = composite.counter("my.counter"); |
| 508 | + counter.increment(); |
| 509 | + assertThat(counter.count()).isEqualTo(1); |
| 510 | + } |
| 511 | + |
| 512 | + static Stream<List<MeterRegistry>> registriesProvider() { |
| 513 | + // Since the order is non-deterministic, the best effort is testing both orders |
| 514 | + SimpleMeterRegistry denyAllRegistry1 = new SimpleMeterRegistry(); |
| 515 | + denyAllRegistry1.config().meterFilter(MeterFilter.deny()); |
| 516 | + |
| 517 | + SimpleMeterRegistry denyAllRegistry2 = new SimpleMeterRegistry(); |
| 518 | + denyAllRegistry2.config().meterFilter(MeterFilter.deny()); |
| 519 | + |
| 520 | + // @formatter:off |
| 521 | + return Stream.of( |
| 522 | + asList(denyAllRegistry1, new SimpleMeterRegistry()), // denyAll, allowAll |
| 523 | + asList(new SimpleMeterRegistry(), denyAllRegistry2) // allowAll, denyAll |
| 524 | + ); |
| 525 | + // @formatter:on |
| 526 | + } |
| 527 | + |
496 | 528 | }
|
0 commit comments