@Test
  public void testThresholdsAndRetries() {
    // Verify that the resource becomes down exactly after receiving 3 errors.
    initiateAndVerifyResourceGoesDownExactlyAtThresholdFailures();

    // Verify that the resource will stay down until 10 ms have passed.
    time.sleep(RETRY_BACKOFF_MS / 2);
    assertTrue(policy.isDown());
    time.sleep(RETRY_BACKOFF_MS - RETRY_BACKOFF_MS / 2);
    assertFalse(policy.isDown());

    // At this time the resource is conditionally up. Verify that a single error should bring it back down.
    policy.onError();
    assertTrue(policy.isDown());

    // A single success should bring a down resource unconditionally up.
    policy.onSuccess();
    // Verify that the resource is unconditionally up - a single error should not bring it down.
    initiateAndVerifyResourceGoesDownExactlyAtThresholdFailures();

    time.sleep(RETRY_BACKOFF_MS);
    assertFalse(policy.isDown());
    // Verify that a conditionally up resource becomes unconditionally up after receiving a single success.
    policy.onSuccess();
    initiateAndVerifyResourceGoesDownExactlyAtThresholdFailures();
  }
Tests to validate that the thresholds and retries are serving exactly their intended purposes.
ambry-clustermap/src/test/java/com/github/ambry/clustermap/FixedBackoffResourceStatePolicyTest.java