@Test
public void testRenewLead() throws InterruptedException {

  DBI dbi = new DBI(DB_URL);
  UUID reaperInstanceId = UUID.randomUUID();
  PostgresStorage storage = new PostgresStorage(reaperInstanceId, dbi);
  Assertions.assertThat(storage.isStorageConnected()).isTrue();
  Handle handle = dbi.open();
  handle.execute("DELETE from leader");
  UUID leaderId = UUID.randomUUID();
  int sleepTime = 3;
  final Instant initialTime = Instant.now();
  storage.takeLead(leaderId);
  // sleep 3 seconds, then renew lead
  TimeUnit.SECONDS.sleep(sleepTime);
  Assertions.assertThat(storage.renewLead(leaderId)).isTrue();
  Instant hbTime = handle.createQuery("SELECT last_heartbeat FROM leader")
      .mapTo(Timestamp.class)
      .first()
      .toInstant();
  Duration between = Duration.between(initialTime, hbTime);
  Assertions.assertThat(between.getSeconds()).isGreaterThanOrEqualTo(sleepTime);
}