@Test
  public void updateInstanceConfigFailureTest() throws Exception {
    generateConfigs(true, true);
    MockDataNodeId localNode = clusterMap.getDataNodes().get(0);
    List<ReplicaId> localReplicas = clusterMap.getReplicaIds(localNode);
    MockClusterParticipant mockHelixParticipant = new MockClusterParticipant();
    StorageManager storageManager =
        createStorageManager(localNode, metricRegistry, Collections.singletonList(mockHelixParticipant));
    storageManager.start();
    // create a new partition and get its replica on local node
    PartitionId newPartition = clusterMap.createNewPartition(Collections.singletonList(localNode));
    // override return value of updateDataNodeInfoInCluster() to mock update InstanceConfig failure
    mockHelixParticipant.updateNodeInfoReturnVal = false;
    try {
      mockHelixParticipant.onPartitionBecomeBootstrapFromOffline(newPartition.toPathString());
      fail("should fail because updating InstanceConfig didn't succeed during Offline-To-Bootstrap");
    } catch (StateTransitionException e) {
      assertEquals("Error code doesn't match", StateTransitionException.TransitionErrorCode.HelixUpdateFailure,
          e.getErrorCode());
    }
    try {
      mockHelixParticipant.onPartitionBecomeDroppedFromOffline(localReplicas.get(0).getPartitionId().toPathString());
      fail("should fail because updating InstanceConfig didn't succeed during Offline-To-Dropped");
    } catch (StateTransitionException e) {
      assertEquals("Error code doesn't match", StateTransitionException.TransitionErrorCode.HelixUpdateFailure,
          e.getErrorCode());
    }
    mockHelixParticipant.updateNodeInfoReturnVal = null;
    // mock InstanceConfig not found error (note that MockHelixAdmin is empty by default, so no InstanceConfig is present)
    newPartition = clusterMap.createNewPartition(Collections.singletonList(localNode));
    try {
      mockHelixParticipant.onPartitionBecomeBootstrapFromOffline(newPartition.toPathString());
      fail("should fail because InstanceConfig is not found during Offline-To-Bootstrap");
    } catch (StateTransitionException e) {
      assertEquals("Error code doesn't match", StateTransitionException.TransitionErrorCode.HelixUpdateFailure,
          e.getErrorCode());
    }
    try {
      mockHelixParticipant.onPartitionBecomeDroppedFromOffline(localReplicas.get(1).getPartitionId().toPathString());
      fail("should fail because InstanceConfig is not found during Offline-To-Dropped");
    } catch (StateTransitionException e) {
      assertEquals("Error code doesn't match", StateTransitionException.TransitionErrorCode.HelixUpdateFailure,
          e.getErrorCode());
    }
    shutdownAndAssertStoresInaccessible(storageManager, localReplicas);
  }
Test failure cases when updating InstanceConfig in Helix for both Offline-To-Bootstrap and Offline-To-Dropped.
ambry-store/src/test/java/com/github/ambry/store/StorageManagerTest.java