@Test
  public void testStoreFileScannerThrowsErrors() throws IOException {
    Path hfilePath = new Path(
      new Path(util.getDataTestDir("internalScannerExposesErrors"), "regionname"), "familyname");
    HFileSystem hfs = (HFileSystem) util.getTestFileSystem();
    FaultyFileSystem faultyfs = new FaultyFileSystem(hfs.getBackingFs());
    HFileSystem fs = new HFileSystem(faultyfs);
    CacheConfig cacheConf = new CacheConfig(util.getConfiguration());
    HFileContext meta = new HFileContextBuilder().withBlockSize(2 * 1024).build();
    StoreFileWriter writer = new StoreFileWriter.Builder(util.getConfiguration(), cacheConf, hfs)
      .withOutputDir(hfilePath).withFileContext(meta).build();
    TestHStoreFile.writeStoreFile(writer, Bytes.toBytes("cf"), Bytes.toBytes("qual"));

    StoreFileInfo storeFileInfo = StoreFileInfo.createStoreFileInfoForHFile(util.getConfiguration(),
      fs, writer.getPath(), true);
    HStoreFile sf = new HStoreFile(storeFileInfo, BloomType.NONE, cacheConf);

    List<StoreFileScanner> scanners = StoreFileScanner.getScannersForStoreFiles(
      Collections.singletonList(sf), false, true, false, false,
      // 0 is passed as readpoint because this test operates on HStoreFile directly
      0);
    try {
      KeyValueScanner scanner = scanners.get(0);

      FaultyInputStream inStream = faultyfs.inStreams.get(0).get();
      assertNotNull(inStream);

      scanner.seek(KeyValue.LOWESTKEY);
      // Do at least one successful read
      assertNotNull(scanner.next());
      faultyfs.startFaults();

      try {
        int scanned = 0;
        while (scanner.next() != null) {
          scanned++;
        }
        fail("Scanner didn't throw after faults injected");
      } catch (IOException ioe) {
        LOG.info("Got expected exception", ioe);
        assertTrue(ioe.getMessage().contains("Could not iterate"));
      }
    } finally {
      for (StoreFileScanner scanner : scanners) {
        scanner.close();
      }
    }
  }
Injects errors into the pread calls of an on-disk file, and makes sure those bubble up to the
StoreFileScanner
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestFSErrorsExposed.java