Skip to content

Commit d2c2cff

Browse files
committed
fix: Capability message for firmware_update workflow
1 parent 65356c4 commit d2c2cff

4 files changed

Lines changed: 57 additions & 19 deletions

File tree

crates/common/tedge_config/src/tedge_config_cli/tedge_config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ define_tedge_config! {
511511
config_update: bool,
512512

513513
/// Enable firmware_update feature
514-
#[tedge_config(example = "true", default(value = false))]
514+
#[tedge_config(example = "true", default(value = true))]
515515
firmware_update: bool,
516516

517517
/// Enable device_profile feature

crates/core/tedge_api/src/workflow/mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,10 @@ impl OperationWorkflow {
308308
) -> Option<MqttMessage> {
309309
match self.operation {
310310
// Custom operations (and restart) have a generic empty capability message
311-
OperationType::Custom(_) | OperationType::Restart | OperationType::DeviceProfile => {
311+
OperationType::Custom(_)
312+
| OperationType::Restart
313+
| OperationType::DeviceProfile
314+
| OperationType::FirmwareUpdate => {
312315
let meta_topic = schema.capability_topic_for(target, self.operation.clone());
313316
let payload = "{}".to_string();
314317
Some(
@@ -319,7 +322,12 @@ impl OperationWorkflow {
319322
}
320323
// Builtin operations dynamically publish their capability message,
321324
// notably to include a list of supported types.
322-
_ => None,
325+
OperationType::SoftwareList
326+
| OperationType::SoftwareUpdate
327+
| OperationType::LogUpload
328+
| OperationType::ConfigSnapshot
329+
| OperationType::ConfigUpdate
330+
| OperationType::Health => None,
323331
}
324332
}
325333

tests/RobotFramework/tests/cumulocity/firmware/firmware_operation.robot

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,23 @@ Library ThinEdgeIO
66
Test Setup Custom Setup
77
Test Teardown Get Logs
88

9-
Test Tags theme:c8y theme:firmware theme:plugins
9+
Test Tags theme:c8y theme:firmware
1010

1111

1212
*** Test Cases ***
13-
Successful firmware operation
14-
${operation}= Cumulocity.Install Firmware ubuntu 1.0.2 https://dummy.url/firmware.zip
15-
${operation}= Cumulocity.Operation Should Be SUCCESSFUL ${operation} timeout=120
16-
Device Should Have Firmware ubuntu 1.0.2 https://dummy.url/firmware.zip
17-
18-
Install with empty firmware name
19-
${operation}= Cumulocity.Install Firmware ${EMPTY} 1.0.2 https://dummy.url/firmware.zip
20-
Operation Should Be FAILED
21-
... ${operation}
22-
... failure_reason=.*Invalid firmware name. Firmware name cannot be empty
23-
... timeout=120
13+
Send firmware update operation from Cumulocity IoT
14+
Should Have MQTT Messages te/device/main///cmd/firmware_update message_pattern=^\{\}$
15+
Cumulocity.Should Contain Supported Operations c8y_Firmware
2416

17+
${operation}= Cumulocity.Install Firmware tedge-core 1.0.0 https://abc.com/some/firmware/url
18+
${operation}= Cumulocity.Operation Should Be SUCCESSFUL ${operation}
19+
Cumulocity.Device Should Have Firmware tedge-core 1.0.0 https://abc.com/some/firmware/url
2520

2621
*** Keywords ***
2722
Custom Setup
2823
${DEVICE_SN}= Setup
2924
Set Suite Variable $DEVICE_SN
3025
Device Should Exist ${DEVICE_SN}
31-
ThinEdgeIO.Transfer To Device ${CURDIR}/firmware_handler.* /etc/tedge/operations/
32-
ThinEdgeIO.Transfer To Device ${CURDIR}/c8y_Firmware* /etc/tedge/operations/c8y/
33-
ThinEdgeIO.Restart Service tedge-agent
34-
ThinEdgeIO.Disconnect Then Connect Mapper c8y
26+
27+
ThinEdgeIO.Transfer To Device ${CURDIR}/firmware_update.toml /etc/tedge/operations/
28+
Restart Service tedge-agent
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
operation = "firmware_update"
2+
3+
[init]
4+
action = "proceed"
5+
on_success = "scheduled"
6+
7+
[scheduled]
8+
script = "/usr/bin/sleep 1"
9+
on_success = "executing"
10+
11+
[executing]
12+
script = "/usr/bin/sleep 1"
13+
on_success = "restart"
14+
15+
[restart]
16+
operation = "restart"
17+
on_exec = "waiting_for_restart"
18+
19+
[waiting_for_restart]
20+
action = "await-operation-completion"
21+
on_success = "verify"
22+
on_error = { status = "failed", reason = "fail to restart"}
23+
24+
[verify]
25+
script = "/usr/bin/sleep 1"
26+
on_success = "commit"
27+
28+
[commit]
29+
script = "/usr/bin/sleep 1"
30+
on_success = "successful"
31+
32+
[successful]
33+
action = "cleanup"
34+
35+
[failed]
36+
action = "cleanup"

0 commit comments

Comments
 (0)