use of com.github.ambry.cloud.CloudStorageException in project ambry by linkedin.
the class AzureStorageCompactorTest method testPurgeWithStorageError.
/**
* Test purgeBlobs with ABS error
*/
@Test
public void testPurgeWithStorageError() throws Exception {
// Unsuccessful case
BlobStorageException ex = mockStorageException(BlobErrorCode.BLOB_ARCHIVED);
BlobBatch mockBatch = mock(BlobBatch.class);
Response<Void> mockResponse = mock(Response.class);
when(mockResponse.getStatusCode()).thenThrow(ex);
when(mockBlobBatchClient.getBlobBatch()).thenReturn(mockBatch);
when(mockBatch.deleteBlob(anyString(), anyString())).thenReturn(mockResponse);
try {
AzureCompactionUtil.purgeBlobs(blobMetadataList, azureBlobDataAccessor, azureMetrics, cosmosDataAccessor);
fail("Expected CloudStorageException");
} catch (CloudStorageException bex) {
}
assertEquals(0, azureMetrics.blobDeletedCount.getCount());
assertEquals(numBlobsPerQuery, azureMetrics.blobDeleteErrorCount.getCount());
}
use of com.github.ambry.cloud.CloudStorageException in project ambry by linkedin.
the class AzureStorageCompactorTest method testPurgeWithCosmosBulkDeleteError.
/**
* Test purgeBlobs with Cosmos bulk delete error
*/
@Test
public void testPurgeWithCosmosBulkDeleteError() throws Exception {
Exception mockException = new RuntimeException(new DocumentClientException(HttpConstants.StatusCodes.TOO_MANY_REQUESTS));
doThrow(mockException).when(mockumentClient).executeStoredProcedure(anyString(), any(RequestOptions.class), any());
try {
AzureCompactionUtil.purgeBlobs(blobMetadataList, azureBlobDataAccessor, azureMetrics, cosmosDataAccessor);
fail("Expected CloudStorageException");
} catch (CloudStorageException bex) {
}
assertEquals(0, azureMetrics.blobDeletedCount.getCount());
assertEquals(numBlobsPerQuery, azureMetrics.blobDeleteErrorCount.getCount());
}
use of com.github.ambry.cloud.CloudStorageException in project ambry by linkedin.
the class AzureStorageCompactorTest method testCompactionFailsOnCheckpointReadError.
/**
* Test compaction on error reading checkpoint.
*/
@Test
public void testCompactionFailsOnCheckpointReadError() throws Exception {
BlobStorageException ex = mockStorageException(BlobErrorCode.INTERNAL_ERROR);
when(mockBlockBlobClient.downloadWithResponse(any(), any(), any(), any(), anyBoolean(), any(), any())).thenThrow(ex);
try {
azureStorageCompactor.compactPartition(partitionPath);
fail("Expected compaction to fail");
} catch (CloudStorageException cse) {
// expected
}
}
Aggregations