Skip to content

Commit

Permalink
refactor: fix tls_test to use refactored config
Browse files Browse the repository at this point in the history
Signed-off-by: Harsh1s <[email protected]>
  • Loading branch information
Harsh1s authored and Phoenix500526 committed May 16, 2024
1 parent ef75856 commit cb9497b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
12 changes: 6 additions & 6 deletions crates/utils/src/config/metrics_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
20 changes: 10 additions & 10 deletions crates/utils/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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!(
Expand All @@ -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()
}
Expand Down
4 changes: 2 additions & 2 deletions crates/utils/src/config/tls_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
}
4 changes: 2 additions & 2 deletions crates/xline/tests/it/tls_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down

0 comments on commit cb9497b

Please sign in to comment.