Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: device profile firmware interaction #113

Merged
merged 3 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions images/child-device-container/config/tedge-log-plugin.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[[files]]
type = "device_profile"
path = "/var/log/tedge/agent/workflow-device_profile-*"

[[files]]
type = "software-management"
path = "/var/log/tedge/agent/workflow-software*"
Expand Down
4 changes: 4 additions & 0 deletions images/child-device-systemd/config/tedge-log-plugin.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[[files]]
type = "device_profile"
path = "/var/log/tedge/agent/workflow-device_profile-*"

[[files]]
type = "software-management"
path = "/var/log/tedge/agent/workflow-software*"
Expand Down
16 changes: 16 additions & 0 deletions images/common/config/tedge-log-plugin.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
[[files]]
type = "device_profile"
path = "/var/log/tedge/agent/workflow-device_profile-*"

[[files]]
type = "software-management"
path = "/var/log/tedge/agent/workflow-software*"

[[files]]
type = "firmware_update"
path = "/var/log/tedge/agent/workflow-firmware_update-*"

[[files]]
type = "restart"
path = "/var/log/tedge/agent/workflow-restart-*"

[[files]]
type = "all-workflows"
path = "/var/log/tedge/agent/workflow-*"

[[files]]
type = "shell"
path = "/var/log/tedge/agent/c8y_Command-*"
Expand Down
5 changes: 5 additions & 0 deletions images/common/utils/workflows/firmware_update.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ on_error = { status = "failed", reason = "fail to restart"}

[commit]
script = "sleep 1"
on_success = "publish"
on_error = "failed"

[publish]
script = "tedge mqtt pub --retain --qos 1 ${.topic.root_prefix}/${.topic.target}/twin/firmware '{\"name\":\"${.payload.name}\",\"version\":\"${.payload.version}\",\"url\":\"${.payload.url}\"}'"
on_success = "successful"
on_error = "failed"

Expand Down
40 changes: 40 additions & 0 deletions tests/debian-systemd/children-container/operations.robot
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,43 @@ Install software package
${operation}= Cumulocity.Install Software {"name": "jq", "version": "latest", "softwareType": "apk"}
Operation Should Be SUCCESSFUL ${operation} timeout=90
Cumulocity.Device Should Have Installed Software jq

Install device profile
${config_url}= Create Inventory Binary
... tedge-configuration-plugin
... tedge-configuration-plugin
... file=${CURDIR}/../tedge-configuration-plugin.toml

${PROFILE_NAME}= Set Variable Test Profile
${PROFILE_PAYLOAD}= Catenate SEPARATOR=\n {
... "firmware": {
... "name":"iot-linux",
... "version":"3.0.0",
... "url":"https://abc.com/some/firmware/url"
... },
... "software":[
... {
... "name":"jq",
... "action":"install",
... "version":"latest",
... "url":""
... }
... ],
... "configuration":[
... {
... "name":"tedge-configuration-plugin",
... "type":"tedge-configuration-plugin",
... "url":"${config_url}"
... }
... ]
... }

${profile}= Cumulocity.Create Device Profile ${PROFILE_NAME} ${PROFILE_PAYLOAD}
${operation}= Cumulocity.Install Device Profile ${profile["id"]}
${operation}= Cumulocity.Operation Should Be SUCCESSFUL ${operation}
Cumulocity.Should Have Device Profile Installed ${profile["id"]}

# Check meta information
Cumulocity.Managed Object Should Have Fragment Values c8y_Firmware.name\=iot-linux c8y_Firmware.version\=3.0.0
Cumulocity.Device Should Have Installed Software {"name":"jq"}
Cumulocity.Should Support Configurations container.env includes=${True}
40 changes: 40 additions & 0 deletions tests/debian-systemd/children-systemd/operations.robot
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,43 @@ Install software package

# lib* packages should be excluded by default due to the custom tedge.toml config
Cumulocity.Device Should Not Have Installed Software libc-bin

Install device profile
${config_url}= Create Inventory Binary
... tedge-configuration-plugin
... tedge-configuration-plugin
... file=${CURDIR}/../tedge-configuration-plugin.toml

