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.stream.Stream;
021import org.apache.hadoop.hbase.HBaseCommonTestingUtil;
022import org.apache.hadoop.hbase.HConstants;
023import org.apache.hadoop.hbase.io.compress.Compression;
024import org.apache.hadoop.hbase.regionserver.wal.CompressionContext;
025import org.apache.hadoop.hbase.testclassification.MediumTests;
026import org.apache.hadoop.hbase.testclassification.RegionServerTests;
027import org.junit.jupiter.api.AfterEach;
028import org.junit.jupiter.api.BeforeEach;
029import org.junit.jupiter.api.Tag;
030import org.junit.jupiter.params.ParameterizedClass;
031import org.junit.jupiter.params.provider.Arguments;
032import org.junit.jupiter.params.provider.MethodSource;
033
034@Tag(RegionServerTests.TAG)
035@Tag(MediumTests.TAG)
036@ParameterizedClass(name = "{index}: compression={0}")
037@MethodSource("parameters")
038public class TestCompressedWALValueCompression extends CompressedWALTestBase {
039
040  private final Compression.Algorithm compression;
041
042  public TestCompressedWALValueCompression(Compression.Algorithm algo) {
043    this.compression = algo;
044  }
045
046  public static Stream<Arguments> parameters() {
047    return HBaseCommonTestingUtil.COMPRESSION_ALGORITHMS_PARAMETERIZED.stream().map(Arguments::of);
048  }
049
050  @BeforeEach
051  public void setUp() throws Exception {
052    TEST_UTIL.getConfiguration().setBoolean(HConstants.ENABLE_WAL_COMPRESSION, true);
053    TEST_UTIL.getConfiguration().setBoolean(CompressionContext.ENABLE_WAL_VALUE_COMPRESSION, true);
054    TEST_UTIL.getConfiguration().set(CompressionContext.WAL_VALUE_COMPRESSION_TYPE,
055      compression.getName());
056    TEST_UTIL.startMiniDFSCluster(3);
057  }
058
059  @AfterEach
060  public void tearDown() throws Exception {
061    TEST_UTIL.shutdownMiniCluster();
062  }
063}