Skip to content

Commit 39b94dd

Browse files
authored
Remove use of deprecated enableMetrics field in Bridge STs (#12096)
Signed-off-by: Jakub Scholz <www@scholzj.com>
1 parent 8559cc9 commit 39b94dd

5 files changed

Lines changed: 72 additions & 41 deletions

File tree

systemtest/src/main/java/io/strimzi/systemtest/TestConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ public interface TestConstants {
201201
String PATH_TO_KAFKA_CONNECT_CONFIG = PATH_TO_PACKAGING_EXAMPLES + "/connect/kafka-connect.yaml";
202202
String PATH_TO_KAFKA_CONNECT_METRICS_CONFIG = PATH_TO_PACKAGING_EXAMPLES + "/metrics/kafka-connect-metrics.yaml";
203203
String PATH_TO_KAFKA_BRIDGE_CONFIG = PATH_TO_PACKAGING_EXAMPLES + "/bridge/kafka-bridge.yaml";
204+
String PATH_TO_KAFKA_BRIDGE_METRICS_CONFIG = PATH_TO_PACKAGING_EXAMPLES + "/metrics/kafka-bridge-metrics.yaml";
204205
String PATH_TO_KAFKA_REBALANCE_CONFIG = PATH_TO_PACKAGING_EXAMPLES + "/cruise-control/kafka-rebalance-full.yaml";
205206
String PATH_TO_KAFKA_CRUISE_CONTROL_CONFIG = PATH_TO_PACKAGING_EXAMPLES + "/cruise-control/kafka-cruise-control.yaml";
206207
String PATH_TO_KAFKA_CRUISE_CONTROL_METRICS_CONFIG = PATH_TO_PACKAGING_EXAMPLES + "/metrics/kafka-cruise-control-metrics.yaml";

systemtest/src/main/java/io/strimzi/systemtest/templates/crd/KafkaBridgeTemplates.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@
44
*/
55
package io.strimzi.systemtest.templates.crd;
66

7+
import io.fabric8.kubernetes.api.model.ConfigMap;
8+
import io.fabric8.kubernetes.api.model.ConfigMapBuilder;
79
import io.strimzi.api.kafka.model.bridge.KafkaBridgeBuilder;
10+
import io.strimzi.systemtest.TestConstants;
11+
import io.strimzi.systemtest.utils.FileUtils;
812

913
public class KafkaBridgeTemplates {
14+
private static final String METRICS_BRIDGE_CONFIG_MAP_SUFFIX = "-bridge-metrics";
15+
private static final String CONFIG_MAP_KEY = "metrics-config.yml";
1016

1117
private KafkaBridgeTemplates() {}
1218

@@ -48,10 +54,27 @@ public static KafkaBridgeBuilder kafkaBridgeWithMetrics(
4854
) {
4955
return defaultKafkaBridge(namespaceName, bridgeName, bootstrap, kafkaBridgeReplicas)
5056
.editSpec()
51-
.withEnableMetrics(true)
57+
.withNewJmxPrometheusExporterMetricsConfig()
58+
.withNewValueFrom()
59+
.withNewConfigMapKeyRef(CONFIG_MAP_KEY, getConfigMapName(bridgeName), false)
60+
.endValueFrom()
61+
.endJmxPrometheusExporterMetricsConfig()
5262
.endSpec();
5363
}
5464

65+
public static ConfigMap bridgeMetricsConfigMap(String namespaceName, String bridgeName) {
66+
return new ConfigMapBuilder(FileUtils.extractConfigMapFromYAMLWithResources(TestConstants.PATH_TO_KAFKA_BRIDGE_METRICS_CONFIG, "bridge-metrics"))
67+
.editOrNewMetadata()
68+
.withNamespace(namespaceName)
69+
.withName(getConfigMapName(bridgeName))
70+
.endMetadata()
71+
.build();
72+
}
73+
74+
private static String getConfigMapName(String kafkaConnectClusterName) {
75+
return kafkaConnectClusterName + METRICS_BRIDGE_CONFIG_MAP_SUFFIX;
76+
}
77+
5578
private static KafkaBridgeBuilder defaultKafkaBridge(
5679
String namespaceName,
5780
String bridgeName,

systemtest/src/test/java/io/strimzi/systemtest/metrics/MetricsST.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -453,12 +453,13 @@ void testKafkaBridgeMetrics() {
453453
final TestStorage testStorage = new TestStorage(KubeResourceManager.get().getTestContext());
454454

455455
KubeResourceManager.get().createResourceWithWait(
456-
KafkaBridgeTemplates.kafkaBridgeWithMetrics(
457-
namespaceFirst,
458-
bridgeClusterName,
459-
KafkaResources.plainBootstrapAddress(kafkaClusterFirstName),
460-
1
461-
).build()
456+
KafkaBridgeTemplates.bridgeMetricsConfigMap(namespaceFirst, bridgeClusterName),
457+
KafkaBridgeTemplates.kafkaBridgeWithMetrics(
458+
namespaceFirst,
459+
bridgeClusterName,
460+
KafkaResources.plainBootstrapAddress(kafkaClusterFirstName),
461+
1
462+
).build()
462463
);
463464

464465
// Allow connections from scraper to Bridge pods when NetworkPolicies are set to denied by default

systemtest/src/test/java/io/strimzi/systemtest/security/oauth/CustomOauthPlainST.java

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -509,24 +509,27 @@ void testProducerConsumerBridgeWithOauthMetrics() {
509509
"oauth.enable.metrics", "true"
510510
));
511511

512-
KubeResourceManager.get().createResourceWithWait(KafkaBridgeTemplates.kafkaBridgeWithMetrics(Environment.TEST_SUITE_NAMESPACE, oauthClusterName, KafkaResources.plainBootstrapAddress(oauthClusterName), 1)
513-
.editSpec()
514-
.withNewKafkaClientAuthenticationCustom()
515-
.withSasl(true)
516-
.withConfig(Map.of(
517-
"sasl.login.callback.handler.class", "io.strimzi.kafka.oauth.client.JaasClientOauthLoginCallbackHandler",
518-
"sasl.mechanism", "OAUTHBEARER",
519-
"sasl.jaas.config", bridgeJassConfig
520-
))
521-
.endKafkaClientAuthenticationCustom()
522-
.withNewTemplate()
523-
.withNewBridgeContainer()
524-
.withEnv(new ContainerEnvVarBuilder().withName("OAUTH_CLIENT_SECRET").withValueFrom(new ContainerEnvVarSourceBuilder().withNewSecretKeyRef(OAUTH_KEY, BRIDGE_OAUTH_SECRET, false).build()).build())
525-
.endBridgeContainer()
526-
.endTemplate()
527-
.withLogging(ilDebug)
528-
.endSpec()
529-
.build());
512+
KubeResourceManager.get().createResourceWithWait(
513+
KafkaBridgeTemplates.bridgeMetricsConfigMap(Environment.TEST_SUITE_NAMESPACE, oauthClusterName),
514+
KafkaBridgeTemplates.kafkaBridgeWithMetrics(Environment.TEST_SUITE_NAMESPACE, oauthClusterName, KafkaResources.plainBootstrapAddress(oauthClusterName), 1)
515+
.editSpec()
516+
.withNewKafkaClientAuthenticationCustom()
517+
.withSasl(true)
518+
.withConfig(Map.of(
519+
"sasl.login.callback.handler.class", "io.strimzi.kafka.oauth.client.JaasClientOauthLoginCallbackHandler",
520+
"sasl.mechanism", "OAUTHBEARER",
521+
"sasl.jaas.config", bridgeJassConfig
522+
))
523+
.endKafkaClientAuthenticationCustom()
524+
.withNewTemplate()
525+
.withNewBridgeContainer()
526+
.withEnv(new ContainerEnvVarBuilder().withName("OAUTH_CLIENT_SECRET").withValueFrom(new ContainerEnvVarSourceBuilder().withNewSecretKeyRef(OAUTH_KEY, BRIDGE_OAUTH_SECRET, false).build()).build())
527+
.endBridgeContainer()
528+
.endTemplate()
529+
.withLogging(ilDebug)
530+
.endSpec()
531+
.build()
532+
);
530533

531534
// Allow connections from scraper to Bridge pods when NetworkPolicies are set to denied by default
532535
NetworkPolicyUtils.allowNetworkPolicySettingsForBridgeScraper(Environment.TEST_SUITE_NAMESPACE, scraperPodName, KafkaBridgeResources.componentName(oauthClusterName));

systemtest/src/test/java/io/strimzi/systemtest/security/oauth/OauthPlainST.java

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -561,22 +561,25 @@ void testProducerConsumerBridgeWithOauthMetrics() {
561561
InlineLogging ilDebug = new InlineLogging();
562562
ilDebug.setLoggers(Map.of("rootLogger.level", "DEBUG"));
563563

564-
KubeResourceManager.get().createResourceWithWait(KafkaBridgeTemplates.kafkaBridgeWithMetrics(Environment.TEST_SUITE_NAMESPACE, oauthClusterName, KafkaResources.plainBootstrapAddress(oauthClusterName), 1)
565-
.editSpec()
566-
.withNewKafkaClientAuthenticationOAuth()
567-
.withEnableMetrics()
568-
.withTokenEndpointUri(keycloakInstance.getOauthTokenEndpointUri())
569-
.withClientId("kafka-bridge")
570-
.withNewClientSecret()
571-
.withSecretName(BRIDGE_OAUTH_SECRET)
572-
.withKey(OAUTH_KEY)
573-
.endClientSecret()
574-
.withConnectTimeoutSeconds(CONNECT_TIMEOUT_S)
575-
.withReadTimeoutSeconds(READ_TIMEOUT_S)
576-
.endKafkaClientAuthenticationOAuth()
577-
.withLogging(ilDebug)
578-
.endSpec()
579-
.build());
564+
KubeResourceManager.get().createResourceWithWait(
565+
KafkaBridgeTemplates.bridgeMetricsConfigMap(Environment.TEST_SUITE_NAMESPACE, oauthClusterName),
566+
KafkaBridgeTemplates.kafkaBridgeWithMetrics(Environment.TEST_SUITE_NAMESPACE, oauthClusterName, KafkaResources.plainBootstrapAddress(oauthClusterName), 1)
567+
.editSpec()
568+
.withNewKafkaClientAuthenticationOAuth()
569+
.withEnableMetrics()
570+
.withTokenEndpointUri(keycloakInstance.getOauthTokenEndpointUri())
571+
.withClientId("kafka-bridge")
572+
.withNewClientSecret()
573+
.withSecretName(BRIDGE_OAUTH_SECRET)
574+
.withKey(OAUTH_KEY)
575+
.endClientSecret()
576+
.withConnectTimeoutSeconds(CONNECT_TIMEOUT_S)
577+
.withReadTimeoutSeconds(READ_TIMEOUT_S)
578+
.endKafkaClientAuthenticationOAuth()
579+
.withLogging(ilDebug)
580+
.endSpec()
581+
.build()
582+
);
580583

581584
// Allow connections from scraper to Bridge pods when NetworkPolicies are set to denied by default
582585
NetworkPolicyUtils.allowNetworkPolicySettingsForBridgeScraper(Environment.TEST_SUITE_NAMESPACE, scraperPodName, KafkaBridgeResources.componentName(oauthClusterName));

0 commit comments

Comments
 (0)