${PROFILE_NAME}= Set Variable Test Profile
${PROFILE_PAYLOAD}= Catenate SEPARATOR=\n {
... "firmware": {
... "name":"iot-linux",
... "version":"3.0.0",
... "url":"https://abc.com/some/firmware/url"
... },
... "software":[
... {
... "name":"jq",
... "action":"install",
... "version":"latest",
... "url":""
... }
... ],
... "configuration":[
... {
... "name":"tedge-configuration-plugin",
... "type":"tedge-configuration-plugin",
... "url":"${config_url}"
... }
... ]
... }

${profile}= Cumulocity.Create Device Profile ${PROFILE_NAME} ${PROFILE_PAYLOAD}
${operation}= Cumulocity.Install Device Profile ${profile["id"]}
${operation}= Cumulocity.Operation Should Be SUCCESSFUL ${operation}
Cumulocity.Should Have Device Profile Installed ${profile["id"]}

# Check meta information
Cumulocity.Managed Object Should Have Fragment Values c8y_Firmware.name\=iot-linux c8y_Firmware.version\=3.0.0
Cumulocity.Device Should Have Installed Software {"name":"jq"}
Cumulocity.Should Support Configurations container.env includes=${True}
40 changes: 40 additions & 0 deletions tests/debian-systemd/main/operations.robot
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,46 @@ Get Logfile Request
apt-terminal-log
dpkg

Install device profile
${config_url}= Create Inventory Binary
... tedge-configuration-plugin
... tedge-configuration-plugin
... file=${CURDIR}/../tedge-configuration-plugin.toml

${PROFILE_NAME}= Set Variable Test Profile
${PROFILE_PAYLOAD}= Catenate SEPARATOR=\n {
... "firmware": {
... "name":"iot-linux",
... "version":"3.0.0",
... "url":"https://abc.com/some/firmware/url"
... },
... "software":[
... {
... "name":"jq",
... "action":"install",
... "version":"latest",
... "url":""
... }
... ],
... "configuration":[
... {
... "name":"tedge-configuration-plugin",
... "type":"tedge-configuration-plugin",
... "url":"${config_url}"
... }
... ]
... }

${profile}= Cumulocity.Create Device Profile ${PROFILE_NAME} ${PROFILE_PAYLOAD}
${operation}= Cumulocity.Install Device Profile ${profile["id"]}
${operation}= Cumulocity.Operation Should Be SUCCESSFUL ${operation}
Cumulocity.Should Have Device Profile Installed ${profile["id"]}

# Check meta information
Cumulocity.Managed Object Should Have Fragment Values c8y_Firmware.name\=iot-linux c8y_Firmware.version\=3.0.0
Cumulocity.Device Should Have Installed Software {"name":"jq"}
Cumulocity.Should Support Configurations container.env includes=${True}

*** Keywords ***

Get Logfile Request
Expand Down
34 changes: 34 additions & 0 deletions tests/debian-systemd/tedge-configuration-plugin.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[[files]]
path = "/etc/tedge/tedge.toml"
type = "tedge.toml"
user = "tedge"
group = "tedge"
mode = 0o444

[[files]]
path = "/etc/tedge/system.toml"
type = "system.toml"
user = "tedge"
group = "tedge"
mode = 0o444

[[files]]
path = "/etc/modem.json"
type = "modem"
user = "tedge"
group = "tedge"
mode = 0o444

[[files]]
path = '/etc/tedge/plugins/tedge-log-plugin.toml'
type = 'tedge-log-plugin'
user = 'tedge'
group = 'tedge'
mode = 0o644

[[files]]
path = '/etc/container.env'
type = 'container.env'
user = 'root'
group = 'root'
mode = 0o644
2 changes: 1 addition & 1 deletion tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
robotframework~=6.0.0
robotframework-c8y @ git+https://github.com/reubenmiller/robotframework-c8y.git@0.31.3
robotframework-c8y @ git+https://github.com/reubenmiller/robotframework-c8y.git@0.37.2
robotframework-devicelibrary[docker] @ git+https://github.com/reubenmiller/robotframework-devicelibrary.git@1.13.0