@Test
  public void testFlushThroughputTuning() throws Exception {
    Configuration conf = hbtu.getConfiguration();
    setMaxMinThroughputs(20L * 1024 * 1024, 10L * 1024 * 1024);
    conf.set(StoreEngine.STORE_ENGINE_CLASS_KEY, DefaultStoreEngine.class.getName());
    conf.setInt(PressureAwareFlushThroughputController.HBASE_HSTORE_FLUSH_THROUGHPUT_TUNE_PERIOD,
      3000);
    hbtu.startMiniCluster(1);
    Connection conn = ConnectionFactory.createConnection(conf);
    hbtu.getAdmin()
      .createTable(TableDescriptorBuilder.newBuilder(tableName)
        .setColumnFamily(ColumnFamilyDescriptorBuilder.of(family)).setCompactionEnabled(false)
        .build());
    hbtu.waitTableAvailable(tableName);
    HRegionServer regionServer = hbtu.getRSForFirstRegionInTable(tableName);
    double pressure = regionServer.getFlushPressure();
    LOG.debug("Flush pressure before flushing: " + pressure);
    PressureAwareFlushThroughputController throughputController =
      (PressureAwareFlushThroughputController) regionServer.getFlushThroughputController();
    for (HRegion region : regionServer.getRegions()) {
      region.flush(true);
    }
    // We used to assert that the flush pressure is zero but after HBASE-15787 or HBASE-18294 we
    // changed to use heapSize instead of dataSize to calculate the flush pressure, and since
    // heapSize will never be zero, so flush pressure will never be zero either. So we changed the
    // assertion here.
    assertTrue(regionServer.getFlushPressure() < pressure);
    Thread.sleep(5000);
    Table table = conn.getTable(tableName);
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
        byte[] value = new byte[256 * 1024];
        Bytes.random(value);
        table.put(new Put(Bytes.toBytes(i * 10 + j)).addColumn(family, qualifier, value));
      }
    }
    Thread.sleep(5000);
    double expectedThroughPut = 10L * 1024 * 1024 * (1 + regionServer.getFlushPressure());
    assertEquals(expectedThroughPut, throughputController.getMaxThroughput(), EPSILON);

    conf.set(FlushThroughputControllerFactory.HBASE_FLUSH_THROUGHPUT_CONTROLLER_KEY,
      NoLimitThroughputController.class.getName());
    regionServer.onConfigurationChange(conf);
    assertTrue(throughputController.isStopped());
    assertTrue(regionServer.getFlushThroughputController() instanceof NoLimitThroughputController);
    conn.close();
  }
Test the tuning task of {@link PressureAwareFlushThroughputController}
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/throttle/TestFlushWithThroughputController.java