From notifications-return-5750-archive-asf-public=cust-asf.ponee.io@ignite.apache.org Mon Aug 5 14:28:58 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 031251806C9 for ; Mon, 5 Aug 2019 16:28:56 +0200 (CEST) Received: (qmail 30010 invoked by uid 500); 5 Aug 2019 14:28:56 -0000 Mailing-List: contact notifications-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list notifications@ignite.apache.org Received: (qmail 29876 invoked by uid 99); 5 Aug 2019 14:28:56 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Aug 2019 14:28:56 +0000 From: GitBox To: notifications@ignite.apache.org Subject: [GitHub] [ignite] agura commented on a change in pull request #6696: IGNITE-11987: Metrics configuration. Message-ID: <156501533617.29291.5540398392124233046.gitbox@gitbox.apache.org> Date: Mon, 05 Aug 2019 14:28:56 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit agura commented on a change in pull request #6696: IGNITE-11987: Metrics configuration. URL: https://github.com/apache/ignite/pull/6696#discussion_r310593733 ########## File path: modules/core/src/test/java/org/apache/ignite/internal/metric/MetricsConfigurationTest.java ########## @@ -0,0 +1,129 @@ +/* + * 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.ignite.internal.metric; + +import java.util.Arrays; +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteException; +import org.apache.ignite.internal.IgniteEx; +import org.apache.ignite.internal.processors.metric.impl.HistogramMetric; +import org.apache.ignite.internal.processors.metric.impl.HitRateMetric; +import org.apache.ignite.mxbean.IgniteMXBean; +import org.apache.ignite.spi.metric.Metric; +import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest; +import org.junit.Test; + +import static org.apache.ignite.internal.processors.metric.impl.MetricUtils.metricName; +import static org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause; +import static org.apache.ignite.testframework.GridTestUtils.getFieldValue; + +/** */ +public class MetricsConfigurationTest extends GridCommonAbstractTest { + /** */ + @Test + public void testHitRateMetric() throws Exception { + HitRateMetric hitRateMetric = new HitRateMetric("test", null, 1000, 3); + + assertThrowsWithCause(() -> hitRateMetric.configure(null), IgniteException.class); + + assertThrowsWithCause(() -> hitRateMetric.configure(""), IgniteException.class); + + assertThrowsWithCause(() -> hitRateMetric.configure("1000"), IgniteException.class); + + assertThrowsWithCause(() -> hitRateMetric.configure("1000, 1"), IgniteException.class); + + assertThrowsWithCause(() -> hitRateMetric.configure("-1000, 1"), IgniteException.class); + + assertThrowsWithCause(() -> hitRateMetric.configure("-1000, 1xxx"), IgniteException.class); + + assertThrowsWithCause(() -> hitRateMetric.configure("xxx"), IgniteException.class); + + hitRateMetric.configure("5000, 42"); + + checkHitRate(hitRateMetric, 5000, 42); + } + + /** */ + private void checkHitRate(HitRateMetric hitRateMetric, long expRateTimeInterval, int expSize) { + Object hitRateMetricImpl = getFieldValue(hitRateMetric, "cntr"); + + long rateTimeInterval = getFieldValue(hitRateMetricImpl, "rateTimeInterval"); Review comment: Please add public method that returns `rateTimeInterval`. ---------------------------------------------------------------- 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: users@infra.apache.org With regards, Apache Git Services