Skip to content

Commit

Permalink
HBASE-25277 Removed the test case
Browse files Browse the repository at this point in the history
  • Loading branch information
pankaj72981 committed Dec 18, 2020
1 parent c3e87d7 commit a42058a
Showing 1 changed file with 0 additions and 72 deletions.
Expand Up @@ -22,14 +22,9 @@
import static org.apache.hadoop.hbase.coprocessor.CoprocessorHost.SKIP_LOAD_DUPLICATE_TABLE_COPROCESSOR;
import static org.apache.hadoop.hbase.coprocessor.CoprocessorHost.USER_COPROCESSORS_ENABLED_CONF_KEY;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

import java.io.IOException;
import java.util.Optional;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration;
Expand All @@ -43,12 +38,9 @@
import org.apache.hadoop.hbase.regionserver.RegionServerServices;
import org.apache.hadoop.hbase.testclassification.SmallTests;

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;

@Category({SmallTests.class})
public class TestRegionCoprocessorHost {
Expand All @@ -57,39 +49,6 @@ public class TestRegionCoprocessorHost {
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestRegionCoprocessorHost.class);

@Rule public final TestName name = new TestName();
private Configuration conf;
private RegionInfo regionInfo;
private HRegion region;
private RegionServerServices rsServices;

@Before public void setup() throws IOException {
init(null);
}

private void init(Boolean flag) throws IOException {
conf = HBaseConfiguration.create();
conf.setBoolean(COPROCESSORS_ENABLED_CONF_KEY, true);
conf.setBoolean(USER_COPROCESSORS_ENABLED_CONF_KEY, true);
TableName tableName = TableName.valueOf(name.getMethodName());
regionInfo = RegionInfoBuilder.newBuilder(tableName).build();
TableDescriptor tableDesc = null;
if (flag == null) {
// configure a coprocessor which override postScannerFilterRow
tableDesc = TableDescriptorBuilder.newBuilder(tableName)
.setCoprocessor(SimpleRegionObserver.class.getName()).build();
} else if (flag) {
// configure a coprocessor which don't override postScannerFilterRow
tableDesc = TableDescriptorBuilder.newBuilder(tableName)
.setCoprocessor(TempRegionObserver.class.getName()).build();
} else {
// configure two coprocessors, one don't override postScannerFilterRow but another one does
conf.set(REGION_COPROCESSOR_CONF_KEY, TempRegionObserver.class.getName());
tableDesc = TableDescriptorBuilder.newBuilder(tableName)
.setCoprocessor(SimpleRegionObserver.class.getName()).build();
}
}

@Test
public void testLoadDuplicateCoprocessor() throws Exception {
Configuration conf = HBaseConfiguration.create();
Expand All @@ -116,35 +75,4 @@ public void testLoadDuplicateCoprocessor() throws Exception {
// Two duplicate coprocessors loaded
assertEquals(2, host.coprocEnvironments.size());
}

@Test
public void testPostScannerFilterRow() throws IOException {
// By default SimpleRegionObserver is set as region coprocessor which implements
// postScannerFilterRow
RegionCoprocessorHost host = new RegionCoprocessorHost(region, rsServices, conf);
assertTrue("Region coprocessor implement postScannerFilterRow",
host.hasCustomPostScannerFilterRow());

// Set a region CP which doesn't implement postScannerFilterRow
init(true);
host = new RegionCoprocessorHost(region, rsServices, conf);
assertFalse("Region coprocessor implement postScannerFilterRow",
host.hasCustomPostScannerFilterRow());

// Set multiple region CPs, in which one implements postScannerFilterRow
init(false);
host = new RegionCoprocessorHost(region, rsServices, conf);
assertTrue("Region coprocessor doesn't implement postScannerFilterRow",
host.hasCustomPostScannerFilterRow());
}

/*
* Simple region coprocessor which doesn't override postScannerFilterRow
*/
public static class TempRegionObserver implements RegionCoprocessor, RegionObserver {
@Override
public Optional<RegionObserver> getRegionObserver() {
return Optional.of(this);
}
}
}

0 comments on commit a42058a

Please sign in to comment.