agresch commented on a change in pull request #3307:
URL: https://github.com/apache/storm/pull/3307#discussion_r467275907



##########
File path: 
storm-client/test/jvm/org/apache/storm/metrics2/WindowedMeterTest.java
##########
@@ -0,0 +1,69 @@
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.storm.metrics2;
+
+import junit.framework.TestCase;
+import org.apache.storm.utils.Time;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class WindowedMeterTest extends TestCase {
+
+    @Test
+    public void testIncrementRotate() {
+        try (Time.SimulatedTime t = new Time.SimulatedTime()) {
+            WindowedMeter meter = new WindowedMeter("meter1", new 
StormMetricRegistry(), "testTopology",
+                    "component1", "stream1",1, 6720, 2);
+            meter.close(); // prevent task from rotating
+
+            // add 10 and verify all timecounts see it
+            meter.incBy(10);
+            Long total = new Long(10L);
+            Assert.assertEquals(total, meter.getTimeCounts().get("600"));
+            Assert.assertEquals(total, meter.getTimeCounts().get("10800"));
+            Assert.assertEquals(total, meter.getTimeCounts().get("86400"));
+            Assert.assertEquals(total, meter.getTimeCounts().get(":all-time"));
+            Assert.assertEquals(total, new Long(meter.getMeter().getCount()));
+
+            // rotate 11 minutes and validate 10 minute bucket is reduced while
+            // others remain steady.
+            Time.advanceTime(11L * 60L * 1000L);
+            meter.rotateSched();
+            Assert.assertTrue(meter.getTimeCounts().get("600") < total);

Review comment:
       Will look

##########
File path: 
storm-client/test/jvm/org/apache/storm/metrics2/BoltExecutorMetricsTest.java
##########
@@ -0,0 +1,91 @@
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.storm.metrics2;
+
+import java.util.HashMap;
+import java.util.Map;
+import junit.framework.TestCase;
+import org.apache.storm.Config;
+import org.apache.storm.task.WorkerTopologyContext;
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+public class BoltExecutorMetricsTest extends TestCase {
+
+    @Test
+    public void testCounts() {

Review comment:
       I'll look at adding the metrics values to the test




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to