Skip to content

Commit

Permalink
fix: humantime serde on heartbeat
Browse files Browse the repository at this point in the history
  • Loading branch information
masonyc committed Oct 12, 2023
1 parent 99167d0 commit 93e019e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/cmd/src/datanode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ mod tests {
use common_base::readable_size::ReadableSize;
use common_test_util::temp_dir::create_named_temp_file;
use datanode::config::{CompactionConfig, FileConfig, ObjectStoreConfig, RegionManifestConfig};
use servers::heartbeat_options::HeartbeatOptions;
use servers::Mode;

use super::*;
Expand All @@ -196,6 +197,9 @@ mod tests {
rpc_hostname = "127.0.0.1"
rpc_runtime_size = 8
[heartbeat]
interval = "300ms"
[meta_client]
metasrv_addrs = ["127.0.0.1:3002"]
timeout = "3s"
Expand Down Expand Up @@ -249,19 +253,26 @@ mod tests {
assert_eq!(1024 * 1024 * 1024 * 50, options.wal.purge_threshold.0);
assert!(!options.wal.sync_write);

let HeartbeatOptions {
interval: heart_beat_interval,
..
} = options.heartbeat;

assert_eq!(300, heart_beat_interval.as_millis());

let MetaClientOptions {
metasrv_addrs: metasrv_addr,
timeout: timeout_millis,
connect_timeout: connect_timeout_millis,
timeout,
connect_timeout,
ddl_timeout,
tcp_nodelay,
ddl_timeout: ddl_timeout_millis,
..
} = options.meta_client.unwrap();

assert_eq!(vec!["127.0.0.1:3002".to_string()], metasrv_addr);
assert_eq!(5000, connect_timeout_millis.as_millis());
assert_eq!(10000, ddl_timeout_millis.as_millis());
assert_eq!(3000, timeout_millis.as_millis());
assert_eq!(5000, connect_timeout.as_millis());
assert_eq!(10000, ddl_timeout.as_millis());
assert_eq!(3000, timeout.as_millis());
assert!(tcp_nodelay);
assert_eq!("/tmp/greptimedb/", options.storage.data_home);
assert!(matches!(
Expand Down
2 changes: 2 additions & 0 deletions src/servers/src/heartbeat_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
#[serde(default)]
pub struct HeartbeatOptions {
#[serde(with = "humantime_serde")]
pub interval: Duration,
#[serde(with = "humantime_serde")]
pub retry_interval: Duration,
}

Expand Down

0 comments on commit 93e019e

Please sign in to comment.