@Test
  public void testWALDurability() throws IOException {
    byte[] bytes = Bytes.toBytes(getName());
    Put put = new Put(bytes);
    put.addColumn(COLUMN_FAMILY_BYTES, Bytes.toBytes("1"), bytes);

    // global hbase.wal.hsync false, no override in put call - hflush
    conf.set(HRegion.WAL_HSYNC_CONF_KEY, "false");
    FileSystem fs = FileSystem.get(conf);
    Path rootDir = new Path(dir + getName());
    T wal = getWAL(fs, rootDir, getName(), conf);
    HRegion region = initHRegion(tableName, null, null, conf, wal);
    try {
      resetSyncFlag(wal);
      assertNull(getSyncFlag(wal));
      assertNull(getWriterSyncFlag(wal));
      region.put(put);
      assertFalse(getSyncFlag(wal));
      assertFalse(getWriterSyncFlag(wal));

      // global hbase.wal.hsync false, durability set in put call - fsync
      put.setDurability(Durability.FSYNC_WAL);
      resetSyncFlag(wal);
      assertNull(getSyncFlag(wal));
      assertNull(getWriterSyncFlag(wal));
      region.put(put);
      assertTrue(getSyncFlag(wal));
      assertTrue(getWriterSyncFlag(wal));
    } finally {
      HBaseTestingUtil.closeRegionAndWAL(region);
    }

    // global hbase.wal.hsync true, no override in put call
    conf.set(HRegion.WAL_HSYNC_CONF_KEY, "true");
    fs = FileSystem.get(conf);
    wal = getWAL(fs, rootDir, getName(), conf);
    region = initHRegion(tableName, null, null, conf, wal);

    try {
      resetSyncFlag(wal);
      assertNull(getSyncFlag(wal));
      assertNull(getWriterSyncFlag(wal));
      region.put(put);
      assertTrue(getSyncFlag(wal));
      assertTrue(getWriterSyncFlag(wal));

      // global hbase.wal.hsync true, durability set in put call - fsync
      put.setDurability(Durability.FSYNC_WAL);
      resetSyncFlag(wal);
      assertNull(getSyncFlag(wal));
      assertNull(getWriterSyncFlag(wal));
      region.put(put);
      assertTrue(getSyncFlag(wal));
      assertTrue(getWriterSyncFlag(wal));

      // global hbase.wal.hsync true, durability set in put call - sync
      put = new Put(bytes);
      put.addColumn(COLUMN_FAMILY_BYTES, Bytes.toBytes("1"), bytes);
      put.setDurability(Durability.SYNC_WAL);
      resetSyncFlag(wal);
      assertNull(getSyncFlag(wal));
      assertNull(getWriterSyncFlag(wal));
      region.put(put);
      assertFalse(getSyncFlag(wal));
      assertFalse(getWriterSyncFlag(wal));
    } finally {
      HBaseTestingUtil.closeRegionAndWAL(region);
    }
  }
Tests for WAL write durability - hflush vs hsync
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/wal/WALDurabilityTestBase.java