Repository: robustmq/robustmq (language: rust)

Issue:
MINOR: Add validation to the delete_resource_config method in GrpcPlacementService and fill in the test case
### What type of enhancement is this?

Refactor

### What does the enhancement do?

Add validation to the delete_resource_config method in GrpcPlacementService and fill in the test case.

Tips:
you can implement the `ValidateExt` trait on `DeleteResourceConfigRequest`, then invoke ` validate_ext ` function to achieve the validation functionality.

- you can locate the ValidateExt trait in the file: src\placement-center\src\server\grpc\validate.rs
- you need to add validation to the delete_resource_config method in this file:  src\placement-center\src\server\grpc\service_placement.rs
- you need to fill in the test case in this file: src\grpc-clients\tests\placement_test.rs


references:
- https://github.com/robustmq/robustmq/pull/548)https://github.com/robustmq/robustmq/pull/548


### Implementation challenges

_No response_


Discussion / hints:
Can this task be assigned to me? @socutes 
I can take a look!

Fix patch:
diff --git a/src/placement-center/src/server/grpc/service_inner.rs b/src/placement-center/src/server/grpc/service_inner.rs
index a9edc72e9..df443fbc3 100644
--- a/src/placement-center/src/server/grpc/service_inner.rs
+++ b/src/placement-center/src/server/grpc/service_inner.rs
@@ -233,6 +233,9 @@ impl PlacementCenterService for GrpcPlacementService {
         request: Request<DeleteResourceConfigRequest>,
     ) -> Result<Response<DeleteResourceConfigReply>, Status> {
         let req = request.into_inner();
+
+        let _ = req.validate_ext()?;
+
         let data = StorageData::new(
             StorageDataType::ClusterDeleteResourceConfig,
             DeleteResourceConfigRequest::encode_to_vec(&req),
diff --git a/src/placement-center/src/server/grpc/validate.rs b/src/placement-center/src/server/grpc/validate.rs
index e2c9eb3a0..3e201285b 100644
--- a/src/placement-center/src/server/grpc/validate.rs
+++ b/src/placement-center/src/server/grpc/validate.rs
@@ -16,9 +16,9 @@ use std::net::{IpAddr, SocketAddr};
 
 use common_base::error::common::CommonError;
 use protocol::placement_center::placement_center_inner::{
-    ClusterType, DeleteIdempotentDataRequest, ExistsIdempotentDataRequest,
-    GetResourceConfigRequest, NodeListRequest, RegisterNodeRequest, SetIdempotentDataRequest,
-    SetResourceConfigRequest, UnRegisterNodeRequest,
+    ClusterType, DeleteIdempotentDataRequest, DeleteResourceConfigRequest,
+    ExistsIdempotentDataRequest, GetResourceConfigRequest, NodeListRequest, RegisterNodeRequest,
+    SetIdempotentDataRequest, SetResourceConfigRequest, UnRegisterNodeRequest,
 };
 use protocol::placement_center::placement_center_mqtt::GetShareSubLeaderRequest;
 use tonic::Status;
@@ -174,6 +174,13 @@ impl ValidateExt for ExistsIdempotentDataRequest {
     }
 }
 
+impl ValidateExt for DeleteResourceConfigRequest {
+    fn validate_ext(&self) -> Result<(), Status> {
+        ensure_param_not_empty("cluster_name", &self.cluster_name)?;
+        Ok(())
+    }
+}
+
 #[cfg(test)]
 mod validate_test {
     use super::*;


Test patch:
diff --git a/src/grpc-clients/tests/placement/mqtt/cluster_test.rs b/src/grpc-clients/tests/placement/mqtt/cluster_test.rs
index 36eaad562..bf2cb0332 100644
--- a/src/grpc-clients/tests/placement/mqtt/cluster_test.rs
+++ b/src/grpc-clients/tests/placement/mqtt/cluster_test.rs
@@ -17,14 +17,14 @@ mod tests {
     use std::sync::Arc;
 
     use grpc_clients::placement::inner::call::{
-        cluster_status, delete_idempotent_data, exists_idempotent_data, get_resource_config,
-        node_list, register_node, set_resource_config, unregister_node,
+        cluster_status, delete_idempotent_data, delete_resource_config, exists_idempotent_data,
+        get_resource_config, node_list, register_node, set_resource_config, unregister_node,
     };
     use grpc_clients::pool::ClientPool;
     use protocol::placement_center::placement_center_inner::{
         ClusterStatusRequest, ClusterType, DeleteIdempotentDataRequest,
-        ExistsIdempotentDataRequest, GetResourceConfigRequest, NodeListRequest,
-        RegisterNodeRequest, SetResourceConfigRequest, UnRegisterNodeRequest,
+        DeleteResourceConfigRequest, ExistsIdempotentDataRequest, GetResourceConfigRequest,
+        NodeListRequest, RegisterNodeRequest, SetResourceConfigRequest, UnRegisterNodeRequest,
     };
 
     use crate::common::get_placement_addr;
@@ -291,4 +291,29 @@ mod tests {
             .await
             .is_err());
     }
+
+    #[tokio::test]
+    async fn delete_resource_config_test() {
+        let client_pool: Arc<ClientPool> = Arc::new(ClientPool::new(1));
+        let addrs = vec![get_placement_addr()];
+
+        let request = ClusterStatusRequest::default();
+        assert!(cluster_status(&client_pool, &addrs, request).await.is_ok());
+
+        let request = DeleteResourceConfigRequest {
+            cluster_name: "test-cluster-name".to_string(),
+            resources: Vec::new(),
+        };
+        assert!(delete_resource_config(&client_pool, &addrs, request)
+            .await
+            .is_ok());
+
+        let request = DeleteResourceConfigRequest {
+            cluster_name: "".to_string(),
+            resources: Vec::new(),
+        };
+        assert!(delete_resource_config(&client_pool, &addrs, request)
+            .await
+            .is_err());
+    }
 }