Skip to content

Commit a7ec6d6

Browse files
authored
[Test](client) Add s3 storage client test sketelon (#57456)
### What problem does this PR solve? If you want to run unit tests using a real cloud provider, you can configure it in `custom_env.sh`. ``` # Enable S3 client for unit tests export ENABLE_S3_CLIENT=1 # S3 client config export S3_AK="xxx" export S3_SK="xxx" export S3_ENDPOINT="xxx" export S3_PROVIDER="xxx" export S3_BUCKET="xxx" export S3_REGION="xxx" export S3_PREFIX="" ```
1 parent 9392c1c commit a7ec6d6

File tree

5 files changed

+1905
-5
lines changed

5 files changed

+1905
-5
lines changed

be/src/io/fs/azure_obj_storage_client.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ ObjectStorageUploadResponse AzureObjStorageClient::upload_part(const ObjectStora
207207
// The blockId must be base64 encoded
208208
s3_put_rate_limit([&]() {
209209
SCOPED_BVAR_LATENCY(s3_bvar::s3_multi_part_upload_latency);
210-
client.StageBlock(base64_encode_part_num(part_num), memory_body);
210+
return client.StageBlock(base64_encode_part_num(part_num), memory_body);
211211
});
212212
} catch (Azure::Core::RequestFailedException& e) {
213213
auto msg = fmt::format(

be/src/io/fs/s3_obj_storage_client.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,6 @@ ObjectStorageHeadResponse S3ObjStorageClient::head_object(const ObjectStoragePat
311311
static_cast<int>(outcome.GetError().GetResponseCode()),
312312
outcome.GetError().GetRequestId()}};
313313
}
314-
return ObjectStorageHeadResponse {
315-
.resp = ObjectStorageResponse::OK(),
316-
};
317314
}
318315

319316
ObjectStorageResponse S3ObjStorageClient::get_object(const ObjectStoragePathOptions& opts,
@@ -334,6 +331,8 @@ ObjectStorageResponse S3ObjStorageClient::get_object(const ObjectStoragePathOpti
334331
outcome.GetError().GetRequestId()};
335332
}
336333
*size_return = outcome.GetResult().GetContentLength();
334+
// case for incomplete read
335+
SYNC_POINT_CALLBACK("s3_obj_storage_client::get_object", size_return);
337336
if (*size_return != bytes_read) {
338337
return {convert_to_obj_response(Status::InternalError(
339338
"failed to read from {}(bytes read: {}, bytes req: {}), request_id: {}",
@@ -405,6 +404,8 @@ ObjectStorageResponse S3ObjStorageClient::delete_objects(const ObjectStoragePath
405404
static_cast<int>(delete_outcome.GetError().GetResponseCode()),
406405
delete_outcome.GetError().GetRequestId()};
407406
}
407+
// case for partial delete object failure
408+
SYNC_POINT_CALLBACK("s3_obj_storage_client::delete_objects", &delete_outcome);
408409
if (!delete_outcome.GetResult().GetErrors().empty()) {
409410
const auto& e = delete_outcome.GetResult().GetErrors().front();
410411
return {convert_to_obj_response(
@@ -470,6 +471,9 @@ ObjectStorageResponse S3ObjStorageClient::delete_objects_recursively(
470471
static_cast<int>(delete_outcome.GetError().GetResponseCode()),
471472
delete_outcome.GetError().GetRequestId()};
472473
}
474+
// case for partial delete object failure
475+
SYNC_POINT_CALLBACK("s3_obj_storage_client::delete_objects_recursively",
476+
&delete_outcome);
473477
if (!delete_outcome.GetResult().GetErrors().empty()) {
474478
const auto& e = delete_outcome.GetResult().GetErrors().front();
475479
return {convert_to_obj_response(Status::InternalError(

be/src/util/s3_util.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ extern bvar::LatencyRecorder s3_copy_object_latency;
6262
}; // namespace s3_bvar
6363

6464
std::string hide_access_key(const std::string& ak);
65+
int reset_s3_rate_limiter(S3RateLimitType type, size_t max_speed, size_t max_burst, size_t limit);
6566

6667
class S3URI;
6768
struct S3ClientConf {

0 commit comments

Comments
 (0)