Skip to content

Commit

Permalink
chore: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shuiyisong committed May 17, 2024
1 parent 2453be1 commit 79c3324
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
4 changes: 2 additions & 2 deletions config/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@
| `rpc_runtime_size` | Integer | `8` | The number of gRPC server worker threads. |
| `rpc_max_recv_message_size` | String | `512MB` | The maximum receive message size for gRPC server. |
| `rpc_max_send_message_size` | String | `512MB` | The maximum send message size for gRPC server. |
| `## Enable telemetry to collect anonymous usage data.` | Array | -- | Supported compression encoding for gRPC server, e.g: gzip, zstd |
| `enable_telemetry` | Bool | `true` | -- |
| `rpc_accept_compressed` | Array | -- | Supported compression encoding for gRPC server, e.g: gzip, zstd. |
| `enable_telemetry` | Bool | `true` | Enable telemetry to collect anonymous usage data. |
| `heartbeat` | -- | -- | The heartbeat options. |
| `heartbeat.interval` | String | `3s` | Interval for sending heartbeat messages to the metasrv. |
| `heartbeat.retry_interval` | String | `3s` | Interval for retrying to send heartbeat messages to the metasrv. |
Expand Down
2 changes: 1 addition & 1 deletion config/datanode.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ rpc_max_recv_message_size = "512MB"
## The maximum send message size for gRPC server.
rpc_max_send_message_size = "512MB"

## Supported compression encoding for gRPC server, e.g: gzip, zstd
## Supported compression encoding for gRPC server, e.g: gzip, zstd.
rpc_accept_compressed = []

## Enable telemetry to collect anonymous usage data.
Expand Down
4 changes: 4 additions & 0 deletions src/cmd/src/standalone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,9 @@ mod tests {
timeout = "33s"
body_limit = "128MB"
[grpc]
accept_compressed = ["gzip"]
[opentsdb]
enable = true
Expand Down Expand Up @@ -662,6 +665,7 @@ mod tests {
assert_eq!(None, fe_opts.mysql.reject_no_database);
assert!(fe_opts.influxdb.enable);
assert!(fe_opts.opentsdb.enable);
assert_eq!(vec!["gzip"], fe_opts.grpc.accept_compressed);

let DatanodeWalConfig::RaftEngine(raft_engine_config) = dn_opts.wal else {
unreachable!()
Expand Down
21 changes: 21 additions & 0 deletions src/servers/src/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,24 @@ impl Server for GrpcServer {
GRPC_SERVER
}
}

#[cfg(test)]
mod tests {

#[test]
fn test_parse_compression_encoding() {
let encodings = vec![];
let result = super::parse_grpc_compression_encoding(&encodings).unwrap();
assert_eq!(result.len(), 0);

let encodings = vec!["gzip".to_string(), "zstd".to_string()];
let result = super::parse_grpc_compression_encoding(&encodings).unwrap();
assert_eq!(result.len(), 2);
assert_eq!(result[0], tonic::codec::CompressionEncoding::Gzip);
assert_eq!(result[1], tonic::codec::CompressionEncoding::Zstd);

let encodings = vec!["unknown".to_string()];
let result = super::parse_grpc_compression_encoding(&encodings);
assert!(result.is_err());
}
}

0 comments on commit 79c3324

Please sign in to comment.