use of com.github.ambry.router.FutureResult in project ambry by linkedin.
the class RouterServerTestFramework method startGetBlobAuthorizationFailTest.
/**
* Submit a getBlob operation with incorrect accountId/ContainerId in blobId.
* @param opChain the {@link OperationChain} object that this operation is a part of.
*/
private void startGetBlobAuthorizationFailTest(final OperationChain opChain) {
Callback<GetBlobResult> callback = new TestCallback<>(opChain, true);
BlobId originalId, fraudId;
try {
originalId = new BlobId(opChain.blobId, clusterMap);
fraudId = BlobId.craft(originalId, originalId.getVersion(), (short) (originalId.getAccountId() + 1), (short) (originalId.getContainerId() + 1));
} catch (IOException e) {
// If there is a blobId creation failure, throw the exception and don't need to do actual action.
FutureResult<Void> future = new FutureResult<>();
// continue the chain
future.done(null, e);
callback.onCompletion(null, e);
TestFuture<Void> testFuture = new TestFuture<Void>(future, genLabel("getBlobAuthorizationFail", true), opChain) {
@Override
void check() throws Exception {
throw e;
}
};
opChain.testFutures.add(testFuture);
return;
}
// If everything good:
Future<GetBlobResult> future = router.getBlob(fraudId.getID(), new GetBlobOptionsBuilder().operationType(GetBlobOptions.OperationType.All).getOption(GetOption.Include_All).build(), callback, quotaChargeCallback);
TestFuture<GetBlobResult> testFuture = new TestFuture<GetBlobResult>(future, genLabel("getBlobAuthorizationFail", true), opChain) {
@Override
void check() throws Exception {
checkExpectedRouterErrorCode(RouterErrorCode.BlobAuthorizationFailure);
}
};
opChain.testFutures.add(testFuture);
}
use of com.github.ambry.router.FutureResult in project ambry by linkedin.
the class RouterServerTestFramework method startDeleteBlobAuthorizationFailTest.
/**
* Submit a deleteBlob operation with incorrect accountId/ContainerId in blobId.
* @param opChain the {@link OperationChain} object that this operation is a part of.
*/
private void startDeleteBlobAuthorizationFailTest(final OperationChain opChain) {
Callback<Void> callback = new TestCallback<>(opChain, true);
BlobId originalId, fraudId;
try {
originalId = new BlobId(opChain.blobId, clusterMap);
fraudId = BlobId.craft(originalId, originalId.getVersion(), (short) (originalId.getAccountId() + 1), (short) (originalId.getContainerId() + 1));
} catch (IOException e) {
// If there is a blobId creation failure, throw the exception and don't need to do actual action.
FutureResult<Void> future = new FutureResult<>();
// continue the chain
future.done(null, e);
callback.onCompletion(null, e);
TestFuture<Void> testFuture = new TestFuture<Void>(future, genLabel("deleteBlobAuthorizationFail", true), opChain) {
@Override
void check() throws Exception {
throw e;
}
};
opChain.testFutures.add(testFuture);
return;
}
Future<Void> future = router.deleteBlob(fraudId.getID(), null, callback, quotaChargeCallback);
TestFuture<Void> testFuture = new TestFuture<Void>(future, genLabel("deleteBlobAuthorizationFail", true), opChain) {
@Override
void check() throws Exception {
checkExpectedRouterErrorCode(RouterErrorCode.BlobAuthorizationFailure);
}
};
opChain.testFutures.add(testFuture);
}
Aggregations