@Test
public void testBackupFutureExecutedEarlyFailure() {

  // First future fails before timeout and the backup future gets executed
  Future<Integer> originalFuture = getFuture(50, 1, false);
  Function0<Future<Integer>> backupFunctionFuture = getBackupFutureFunctionWithSuccess(500, 2);
  Future<Integer> speculativeFuture = FutureUtil.getSpeculativeFuture(
      originalFuture,
      backupFunctionFuture,
      100,
      STATS_PREFIX,
      BackupFutureRetryPolicy.UN_CONDITIONAL_RETRY_POLICY);
  speculativeFuture.get();
  assertTrue(isBackupFutureInvoked);
  checkStats(1, 0, 1);
}