From cb9497bcc2c4464040ef7a33668fcf9ce5dcae8a Mon Sep 17 00:00:00 2001 From: Harsh1s Date: Tue, 14 May 2024 16:22:59 +0800 Subject: [PATCH] refactor: fix tls_test to use refactored config Signed-off-by: Harsh1s --- crates/utils/src/config/metrics_config.rs | 12 ++++++------ crates/utils/src/config/mod.rs | 20 ++++++++++---------- crates/utils/src/config/tls_config.rs | 4 ++-- crates/xline/tests/it/tls_test.rs | 4 ++-- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/crates/utils/src/config/metrics_config.rs b/crates/utils/src/config/metrics_config.rs index c40779ac3..40d974c61 100644 --- a/crates/utils/src/config/metrics_config.rs +++ b/crates/utils/src/config/metrics_config.rs @@ -8,27 +8,27 @@ pub struct MetricsConfig { /// Enable or not #[getset(get = "pub")] #[serde(default = "default_metrics_enable")] - enable: bool, + pub enable: bool, /// The http port to expose #[getset(get = "pub")] #[serde(default = "default_metrics_port")] - port: u16, + pub port: u16, /// The http path to expose #[getset(get = "pub")] #[serde(default = "default_metrics_path")] - path: String, + pub path: String, /// Enable push or not #[getset(get = "pub")] #[serde(default = "default_metrics_push")] - push: bool, + pub push: bool, /// Push endpoint #[getset(get = "pub")] #[serde(default = "default_metrics_push_endpoint")] - push_endpoint: String, + pub push_endpoint: String, /// Push protocol #[getset(get = "pub")] #[serde(with = "protocol_format", default = "default_metrics_push_protocol")] - push_protocol: MetricsPushProtocol, + pub push_protocol: MetricsPushProtocol, } impl MetricsConfig { diff --git a/crates/utils/src/config/mod.rs b/crates/utils/src/config/mod.rs index 0c28f91f2..4be9f6327 100644 --- a/crates/utils/src/config/mod.rs +++ b/crates/utils/src/config/mod.rs @@ -99,7 +99,7 @@ mod tests { use crate::{ config::{ client_config::{ - default_client_wait_synced_timeout, default_fixed_backoff, default_propose_timeout, + default_client_id_keep_alive_interval, default_client_wait_synced_timeout, default_fixed_backoff, default_propose_timeout, default_retry_count, ClientConfig, }, compact_config::AutoCompactConfig, @@ -175,8 +175,8 @@ mod tests { auth_private_key = './private_key.pem' [tls] - server_cert_path = './cert.pem' - server_key_path = './key.pem' + peer_cert_path = './cert.pem' + peer_key_path = './key.pem' client_ca_cert_path = './ca.pem' [metrics] @@ -263,13 +263,13 @@ mod tests { assert_eq!( config.compact, - CompactConfig::new( - 123, - Duration::from_millis(5), - Some(AutoCompactConfig::Periodic(Duration::from_secs( + CompactConfig { + compact_batch_size: 123, + compact_sleep_interval: Duration::from_millis(5), + auto_compact_config: Some(AutoCompactConfig::Periodic(Duration::from_secs( 10 * 60 * 60 ))) - ) + } ); assert_eq!( @@ -283,8 +283,8 @@ mod tests { assert_eq!( config.tls, TlsConfig { - server_cert_path: Some(PathBuf::from("./cert.pem")), - server_key_path: Some(PathBuf::from("./key.pem")), + peer_cert_path: Some(PathBuf::from("./cert.pem")), + peer_key_path: Some(PathBuf::from("./key.pem")), client_ca_cert_path: Some(PathBuf::from("./ca.pem")), ..Default::default() } diff --git a/crates/utils/src/config/tls_config.rs b/crates/utils/src/config/tls_config.rs index 5d5d13d92..de56d1bc3 100644 --- a/crates/utils/src/config/tls_config.rs +++ b/crates/utils/src/config/tls_config.rs @@ -49,11 +49,11 @@ impl TlsConfig { client_key_path, } } - + /// Whether the server tls is enabled #[must_use] #[inline] pub fn server_tls_enabled(&self) -> bool { self.peer_cert_path.is_some() && self.peer_key_path.is_some() } -} \ No newline at end of file +} diff --git a/crates/xline/tests/it/tls_test.rs b/crates/xline/tests/it/tls_test.rs index 527b305c1..64b856bb0 100644 --- a/crates/xline/tests/it/tls_test.rs +++ b/crates/xline/tests/it/tls_test.rs @@ -4,8 +4,8 @@ use etcd_client::ConnectOptions; use test_macros::abort_on_panic; use tonic::transport::{Certificate, ClientTlsConfig, Identity}; use utils::config::{ - AuthConfig, ClusterConfig, CompactConfig, LogConfig, MetricsConfig, StorageConfig, TlsConfig, - TraceConfig, XlineServerConfig, + auth_config::AuthConfig, cluster_config::ClusterConfig, compact_config::CompactConfig, log_config::LogConfig, metrics_config::MetricsConfig, storage_config::StorageConfig, tls_config::TlsConfig, + trace_config::TraceConfig, XlineServerConfig, }; use xline_client::types::kv::PutRequest; use xline_test_utils::{enable_auth, set_user, Cluster};