diff --git a/crates/core/tedge/src/cli/connect/command.rs b/crates/core/tedge/src/cli/connect/command.rs index 7f7416c87e3..963fb2aa047 100644 --- a/crates/core/tedge/src/cli/connect/command.rs +++ b/crates/core/tedge/src/cli/connect/command.rs @@ -289,6 +289,7 @@ fn check_device_status_c8y(tedge_config: &TEdgeConfig) -> Result Result { @@ -332,6 +334,19 @@ fn check_device_status_c8y(tedge_config: &TEdgeConfig) -> Result break, + _ => {} + } + } + + if exists { + return Ok(DeviceStatus::AlreadyExists); + } + if acknowledged { // The request has been sent but without a response Ok(DeviceStatus::Unknown) @@ -363,6 +378,7 @@ fn check_device_status_azure(tedge_config: &TEdgeConfig) -> Result Result Result break, + _ => {} + } + } + + if exists { + return Ok(DeviceStatus::AlreadyExists); + } + if acknowledged { // The request has been sent but without a response Ok(DeviceStatus::Unknown) @@ -430,6 +460,7 @@ fn check_device_status_aws(tedge_config: &TEdgeConfig) -> Result Result { // We got a response println!("Received expected response on topic {}.", response.topic); - return Ok(DeviceStatus::AlreadyExists); + exists = true; + break; } Ok(Event::Outgoing(Outgoing::PingReq)) => { // No messages have been received for a while @@ -470,6 +502,19 @@ fn check_device_status_aws(tedge_config: &TEdgeConfig) -> Result break, + _ => {} + } + } + + if exists { + return Ok(DeviceStatus::AlreadyExists); + } + if acknowledged { // The request has been sent but without a response Ok(DeviceStatus::Unknown) diff --git a/crates/core/tedge/src/cli/connect/jwt_token.rs b/crates/core/tedge/src/cli/connect/jwt_token.rs index d203eb4b2b2..c8c12349290 100644 --- a/crates/core/tedge/src/cli/connect/jwt_token.rs +++ b/crates/core/tedge/src/cli/connect/jwt_token.rs @@ -27,6 +27,7 @@ pub(crate) fn get_connected_c8y_url(tedge_config: &TEdgeConfig) -> Result = None; client.subscribe(&c8y_topic_builtin_jwt_token_downstream, AtLeastOnce)?; @@ -49,7 +50,8 @@ pub(crate) fn get_connected_c8y_url(tedge_config: &TEdgeConfig) -> Result { // No messages have been received for a while @@ -68,6 +70,19 @@ pub(crate) fn get_connected_c8y_url(tedge_config: &TEdgeConfig) -> Result break, + _ => {} + } + } + + if let Some(c8y_url) = c8y_url { + return Ok(c8y_url); + } + if acknowledged { // The request has been sent but without a response println!("\nThe request has been sent, however, no response."); diff --git a/tests/RobotFramework/tests/tedge_connect/tedge_connect_test.robot b/tests/RobotFramework/tests/tedge_connect/tedge_connect_test.robot index 9b7e80f594e..e27d0541536 100644 --- a/tests/RobotFramework/tests/tedge_connect/tedge_connect_test.robot +++ b/tests/RobotFramework/tests/tedge_connect/tedge_connect_test.robot @@ -7,7 +7,7 @@ Resource ../../resources/common.resource Library ThinEdgeIO Test Tags theme:cli theme:mqtt theme:c8y -Suite Setup Setup +Suite Setup Suite Setup Suite Teardown Get Logs *** Test Cases *** @@ -58,8 +58,19 @@ tedge reconnect restarts mapper ${pid_after}= Execute Command sudo systemctl show --property MainPID tedge-mapper-c8y Should Not Be Equal ${pid_before} ${pid_after} +Check absence of OpenSSL Error messages #3024 + ${SuiteStart}= Get Suite Start Time + # Only checkout output if mosquitto is being used + ${output}= Execute Command systemctl is-active mosquitto && journalctl -u mosquitto -n 5000 --since "@${SuiteStartSeconds}" || true + Should Not Contain ${output} OpenSSL Error + *** Keywords *** +Suite Setup + Setup + ${SuiteStartSeconds}= Get Unix Timestamp + Set Suite Variable $SuiteStartSeconds + Should Have File Permissions [Arguments] ${file} ${expected_permissions} ${FILE_MODE_OWNERSHIP}= Execute Command stat -c '%a %U:%G' ${file} strip=${True}