Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@
*/
package org.apache.hadoop.hbase.regionserver;

import static junit.framework.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.TableExistsException;
import org.apache.hadoop.hbase.TableName;
Expand All @@ -46,23 +45,18 @@
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

@Category({ RegionServerTests.class, MediumTests.class })
@Tag(RegionServerTests.TAG)
@Tag(MediumTests.TAG)
/*
* This test verifies that the scenarios illustrated by HBASE-10850 work w.r.t. essential column
* family optimization
*/
public class TestSCVFWithMiniCluster {

@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestSCVFWithMiniCluster.class);

private static final TableName HBASE_TABLE_NAME = TableName.valueOf("TestSCVFWithMiniCluster");

private static final byte[] FAMILY_A = Bytes.toBytes("a");
Expand All @@ -77,7 +71,7 @@ public class TestSCVFWithMiniCluster {

private int expected = 1;

@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
HBaseTestingUtil util = new HBaseTestingUtil();

Expand Down Expand Up @@ -128,7 +122,7 @@ public static void setUp() throws Exception {
((SingleColumnValueFilter) scanFilter).setFilterIfMissing(true);
}

@AfterClass
@AfterAll
public static void tearDown() throws Exception {
htable.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@
*/
package org.apache.hadoop.hbase.regionserver;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.NavigableSet;
import java.util.TreeSet;
import java.util.stream.Stream;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseParameterizedTestTemplate;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.KeyValueTestUtil;
Expand All @@ -48,28 +48,21 @@
import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.BloomFilterUtil;
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.params.provider.Arguments;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Test a multi-column scanner when there is a Bloom filter false-positive. This is needed for the
* multi-column Bloom filter optimization.
*/
@RunWith(Parameterized.class)
@Category({ RegionServerTests.class, SmallTests.class })
@Tag(RegionServerTests.TAG)
@Tag(SmallTests.TAG)
@HBaseParameterizedTestTemplate(name = "{index}: bloomType={0}")
public class TestScanWithBloomError {

@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestScanWithBloomError.class);

private static final Logger LOG = LoggerFactory.getLogger(TestScanWithBloomError.class);

private static final String TABLE_NAME = "ScanWithBloomError";
Expand All @@ -86,27 +79,26 @@ public class TestScanWithBloomError {

private final static HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();

@Parameters
public static final Collection<Object[]> parameters() {
List<Object[]> configurations = new ArrayList<>();
public static final Stream<Arguments> parameters() {
List<Arguments> configurations = new ArrayList<>();
for (BloomType bloomType : BloomType.values()) {
configurations.add(new Object[] { bloomType });
configurations.add(Arguments.of(bloomType));
}
return configurations;
return configurations.stream();
}

public TestScanWithBloomError(BloomType bloomType) {
this.bloomType = bloomType;
}

@Before
@BeforeEach
public void setUp() throws IOException {
conf = TEST_UTIL.getConfiguration();
fs = FileSystem.get(conf);
conf.setInt(BloomFilterUtil.PREFIX_LENGTH_KEY, 10);
}

@Test
@TestTemplate
public void testThreeStoreFiles() throws IOException {
ColumnFamilyDescriptor columnFamilyDescriptor = ColumnFamilyDescriptorBuilder
.newBuilder(Bytes.toBytes(FAMILY)).setCompressionType(Compression.Algorithm.GZ)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,17 @@
import static org.apache.hadoop.hbase.HBaseTestingUtil.START_KEY_BYTES;
import static org.apache.hadoop.hbase.HBaseTestingUtil.fam1;
import static org.apache.hadoop.hbase.HBaseTestingUtil.fam2;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HTestConst;
Expand All @@ -57,26 +56,20 @@
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.rules.TestName;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Test of a long-lived scanner validating as we go.
*/
@Category({ RegionServerTests.class, MediumTests.class })
@Tag(RegionServerTests.TAG)
@Tag(MediumTests.TAG)
public class TestScanner {

@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestScanner.class);

@Rule
public TestName name = new TestName();
private String name;

private static final Logger LOG = LoggerFactory.getLogger(TestScanner.class);
private final static HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
Expand All @@ -100,6 +93,11 @@ public class TestScanner {
public static final RegionInfo REGION_INFO =
RegionInfoBuilder.newBuilder(TESTTABLEDESC.getTableName()).build();

@BeforeEach
public void setTestName(TestInfo testInfo) {
this.name = testInfo.getTestMethod().get().getName();
}

private static final byte[] ROW_KEY = REGION_INFO.getRegionName();

private static final long START_CODE = Long.MAX_VALUE;
Expand Down Expand Up @@ -493,7 +491,7 @@ public void testScanAndRealConcurrentFlush() throws Exception {
*/
@Test
public void testScanAndConcurrentMajorCompact() throws Exception {
TableDescriptor htd = TEST_UTIL.createTableDescriptor(TableName.valueOf(name.getMethodName()),
TableDescriptor htd = TEST_UTIL.createTableDescriptor(TableName.valueOf(name),
ColumnFamilyDescriptorBuilder.DEFAULT_MIN_VERSIONS, 3, HConstants.FOREVER,
ColumnFamilyDescriptorBuilder.DEFAULT_KEEP_DELETED);
this.region = TEST_UTIL.createLocalHRegion(htd, null, null);
Expand Down Expand Up @@ -525,7 +523,7 @@ public void testScanAndConcurrentMajorCompact() throws Exception {
s.next(results);

// make sure returns column2 of firstRow
assertTrue("result is not correct, keyValues : " + results, results.size() == 1);
assertTrue(results.size() == 1, "result is not correct, keyValues : " + results);
assertTrue(CellUtil.matchingRows(results.get(0), firstRowBytes));
assertTrue(CellUtil.matchingFamily(results.get(0), fam2));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@
*/
package org.apache.hadoop.hbase.regionserver;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtil;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.TableName;
Expand All @@ -46,19 +45,13 @@
import org.apache.hadoop.hbase.filter.SkipFilter;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

@Category({ LargeTests.class })
@Tag(LargeTests.TAG)
public class TestScannerBlockSizeLimits {

@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestScannerBlockSizeLimits.class);

private static final HBaseTestingUtil TEST_UTIL = new HBaseTestingUtil();
private static final TableName TABLE = TableName.valueOf("TestScannerBlockSizeLimits");
private static final byte[] FAMILY1 = Bytes.toBytes("0");
Expand All @@ -72,7 +65,7 @@ public class TestScannerBlockSizeLimits {
private static final byte[] COLUMN3 = Bytes.toBytes(2);
private static final byte[] COLUMN5 = Bytes.toBytes(5);

@BeforeClass
@BeforeAll
public static void setUp() throws Exception {
Configuration conf = TEST_UTIL.getConfiguration();
conf.setInt(HConstants.HBASE_SERVER_SCANNER_MAX_RESULT_SIZE_KEY, 4200);
Expand All @@ -81,7 +74,7 @@ public static void setUp() throws Exception {
createTestData();
}

@Before
@BeforeEach
public void setupEach() throws Exception {
HRegionServer regionServer = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0);
for (HRegion region : regionServer.getRegions(TABLE)) {
Expand Down Expand Up @@ -169,8 +162,8 @@ public void testCheckLimitAfterFilterRowKey() throws IOException {
rows.add(Bytes.toInt(cell.getRowArray(), cell.getRowOffset(), cell.getRowLength()));
}
if (rows.contains(3)) {
assertFalse("expected row3 to come all in one result, but found it in two results",
foundRow3);
assertFalse(foundRow3,
"expected row3 to come all in one result, but found it in two results");
assertEquals(1, rows.size());
foundRow3 = true;
}
Expand Down
Loading