github-actions[bot] commented on code in PR #38685: URL: https://github.com/apache/doris/pull/38685#discussion_r1711379866
########## cloud/src/meta-service/meta_service_resource.cpp: ########## @@ -510,13 +519,114 @@ static void set_default_vault_log_helper(const InstanceInfoPB& instance, LOG(INFO) << vault_msg; } +static int alter_hdfs_storage_vault(InstanceInfoPB& instance, std::unique_ptr<Transaction> txn, Review Comment: warning: function 'alter_hdfs_storage_vault' exceeds recommended size/complexity thresholds [readability-function-size] ```cpp static int alter_hdfs_storage_vault(InstanceInfoPB& instance, std::unique_ptr<Transaction> txn, ^ ``` <details> <summary>Additional context</summary> **cloud/src/meta-service/meta_service_resource.cpp:521:** 97 lines including whitespace and comments (threshold 80) ```cpp static int alter_hdfs_storage_vault(InstanceInfoPB& instance, std::unique_ptr<Transaction> txn, ^ ``` </details> ########## cloud/test/meta_service_test.cpp: ########## @@ -528,6 +529,215 @@ TEST(MetaServiceTest, AlterS3StorageVaultTest) { ASSERT_NE(res.status().code(), MetaServiceCode::OK) << res.status().msg(); } + { + AlterObjStoreInfoRequest req; + constexpr char new_vault_name[] = "@!#vault_name"; + req.set_cloud_unique_id("test_cloud_unique_id"); + req.set_op(AlterObjStoreInfoRequest::ALTER_S3_VAULT); + StorageVaultPB vault; + vault.set_alter_name(new_vault_name); + ObjectStoreInfoPB obj; + obj_info.set_ak("new_ak"); + vault.mutable_obj_info()->MergeFrom(obj); + vault.set_name(vault_name); + req.mutable_vault()->CopyFrom(vault); + + brpc::Controller cntl; + AlterObjStoreInfoResponse res; + meta_service->alter_storage_vault( + reinterpret_cast<::google::protobuf::RpcController*>(&cntl), &req, &res, nullptr); + ASSERT_NE(res.status().code(), MetaServiceCode::OK) << res.status().msg(); + ASSERT_TRUE(res.status().msg().find("invalid storage vault name") != std::string::npos) + << res.status().msg(); + } + + { + AlterObjStoreInfoRequest req; + constexpr char new_vault_name[] = "new_test_alter_s3_vault"; + req.set_cloud_unique_id("test_cloud_unique_id"); + req.set_op(AlterObjStoreInfoRequest::ALTER_S3_VAULT); + StorageVaultPB vault; + vault.set_alter_name(new_vault_name); + ObjectStoreInfoPB obj; + obj_info.set_ak("new_ak"); + vault.mutable_obj_info()->MergeFrom(obj); + vault.set_name(vault_name); + req.mutable_vault()->CopyFrom(vault); + + brpc::Controller cntl; + AlterObjStoreInfoResponse res; + meta_service->alter_storage_vault( + reinterpret_cast<::google::protobuf::RpcController*>(&cntl), &req, &res, nullptr); + ASSERT_EQ(res.status().code(), MetaServiceCode::OK) << res.status().msg(); + InstanceInfoPB instance; + get_test_instance(instance); + + std::unique_ptr<Transaction> txn; + ASSERT_EQ(meta_service->txn_kv()->create_txn(&txn), TxnErrorCode::TXN_OK); + std::string val; + ASSERT_EQ(txn->get(storage_vault_key({instance.instance_id(), "2"}), &val), + TxnErrorCode::TXN_OK); + StorageVaultPB get_obj; + get_obj.ParseFromString(val); + ASSERT_EQ(get_obj.name(), new_vault_name) << get_obj.obj_info().ak(); + } + + SyncPoint::get_instance()->disable_processing(); + SyncPoint::get_instance()->clear_all_call_backs(); +} + +TEST(MetaServiceTest, AlterHdfsStorageVaultTest) { Review Comment: warning: function 'TEST' exceeds recommended size/complexity thresholds [readability-function-size] ```cpp TEST(MetaServiceTest, AlterHdfsStorageVaultTest) { ^ ``` <details> <summary>Additional context</summary> **cloud/test/meta_service_test.cpp:588:** 154 lines including whitespace and comments (threshold 80) ```cpp TEST(MetaServiceTest, AlterHdfsStorageVaultTest) { ^ ``` </details> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org