Skip to content

Commit

Permalink
Merge pull request #2171 from jarhodes314/feat/2159/mqtt-clean-session
Browse files Browse the repository at this point in the history
Use MQTT clean session for the mosquitto c8y bridge connection
  • Loading branch information
reubenmiller authored Aug 21, 2023
2 parents 05cec39 + 0f6a7f2 commit f900160
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
13 changes: 11 additions & 2 deletions crates/core/tedge/src/cli/connect/bridge_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub struct BridgeConfig {
pub try_private: bool,
pub start_type: String,
pub clean_session: bool,
pub local_clean_session: bool,
pub notifications: bool,
pub notifications_local_only: bool,
pub notification_topic: String,
Expand Down Expand Up @@ -52,6 +53,7 @@ impl BridgeConfig {
writeln!(writer, "try_private {}", self.try_private)?;
writeln!(writer, "start_type {}", self.start_type)?;
writeln!(writer, "cleansession {}", self.clean_session)?;
writeln!(writer, "local_cleansession {}", self.local_clean_session)?;
writeln!(writer, "notifications {}", self.notifications)?;
writeln!(
writer,
Expand Down Expand Up @@ -123,6 +125,7 @@ mod test {
try_private: false,
start_type: "automatic".into(),
clean_session: true,
local_clean_session: true,
notifications: false,
notifications_local_only: false,
notification_topic: "test_topic".into(),
Expand All @@ -149,6 +152,7 @@ bridge_keyfile ./test-private-key.pem
try_private false
start_type automatic
cleansession true
local_cleansession true
notifications false
notifications_local_only false
notification_topic test_topic
Expand All @@ -158,7 +162,7 @@ bridge_attempt_unsubscribe false
"#,
);

assert_eq!(serialized_config, expected.as_bytes());
assert_eq!(std::str::from_utf8(&serialized_config).unwrap(), expected);

Ok(())
}
Expand All @@ -185,6 +189,7 @@ bridge_attempt_unsubscribe false
try_private: false,
start_type: "automatic".into(),
clean_session: true,
local_clean_session: true,
notifications: false,
notifications_local_only: false,
notification_topic: "test_topic".into(),
Expand All @@ -210,6 +215,7 @@ bridge_keyfile ./test-private-key.pem
try_private false
start_type automatic
cleansession true
local_cleansession true
notifications false
notifications_local_only false
notification_topic test_topic
Expand All @@ -219,7 +225,7 @@ bridge_attempt_unsubscribe false
"#,
);

assert_eq!(serialized_config, expected.as_bytes());
assert_eq!(std::str::from_utf8(&serialized_config).unwrap(), expected);

Ok(())
}
Expand Down Expand Up @@ -249,6 +255,7 @@ bridge_attempt_unsubscribe false
try_private: false,
start_type: "automatic".into(),
clean_session: true,
local_clean_session: true,
notifications: false,
notifications_local_only: false,
notification_topic: "test_topic".into(),
Expand Down Expand Up @@ -277,6 +284,7 @@ bridge_attempt_unsubscribe false
expected.insert("start_type automatic");
expected.insert("try_private false");
expected.insert("cleansession true");
expected.insert("local_cleansession true");
expected.insert("notifications false");
expected.insert("notifications_local_only false");
expected.insert("notification_topic test_topic");
Expand Down Expand Up @@ -382,6 +390,7 @@ bridge_attempt_unsubscribe false
try_private: false,
start_type: "automatic".into(),
clean_session: true,
local_clean_session: true,
notifications: false,
notifications_local_only: false,
notification_topic: "test_topic".into(),
Expand Down
2 changes: 2 additions & 0 deletions crates/core/tedge/src/cli/connect/bridge_config_aws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ impl From<BridgeConfigAwsParams> for BridgeConfig {
try_private: false,
start_type: "automatic".into(),
clean_session: false,
local_clean_session: false,
notifications: true,
notifications_local_only: true,
notification_topic: "tedge/health/mosquitto-aws-bridge".into(),
Expand Down Expand Up @@ -113,6 +114,7 @@ fn test_bridge_config_from_aws_params() -> anyhow::Result<()> {
try_private: false,
start_type: "automatic".into(),
clean_session: false,
local_clean_session: false,
notifications: true,
notifications_local_only: true,
notification_topic: "tedge/health/mosquitto-aws-bridge".into(),
Expand Down
2 changes: 2 additions & 0 deletions crates/core/tedge/src/cli/connect/bridge_config_azure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ impl From<BridgeConfigAzureParams> for BridgeConfig {
try_private: false,
start_type: "automatic".into(),
clean_session: false,
local_clean_session: false,
notifications: true,
notifications_local_only: true,
notification_topic: "tedge/health/mosquitto-az-bridge".into(),
Expand Down Expand Up @@ -103,6 +104,7 @@ fn test_bridge_config_from_azure_params() -> anyhow::Result<()> {
try_private: false,
start_type: "automatic".into(),
clean_session: false,
local_clean_session: false,
notifications: true,
notifications_local_only: true,
notification_topic: "tedge/health/mosquitto-az-bridge".into(),
Expand Down
6 changes: 4 additions & 2 deletions crates/core/tedge/src/cli/connect/bridge_config_c8y.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ impl From<BridgeConfigC8yParams> for BridgeConfig {
use_agent: true,
try_private: false,
start_type: "automatic".into(),
clean_session: false,
clean_session: true,
local_clean_session: false,
notifications: true,
notifications_local_only: true,
notification_topic: "tedge/health/mosquitto-c8y-bridge".into(),
Expand Down Expand Up @@ -172,7 +173,8 @@ fn test_bridge_config_from_c8y_params() -> anyhow::Result<()> {
],
try_private: false,
start_type: "automatic".into(),
clean_session: false,
clean_session: true,
local_clean_session: false,
notifications: true,
notifications_local_only: true,
notification_topic: "tedge/health/mosquitto-c8y-bridge".into(),
Expand Down

1 comment on commit f900160

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
255 0 5 255 100

Please sign in to comment.