1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.hadoop.hbase.regionserver.wal;
21
22 import org.apache.hadoop.hbase.testclassification.SmallTests;
23 import org.junit.Test;
24 import org.junit.experimental.categories.Category;
25
26 import static org.mockito.Mockito.mock;
27 import static org.mockito.Mockito.times;
28 import static org.mockito.Mockito.verify;
29
30 @Category(SmallTests.class)
31 public class TestMetricsWAL {
32 @Test
33 public void testLogRollRequested() throws Exception {
34 MetricsWALSource source = mock(MetricsWALSourceImpl.class);
35 MetricsWAL metricsWAL = new MetricsWAL(source);
36 metricsWAL.logRollRequested(false);
37 metricsWAL.logRollRequested(true);
38
39
40 verify(source, times(2)).incrementLogRollRequested();
41
42 verify(source, times(1)).incrementLowReplicationLogRoll();
43 }
44
45 @Test
46 public void testWalWrittenInBytes() throws Exception {
47 MetricsWALSource source = mock(MetricsWALSourceImpl.class);
48 MetricsWAL metricsWAL = new MetricsWAL(source);
49 metricsWAL.finishAppend(900, 100);
50 metricsWAL.finishAppend(1000, 200);
51 verify(source, times(1)).incrementWrittenBytes(100);
52 verify(source, times(1)).incrementWrittenBytes(200);
53 }
54
55 }