@Test
  public void testGetCompletedSnapshotsWithCleanup() throws Exception {
    // Enable auto snapshot cleanup for the cluster
    SetSnapshotCleanupRequest setSnapshotCleanupRequest =
      SetSnapshotCleanupRequest.newBuilder().setEnabled(true).build();
    master.getMasterRpcServices().switchSnapshotCleanup(null, setSnapshotCleanupRequest);

    // first check when there are no snapshots
    GetCompletedSnapshotsRequest request = GetCompletedSnapshotsRequest.newBuilder().build();
    GetCompletedSnapshotsResponse response =
      master.getMasterRpcServices().getCompletedSnapshots(null, request);
    assertEquals("Found unexpected number of snapshots", 0, response.getSnapshotsCount());

    // NOTE: This is going to be flakey. Its timing based. For now made it more coarse
    // so more likely to pass though we have to hang around longer.

    // write one snapshot to the fs
    createSnapshotWithTtl("snapshot_01", 5L);
    createSnapshotWithTtl("snapshot_02", 100L);

    // check that we get one snapshot
    response = master.getMasterRpcServices().getCompletedSnapshots(null, request);
    assertEquals("Found unexpected number of snapshots", 2, response.getSnapshotsCount());

    // Check that 1 snapshot is auto cleaned after 5 sec of TTL expiration. Wait 10 seconds
    // just in case.
    Uninterruptibles.sleepUninterruptibly(10, TimeUnit.SECONDS);
    response = master.getMasterRpcServices().getCompletedSnapshots(null, request);
    assertEquals("Found unexpected number of snapshots", 1, response.getSnapshotsCount());
  }
Test that the contract from the master for checking on a snapshot are valid.
<p>
<ol>
<li>If a snapshot fails with an error, we expect to get the source error.</li>
<li>If there is no snapshot name supplied, we should get an error.</li>
<li>If asking about a snapshot has hasn't occurred, you should get an error.</li>
</ol>
hbase-server/src/test/java/org/apache/hadoop/hbase/master/cleaner/TestSnapshotFromMaster.java