@Test
  public void startBlobStoreFailureTest() throws Exception {
    // Recreate storage manager and ambryRequest to pass in HelixParticipant
    storageManager.shutdown();
    storageManager =
        new MockStorageManager(validKeysInStore, clusterMap, dataNodeId, findTokenHelper, helixParticipant);
    ambryRequests = new AmbryServerRequests(storageManager, requestResponseChannel, clusterMap, dataNodeId,
        clusterMap.getMetricRegistry(), serverMetrics, findTokenHelper, null, replicationManager, null, serverConfig,
        diskManagerConfig, storeKeyConverterFactory, statsManager, helixParticipant);

    // find a partition that has a replica on current node
    ReplicaId localReplica = clusterMap.getReplicaIds(dataNodeId).get(0);
    MockPartitionId id = (MockPartitionId) localReplica.getPartitionId();
    short numReplicasCaughtUpPerPartition = 3;
    // test start BlobStore failure
    storageManager.returnValueOfStartingBlobStore = false;
    sendAndVerifyStoreControlRequest(id, BlobStoreControlAction.StartStore, numReplicasCaughtUpPerPartition,
        ServerErrorCode.UnknownError);
    storageManager.returnValueOfStartingBlobStore = true;
    // test start BlobStore with runtime exception
    storageManager.exceptionToThrowOnStartingBlobStore = new IllegalStateException();
    sendAndVerifyStoreControlRequest(id, BlobStoreControlAction.StartStore, numReplicasCaughtUpPerPartition,
        ServerErrorCode.UnknownError);
    storageManager.exceptionToThrowOnStartingBlobStore = null;
    // test enable replication failure
    replicationManager.controlReplicationReturnVal = false;
    sendAndVerifyStoreControlRequest(id, BlobStoreControlAction.StartStore, numReplicasCaughtUpPerPartition,
        ServerErrorCode.UnknownError);
    replicationManager.controlReplicationReturnVal = true;
    // test enable compaction failure
    storageManager.returnValueOfControllingCompaction = false;
    sendAndVerifyStoreControlRequest(id, BlobStoreControlAction.StartStore, numReplicasCaughtUpPerPartition,
        ServerErrorCode.UnknownError);
    storageManager.returnValueOfControllingCompaction = true;
    // test enable compaction with runtime exception
    storageManager.exceptionToThrowOnControllingCompaction = new IllegalStateException();
    sendAndVerifyStoreControlRequest(id, BlobStoreControlAction.StartStore, numReplicasCaughtUpPerPartition,
        ServerErrorCode.UnknownError);
    storageManager.exceptionToThrowOnControllingCompaction = null;
    // test HelixParticipant resets partition error
    helixParticipant.resetPartitionVal = false;
    id.replicaAndState.put(localReplica, ReplicaState.ERROR);
    sendAndVerifyStoreControlRequest(id, BlobStoreControlAction.StartStore, numReplicasCaughtUpPerPartition,
        ServerErrorCode.UnknownError);
    helixParticipant.resetPartitionVal = true;
    id.replicaAndState.put(localReplica, ReplicaState.STANDBY);
    // test stop list update failure
    helixParticipant.setStoppedStateReturnVal = false;
    sendAndVerifyStoreControlRequest(id, BlobStoreControlAction.StartStore, numReplicasCaughtUpPerPartition,
        ServerErrorCode.UnknownError);
    helixParticipant.setStoppedStateReturnVal = null;
  }
Tests for the startBlobStore response received on a {@link BlobStoreControlAdminRequest} for different failure cases
@throws InterruptedException
@throws IOException
ambry-server/src/test/java/com/github/ambry/server/AmbryServerRequestsTest.java