HBASE-22882 TestFlushSnapshotFromClient#testConcurrentSnapshottingAttempts is flakey (was written flakey)

This commit is contained in:
stack 2019-08-19 12:57:12 -07:00
parent 0b3db5099c
commit 8e488ce9ef
2 changed files with 13 additions and 9 deletions

View File

@ -29,6 +29,7 @@ import java.util.concurrent.SynchronousQueue;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesting;
import org.apache.yetus.audience.InterfaceAudience; import org.apache.yetus.audience.InterfaceAudience;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -67,9 +68,9 @@ public class ProcedureCoordinator {
* The rpc object registers the ProcedureCoordinator and starts any threads in this * The rpc object registers the ProcedureCoordinator and starts any threads in this
* constructor. * constructor.
* *
* @param rpcs
* @param pool Used for executing procedures. * @param pool Used for executing procedures.
*/ */
@VisibleForTesting // Only used in tests. SimpleMasterProcedureManager is a test class.
public ProcedureCoordinator(ProcedureCoordinatorRpcs rpcs, ThreadPoolExecutor pool) { public ProcedureCoordinator(ProcedureCoordinatorRpcs rpcs, ThreadPoolExecutor pool) {
this(rpcs, pool, TIMEOUT_MILLIS_DEFAULT, WAKE_MILLIS_DEFAULT); this(rpcs, pool, TIMEOUT_MILLIS_DEFAULT, WAKE_MILLIS_DEFAULT);
} }
@ -80,9 +81,7 @@ public class ProcedureCoordinator {
* The rpc object registers the ProcedureCoordinator and starts any threads in * The rpc object registers the ProcedureCoordinator and starts any threads in
* this constructor. * this constructor.
* *
* @param rpcs
* @param pool Used for executing procedures. * @param pool Used for executing procedures.
* @param timeoutMillis
*/ */
public ProcedureCoordinator(ProcedureCoordinatorRpcs rpcs, ThreadPoolExecutor pool, public ProcedureCoordinator(ProcedureCoordinatorRpcs rpcs, ThreadPoolExecutor pool,
long timeoutMillis, long wakeTimeMillis) { long timeoutMillis, long wakeTimeMillis) {

View File

@ -54,6 +54,7 @@ import org.junit.AfterClass;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.experimental.categories.Category; import org.junit.experimental.categories.Category;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -142,7 +143,6 @@ public class TestFlushSnapshotFromClient {
/** /**
* Test simple flush snapshotting a table that is online * Test simple flush snapshotting a table that is online
* @throws Exception
*/ */
@Test @Test
public void testFlushTableSnapshot() throws Exception { public void testFlushTableSnapshot() throws Exception {
@ -175,7 +175,6 @@ public class TestFlushSnapshotFromClient {
/** /**
* Test snapshotting a table that is online without flushing * Test snapshotting a table that is online without flushing
* @throws Exception
*/ */
@Test @Test
public void testSkipFlushTableSnapshot() throws Exception { public void testSkipFlushTableSnapshot() throws Exception {
@ -215,7 +214,6 @@ public class TestFlushSnapshotFromClient {
/** /**
* Test simple flush snapshotting a table that is online * Test simple flush snapshotting a table that is online
* @throws Exception
*/ */
@Test @Test
public void testFlushTableSnapshotWithProcedure() throws Exception { public void testFlushTableSnapshotWithProcedure() throws Exception {
@ -446,13 +444,20 @@ public class TestFlushSnapshotFromClient {
/** /**
* Demonstrate that we reject snapshot requests if there is a snapshot already running on the * Demonstrate that we reject snapshot requests if there is a snapshot already running on the
* same table currently running and that concurrent snapshots on different tables can both * same table currently running and that concurrent snapshots on different tables can both
* succeed concurretly. * succeed concurrently.
*/ */
@Ignore // Turning this test off. It is written flakey (See original submission in HBASE-7536
// for admission). While the test ensures we run one snapshot at a time as the above comment
// describes, the second part of the comment where we are supposed to allow snapshots against
// different tables run concurrently is where there is issue. There is only one
// handler thread on the regionserver-side which means that on a second submission, the
// second request gets rejected with RejectedExecutionException. The test used to sort-of
// pass with 20 attempts but as often-as-not, fails.
@Test @Test
public void testConcurrentSnapshottingAttempts() throws IOException, InterruptedException { public void testConcurrentSnapshottingAttempts() throws IOException, InterruptedException {
final TableName TABLE2_NAME = TableName.valueOf(TABLE_NAME + "2"); final TableName TABLE2_NAME = TableName.valueOf(TABLE_NAME + "2");
int ssNum = 20; int ssNum = 2;
// make sure we don't fail on listing snapshots // make sure we don't fail on listing snapshots
SnapshotTestingUtils.assertNoSnapshots(admin); SnapshotTestingUtils.assertNoSnapshots(admin);
// create second testing table // create second testing table
@ -489,7 +494,7 @@ public class TestFlushSnapshotFromClient {
// build descriptions // build descriptions
SnapshotDescription[] descs = new SnapshotDescription[ssNum]; SnapshotDescription[] descs = new SnapshotDescription[ssNum];
for (int i = 0; i < ssNum; i++) { for (int i = 0; i < ssNum; i++) {
if(i % 2 ==0) { if (i % 2 == 0) {
descs[i] = new SnapshotDescription("ss" + i, TABLE_NAME, SnapshotType.FLUSH); descs[i] = new SnapshotDescription("ss" + i, TABLE_NAME, SnapshotType.FLUSH);
} else { } else {
descs[i] = new SnapshotDescription("ss" + i, TABLE2_NAME, SnapshotType.FLUSH); descs[i] = new SnapshotDescription("ss" + i, TABLE2_NAME, SnapshotType.FLUSH);