@Test
  public void testHardDownandHardUp() {
    // Verify that once the resource is hard down, it stays down indefinitely unless an explicit event occurs.
    assertFalse(policy.isDown());
    policy.onHardDown();
    assertTrue(policy.isDown());
    time.sleep(RETRY_BACKOFF_MS * 2);
    assertTrue(policy.isDown());
    assertTrue(policy.isHardDown());

    // A single success should not bring it back up, as the resource is hard down.
    policy.onSuccess();
    assertTrue(policy.isDown());
    assertTrue(policy.isHardDown());

    // A single hard up should bring it back up.
    policy.onHardUp();
    assertFalse(policy.isDown());
    assertFalse(policy.isHardDown());

    // Verify that a hard up resource goes down immediately if onHardDown() is called.
    policy.onHardDown();
    assertTrue(policy.isDown());
    assertTrue(policy.isHardDown());

    policy.onHardUp();
    assertFalse(policy.isDown());
    assertFalse(policy.isHardDown());

    // Verify that a hard up resource goes down as part of normal errors when thresholds are reached.
    initiateAndVerifyResourceGoesDownExactlyAtThresholdFailures();
  }
Tests that hard events are honored in the way expected.
ambry-clustermap/src/test/java/com/github/ambry/clustermap/FixedBackoffResourceStatePolicyTest.java