Skip to content

Commit

Permalink
fix(cli): update CLI and tests for server default parameters
Browse files Browse the repository at this point in the history
This commit updates the CLI and associated tests to use "server_default"
as the default value for max topic size and message expiry time, instead
of "unlimited". This change ensures that the CLI uses the server's
default configuration when parameters are not explicitly specified by
the user. Additionally, the commit modifies the display and parsing
logic for `IggyExpiry` to use "never_expire" instead of "none" for
clarity. The tests have been updated to reflect these changes, ensuring
that the new defaults are correctly applied and tested.

This closes #1536.
  • Loading branch information
hubcio committed Feb 17, 2025
1 parent bdac9c8 commit 4bab151
Show file tree
Hide file tree
Showing 8 changed files with 166 additions and 156 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "iggy-cli"
version = "0.8.8"
version = "0.8.9"
edition = "2021"
authors = ["[email protected]"]
repository = "https://github.com/iggy-rs/iggy"
Expand Down
24 changes: 12 additions & 12 deletions cli/src/args/topic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,19 @@ pub(crate) struct TopicCreateArgs {
/// Compression algorithm for the topic, set to "none" for no compression
#[arg(value_parser = clap::value_parser!(CompressionAlgorithm), verbatim_doc_comment)]
pub(crate) compression_algorithm: CompressionAlgorithm,
/// Max topic size
/// Max topic size in human-readable format like "unlimited" or "15GB"
///
/// ("unlimited" or skipping parameter disables max topic size functionality in topic)
/// "server_default" or skipping parameter makes CLI to use server default (from current server config) max topic size
/// Can't be lower than segment size in the config.
#[arg(short, long, default_value = "unlimited", verbatim_doc_comment)]
#[arg(short, long, default_value = "server_default", verbatim_doc_comment)]
pub(crate) max_topic_size: MaxTopicSize,
/// Replication factor for the topic
#[arg(short, long, default_value = "1")]
pub(crate) replication_factor: u8,
/// Message expiry time in human-readable format like 15days 2min 2s
/// Message expiry time in human-readable format like "unlimited" or "15days 2min 2s"
///
/// ("unlimited" or skipping parameter disables message expiry functionality in topic)
#[arg(value_parser = clap::value_parser!(IggyExpiry), verbatim_doc_comment)]
/// "server_default" or skipping parameter makes CLI to use server default (from current server config) expiry time
#[arg(default_value = "server_default", value_parser = clap::value_parser!(IggyExpiry), verbatim_doc_comment)]
pub(crate) message_expiry: Vec<IggyExpiry>,
}

Expand Down Expand Up @@ -144,19 +144,19 @@ pub(crate) struct TopicUpdateArgs {
/// Compression algorithm for the topic, set to "none" for no compression
#[arg(value_parser = clap::value_parser!(CompressionAlgorithm), verbatim_doc_comment)]
pub(crate) compression_algorithm: CompressionAlgorithm,
/// New max topic size
/// New max topic size in human-readable format like "unlimited" or "15GB"
///
/// ("unlimited" or skipping parameter causes removal of max topic size parameter in topic)
/// "server_default" or skipping parameter makes CLI to use server default (from current server config) max topic size
/// Can't be lower than segment size in the config.
#[arg(short, long, default_value = "unlimited", verbatim_doc_comment)]
#[arg(short, long, default_value = "server_default", verbatim_doc_comment)]
pub(crate) max_topic_size: MaxTopicSize,
#[arg(short, long, default_value = "1")]
/// New replication factor for the topic
pub(crate) replication_factor: u8,
/// New message expiry time in human-readable format like 15days 2min 2s
/// New message expiry time in human-readable format like "unlimited" or "15days 2min 2s"
///
/// ("unlimited" or skipping parameter causes removal of expiry parameter in topic)
#[arg(value_parser = clap::value_parser!(IggyExpiry), verbatim_doc_comment)]
/// "server_default" or skipping parameter makes CLI to use server default (from current server config) expiry time
#[arg(default_value = "server_default", value_parser = clap::value_parser!(IggyExpiry), verbatim_doc_comment)]
pub(crate) message_expiry: Vec<IggyExpiry>,
}

Expand Down
32 changes: 19 additions & 13 deletions integration/tests/cli/topic/test_topic_create_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl IggyCmdTestCase for TestTopicCreateCmd {
let compression_algorithm = &self.compression_algorithm;
let message_expiry = (match &self.message_expiry {
Some(value) => value.join(" "),
None => IggyExpiry::NeverExpire.to_string(),
None => IggyExpiry::ServerDefault.to_string(),
})
.to_string();

Expand Down Expand Up @@ -189,7 +189,7 @@ pub async fn should_be_successful() {
1,
Default::default(),
None,
MaxTopicSize::Unlimited,
MaxTopicSize::ServerDefault,
1,
TestStreamId::Numeric,
))
Expand All @@ -203,7 +203,7 @@ pub async fn should_be_successful() {
5,
Default::default(),
None,
MaxTopicSize::Unlimited,
MaxTopicSize::ServerDefault,
1,
TestStreamId::Named,
))
Expand Down Expand Up @@ -281,21 +281,23 @@ Arguments:
Compression algorithm for the topic, set to "none" for no compression
[MESSAGE_EXPIRY]...
Message expiry time in human-readable format like 15days 2min 2s
Message expiry time in human-readable format like "unlimited" or "15days 2min 2s"
{CLAP_INDENT}
("unlimited" or skipping parameter disables message expiry functionality in topic)
"server_default" or skipping parameter makes CLI to use server default (from current server config) expiry time
{CLAP_INDENT}
[default: server_default]
Options:
-t, --topic-id <TOPIC_ID>
Topic ID to create
-m, --max-topic-size <MAX_TOPIC_SIZE>
Max topic size
Max topic size in human-readable format like "unlimited" or "15GB"
{CLAP_INDENT}
("unlimited" or skipping parameter disables max topic size functionality in topic)
"server_default" or skipping parameter makes CLI to use server default (from current server config) max topic size
Can't be lower than segment size in the config.
{CLAP_INDENT}
[default: unlimited]
[default: server_default]
-r, --replication-factor <REPLICATION_FACTOR>
Replication factor for the topic
Expand Down Expand Up @@ -327,13 +329,17 @@ Arguments:
<NAME> Name of the topic
<PARTITIONS_COUNT> Number of partitions inside the topic
<COMPRESSION_ALGORITHM> Compression algorithm for the topic, set to "none" for no compression
[MESSAGE_EXPIRY]... Message expiry time in human-readable format like 15days 2min 2s
[MESSAGE_EXPIRY]... Message expiry time in human-readable format like "unlimited" or "15days 2min 2s" [default: server_default]
Options:
-t, --topic-id <TOPIC_ID> Topic ID to create
-m, --max-topic-size <MAX_TOPIC_SIZE> Max topic size [default: unlimited]
-r, --replication-factor <REPLICATION_FACTOR> Replication factor for the topic [default: 1]
-h, --help Print help (see more with '--help')
-t, --topic-id <TOPIC_ID>
Topic ID to create
-m, --max-topic-size <MAX_TOPIC_SIZE>
Max topic size in human-readable format like "unlimited" or "15GB" [default: server_default]
-r, --replication-factor <REPLICATION_FACTOR>
Replication factor for the topic [default: 1]
-h, --help
Print help (see more with '--help')
"#,
),
))
Expand Down
Loading

0 comments on commit 4bab151

Please sign in to comment.