mimaison commented on code in PR #20672: URL: https://github.com/apache/kafka/pull/20672#discussion_r2477322568
########## server/src/test/java/org/apache/kafka/server/metrics/ClientTelemetryInterfaceTest.java: ########## @@ -0,0 +1,84 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.kafka.server.metrics; + +import org.apache.kafka.common.message.PushTelemetryRequestData; +import org.apache.kafka.common.requests.PushTelemetryRequest; +import org.apache.kafka.server.metrics.ClientMetricsTestUtils.TestClientMetricsReceiver; +import org.apache.kafka.server.metrics.ClientMetricsTestUtils.TestClientTelemetryExporter; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.net.UnknownHostException; +import java.nio.ByteBuffer; +import java.nio.charset.StandardCharsets; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class ClientTelemetryInterfaceTest { Review Comment: Let's remove `Interface` in the class name ########## streams/integration-tests/src/test/java/org/apache/kafka/streams/integration/KafkaStreamsTelemetryBase.java: ########## @@ -249,28 +277,68 @@ public void shouldPushMetricsToBroker(final String recordingLevel, final String return "org.apache.kafka." + group + "." + name; }).filter(name -> !name.equals("org.apache.kafka.stream.thread.state"))// telemetry reporter filters out string metrics .sorted().toList(); - final List<String> actualMetrics = new ArrayList<>(TelemetryPlugin.SUBSCRIBED_METRICS.get(mainConsumerInstanceId)); + final List<String> actualMetrics = new ArrayList<>(getSubscribedMetricsMap().get(mainConsumerInstanceId)); assertEquals(expectedMetrics, actualMetrics); TestUtils.waitForCondition( - () -> !TelemetryPlugin.SUBSCRIBED_METRICS.getOrDefault(adminInstanceId, Collections.emptyList()).isEmpty(), + () -> !getSubscribedMetricsMap().getOrDefault(adminInstanceId, Collections.emptyList()).isEmpty(), 30_000, "Never received subscribed metrics" ); - final List<String> actualInstanceMetrics = TelemetryPlugin.SUBSCRIBED_METRICS.get(adminInstanceId); + final List<String> actualInstanceMetrics = getSubscribedMetricsMap().get(adminInstanceId); final List<String> expectedInstanceMetrics = Arrays.asList( "org.apache.kafka.stream.alive.stream.threads", "org.apache.kafka.stream.client.state", "org.apache.kafka.stream.failed.stream.threads", "org.apache.kafka.stream.recording.level"); - + assertEquals(expectedInstanceMetrics, actualInstanceMetrics); - TestUtils.waitForCondition(() -> TelemetryPlugin.processId != null, + TestUtils.waitForCondition(() -> getProcessId() != null, 30_000, "Never received the process id"); - assertEquals(expectedProcessId, TelemetryPlugin.processId); + assertEquals(expectedProcessId, getProcessId()); + } + } + + @Test + public void shouldReceivePushInterval() throws Exception { Review Comment: I'm really confused by this test. My understand is that this test checks that metrics are emitted at the correct configured interval. At no point the actual value of `intervalMs` is checked. If so this is not testing the feature this PR introduces. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
