HBASE-26921 Rewrite the counting cells part in TestMultiVersions (#4316)
[hbase.git] / hbase-server / src / test / java / org / apache / hadoop / hbase / wal / TestWALProvider.java
blobbc06147d7cca3b0fe92296477a9dc075485154ee
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 package org.apache.hadoop.hbase.wal;
20 import static org.junit.Assert.assertTrue;
21 import java.io.IOException;
22 import java.util.Comparator;
23 import org.apache.hadoop.fs.Path;
24 import org.apache.hadoop.hbase.HBaseClassTestRule;
25 import org.apache.hadoop.hbase.testclassification.RegionServerTests;
26 import org.apache.hadoop.hbase.testclassification.SmallTests;
27 import org.junit.ClassRule;
28 import org.junit.Test;
29 import org.junit.experimental.categories.Category;
31 @Category({ RegionServerTests.class, SmallTests.class})
32 public class TestWALProvider {
33 @ClassRule
34 public static final HBaseClassTestRule CLASS_RULE =
35 HBaseClassTestRule.forClass(TestWALProvider.class);
37 /**
38 * Test start time comparator.
40 @Test
41 public void testWALStartTimeComparator() throws IOException {
42 Path metaPath1 = new Path("hdfs://localhost:59875/user/stack/test-data/" +
43 "f4cb8ffa-6ff7-59a6-f167-6cc00f24899a/WALs/localhost,59908,1600304600425/" +
44 "localhost%2C59908%2C1600304600425.meta.1600304604319.meta");
45 Path metaPath2 = new Path("hdfs://localhost:59875/user/stack/test-data/" +
46 "f4cb8ffa-6ff7-59a6-f167-6cc00f24899a/WALs/localhost,59908,1600304600425/" +
47 "localhost%2C59908%2C1600304600425.meta.1600304604320.meta");
48 Path path3 = new Path("hdfs://localhost:59875/user/stack/test-data/" +
49 "f4cb8ffa-6ff7-59a6-f167-6cc00f24899a/WALs/localhost,59908,1600304600425/" +
50 "localhost%2C59908%2C1600304600425.1600304604321");
51 Path metaPath4 = new Path("hdfs://localhost:59875/user/stack/test-data/" +
52 "f4cb8ffa-6ff7-59a6-f167-6cc00f24899a/WALs/localhost,59908,1600304600425/" +
53 "localhost%2C59908%2C1600304600425.meta.1600304604321.meta");
54 Comparator c = new AbstractFSWALProvider.WALStartTimeComparator();
55 assertTrue(c.compare(metaPath1, metaPath1) == 0);
56 assertTrue(c.compare(metaPath2, metaPath2) == 0);
57 assertTrue(c.compare(metaPath1, metaPath2) < 0);
58 assertTrue(c.compare(metaPath2, metaPath1) > 0);
59 assertTrue(c.compare(metaPath2, path3) < 0);
60 assertTrue(c.compare(path3, metaPath4) == 0);