blob: d75063f2c4e175b51f84654863c2b3c462e1a29f [file] [log] [blame]
// 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.doris.metric;
import org.apache.doris.common.FeConstants;
import java.util.List;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
public class MetricsTest {
@BeforeClass
public static void setUp() {
FeConstants.runningUnitTest = true;
MetricRepo.init();
}
@Test
public void testTcpMetrics() {
List<Metric> metrics = MetricRepo.getMetricsByName("snmp");
Assert.assertEquals(4, metrics.size());
for (Metric metric : metrics) {
GaugeMetric<Long> gm = (GaugeMetric<Long>) metric;
String metricName = gm.getLabels().get(0).getValue();
if (metricName.equals("tcp_retrans_segs")) {
Assert.assertEquals(Long.valueOf(826271L), (Long) gm.getValue());
} else if (metricName.equals("tcp_in_errs")) {
Assert.assertEquals(Long.valueOf(12712L), (Long) gm.getValue());
} else if (metricName.equals("tcp_in_segs")) {
Assert.assertEquals(Long.valueOf(1034019111L), (Long) gm.getValue());
} else if (metricName.equals("tcp_out_segs")) {
Assert.assertEquals(Long.valueOf(1166716939L), (Long) gm.getValue());
} else {
Assert.fail();
}
}
}
}