You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by le...@apache.org on 2023/02/21 03:52:38 UTC

[flink] 02/02: [FLINK-21000][runtime] Add tests for the InternalSplitEnumeratorMetricGroup This closes #21952.

This is an automated email from the ASF dual-hosted git repository.

leonard pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git

commit bacdc326b58749924acbd8921d63eda06663a225
Author: Hang Ruan <ru...@hotmail.com>
AuthorDate: Fri Feb 17 10:17:31 2023 +0800

    [FLINK-21000][runtime] Add tests for the InternalSplitEnumeratorMetricGroup
    This closes #21952.
---
 .../groups/InternalSplitEnumeratorGroupTest.java   | 61 ++++++++++++++++++++++
 1 file changed, 61 insertions(+)

diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/InternalSplitEnumeratorGroupTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/InternalSplitEnumeratorGroupTest.java
new file mode 100644
index 00000000000..76bab219571
--- /dev/null
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/metrics/groups/InternalSplitEnumeratorGroupTest.java
@@ -0,0 +1,61 @@
+/*
+ * 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.flink.runtime.metrics.groups;
+
+import org.apache.flink.api.common.JobID;
+import org.apache.flink.runtime.jobgraph.JobVertexID;
+import org.apache.flink.runtime.jobgraph.OperatorID;
+import org.apache.flink.runtime.metrics.MetricRegistry;
+import org.apache.flink.runtime.metrics.util.TestingMetricRegistry;
+
+import org.junit.jupiter.api.Test;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for the {@link InternalSplitEnumeratorMetricGroup}. */
+class InternalSplitEnumeratorGroupTest {
+
+    private static final MetricRegistry registry = TestingMetricRegistry.builder().build();
+
+    @Test
+    void testGenerateScopeDefault() {
+        final JobID jobId = new JobID();
+        final JobVertexID jobVertexId = new JobVertexID();
+        final OperatorID operatorId = new OperatorID();
+        JobManagerOperatorMetricGroup jmJobGroup =
+                JobManagerMetricGroup.createJobManagerMetricGroup(registry, "localhost")
+                        .addJob(jobId, "myJobName")
+                        .getOrAddOperator(jobVertexId, "taskName", operatorId, "opName");
+        InternalOperatorCoordinatorMetricGroup operatorCoordinatorMetricGroup =
+                new InternalOperatorCoordinatorMetricGroup(jmJobGroup);
+        InternalSplitEnumeratorMetricGroup splitEnumeratorMetricGroup =
+                new InternalSplitEnumeratorMetricGroup(operatorCoordinatorMetricGroup);
+
+        assertThat(splitEnumeratorMetricGroup.getScopeComponents())
+                .containsExactly(
+                        "localhost",
+                        "jobmanager",
+                        "myJobName",
+                        "opName",
+                        "coordinator",
+                        "enumerator");
+        assertThat(splitEnumeratorMetricGroup.getMetricIdentifier("name"))
+                .isEqualTo("localhost.jobmanager.myJobName.opName.coordinator.enumerator.name");
+    }
+}