public static void doSmokeTest(FileSystem fs, Path path, String codec) throws Exception {
    Configuration conf = HBaseConfiguration.create();
    HFileContext context =
      new HFileContextBuilder().withCompression(HFileWriterImpl.compressionByName(codec)).build();
    HFile.Writer writer =
      HFile.getWriterFactoryNoCache(conf).withPath(fs, path).withFileContext(context).create();
    // Write any-old Cell...
    final byte[] rowKey = Bytes.toBytes("compressiontestkey");
    ExtendedCell c = ExtendedCellBuilderFactory.create(CellBuilderType.DEEP_COPY).setRow(rowKey)
      .setFamily(HConstants.EMPTY_BYTE_ARRAY).setQualifier(HConstants.EMPTY_BYTE_ARRAY)
      .setTimestamp(HConstants.LATEST_TIMESTAMP).setType(KeyValue.Type.Maximum.getCode())
      .setValue(Bytes.toBytes("compressiontestval")).build();
    writer.append(c);
    writer.appendFileInfo(Bytes.toBytes("compressioninfokey"), Bytes.toBytes("compressioninfoval"));
    writer.close();
    Cell cc = null;
    HFile.Reader reader = HFile.createReader(fs, path, CacheConfig.DISABLED, true, conf);
    try {
      HFileScanner scanner = reader.getScanner(conf, false, true);
      scanner.seekTo(); // position to the start of file
      // Scanner does not do Cells yet. Do below for now till fixed.
      cc = scanner.getCell();
      if (CellComparator.getInstance().compareRows(c, cc) != 0) {
        throw new Exception("Read back incorrect result: " + c.toString() + " vs " + cc.toString());
      }
    } finally {
      reader.close();
    }
  }
Compression validation test. Checks compression is working. Be sure to run on every node in your
cluster.
hbase-server/src/main/java/org/apache/hadoop/hbase/util/CompressionTest.java