001/**
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.wal;
019
020import java.util.List;
021
022import org.apache.hadoop.hbase.HBaseClassTestRule;
023import org.apache.hadoop.hbase.HBaseCommonTestingUtil;
024import org.apache.hadoop.hbase.HBaseTestingUtil;
025import org.apache.hadoop.hbase.HConstants;
026import org.apache.hadoop.hbase.TableName;
027import org.apache.hadoop.hbase.io.compress.Compression;
028import org.apache.hadoop.hbase.regionserver.wal.CompressionContext;
029import org.apache.hadoop.hbase.testclassification.MediumTests;
030import org.apache.hadoop.hbase.testclassification.RegionServerTests;
031import org.junit.After;
032import org.junit.Before;
033import org.junit.ClassRule;
034import org.junit.Rule;
035import org.junit.Test;
036import org.junit.experimental.categories.Category;
037import org.junit.rules.TestName;
038import org.junit.runner.RunWith;
039import org.junit.runners.Parameterized;
040import org.junit.runners.Parameterized.Parameters;
041
042@RunWith(Parameterized.class)
043@Category({ RegionServerTests.class, MediumTests.class })
044public class TestCompressedWALValueCompression extends CompressedWALTestBase {
045
046  @ClassRule
047  public static final HBaseClassTestRule CLASS_RULE =
048      HBaseClassTestRule.forClass(TestCompressedWALValueCompression.class);
049
050  private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
051
052  @Parameters
053  public static List<Object[]> params() {
054    return HBaseCommonTestingUtil.COMPRESSION_ALGORITHMS_PARAMETERIZED;
055  }
056
057  @Rule
058  public TestName name = new TestName();
059
060  private final Compression.Algorithm compression;
061
062  public TestCompressedWALValueCompression(Compression.Algorithm algo) {
063    this.compression = algo;
064  }
065
066  @Before
067  public void setUp() throws Exception {
068    TEST_UTIL.getConfiguration()
069      .setBoolean(HConstants.ENABLE_WAL_COMPRESSION, true);
070    TEST_UTIL.getConfiguration()
071      .setBoolean(CompressionContext.ENABLE_WAL_VALUE_COMPRESSION, true);
072    TEST_UTIL.getConfiguration()
073      .set(CompressionContext.WAL_VALUE_COMPRESSION_TYPE, compression.getName());
074    TEST_UTIL.startMiniDFSCluster(3);
075  }
076
077  @After
078  public void tearDown() throws Exception {
079    TEST_UTIL.shutdownMiniCluster();
080  }
081
082  @Test
083  public void test() throws Exception {
084    TableName tableName = TableName.valueOf(name.getMethodName().replaceAll("[^a-zA-Z0-9]", "_"));
085    doTest(tableName);
086  }
087
088}