From 8eed947961d69016e3ea13cc0f388ed62da05f9e Mon Sep 17 00:00:00 2001 From: Rina Fujino Date: Fri, 16 Aug 2024 15:44:49 +0000 Subject: [PATCH] Add system test for the fix Signed-off-by: Rina Fujino --- crates/core/plugin_sm/src/plugin.rs | 4 +++- .../cumulocity/software_management/dummy-plugin.sh | 9 ++++++++- .../cumulocity/software_management/sm-plugin.robot | 11 +++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/crates/core/plugin_sm/src/plugin.rs b/crates/core/plugin_sm/src/plugin.rs index 0843197ce50..818d2f33c83 100644 --- a/crates/core/plugin_sm/src/plugin.rs +++ b/crates/core/plugin_sm/src/plugin.rs @@ -20,6 +20,7 @@ use tedge_api::DEFAULT; use tedge_config::SudoCommandBuilder; use tokio::io::AsyncWriteExt; use tracing::error; +use tracing::info; #[async_trait] pub trait Plugin { @@ -134,7 +135,8 @@ pub trait Plugin { // Execute the updates if failed_updates.is_empty() { let outcome = self.update_list(&updates, command_log.as_deref_mut()).await; - if let Err(SoftwareError::UpdateListNotSupported(_)) = outcome { + if let Err(SoftwareError::UpdateListNotSupported(name)) = outcome { + info!("{}", SoftwareError::UpdateListNotSupported(name)); for update in updates.iter() { if let Err(error) = self .apply(update, command_log.as_deref_mut(), download_path) diff --git a/tests/RobotFramework/tests/cumulocity/software_management/dummy-plugin.sh b/tests/RobotFramework/tests/cumulocity/software_management/dummy-plugin.sh index 3c27fc77096..b04f22d0802 100755 --- a/tests/RobotFramework/tests/cumulocity/software_management/dummy-plugin.sh +++ b/tests/RobotFramework/tests/cumulocity/software_management/dummy-plugin.sh @@ -7,11 +7,18 @@ case "$1" in done exit 0 ;; + install) + exit 0 + ;; + remove) + exit 0 + ;; prepare) exit 0 ;; update-list) - exit 0 + # means update-list is unsupported by this plugin + exit 1 ;; finalize) exit 0 diff --git a/tests/RobotFramework/tests/cumulocity/software_management/sm-plugin.robot b/tests/RobotFramework/tests/cumulocity/software_management/sm-plugin.robot index 428dc1d6297..1ea0b2cc76b 100644 --- a/tests/RobotFramework/tests/cumulocity/software_management/sm-plugin.robot +++ b/tests/RobotFramework/tests/cumulocity/software_management/sm-plugin.robot @@ -3,6 +3,7 @@ Resource ../../../resources/common.resource Library ThinEdgeIO Library Cumulocity +Library Collections Test Setup Custom Setup Test Teardown Custom Teardown @@ -119,6 +120,16 @@ Filter packages list using both patterns ... {"name": "dummy2-1500", "version": "1.0.0", "softwareType": "dummy2"} Length Should Be ${software} 1504 +Software updates download software packages only once #3062 + Connect Mapper c8y + Device Should Exist ${DEVICE_SN} + ${file_url}= Cumulocity.Create Inventory Binary sm-plugin-test-file software1 contents=Testing a thing + ${OPERATION}= Install Software dummy-software,1.0.0::dummy1,${file_url} + ${OPERATION}= Operation Should Be SUCCESSFUL ${OPERATION} timeout=60 + ${op_id}= Get From Dictionary ${OPERATION} id + ${count}= Execute Command grep Downloading /var/log/tedge/agent/workflow-software_update-c8y-mapper-${op_id}.log -c + Should Be Equal As Numbers ${count} 1 + *** Keywords *** Custom Setup ${DEVICE_SN}= Setup skip_bootstrap=${True}