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 @@ -33,8 +33,6 @@
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.rules.TestName;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Category({ MiscTests.class, SmallTests.class })
public class TestCoprocessorDescriptor {
Expand All @@ -43,8 +41,6 @@ public class TestCoprocessorDescriptor {
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestCoprocessorDescriptor.class);

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

@Rule
public TestName name = new TestName();

Expand All @@ -71,7 +67,7 @@ public void testSetCoprocessor() throws IOException {
List<CoprocessorDescriptor> cps = new ArrayList<>();
for (String className : Arrays.asList("className0", "className1", "className2")) {
String path = "path";
int priority = Math.abs(className.hashCode());
int priority = 100;
String propertyValue = "propertyValue";
cps.add(
CoprocessorDescriptorBuilder.newBuilder(className).setJarPath(path).setPriority(priority)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package org.apache.hadoop.hbase.client;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
Expand Down Expand Up @@ -107,7 +108,7 @@ public void testGetToScan() throws Exception {
assertEquals(get.getColumnFamilyTimeRange().get(Bytes.toBytes("cf")).getMax(),
scan.getColumnFamilyTimeRange().get(Bytes.toBytes("cf")).getMax());
assertEquals(get.getReplicaId(), scan.getReplicaId());
assertEquals(get.getACL(), scan.getACL());
assertArrayEquals(get.getACL(), scan.getACL());
assertEquals(get.getAuthorizations().getLabels(), scan.getAuthorizations().getLabels());
assertEquals(get.getPriority(), scan.getPriority());
}
Expand Down Expand Up @@ -259,9 +260,9 @@ public void testScanCopyConstructor() throws Exception {
Scan scanCopy = new Scan(scan);

// validate fields of copied scan object match with the original scan object
assertEquals(scan.getACL(), scanCopy.getACL());
assertArrayEquals(scan.getACL(), scanCopy.getACL());
assertEquals(scan.getAllowPartialResults(), scanCopy.getAllowPartialResults());
assertEquals(scan.getAttribute("test_key"), scanCopy.getAttribute("test_key"));
assertArrayEquals(scan.getAttribute("test_key"), scanCopy.getAttribute("test_key"));
assertEquals(scan.getAttributeSize(), scanCopy.getAttributeSize());
assertEquals(scan.getAttributesMap(), scanCopy.getAttributesMap());
assertEquals(scan.getAuthorizations().getLabels(), scanCopy.getAuthorizations().getLabels());
Expand All @@ -270,7 +271,7 @@ public void testScanCopyConstructor() throws Exception {
assertEquals(scan.getCaching(), scanCopy.getCaching());
assertEquals(scan.getConsistency(), scanCopy.getConsistency());
assertEquals(scan.getFamilies().length, scanCopy.getFamilies().length);
assertEquals(scan.getFamilies()[0], scanCopy.getFamilies()[0]);
assertArrayEquals(scan.getFamilies()[0], scanCopy.getFamilies()[0]);
assertEquals(scan.getFamilyMap(), scanCopy.getFamilyMap());
assertEquals(scan.getFilter(), scanCopy.getFilter());
assertEquals(scan.getId(), scanCopy.getId());
Expand All @@ -286,8 +287,8 @@ public void testScanCopyConstructor() throws Exception {
assertEquals(scan.getReadType(), scanCopy.getReadType());
assertEquals(scan.getReplicaId(), scanCopy.getReplicaId());
assertEquals(scan.getRowOffsetPerColumnFamily(), scanCopy.getRowOffsetPerColumnFamily());
assertEquals(scan.getStartRow(), scanCopy.getStartRow());
assertEquals(scan.getStopRow(), scanCopy.getStopRow());
assertArrayEquals(scan.getStartRow(), scanCopy.getStartRow());
assertArrayEquals(scan.getStopRow(), scanCopy.getStopRow());
assertEquals(scan.getTimeRange(), scanCopy.getTimeRange());

assertTrue("Make sure copy constructor adds all the fields in the copied object",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;

import java.io.IOException;
import java.lang.reflect.Field;
Expand Down Expand Up @@ -66,7 +67,7 @@ public void testObtainToken() throws Exception {
shouldInjectFault.set(null, injected);

try {
ClientTokenUtil.obtainToken((Connection)null);
ClientTokenUtil.obtainToken(mock(Connection.class));
fail("Should have injected exception.");
} catch (IOException e) {
Throwable t = e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MiscTests;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@
import static org.junit.Assert.assertEquals;

import java.io.IOException;
import java.util.Random;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.testclassification.MiscTests;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package org.apache.hadoop.hbase.nio;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
Expand Down Expand Up @@ -153,7 +154,7 @@ public void testArrayBasedMethods() {
mbb1 = new SingleByteBuff(bb1);
assertTrue(mbb1.hasArray());
assertEquals(1, mbb1.arrayOffset());
assertEquals(b, mbb1.array());
assertArrayEquals(b, mbb1.array());
mbb1 = new SingleByteBuff(ByteBuffer.allocateDirect(10));
assertFalse(mbb1.hasArray());
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ public void testBindException() throws KrbException, IOException {
getRunningSimpleKdcServer(dir, HBaseCommonTestingUtility::randomFreePort, true);
kdc.createPrincipal("wah");
} finally {
kdc.stop();
if (kdc != null) {
kdc.stop();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,15 @@ protected static String readOutput(URL url) throws IOException {
*/
protected static void deleteRecursively(File d) {
if (d.isDirectory()) {
for (String name : d.list()) {
File child = new File(d, name);
if (child.isFile()) {
child.delete();
} else {
deleteRecursively(child);
String[] names = d.list();
if (names != null) {
for (String name: names) {
File child = new File(d, name);
if (child.isFile()) {
child.delete();
} else {
deleteRecursively(child);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@ public void testMonkeyPropertiesParsing() {
conf.set(MonkeyConstants.BATCH_RESTART_RS_RATIO, "0.85");
conf.set(MonkeyConstants.MOVE_REGIONS_MAX_TIME, "60000");
conf.set("hbase.rootdir", "/foo/bar/baz");

final Properties props = new Properties();
IntegrationTestBase testBase = new IntegrationTestDDLMasterFailover();
assertEquals(0, props.size());
testBase.loadMonkeyProperties(props, conf);
new IntegrationTestDDLMasterFailover();
IntegrationTestBase.loadMonkeyProperties(props, conf);
assertEquals(2, props.size());
assertEquals("0.85", props.getProperty(MonkeyConstants.BATCH_RESTART_RS_RATIO));
assertEquals("60000", props.getProperty(MonkeyConstants.MOVE_REGIONS_MAX_TIME));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,14 @@ void stopRandomServer() throws Exception {
int size = rpcServers.size();
int rand = random.nextInt(size);
rpcServer = serverList.remove(rand);
InetSocketAddress address = rpcServer.getListenerAddress();
if (address == null) {
// Throw exception here. We can't remove this instance from the server map because
// we no longer have access to its map key
throw new IOException("Listener channel is closed");
}
rpcServers.remove(address);

if (rpcServer != null) {
InetSocketAddress address = rpcServer.getListenerAddress();
if (address == null) {
// Throw exception here. We can't remove this instance from the server map because
// we no longer have access to its map key
throw new IOException("Listener channel is closed");
}
rpcServers.remove(address);
stopServer(rpcServer);
}
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public class IntegrationTestMTTR {
/**
* Util to get at the cluster.
*/
private static IntegrationTestingUtility util;
private static final IntegrationTestingUtility util = new IntegrationTestingUtility();

/**
* Executor for test threads.
Expand All @@ -156,10 +156,6 @@ public class IntegrationTestMTTR {

@BeforeClass
public static void setUp() throws Exception {
// Set up the integration test util
if (util == null) {
util = new IntegrationTestingUtility();
}

// Make sure there are three servers.
util.initializeCluster(3);
Expand Down Expand Up @@ -250,7 +246,6 @@ private static void setupTables() throws IOException {
public static void after() throws IOException {
// Clean everything up.
util.restoreCluster();
util = null;

// Stop the threads so that we know everything is complete.
executorService.shutdown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1316,15 +1316,15 @@ private StringBuilder dumpExtraInfoOnRefs(final BytesWritable key, final Context
hrl = rl.getRegionLocation(key.getBytes());
if (hrl != null) keyRegionLocation = hrl.toString();
}
LOG.error("Extras on ref without a def, ref=" + Bytes.toStringBinary(ref) +
", refPrevEqualsKey=" +
(Bytes.compareTo(key.getBytes(), 0, key.getLength(), b, 0, b.length) == 0) +
", key=" + Bytes.toStringBinary(key.getBytes(), 0, key.getLength()) +
", ref row date=" + ts + ", jobStr=" + jobStr +
", ref row count=" + count +
", ref row regionLocation=" + refRegionLocation +
", key row regionLocation=" + keyRegionLocation);
}
LOG.error("Extras on ref without a def, ref=" + Bytes.toStringBinary(ref) +
", refPrevEqualsKey=" +
(Bytes.compareTo(key.getBytes(), 0, key.getLength(), b, 0, b.length) == 0) +
", key=" + Bytes.toStringBinary(key.getBytes(), 0, key.getLength()) +
", ref row date=" + ts + ", jobStr=" + jobStr +
", ref row count=" + count +
", ref row regionLocation=" + refRegionLocation +
", key row regionLocation=" + keyRegionLocation);
refsSb.append(comma);
comma = ",";
refsSb.append(Bytes.toStringBinary(ref));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.HBaseCommonTestingUtil;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HRegionLocation;
import org.apache.hadoop.hbase.IntegrationTestingUtility;
Expand Down Expand Up @@ -155,9 +156,16 @@ public void closeConnection() throws Exception {
this.connection = null;
}

public boolean equals(ClusterID other) {
public boolean equals(Object other) {
if (other == null) {
return false;
}
return this.toString().equalsIgnoreCase(other.toString());
}

public int hashCode() {
return this.toString().hashCode();
}
}

/**
Expand Down Expand Up @@ -264,7 +272,7 @@ protected void waitForReplication() throws Exception {
*/
protected void runGenerator() throws Exception {
Path outputPath = new Path(outputDir);
UUID uuid = util.getRandomUUID(); //create a random UUID.
UUID uuid = HBaseCommonTestingUtil.getRandomUUID(); //create a random UUID.
Path generatorOutput = new Path(outputPath, uuid.toString());

Generator generator = new Generator();
Expand All @@ -288,7 +296,7 @@ protected void runGenerator() throws Exception {
*/
protected void runVerify(long expectedNumNodes) throws Exception {
Path outputPath = new Path(outputDir);
UUID uuid = util.getRandomUUID(); //create a random UUID.
UUID uuid = HBaseCommonTestingUtil.getRandomUUID(); //create a random UUID.
Path iterationOutput = new Path(outputPath, uuid.toString());

Verify verify = new Verify();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ private void assertTargetDoDeletesFalse(int expectedRows, TableName sourceTableN
if (!CellUtil.matchingQualifier(sourceCell, targetCell)) {
Assert.fail("Qualifiers don't match");
}
if (targetRowKey < 80 && targetRowKey >= 90){
if (targetRowKey < 80 || targetRowKey >= 90){
if (!CellUtil.matchingTimestamp(sourceCell, targetCell)) {
Assert.fail("Timestamps don't match");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ protected byte[] getEndRow() {

@Test
public void testGetBestLocations() throws IOException {
TableSnapshotInputFormatImpl tsif = new TableSnapshotInputFormatImpl();
new TableSnapshotInputFormatImpl();
Configuration conf = UTIL.getConfiguration();

HDFSBlocksDistribution blockDistribution = new HDFSBlocksDistribution();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.io.IOException;
import java.util.concurrent.CountDownLatch;
Expand Down Expand Up @@ -88,8 +89,8 @@ public void testChoreAddAndRemove() throws Exception {
procExecutor.removeChore(chore);
latch = new CountDownLatch(nCountDown);
chore.setLatch(latch);
latch.await(timeoutMSec * nCountDown, TimeUnit.MILLISECONDS);
LOG.info("chore latch count=" + latch.getCount());
boolean reached = latch.await(timeoutMSec * nCountDown, TimeUnit.MILLISECONDS);
LOG.info("chore latch reached={} count={}", reached, latch.getCount());
assertFalse(chore.isWaiting());
assertTrue("latchCount=" + latch.getCount(), latch.getCount() > 0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
import java.util.Collection;
import javax.ws.rs.core.MediaType;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseClassTestRule;
Expand Down Expand Up @@ -80,8 +78,6 @@ public class TestMultiRowResource {

private static Client client;
private static JAXBContext context;
private static Marshaller marshaller;
private static Unmarshaller unmarshaller;
private static Configuration conf;

private static Header extraHdr = null;
Expand All @@ -93,7 +89,11 @@ public static Collection<Object[]> data() {
}

public TestMultiRowResource(Boolean csrf) {
csrfEnabled = csrf;
setCsrfEnabled(csrf);
}

protected static void setCsrfEnabled(boolean flag) {
csrfEnabled = flag;
}

@BeforeClass
Expand All @@ -110,8 +110,6 @@ public static void setUpBeforeClass() throws Exception {
CellModel.class,
CellSetModel.class,
RowModel.class);
marshaller = context.createMarshaller();
unmarshaller = context.createUnmarshaller();
client = new Client(new Cluster().add("localhost", REST_TEST_UTIL.getServletPort()));
Admin admin = TEST_UTIL.getAdmin();
if (admin.tableExists(TABLE)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public static Collection<Object[]> parameters() {
}

public TestSchemaResource(Boolean csrf) {
csrfEnabled = csrf;
TestMultiRowResource.setCsrfEnabled(csrf);
}

@BeforeClass
Expand Down
Loading