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;
021import org.apache.hadoop.hbase.HBaseClassTestRule;
022import org.apache.hadoop.hbase.HBaseTestingUtility;
023import org.apache.hadoop.hbase.HConstants;
024import org.apache.hadoop.hbase.TableName;
025import org.apache.hadoop.hbase.io.compress.Compression;
026import org.apache.hadoop.hbase.regionserver.wal.CompressionContext;
027import org.apache.hadoop.hbase.testclassification.MediumTests;
028import org.apache.hadoop.hbase.testclassification.RegionServerTests;
029import org.junit.After;
030import org.junit.Before;
031import org.junit.ClassRule;
032import org.junit.Rule;
033import org.junit.Test;
034import org.junit.experimental.categories.Category;
035import org.junit.rules.TestName;
036import org.junit.runner.RunWith;
037import org.junit.runners.Parameterized;
038import org.junit.runners.Parameterized.Parameters;
039
040@RunWith(Parameterized.class)
041@Category({ RegionServerTests.class, MediumTests.class })
042public class TestCompressedWALValueCompression extends CompressedWALTestBase {
043
044  @ClassRule
045  public static final HBaseClassTestRule CLASS_RULE =
046    HBaseClassTestRule.forClass(TestCompressedWALValueCompression.class);
047
048  @Parameters
049  public static List<Object[]> params() {
050    return HBaseTestingUtility.COMPRESSION_ALGORITHMS_PARAMETERIZED;
051  }
052
053  @Rule
054  public TestName name = new TestName();
055
056  private final Compression.Algorithm compression;
057
058  public TestCompressedWALValueCompression(Compression.Algorithm algo) {
059    this.compression = algo;
060  }
061
062  @Before
063  public void setUp() throws Exception {
064    TEST_UTIL.getConfiguration().setBoolean(HConstants.ENABLE_WAL_COMPRESSION, true);
065    TEST_UTIL.getConfiguration().setBoolean(CompressionContext.ENABLE_WAL_VALUE_COMPRESSION, true);
066    TEST_UTIL.getConfiguration().set(CompressionContext.WAL_VALUE_COMPRESSION_TYPE,
067      compression.getName());
068    TEST_UTIL.startMiniDFSCluster(3);
069  }
070
071  @After
072  public void tearDown() throws Exception {
073    TEST_UTIL.shutdownMiniCluster();
074  }
075
076  @Test
077  public void test() throws Exception {
078    TableName tableName = TableName.valueOf(name.getMethodName().replaceAll("[^a-zA-Z0-9]", "_"));
079    doTest(tableName);
080  }
081
082}