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

Test configuration management on main device #1875

Merged
merged 1 commit into from
Apr 25, 2023

Conversation

reubenmiller
Copy link
Contributor

@reubenmiller reubenmiller commented Mar 30, 2023

Proposed changes

Add Cumulocity configuration management integration tests (for the main device)

Add test cases to cover the following:

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Improvement (general improvements like code refactoring that doesn't explicitly fix a bug or add any new functionality)
  • Documentation Update (if none of the other choices apply)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Paste Link to the issue


Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA (in all commits with git commit -s)
  • I ran cargo fmt as mentioned in CODING_GUIDELINES
  • I used cargo clippy as mentioned in CODING_GUIDELINES
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

@reubenmiller reubenmiller added theme:configuration Theme: Configuration management theme:c8y Theme: Cumulocity related topics labels Mar 30, 2023
@reubenmiller reubenmiller self-assigned this Mar 30, 2023
@reubenmiller reubenmiller changed the title Test configuration tests Test configuration management on main device Mar 30, 2023
@didier-wenzek
Copy link
Contributor

Beware that the refactoring of configuration management has been merged. Hence, if we want to compare before/after behavior we will have to compare with the 0.10 release.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 30, 2023

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
183 0 7 183 100

Passed Tests

Name ⏱️ Duration Suite
Define Child device 1 ID 0.013 s C8Y Child Alarms Rpi
Normal case when the child device does not exist on c8y cloud 3.932 s C8Y Child Alarms Rpi
Normal case when the child device already exists 1.75 s C8Y Child Alarms Rpi
Reconciliation when the new alarm message arrives, restart the mapper 2.941 s C8Y Child Alarms Rpi
Reconciliation when the alarm that is cleared 6.002 s C8Y Child Alarms Rpi
Prerequisite Parent 79.686 s Child Conf Mgmt Plugin
Prerequisite Child 0.621 s Child Conf Mgmt Plugin
Child device bootstrapping 15.833 s Child Conf Mgmt Plugin
Snapshot from device 62.976 s Child Conf Mgmt Plugin
Child device config update 63.475 s Child Conf Mgmt Plugin
Configuration types should be detected on file change (without restarting service) 121.604 s Inotify Crate
Check lock file existence in default folder 2.852 s Lock File
Check PID number in lock file 3.425 s Lock File
Check PID number in lock file after restarting the services 3.008 s Lock File
Check starting same service twice 1.7069999999999999 s Lock File
Switch off lock file creation 2.293 s Lock File
Set configuration when file exists 54.885 s Configuration Operation
Set configuration when file does not exist 6.741 s Configuration Operation
Set configuration with broken url 6.272 s Configuration Operation
Get configuration 10.26 s Configuration Operation
Get non existent configuration file 6.477 s Configuration Operation
Get non existent configuration type 7.599 s Configuration Operation
Update configuration plugin config via cloud 25.95 s Configuration Operation
Modify configuration plugin config via local filesystem overwrite 6.493 s Configuration Operation
Update configuration plugin config via local filesystem copy 12.653 s Configuration Operation
Update configuration plugin config via local filesystem move (different directory) 6.632 s Configuration Operation
Successful firmware operation 90.365 s Firmware Operation
Install with empty firmware name 67.316 s Firmware Operation
Prerequisite Parent 21.689 s Firmware Operation Child Device
Prerequisite Child 10.652 s Firmware Operation Child Device
Child device firmware update 7.874 s Firmware Operation Child Device
Child device firmware update with cache 8.32 s Firmware Operation Child Device
Update Inventory data via inventory.json 6.89 s Inventory Update
Retrieve a JWT tokens 132.459 s Jwt Request
Main device registration 4.747 s Device Registration
Child device registration 5.901 s Device Registration
Supports restarting the device 134.776 s Restart Device
Update tedge version from previous using Cumulocity 98.925 s Tedge Self Update
Test if all c8y services are up 147.403 s Service Monitoring
Test if all c8y services are down 141.249 s Service Monitoring
Test if all c8y services are using configured service type 115.682 s Service Monitoring
Test if all c8y services using default service type when service type configured as empty 100.952 s Service Monitoring
Check health status of tedge-mapper-c8y service on broker stop start 41.956 s Service Monitoring
Check health status of tedge-mapper-c8y service on broker restart 41.103 s Service Monitoring
Check health status of child device service 31.872 s Service Monitoring
Successful shell command with output 7.651 s Shell Operation
Check Successful shell command with literal double quotes output 2.356 s Shell Operation
Execute multiline shell command 3.044 s Shell Operation
Failed shell command 3.543 s Shell Operation
Software list should be populated during startup 58.863 s Software
Install software via Cumulocity 70.301 s Software
Software list should only show currently installed software and not candidates 49.029 s Software
Child devices support sending simple measurements 6.26 s Child Device Telemetry
Child devices support sending custom measurements 6.218 s Child Device Telemetry
Child devices support sending custom events 4.026 s Child Device Telemetry
Child devices support sending custom events overriding the type 6.782 s Child Device Telemetry
Child devices support sending custom alarms #1699 8.017 s Child Device Telemetry
Child devices support sending inventory data via c8y topic 6.354 s Child Device Telemetry
Main device support sending inventory data via c8y topic 5.88 s Child Device Telemetry
Child device supports sending custom child device measurements directly to c8y 4.111 s Child Device Telemetry
Main device supports sending custom child device measurements directly to c8y 3.57 s Child Device Telemetry
Check retained alarms 74.397 s Raise Alarms
Validate updated data path used by tedge-agent 0.604 s Data Path Config
Validate updated data path used by c8y-firmware-plugin 12.988 s Data Path Config
Stop tedge-agent service 0.862 s Log Path Config
Customize the log path 0.235 s Log Path Config
Initialize tedge-agent 0.222 s Log Path Config
Check created folders 0.215 s Log Path Config
Remove created custom folders 0.224 s Log Path Config
Install thin-edge via apt 53.602 s Install Apt
Install latest via script (from current branch) 35.687 s Install Tedge
Install specific version via script (from current branch) 27.254 s Install Tedge
Install latest tedge via script (from main branch) 23.732 s Install Tedge
Install then uninstall latest tedge via script (from main branch) 56.302 s Install Tedge
Support starting and stopping services 62.035 s Service-Control
Supports a reconnect 80.424 s Test-Commands
Supports disconnect then connect 54.965 s Test-Commands
Update unknown setting 48.259 s Test-Commands
Update known setting 38.445 s Test-Commands
Stop c8y-configuration-plugin 60.355 s Health C8Y-Configuration-Plugin
Update the service file 0.131 s Health C8Y-Configuration-Plugin
Reload systemd files 0.456 s Health C8Y-Configuration-Plugin
Start c8y-configuration-plugin 0.241 s Health C8Y-Configuration-Plugin
Start watchdog service 10.282 s Health C8Y-Configuration-Plugin
Check PID of c8y-configuration-plugin 0.355 s Health C8Y-Configuration-Plugin
Kill the PID 0.675 s Health C8Y-Configuration-Plugin
Recheck PID of c8y-configuration-plugin 6.689 s Health C8Y-Configuration-Plugin
Compare PID change 0.001 s Health C8Y-Configuration-Plugin
Stop watchdog service 0.283 s Health C8Y-Configuration-Plugin
Remove entry from service file 0.281 s Health C8Y-Configuration-Plugin
Stop c8y-log-plugin 60.228 s Health C8Y-Log-Plugin
Update the service file 0.217 s Health C8Y-Log-Plugin
Reload systemd files 0.522 s Health C8Y-Log-Plugin
Start c8y-log-plugin 0.298 s Health C8Y-Log-Plugin
Start watchdog service 10.206 s Health C8Y-Log-Plugin
Check PID of c8y-log-plugin 0.357 s Health C8Y-Log-Plugin
Kill the PID 0.748 s Health C8Y-Log-Plugin
Recheck PID of c8y-log-plugin 6.861 s Health C8Y-Log-Plugin
Compare PID change 0.038 s Health C8Y-Log-Plugin
Stop watchdog service 0.386 s Health C8Y-Log-Plugin
Remove entry from service file 0.149 s Health C8Y-Log-Plugin
Stop tedge-mapper 0.338 s Health Tedge Mapper C8Y
Update the service file 0.285 s Health Tedge Mapper C8Y
Reload systemd files 1.078 s Health Tedge Mapper C8Y
Start tedge-mapper 0.212 s Health Tedge Mapper C8Y
Start watchdog service 10.302 s Health Tedge Mapper C8Y
Check PID of tedge-mapper 0.11 s Health Tedge Mapper C8Y
Kill the PID 0.252 s Health Tedge Mapper C8Y
Recheck PID of tedge-mapper 6.504 s Health Tedge Mapper C8Y
Compare PID change 0.002 s Health Tedge Mapper C8Y
Stop watchdog service 0.109 s Health Tedge Mapper C8Y
Remove entry from service file 0.087 s Health Tedge Mapper C8Y
Stop tedge-agent 0.425 s Health Tedge-Agent
Update the service file 0.344 s Health Tedge-Agent
Reload systemd files 0.796 s Health Tedge-Agent
Start tedge-agent 0.285 s Health Tedge-Agent
Start watchdog service 10.515 s Health Tedge-Agent
Check PID of tedge-mapper 0.143 s Health Tedge-Agent
Kill the PID 0.263 s Health Tedge-Agent
Recheck PID of tedge-agent 6.5600000000000005 s Health Tedge-Agent
Compare PID change 0.016 s Health Tedge-Agent
Stop watchdog service 0.207 s Health Tedge-Agent
Remove entry from service file 0.175 s Health Tedge-Agent
Stop tedge-mapper-az 0.147 s Health Tedge-Mapper-Az
Update the service file 0.166 s Health Tedge-Mapper-Az
Reload systemd files 0.431 s Health Tedge-Mapper-Az
Start tedge-mapper-az 0.167 s Health Tedge-Mapper-Az
Start watchdog service 10.193 s Health Tedge-Mapper-Az
Check PID of tedge-mapper-az 0.152 s Health Tedge-Mapper-Az
Kill the PID 0.368 s Health Tedge-Mapper-Az
Recheck PID of tedge-agent 6.537 s Health Tedge-Mapper-Az
Compare PID change 0.001 s Health Tedge-Mapper-Az
Stop watchdog service 0.169 s Health Tedge-Mapper-Az
Remove entry from service file 0.166 s Health Tedge-Mapper-Az
Stop tedge-mapper-collectd 0.233 s Health Tedge-Mapper-Collectd
Update the service file 0.427 s Health Tedge-Mapper-Collectd
Reload systemd files 1.267 s Health Tedge-Mapper-Collectd
Start tedge-mapper-collectd 0.253 s Health Tedge-Mapper-Collectd
Start watchdog service 10.362 s Health Tedge-Mapper-Collectd
Check PID of tedge-mapper-collectd 0.252 s Health Tedge-Mapper-Collectd
Kill the PID 0.482 s Health Tedge-Mapper-Collectd
Recheck PID of tedge-mapper-collectd 7.066 s Health Tedge-Mapper-Collectd
Compare PID change 0.036 s Health Tedge-Mapper-Collectd
Stop watchdog service 0.434 s Health Tedge-Mapper-Collectd
Remove entry from service file 0.293 s Health Tedge-Mapper-Collectd
tedge-collectd-mapper health status 5.893 s Health Tedge-Mapper-Collectd
c8y-log-plugin health status 5.72 s MQTT health endpoints
c8y-configuration-plugin health status 5.904 s MQTT health endpoints
Publish on a local insecure broker 0.311 s Basic Pub Sub
Publish on a local secure broker 3.094 s Basic Pub Sub
Publish on a local secure broker with client authentication 3.734 s Basic Pub Sub
Wrong package name 0.165 s Improve Tedge Apt Plugin Error Messages
Wrong version 0.144 s Improve Tedge Apt Plugin Error Messages
Wrong type 0.431 s Improve Tedge Apt Plugin Error Messages
tedge_connect_test_positive 0.211 s Tedge Connect Test
tedge_connect_test_negative 0.812 s Tedge Connect Test
tedge_connect_test_sm_services 7.5 s Tedge Connect Test
tedge_disconnect_test_sm_services 0.495 s Tedge Connect Test
Install thin-edge.io 23.316 s Call Tedge
call tedge -V 0.123 s Call Tedge
call tedge -h 0.165 s Call Tedge
call tedge -h -V 0.121 s Call Tedge
call tedge help 0.116 s Call Tedge
tedge config list 0.112 s Call Tedge Config List
tedge config list --all 0.104 s Call Tedge Config List
set/unset device.type 0.724 s Call Tedge Config List
set/unset device.key.path 0.781 s Call Tedge Config List
set/unset device.cert.path 0.742 s Call Tedge Config List
set/unset c8y.root.cert.path 0.861 s Call Tedge Config List
set/unset c8y.smartrest.templates 0.808 s Call Tedge Config List
set/unset az.root.cert.path 0.853 s Call Tedge Config List
set/unset az.mapper.timestamp 0.667 s Call Tedge Config List
set/unset mqtt.bind_address 0.699 s Call Tedge Config List
set/unset mqtt.port 0.865 s Call Tedge Config List
set/unset tmp.path 1.017 s Call Tedge Config List
set/unset logs.path 0.426 s Call Tedge Config List
set/unset run.path 0.482 s Call Tedge Config List
Get Put Delete 4.576 s Http File Transfer Api
Set keys should return value on stdout 0.159 s Tedge Config Get
Unset keys should not return anything on stdout and warnings on stderr 0.256 s Tedge Config Get
Invalid keys should not return anything on stdout and warnings on stderr 0.352 s Tedge Config Get
Set configuration via environment variables 1.6400000000000001 s Tedge Config Get
Set unknown configuration via environment variables 0.192 s Tedge Config Get

@reubenmiller reubenmiller temporarily deployed to Test Pull Request March 30, 2023 21:26 — with GitHub Actions Inactive
Copy link
Contributor

@albinsuresh albinsuresh left a comment

Choose a reason for hiding this comment

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

The test looks fine. A few more tests cases that could be added for improved coverage (not necessarily to be added in this PR itself):

  1. Updates to the c8y-configuration-plugin.toml are automatically picked up and the supported config list is updated
  2. Set non-existent config file with the desired file permissions
  3. Updating c8y-configuration-plugin.toml from the cloud updates the supported config list automatically

I can think of some more negative test cases like setting broken/invalid c8y-config-plugin.toml, setting non-existent config-type etc. But, not sure if they're all relevant here at a system test level.

@reubenmiller reubenmiller temporarily deployed to Test Pull Request March 31, 2023 07:44 — with GitHub Actions Inactive
@reubenmiller
Copy link
Contributor Author

The test looks fine. A few more tests cases that could be added for improved coverage (not necessarily to be added in this PR itself):

  1. Updates to the c8y-configuration-plugin.toml are automatically picked up and the supported config list is updated
  2. Set non-existent config file with the desired file permissions
  3. Updating c8y-configuration-plugin.toml from the cloud updates the supported config list automatically

I can think of some more negative test cases like setting broken/invalid c8y-config-plugin.toml, setting non-existent config-type etc. But, not sure if they're all relevant here at a system test level.

I just re-read the list of extra test cases and I think it would be definitely worthwhile extending this PR to cover them, thanks for the suggestions.

@jmshark
Copy link
Contributor

jmshark commented Apr 18, 2023

For "sed", I can see the notify stream has events for the tmp file creation as well as renaming the tmp file to the c8y-configuration-plugin.toml but the notify stream match (crates/common/tedge_utils/src/notify.rs:73) drops the modification events which renames the tmp file to c8y-configuration-plugin.toml because we only match on modification events which have kind "data" but they're multiple event types created here which are Modify(Name(From)), Modify(Name(To)) and Modify(Name(Both)) the types can be seen at https://docs.rs/notify/latest/notify/event/enum.ModifyKind.html and these events are dropped so I'm not surprised this fails.

@reubenmiller On the other hand when manually testing the "mv" I can see appropriate logs all the way from the notify stream to the ConfigManagerMessageBox sending a message with an updated config but the Robotest fails and I'm not why.

@rina23q rina23q mentioned this pull request Apr 20, 2023
11 tasks
@reubenmiller reubenmiller temporarily deployed to Test Pull Request April 20, 2023 13:49 — with GitHub Actions Inactive
@reubenmiller
Copy link
Contributor Author

reubenmiller commented Apr 20, 2023

@reubenmiller On the other hand when manually testing the "mv" I can see appropriate logs all the way from the notify stream to the ConfigManagerMessageBox sending a message with an updated config but the Robotest fails and I'm not why.

@jmshark There is actually a different here. I posted a comment describing when a move will work and when it won't. #1896 (comment)

@reubenmiller reubenmiller temporarily deployed to Test Pull Request April 20, 2023 14:15 — with GitHub Actions Inactive
@reubenmiller reubenmiller marked this pull request as ready for review April 24, 2023 06:41
@reubenmiller reubenmiller temporarily deployed to Test Pull Request April 24, 2023 16:13 — with GitHub Actions Inactive
@reubenmiller reubenmiller mentioned this pull request Apr 25, 2023
11 tasks
Signed-off-by: Reuben Miller <reuben.d.miller@gmail.com>
@reubenmiller reubenmiller temporarily deployed to Test Pull Request April 25, 2023 09:39 — with GitHub Actions Inactive
@reubenmiller reubenmiller merged commit a817862 into thin-edge:main Apr 25, 2023
15 checks passed
@reubenmiller reubenmiller deleted the test-configuration-tests branch April 25, 2023 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme:c8y Theme: Cumulocity related topics theme:configuration Theme: Configuration management
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants