Skip to content
Merged
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 @@ -24,7 +24,7 @@
import java.util.concurrent.atomic.AtomicLong;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseParameterizedTestTemplate;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.MultithreadedTestUtil.RepeatingTestThread;
import org.apache.hadoop.hbase.MultithreadedTestUtil.TestContext;
Expand All @@ -40,12 +40,9 @@
import org.apache.hadoop.hbase.testclassification.RegionServerTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.Pair;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Ignore;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -59,22 +56,20 @@
* Tests bulk loading of HFiles with old secure Endpoint client for backward compatibility. Will be
* removed when old non-secure client for backward compatibility is not supported.
*/
@RunWith(Parameterized.class)
@Category({ RegionServerTests.class, LargeTests.class })
@Ignore // BROKEN. FIX OR REMOVE.
@Tag(RegionServerTests.TAG)
@Tag(LargeTests.TAG)
@HBaseParameterizedTestTemplate(name = "{index}: duration={0}")
@Disabled // BROKEN. FIX OR REMOVE.
public class TestHRegionServerBulkLoadWithOldSecureEndpoint extends TestHRegionServerBulkLoad {
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestHRegionServerBulkLoadWithOldSecureEndpoint.class);

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

public TestHRegionServerBulkLoadWithOldSecureEndpoint(int duration) {
super(duration);
}

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

@BeforeClass
@BeforeAll
public static void setUpBeforeClass() throws IOException {
conf.setInt("hbase.rpc.timeout", 10 * 1000);
conf.set(CoprocessorHost.REGION_COPROCESSOR_CONF_KEY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
package org.apache.hadoop.hbase.regionserver;

import static org.apache.hadoop.hbase.regionserver.Store.PRIORITY_USER;
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 java.io.IOException;
import java.security.Key;
Expand All @@ -38,7 +42,6 @@
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellComparatorImpl;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.HConstants;
Expand Down Expand Up @@ -71,27 +74,18 @@
import org.apache.hadoop.hbase.util.CommonFSUtils;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.wal.WALFactory;
import org.junit.Assert;
import org.junit.Before;
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.Test;
import org.junit.jupiter.api.TestInfo;
import org.mockito.Mockito;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Category(MediumTests.class)
@org.junit.jupiter.api.Tag(MediumTests.TAG)
public class TestHMobStore {

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

public static final Logger LOG = LoggerFactory.getLogger(TestHMobStore.class);
@Rule
public TestName name = new TestName();
private String name;

private HMobStore store;
private HRegion region;
Expand Down Expand Up @@ -123,8 +117,9 @@ public class TestHMobStore {
/**
* Setup
*/
@Before
public void setUp() throws Exception {
@BeforeEach
public void setUp(TestInfo testInfo) throws Exception {
this.name = testInfo.getTestMethod().get().getName();
qualifiers.add(qf1);
qualifiers.add(qf3);
qualifiers.add(qf5);
Expand Down Expand Up @@ -210,7 +205,7 @@ private void init(Configuration conf, ColumnFamilyDescriptor cfd) throws IOExcep
@Test
public void testGetFromMemStore() throws IOException {
final Configuration conf = HBaseConfiguration.create();
init(name.getMethodName(), conf, false);
init(name, conf, false);

// Put data in memstore
this.store.add(new KeyValue(row, family, qf1, 1, value), null);
Expand All @@ -230,10 +225,10 @@ public void testGetFromMemStore() throws IOException {
scanner.close();

// Compare
Assert.assertEquals(expected.size(), results.size());
assertEquals(expected.size(), results.size());
for (int i = 0; i < results.size(); i++) {
// Verify the values
Assert.assertEquals(expected.get(i), results.get(i));
assertEquals(expected.get(i), results.get(i));
}
}

Expand All @@ -243,7 +238,7 @@ public void testGetFromMemStore() throws IOException {
@Test
public void testGetFromFiles() throws IOException {
final Configuration conf = TEST_UTIL.getConfiguration();
init(name.getMethodName(), conf, false);
init(name, conf, false);

// Put data in memstore
this.store.add(new KeyValue(row, family, qf1, 1, value), null);
Expand Down Expand Up @@ -273,9 +268,9 @@ public void testGetFromFiles() throws IOException {
scanner.close();

// Compare
Assert.assertEquals(expected.size(), results.size());
assertEquals(expected.size(), results.size());
for (int i = 0; i < results.size(); i++) {
Assert.assertEquals(expected.get(i), results.get(i));
assertEquals(expected.get(i), results.get(i));
}
}

Expand All @@ -285,7 +280,7 @@ public void testGetFromFiles() throws IOException {
@Test
public void testGetReferencesFromFiles() throws IOException {
final Configuration conf = HBaseConfiguration.create();
init(name.getMethodName(), conf, false);
init(name, conf, false);

// Put data in memstore
this.store.add(new KeyValue(row, family, qf1, 1, value), null);
Expand Down Expand Up @@ -316,10 +311,10 @@ public void testGetReferencesFromFiles() throws IOException {
scanner.close();

// Compare
Assert.assertEquals(expected.size(), results.size());
assertEquals(expected.size(), results.size());
for (int i = 0; i < results.size(); i++) {
Cell cell = results.get(i);
Assert.assertTrue(MobUtils.isMobReferenceCell(cell));
assertTrue(MobUtils.isMobReferenceCell(cell));
}
}

Expand All @@ -331,7 +326,7 @@ public void testGetFromMemStoreAndFiles() throws IOException {

final Configuration conf = HBaseConfiguration.create();

init(name.getMethodName(), conf, false);
init(name, conf, false);

// Put data in memstore
this.store.add(new KeyValue(row, family, qf1, 1, value), null);
Expand Down Expand Up @@ -359,9 +354,9 @@ public void testGetFromMemStoreAndFiles() throws IOException {
scanner.close();

// Compare
Assert.assertEquals(expected.size(), results.size());
assertEquals(expected.size(), results.size());
for (int i = 0; i < results.size(); i++) {
Assert.assertEquals(expected.get(i), results.get(i));
assertEquals(expected.get(i), results.get(i));
}
}

Expand All @@ -373,7 +368,7 @@ public void testMobCellSizeThreshold() throws IOException {
final Configuration conf = HBaseConfiguration.create();
ColumnFamilyDescriptor cfd = ColumnFamilyDescriptorBuilder.newBuilder(family)
.setMobEnabled(true).setMobThreshold(100).setMaxVersions(4).build();
init(name.getMethodName(), conf, cfd, false);
init(name, conf, cfd, false);

// Put data in memstore
this.store.add(new KeyValue(row, family, qf1, 1, value), null);
Expand Down Expand Up @@ -404,34 +399,34 @@ public void testMobCellSizeThreshold() throws IOException {
scanner.close();

// Compare
Assert.assertEquals(expected.size(), results.size());
assertEquals(expected.size(), results.size());
for (int i = 0; i < results.size(); i++) {
Cell cell = results.get(i);
// this is not mob reference cell.
Assert.assertFalse(MobUtils.isMobReferenceCell(cell));
Assert.assertEquals(expected.get(i), results.get(i));
Assert.assertEquals(100, store.getColumnFamilyDescriptor().getMobThreshold());
assertFalse(MobUtils.isMobReferenceCell(cell));
assertEquals(expected.get(i), results.get(i));
assertEquals(100, store.getColumnFamilyDescriptor().getMobThreshold());
}
}

@Test
public void testCommitFile() throws Exception {
final Configuration conf = HBaseConfiguration.create();
init(name.getMethodName(), conf, true);
init(name, conf, true);
String targetPathName = MobUtils.formatDate(new Date());
Path targetPath =
new Path(store.getPath(), (targetPathName + Path.SEPARATOR + mobFilePath.getName()));
fs.delete(targetPath, true);
Assert.assertFalse(fs.exists(targetPath));
assertFalse(fs.exists(targetPath));
// commit file
store.commitFile(mobFilePath, targetPath);
Assert.assertTrue(fs.exists(targetPath));
assertTrue(fs.exists(targetPath));
}

@Test
public void testResolve() throws Exception {
final Configuration conf = HBaseConfiguration.create();
init(name.getMethodName(), conf, true);
init(name, conf, true);
String targetPathName = MobUtils.formatDate(currentDate);
Path targetPath = new Path(store.getPath(), targetPathName);
store.commitFile(mobFilePath, targetPath);
Expand All @@ -440,18 +435,18 @@ public void testResolve() throws Exception {
Cell resultCell2 = store.resolve(seekKey2, false).getCell();
Cell resultCell3 = store.resolve(seekKey3, false).getCell();
// compare
Assert.assertEquals(Bytes.toString(value), Bytes.toString(CellUtil.cloneValue(resultCell1)));
Assert.assertEquals(Bytes.toString(value), Bytes.toString(CellUtil.cloneValue(resultCell2)));
Assert.assertEquals(Bytes.toString(value2), Bytes.toString(CellUtil.cloneValue(resultCell3)));
assertEquals(Bytes.toString(value), Bytes.toString(CellUtil.cloneValue(resultCell1)));
assertEquals(Bytes.toString(value), Bytes.toString(CellUtil.cloneValue(resultCell2)));
assertEquals(Bytes.toString(value2), Bytes.toString(CellUtil.cloneValue(resultCell3)));
}

/**
* Flush the memstore
*/
private void flush(int storeFilesSize) throws IOException {
flushStore(store, id++);
Assert.assertEquals(storeFilesSize, this.store.getStorefiles().size());
Assert.assertEquals(0, ((AbstractMemStore) this.store.memstore).getActive().getCellsCount());
assertEquals(storeFilesSize, this.store.getStorefiles().size());
assertEquals(0, ((AbstractMemStore) this.store.memstore).getActive().getCellsCount());
}

/**
Expand Down Expand Up @@ -481,7 +476,7 @@ public void testMOBStoreEncryption() throws Exception {
conf.get(HConstants.CRYPTO_MASTERKEY_NAME_CONF_KEY, User.getCurrent().getShortName()),
cfKey))
.build();
init(name.getMethodName(), conf, cfd, false);
init(name, conf, cfd, false);

this.store.add(new KeyValue(row, family, qf1, 1, value), null);
this.store.add(new KeyValue(row, family, qf2, 1, value), null);
Expand All @@ -505,17 +500,17 @@ public void testMOBStoreEncryption() throws Exception {
scanner.next(results);
Collections.sort(results, CellComparatorImpl.COMPARATOR);
scanner.close();
Assert.assertEquals(expected.size(), results.size());
assertEquals(expected.size(), results.size());
for (int i = 0; i < results.size(); i++) {
Assert.assertEquals(expected.get(i), results.get(i));
assertEquals(expected.get(i), results.get(i));
}

// Trigger major compaction
this.store.triggerMajorCompaction();
Optional<CompactionContext> requestCompaction =
this.store.requestCompaction(PRIORITY_USER, CompactionLifeCycleTracker.DUMMY, null);
this.store.compact(requestCompaction.get(), NoLimitThroughputController.INSTANCE, null);
Assert.assertEquals(1, this.store.getStorefiles().size());
assertEquals(1, this.store.getStorefiles().size());

// Check encryption after compaction
checkMobHFileEncrytption(this.store.getStorefiles());
Expand All @@ -525,9 +520,8 @@ private void checkMobHFileEncrytption(Collection<HStoreFile> storefiles) {
HStoreFile storeFile = storefiles.iterator().next();
HFile.Reader reader = storeFile.getReader().getHFileReader();
byte[] encryptionKey = reader.getTrailer().getEncryptionKey();
Assert.assertTrue(null != encryptionKey);
Assert.assertTrue(reader.getFileContext().getEncryptionContext().getCipher().getName()
.equals(HConstants.CIPHER_AES));
assertNotNull(encryptionKey);
assertEquals(HConstants.CIPHER_AES,
reader.getFileContext().getEncryptionContext().getCipher().getName());
}

}
Loading
Loading