|
11 | 11 | import io.skodjob.annotations.TestDoc; |
12 | 12 | import io.skodjob.kubetest4j.resources.KubeResourceManager; |
13 | 13 | import io.strimzi.api.kafka.model.bridge.KafkaBridgeResources; |
| 14 | +import io.strimzi.api.kafka.model.common.metrics.StrimziMetricsReporter; |
14 | 15 | import io.strimzi.api.kafka.model.kafka.KafkaResources; |
15 | 16 | import io.strimzi.operator.common.Annotations; |
16 | 17 | import io.strimzi.systemtest.AbstractST; |
17 | 18 | import io.strimzi.systemtest.Environment; |
18 | 19 | import io.strimzi.systemtest.TestConstants; |
| 20 | +import io.strimzi.systemtest.annotations.IsolatedTest; |
19 | 21 | import io.strimzi.systemtest.annotations.ParallelTest; |
20 | 22 | import io.strimzi.systemtest.docs.TestDocsLabels; |
21 | 23 | import io.strimzi.systemtest.kafkaclients.internalClients.BridgeClients; |
22 | 24 | import io.strimzi.systemtest.kafkaclients.internalClients.BridgeClientsBuilder; |
| 25 | +import io.strimzi.systemtest.labels.LabelSelectors; |
23 | 26 | import io.strimzi.systemtest.performance.gather.collectors.BaseMetricsCollector; |
24 | 27 | import io.strimzi.systemtest.resources.operator.SetupClusterOperator; |
25 | 28 | import io.strimzi.systemtest.storage.TestStorage; |
|
31 | 34 | import io.strimzi.systemtest.templates.crd.KafkaTemplates; |
32 | 35 | import io.strimzi.systemtest.templates.crd.KafkaTopicTemplates; |
33 | 36 | import io.strimzi.systemtest.templates.specific.ScraperTemplates; |
| 37 | +import io.strimzi.systemtest.utils.RollingUpdateUtils; |
| 38 | +import io.strimzi.systemtest.utils.kafkaUtils.KafkaUtils; |
34 | 39 | import io.strimzi.systemtest.utils.kubeUtils.objects.NetworkPolicyUtils; |
| 40 | +import io.strimzi.systemtest.utils.kubeUtils.objects.PodUtils; |
| 41 | +import io.strimzi.systemtest.utils.specific.MetricsUtils; |
35 | 42 | import org.apache.logging.log4j.LogManager; |
36 | 43 | import org.apache.logging.log4j.Logger; |
37 | 44 | import org.junit.jupiter.api.BeforeAll; |
38 | 45 | import org.junit.jupiter.api.Tag; |
39 | 46 |
|
| 47 | +import java.util.List; |
| 48 | +import java.util.Map; |
40 | 49 | import java.util.concurrent.TimeUnit; |
41 | 50 | import java.util.concurrent.locks.LockSupport; |
42 | 51 |
|
|
51 | 60 | import static io.strimzi.systemtest.utils.specific.MetricsUtils.assertMetricValue; |
52 | 61 | import static io.strimzi.systemtest.utils.specific.MetricsUtils.assertMetricValueHigherThanOrEqualTo; |
53 | 62 | import static io.strimzi.systemtest.utils.specific.MetricsUtils.assertMetricValueNotNull; |
| 63 | +import static org.hamcrest.CoreMatchers.is; |
| 64 | +import static org.hamcrest.MatcherAssert.assertThat; |
54 | 65 | import static org.junit.jupiter.api.Assumptions.assumeFalse; |
55 | 66 |
|
56 | 67 | @Tag(SANITY) |
@@ -271,6 +282,43 @@ void testKafkaBridgeMetrics() { |
271 | 282 | assertMetricValueNotNull(bridgeCollector, "kafka_consumer_consumer_metrics_connection_count\\{.*}"); |
272 | 283 | } |
273 | 284 |
|
| 285 | + @IsolatedTest |
| 286 | + void testDynamicReconfigurationAllowList() { |
| 287 | + Map<String, String> kafkaPods = PodUtils.podSnapshot(testStorage.getNamespaceName(), LabelSelectors.allKafkaPodsLabelSelector(testStorage.getClusterName())); |
| 288 | + |
| 289 | + // change configuration to disable kafka_server.* metrics and add kafka_controller.* metrics |
| 290 | + KafkaUtils.replace(testStorage.getNamespaceName(), testStorage.getClusterName(), kafka -> { |
| 291 | + StrimziMetricsReporter config = (StrimziMetricsReporter) kafka.getSpec().getKafka().getMetricsConfig(); |
| 292 | + config.getValues().setAllowList(List.of("kafka_controller.*")); |
| 293 | + |
| 294 | + kafka.getSpec().getKafka().setMetricsConfig(config); |
| 295 | + } |
| 296 | + ); |
| 297 | + |
| 298 | + RollingUpdateUtils.waitForNoRollingUpdate(testStorage.getNamespaceName(), LabelSelectors.allKafkaPodsLabelSelector(testStorage.getClusterName()), kafkaPods); |
| 299 | + |
| 300 | + LOGGER.info("Check if Kafka Pods are missing the 'kafka_server_' metrics"); |
| 301 | + kafkaCollector.collectMetricsFromPods(TestConstants.METRICS_COLLECT_TIMEOUT); |
| 302 | + |
| 303 | + assertThat(MetricsUtils.createPatternAndCollectWithoutWait(kafkaCollector, "kafka_server_replicamanager_leadercount").isEmpty(), is(true)); |
| 304 | + |
| 305 | + LOGGER.info("Changing back to previous state"); |
| 306 | + KafkaUtils.replace(testStorage.getNamespaceName(), testStorage.getClusterName(), kafka -> { |
| 307 | + StrimziMetricsReporter config = (StrimziMetricsReporter) kafka.getSpec().getKafka().getMetricsConfig(); |
| 308 | + config.getValues().setAllowList(List.of("kafka_server.*")); |
| 309 | + |
| 310 | + kafka.getSpec().getKafka().setMetricsConfig(config); |
| 311 | + } |
| 312 | + ); |
| 313 | + |
| 314 | + RollingUpdateUtils.waitForNoRollingUpdate(testStorage.getNamespaceName(), LabelSelectors.allKafkaPodsLabelSelector(testStorage.getClusterName()), kafkaPods); |
| 315 | + |
| 316 | + LOGGER.info("Check if Kafka Pods are not missing the 'kafka_server_' metrics"); |
| 317 | + kafkaCollector.collectMetricsFromPods(TestConstants.METRICS_COLLECT_TIMEOUT); |
| 318 | + |
| 319 | + assertThat(MetricsUtils.createPatternAndCollect(kafkaCollector, "kafka_server_replicamanager_leadercount").isEmpty(), is(false)); |
| 320 | + } |
| 321 | + |
274 | 322 | @BeforeAll |
275 | 323 | void setupEnvironment() { |
276 | 324 | testStorage = new TestStorage(KubeResourceManager.get().getTestContext()); |
|
0 commit comments