Github user tzulitai commented on a diff in the pull request:
https://github.com/apache/flink/pull/5092#discussion_r153736792
--- Diff:
flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/metrics/StreamOperatorWatermarkMetricsTest.java
---
@@ -0,0 +1,96 @@
+/*
+ * 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.streaming.runtime.metrics;
+
+import org.apache.flink.streaming.api.operators.AbstractStreamOperator;
+import org.apache.flink.streaming.api.operators.OneInputStreamOperator;
+import org.apache.flink.streaming.api.operators.TwoInputStreamOperator;
+import org.apache.flink.streaming.api.watermark.Watermark;
+import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
+import org.apache.flink.streaming.util.OneInputStreamOperatorTestHarness;
+import org.apache.flink.streaming.util.TwoInputStreamOperatorTestHarness;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Tests to verify that {@link AbstractStreamOperator} properly updates
the {@link WatermarkGauge}.
+ */
+public class StreamOperatorWatermarkMetricsTest {
+
+ @Test
+ public void testOneInputWatermarkReporting() throws Exception {
+ TestOneInputStreamOperator operator = new
TestOneInputStreamOperator();
+ try (OneInputStreamOperatorTestHarness<Integer, Integer>
harness = new OneInputStreamOperatorTestHarness<>(operator)) {
+ harness.setup();
+ WatermarkGauge watermarkGauge =
operator.getWatermarkGauge();
+
+ Assert.assertEquals(Long.MIN_VALUE,
watermarkGauge.getValue().longValue());
+
+ harness.processWatermark(new Watermark(64L));
+ Assert.assertEquals(64L,
watermarkGauge.getValue().longValue());
+ harness.processWatermark(new Watermark(128L));
+ Assert.assertEquals(128L,
watermarkGauge.getValue().longValue());
+ }
+ }
+
+ @Test
+ public void testTwoInputWatermarkReporting() throws Exception {
--- End diff --
Probably should add verifying the gauge value after processing the
`Long.MAX_VALUE` watermark on both inputs to this test, just to be on the safe
side.
---