Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions hbase-metrics/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,6 @@
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,23 @@
*/
package org.apache.hadoop.hbase.metrics.impl;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.metrics.Counter;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

/**
* Test class for {@link CounterImpl}.
*/
@Category(SmallTests.class)
@Tag(SmallTests.TAG)
public class TestCounterImpl {

@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestCounterImpl.class);

private Counter counter;

@Before
@BeforeEach
public void setup() {
this.counter = new CounterImpl();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,21 @@
package org.apache.hadoop.hbase.metrics.impl;

import com.codahale.metrics.Meter;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

/**
* Test class for {@link DropwizardMeter}.
*/
@Category(SmallTests.class)
@Tag(SmallTests.TAG)
public class TestDropwizardMeter {

@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestDropwizardMeter.class);

private Meter meter;

@Before
@BeforeEach
public void setup() {
this.meter = Mockito.mock(Meter.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,24 @@
*/
package org.apache.hadoop.hbase.metrics.impl;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.Arrays;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MiscTests;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.junit.Assert;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

/**
* Testcases for FastLongHistogram.
*/
@Category({ MiscTests.class, SmallTests.class })
@Tag(MiscTests.TAG)
@Tag(SmallTests.TAG)
public class TestFastLongHistogram {

@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestFastLongHistogram.class);

private static void doTestUniform(FastLongHistogram hist) {
long[] VALUES = { 0, 10, 20, 30, 40, 50 };
double[] qs = new double[VALUES.length];
Expand All @@ -54,8 +49,8 @@ private static void doTestUniform(FastLongHistogram hist) {
long[] vals = hist.getQuantiles(qs);
System.out.println(Arrays.toString(vals));
for (int j = 0; j < qs.length; j++) {
Assert.assertTrue(j + "-th element org: " + VALUES[j] + ", act: " + vals[j],
Math.abs(vals[j] - VALUES[j]) <= 10);
assertTrue(Math.abs(vals[j] - VALUES[j]) <= 10,
j + "-th element org: " + VALUES[j] + ", act: " + vals[j]);
}
hist.snapshotAndReset();
}
Expand Down Expand Up @@ -87,9 +82,9 @@ public void testAdaptionOfChange() {
long[] vals = hist.getQuantiles(new double[] { 0.25, 0.75, 0.95 });
System.out.println(Arrays.toString(vals));
if (n == 0) {
Assert.assertTrue("Out of possible value", vals[0] >= 0 && vals[0] <= 50);
Assert.assertTrue("Out of possible value", vals[1] >= 50 && vals[1] <= 100);
Assert.assertTrue("Out of possible value", vals[2] >= 900 && vals[2] <= 1100);
assertTrue(vals[0] >= 0 && vals[0] <= 50, "Out of possible value");
assertTrue(vals[1] >= 50 && vals[1] <= 100, "Out of possible value");
assertTrue(vals[2] >= 900 && vals[2] <= 1100, "Out of possible value");
}

hist.snapshotAndReset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,26 @@
*/
package org.apache.hadoop.hbase.metrics.impl;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.concurrent.atomic.AtomicLong;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.metrics.Gauge;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

/**
* Test class for {@link Gauge}.
*/
@Category(SmallTests.class)
@Tag(SmallTests.TAG)
public class TestGauge {

@ClassRule
public static final HBaseClassTestRule CLASS_RULE = HBaseClassTestRule.forClass(TestGauge.class);

@Test
public void testGetValue() {
SimpleGauge gauge = new SimpleGauge();

assertEquals(0, (long) gauge.getValue());

gauge.setValue(1000L);

assertEquals(1000L, (long) gauge.getValue());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,23 @@
*/
package org.apache.hadoop.hbase.metrics.impl;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.stream.IntStream;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.metrics.Snapshot;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

/**
* Test case for {@link HistogramImpl}
*/
@Category(SmallTests.class)
@Tag(SmallTests.TAG)
public class TestHistogramImpl {

@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestHistogramImpl.class);

@Test
public void testUpdate() {
HistogramImpl histogram = new HistogramImpl();

assertEquals(0, histogram.getCount());

histogram.update(0);
Expand All @@ -51,7 +44,6 @@ public void testUpdate() {

histogram.update(20);
histogram.update(30);

assertEquals(4, histogram.getCount());
}

Expand All @@ -61,7 +53,6 @@ public void testSnapshot() {
IntStream.range(0, 100).forEach(histogram::update);

Snapshot snapshot = histogram.snapshot();

assertEquals(100, snapshot.getCount());
assertEquals(49, snapshot.getMedian());
assertEquals(49, snapshot.getMean());
Expand Down Expand Up @@ -100,9 +91,7 @@ public void testSnapshot() {
assertEquals(199, snapshot.get999thPercentile());

IntStream.range(500, 1000).forEach(histogram::update);

snapshot = histogram.snapshot();

assertEquals(500, snapshot.getCount());
assertEquals(749, snapshot.getMedian());
assertEquals(749, snapshot.getMean());
Expand All @@ -115,6 +104,5 @@ public void testSnapshot() {
assertEquals(989, snapshot.get98thPercentile());
assertEquals(994, snapshot.get99thPercentile());
assertEquals(998, snapshot.get999thPercentile());

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,23 @@
*/
package org.apache.hadoop.hbase.metrics.impl;

import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.Optional;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.metrics.MetricRegistries;
import org.apache.hadoop.hbase.metrics.MetricRegistry;
import org.apache.hadoop.hbase.metrics.MetricRegistryInfo;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

/**
* Test class for {@link MetricRegistries}.
*/
@Category(SmallTests.class)
@Tag(SmallTests.TAG)
public class TestMetricRegistriesImpl {

@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestMetricRegistriesImpl.class);

@Test
public void testMetricsRegistriesRemoveRef() {
MetricRegistryInfo registryInfo =
Expand All @@ -57,6 +52,6 @@ public void testMetricsRegistriesRemoveRef() {

MetricRegistries.global().remove(registryInfo);
Optional<MetricRegistry> registry4 = MetricRegistries.global().get(registryInfo);
assertTrue(!registry4.isPresent());
assertFalse(registry4.isPresent());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,31 @@
*/
package org.apache.hadoop.hbase.metrics.impl;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.Map;
import java.util.Optional;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.metrics.Counter;
import org.apache.hadoop.hbase.metrics.Gauge;
import org.apache.hadoop.hbase.metrics.Meter;
import org.apache.hadoop.hbase.metrics.Metric;
import org.apache.hadoop.hbase.metrics.MetricRegistryInfo;
import org.apache.hadoop.hbase.metrics.Timer;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

@Category(SmallTests.class)
@Tag(SmallTests.TAG)
public class TestMetricRegistryImpl {

@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestMetricRegistryImpl.class);

private MetricRegistryInfo info;
private MetricRegistryImpl registry;

@Before
@BeforeEach
public void setUp() {
info = new MetricRegistryInfo("foo", "bar", "baz", "foobar", false);
registry = new MetricRegistryImpl(info);
Expand Down Expand Up @@ -112,8 +106,8 @@ public void testRegister() {

@Test
public void testDoubleRegister() {
Gauge g1 = registry.register("mygauge", () -> 42L);
Gauge g2 = registry.register("mygauge", () -> 52L);
Gauge<Long> g1 = registry.register("mygauge", () -> 42L);
Gauge<Long> g2 = registry.register("mygauge", () -> 52L);

// second gauge is ignored if it exists
assertEquals(g1, g2);
Expand All @@ -132,7 +126,7 @@ public void testDoubleRegister() {
public void testGetMetrics() {
CounterImpl counter = new CounterImpl();
registry.register("mycounter", counter);
Gauge gauge = registry.register("mygauge", () -> 42L);
Gauge<Long> gauge = registry.register("mygauge", () -> 42L);
Timer timer = registry.timer("mytimer");

Map<String, Metric> metrics = registry.getMetrics();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,26 @@
*/
package org.apache.hadoop.hbase.metrics.impl;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.Collection;
import java.util.Set;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

import org.apache.hbase.thirdparty.com.google.common.collect.Lists;

@Category(SmallTests.class)
@Tag(SmallTests.TAG)
public class TestRefCountingMap {

@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestRefCountingMap.class);

private RefCountingMap<String, String> map;

@Before
@BeforeEach
public void setUp() {
map = new RefCountingMap<>();
}
Expand Down
Loading