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(software): use local http server with rate limiting instead of external resource #2085

Conversation

reubenmiller
Copy link
Contributor

@reubenmiller reubenmiller commented Jul 20, 2023

Proposed changes

Downloading a test file from external urls is very unreliable and it often caused problems whilst running on the GitHub runner. A local http server offers more control over the download process.

The solution adds a nginx service to the integration test container which can be started on-demand. The server also creates a dummy test file which can be served via a rate limited endpoint.

Some of the advantages are:

  • http server is available everywhere as it is only on localhost (not subject to a countries firewall rules, e.g. China)
  • more control over rate limiting which allows using a smaller test file (e.g. 10MB vs 1GB)

Examples of a failed CI runs due to a failing test "tedge-agent should terminate on SIGINT while downloading file":

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 ci/cd Repository management and pipeline topics theme:testing labels Jul 20, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jul 20, 2023

Robot Results

✅ Passed ❌ Failed ⏭️ Skipped Total Pass %
239 0 5 239 100

Passed Tests

Name ⏱️ Duration Suite
Define Child device 1 ID 0.018 s C8Y Child Alarms Rpi
Normal case when the child device does not exist on c8y cloud 2.382 s C8Y Child Alarms Rpi
Normal case when the child device already exists 0.787 s C8Y Child Alarms Rpi
Reconciliation when the new alarm message arrives, restart the mapper 1.081 s C8Y Child Alarms Rpi
Reconciliation when the alarm that is cleared 65.704 s C8Y Child Alarms Rpi
Prerequisite Parent 13.838 s Child Conf Mgmt Plugin
Prerequisite Child 0.332 s Child Conf Mgmt Plugin
Child device bootstrapping 14.128 s Child Conf Mgmt Plugin
Snapshot from device 62.407 s Child Conf Mgmt Plugin
Child device config update 61.851 s Child Conf Mgmt Plugin
Configuration types should be detected on file change (without restarting service) 49.291 s Inotify Crate
Check lock file existence in default folder 1.517 s Lock File
Check PID number in lock file 1.309 s Lock File
Check PID number in lock file after restarting the services 1.975 s Lock File
Check starting same service twice 1.407 s Lock File
Switch off lock file creation 2.757 s Lock File
Set configuration when file exists 6.614 s Configuration Operation
Set configuration when file does not exist 6.015 s Configuration Operation
Set configuration with broken url 5.734 s Configuration Operation
Get configuration 5.493 s Configuration Operation
Get non existent configuration file 5.067 s Configuration Operation
Get non existent configuration type 4.6129999999999995 s Configuration Operation
Update configuration plugin config via cloud 4.945 s Configuration Operation
Modify configuration plugin config via local filesystem modify inplace 4.76 s Configuration Operation
Modify configuration plugin config via local filesystem overwrite 6.138 s Configuration Operation
Update configuration plugin config via local filesystem copy 5.621 s Configuration Operation
Update configuration plugin config via local filesystem move (different directory) 5.339 s Configuration Operation
Update configuration plugin config via local filesystem move (same directory) 4.113 s Configuration Operation
Update the custom operation dynamically 52.428 s Dynamically Reload Operation
Custom operation successful 122.746 s Custom Operation
Custom operation fails 69.334 s Custom Operation
Successful firmware operation 63.479 s Firmware Operation
Install with empty firmware name 40.103 s Firmware Operation
Prerequisite Parent 17.101 s Firmware Operation Child Device
Prerequisite Child 8.211 s Firmware Operation Child Device
Child device firmware update 6.185 s Firmware Operation Child Device
Child device firmware update with cache 6.21 s Firmware Operation Child Device
Firmware plugin supports restart via service manager #1932 5.459 s Firmware Operation Child Device Retry
Update Inventory data via inventory.json 1.557 s Inventory Update
Inventory includes the agent fragment with version information 1.279 s Inventory Update
Retrieve a JWT tokens 35.095 s Jwt Request
Mapper recovers and processes output of ongoing software update request 15.775 s Recover And Publish Software Update Message
Check running collectd 1.455 s Monitor Device Collectd
Is collectd publishing MQTT messages? 3.254 s Monitor Device Collectd
Check thin-edge monitoring 3.949 s Monitor Device Collectd
Check grouping of measurements 9.348 s Monitor Device Collectd
Main device registration 2.626 s Device Registration
Child device registration 2.496 s Device Registration
Supports restarting the device 52.903 s Restart Device
Update tedge version from previous using Cumulocity 73.192 s Tedge Self Update
Test if all c8y services are up 100.599 s Service Monitoring
Test if all c8y services are down 112.108 s Service Monitoring
Test if all c8y services are using configured service type 164.473 s Service Monitoring
Test if all c8y services using default service type when service type configured as empty 150.106 s Service Monitoring
Check health status of tedge-mapper-c8y service on broker stop start 21.888 s Service Monitoring
Check health status of tedge-mapper-c8y service on broker restart 83.972 s Service Monitoring
Check health status of child device service 18.998 s Service Monitoring
Successful shell command with output 4.153 s Shell Operation
Check Successful shell command with literal double quotes output 3.839 s Shell Operation
Execute multiline shell command 3.476 s Shell Operation
Failed shell command 3.444 s Shell Operation
Software list should be populated during startup 40.167 s Software
Install software via Cumulocity 42.668 s Software
tedge-agent should terminate on SIGINT while downloading file 50.058 s Software
Software list should only show currently installed software and not candidates 35.596 s Software
Create and publish the tedge agent supported operations on mapper restart 37.32 s Mapper-Publishing-Agent-Supported-Ops
Agent gets the software list request once it comes up 28.547 s Mapper-Publishing-Agent-Supported-Ops
Child devices support sending simple measurements 1.677 s Child Device Telemetry
Child devices support sending custom measurements 1.246 s Child Device Telemetry
Child devices support sending custom events 1.21 s Child Device Telemetry
Child devices support sending custom events overriding the type 1.11 s Child Device Telemetry
Child devices support sending custom alarms #1699 3.3609999999999998 s Child Device Telemetry
Child devices support sending inventory data via c8y topic 3.191 s Child Device Telemetry
Child device supports sending custom child device measurements directly to c8y 1.538 s Child Device Telemetry
Check retained alarms 159.179 s Raise Alarms
Thin-edge devices support sending simple measurements 1.491 s Thin-Edge Device Telemetry
Thin-edge devices support sending simple measurements with custom type 1.15 s Thin-Edge Device Telemetry
Thin-edge devices support sending custom measurements 1.432 s Thin-Edge Device Telemetry
Thin-edge devices support sending custom events 1.283 s Thin-Edge Device Telemetry
Thin-edge devices support sending custom events overriding the type 1.185 s Thin-Edge Device Telemetry
Thin-edge devices support sending custom alarms #1699 1.094 s Thin-Edge Device Telemetry
Thin-edge device supports sending custom Thin-edge device measurements directly to c8y 1.53 s Thin-Edge Device Telemetry
Thin-edge device support sending inventory data via c8y topic 1.343 s Thin-Edge Device Telemetry
thin-edge components support a custom config-dir location via flags 26.848 s Config Dir
Validate updated data path used by tedge-agent 0.354 s Data Path Config
Validate updated data path used by c8y-firmware-plugin 10.859 s Data Path Config
Validate updated data path used by tedge-agent 0.465 s Log Path Config
Check existence of init directories 0.783 s Tedge Init
Tedge init and check creation of folders 0.809 s Tedge Init
Check ownership of the folders 0.742 s Tedge Init
Change user/group and check the change 0.814 s Tedge Init
Tedge init and check if default values are restored 0.814 s Tedge Init
Install thin-edge via apt 54.276 s Install Apt
Install latest via script (from current branch) 31.523 s Install Tedge
Install specific version via script (from current branch) 25.719 s Install Tedge
Install latest tedge via script (from main branch) 23.377 s Install Tedge
Install then uninstall latest tedge via script (from main branch) 68.991 s Install Tedge
Support starting and stopping services 40.31 s Service-Control
Supports a reconnect 53.954 s Test-Commands
Supports disconnect then connect 38.091 s Test-Commands
Update unknown setting 38.043 s Test-Commands
Update known setting 35.727 s Test-Commands
It checks MQTT messages using a pattern 66.617 s Test-Mqtt
Stop c8y-configuration-plugin 0.121 s Health C8Y-Configuration-Plugin
Update the service file 0.116 s Health C8Y-Configuration-Plugin
Reload systemd files 0.325 s Health C8Y-Configuration-Plugin
Start c8y-configuration-plugin 0.141 s Health C8Y-Configuration-Plugin
Start watchdog service 10.174 s Health C8Y-Configuration-Plugin
Check PID of c8y-configuration-plugin 0.076 s Health C8Y-Configuration-Plugin
Kill the PID 0.162 s Health C8Y-Configuration-Plugin
Recheck PID of c8y-configuration-plugin 6.364 s Health C8Y-Configuration-Plugin
Compare PID change 0.001 s Health C8Y-Configuration-Plugin
Stop watchdog service 0.118 s Health C8Y-Configuration-Plugin
Remove entry from service file 0.096 s Health C8Y-Configuration-Plugin
Stop c8y-log-plugin 0.152 s Health C8Y-Log-Plugin
Update the service file 0.102 s Health C8Y-Log-Plugin
Reload systemd files 0.437 s Health C8Y-Log-Plugin
Start c8y-log-plugin 0.1 s Health C8Y-Log-Plugin
Start watchdog service 10.26 s Health C8Y-Log-Plugin
Check PID of c8y-log-plugin 0.086 s Health C8Y-Log-Plugin
Kill the PID 0.208 s Health C8Y-Log-Plugin
Recheck PID of c8y-log-plugin 6.424 s Health C8Y-Log-Plugin
Compare PID change 0.001 s Health C8Y-Log-Plugin
Stop watchdog service 0.129 s Health C8Y-Log-Plugin
Remove entry from service file 0.135 s Health C8Y-Log-Plugin
Stop tedge-mapper 0.126 s Health Tedge Mapper C8Y
Update the service file 0.114 s Health Tedge Mapper C8Y
Reload systemd files 0.287 s Health Tedge Mapper C8Y
Start tedge-mapper 0.13 s Health Tedge Mapper C8Y
Start watchdog service 10.139 s Health Tedge Mapper C8Y
Check PID of tedge-mapper 0.179 s Health Tedge Mapper C8Y
Kill the PID 0.371 s Health Tedge Mapper C8Y
Recheck PID of tedge-mapper 6.787 s Health Tedge Mapper C8Y
Compare PID change 0.002 s Health Tedge Mapper C8Y
Stop watchdog service 0.335 s Health Tedge Mapper C8Y
Remove entry from service file 0.195 s Health Tedge Mapper C8Y
Stop tedge-agent 0.128 s Health Tedge-Agent
Update the service file 0.12 s Health Tedge-Agent
Reload systemd files 0.539 s Health Tedge-Agent
Start tedge-agent 0.178 s Health Tedge-Agent
Start watchdog service 10.349 s Health Tedge-Agent
Check PID of tedge-mapper 0.234 s Health Tedge-Agent
Kill the PID 0.269 s Health Tedge-Agent
Recheck PID of tedge-agent 6.638 s Health Tedge-Agent
Compare PID change 0.001 s Health Tedge-Agent
Stop watchdog service 0.116 s Health Tedge-Agent
Remove entry from service file 0.203 s Health Tedge-Agent
Stop tedge-mapper-az 0.217 s Health Tedge-Mapper-Az
Update the service file 0.114 s Health Tedge-Mapper-Az
Reload systemd files 0.687 s Health Tedge-Mapper-Az
Start tedge-mapper-az 0.15 s Health Tedge-Mapper-Az
Start watchdog service 10.266 s Health Tedge-Mapper-Az
Check PID of tedge-mapper-az 0.136 s Health Tedge-Mapper-Az
Kill the PID 0.142 s Health Tedge-Mapper-Az
Recheck PID of tedge-agent 6.5809999999999995 s Health Tedge-Mapper-Az
Compare PID change 0.001 s Health Tedge-Mapper-Az
Stop watchdog service 0.15 s Health Tedge-Mapper-Az
Remove entry from service file 0.131 s Health Tedge-Mapper-Az
Stop tedge-mapper-collectd 0.113 s Health Tedge-Mapper-Collectd
Update the service file 0.121 s Health Tedge-Mapper-Collectd
Reload systemd files 0.525 s Health Tedge-Mapper-Collectd
Start tedge-mapper-collectd 0.195 s Health Tedge-Mapper-Collectd
Start watchdog service 10.25 s Health Tedge-Mapper-Collectd
Check PID of tedge-mapper-collectd 0.09 s Health Tedge-Mapper-Collectd
Kill the PID 0.309 s Health Tedge-Mapper-Collectd
Recheck PID of tedge-mapper-collectd 6.723 s Health Tedge-Mapper-Collectd
Compare PID change 0.01 s Health Tedge-Mapper-Collectd
Stop watchdog service 0.252 s Health Tedge-Mapper-Collectd
Remove entry from service file 0.225 s Health Tedge-Mapper-Collectd
tedge-collectd-mapper health status 5.773 s Health Tedge-Mapper-Collectd
c8y-log-plugin health status 5.534 s MQTT health endpoints
c8y-configuration-plugin health status 5.953 s MQTT health endpoints
Publish on a local insecure broker 0.232 s Basic Pub Sub
Publish on a local secure broker 3.407 s Basic Pub Sub
Publish on a local secure broker with client authentication 2.899 s Basic Pub Sub
Publish events to subscribed topic 0.305 s Custom Sub Topics Tedge-Mapper-Aws
Publish measurements to unsubscribed topic 5.26 s Custom Sub Topics Tedge-Mapper-Aws
Publish measurements to subscribed topic 0.377 s Custom Sub Topics Tedge-Mapper-Az
Publish measurements to unsubscribed topic 5.45 s Custom Sub Topics Tedge-Mapper-Az
Publish events to subscribed topic 0.167 s Custom Sub Topics Tedge-Mapper-C8Y
Publish measurements to unsubscribed topic 5.175 s Custom Sub Topics Tedge-Mapper-C8Y
Check remote mqtt broker #1773 3.568 s Remote Mqtt Broker
Apply name filter 0.101 s Filter Packages List Output
Apply maintainer filter 0.115 s Filter Packages List Output
Apply both filters 0.108 s Filter Packages List Output
No filters 0.109 s Filter Packages List Output
Both filters but name filter as empty string 0.149 s Filter Packages List Output
Both filters but maintainer filter as empty string 0.218 s Filter Packages List Output
Both filters as empty string 0.293 s Filter Packages List Output
Wrong package name 0.215 s Improve Tedge Apt Plugin Error Messages
Wrong version 0.101 s Improve Tedge Apt Plugin Error Messages
Wrong type 0.272 s Improve Tedge Apt Plugin Error Messages
tedge_connect_test_positive 0.303 s Tedge Connect Test
tedge_connect_test_negative 0.801 s Tedge Connect Test
tedge_connect_test_sm_services 8.203 s Tedge Connect Test
tedge_disconnect_test_sm_services 0.92 s Tedge Connect Test
Install thin-edge.io 17.903 s Call Tedge
call tedge -V 0.089 s Call Tedge
call tedge -h 0.105 s Call Tedge
call tedge -h -V 0.107 s Call Tedge
call tedge help 0.132 s Call Tedge
tedge config list 0.111 s Call Tedge Config List
tedge config list --all 0.086 s Call Tedge Config List
set/unset device.type 0.704 s Call Tedge Config List
set/unset device.key_path 0.403 s Call Tedge Config List
set/unset device.cert_path 0.426 s Call Tedge Config List
set/unset c8y.root_cert_path 0.335 s Call Tedge Config List
set/unset c8y.smartrest.templates 0.313 s Call Tedge Config List
set/unset c8y.topics 0.394 s Call Tedge Config List
set/unset az.root_cert_path 0.329 s Call Tedge Config List
set/unset az.topics 0.331 s Call Tedge Config List
set/unset aws.topics 0.309 s Call Tedge Config List
set/unset aws.url 0.328 s Call Tedge Config List
set/unset aws.root_cert_path 0.5 s Call Tedge Config List
set/unset aws.mapper.timestamp 0.576 s Call Tedge Config List
set/unset az.mapper.timestamp 0.579 s Call Tedge Config List
set/unset mqtt.bind.address 0.527 s Call Tedge Config List
set/unset mqtt.bind.port 0.685 s Call Tedge Config List
set/unset http.bind.port 0.478 s Call Tedge Config List
set/unset tmp.path 0.301 s Call Tedge Config List
set/unset logs.path 0.357 s Call Tedge Config List
set/unset run.path 0.418 s Call Tedge Config List
set/unset firmware.child.update.timeout 0.303 s Call Tedge Config List
set/unset c8y.url 0.27 s Call Tedge Config List
set/unset az.url 0.223 s Call Tedge Config List
set/unset mqtt.external.bind.port 0.273 s Call Tedge Config List
mqtt.external.bind.address 0.396 s Call Tedge Config List
mqtt.external.bind.interface 0.348 s Call Tedge Config List
set/unset mqtt.external.ca_path 0.354 s Call Tedge Config List
set/unset mqtt.external.cert_file 0.246 s Call Tedge Config List
set/unset mqtt.external.key_file 0.265 s Call Tedge Config List
set/unset software.plugin.default 0.28 s Call Tedge Config List
Get Put Delete 1.767 s Http File Transfer Api
Set keys should return value on stdout 0.058 s Tedge Config Get
Unset keys should not return anything on stdout and warnings on stderr 0.098 s Tedge Config Get
Invalid keys should not return anything on stdout and warnings on stderr 0.111 s Tedge Config Get
Set configuration via environment variables 0.418 s Tedge Config Get
Set configuration via environment variables for topics 0.179 s Tedge Config Get
Set unknown configuration via environment variables 0.055 s Tedge Config Get

@reubenmiller reubenmiller temporarily deployed to Test Pull Request July 20, 2023 18:38 — with GitHub Actions Inactive
@reubenmiller reubenmiller temporarily deployed to Test Pull Request July 20, 2023 19:08 — with GitHub Actions Inactive
Copy link
Contributor

@Bravo555 Bravo555 left a comment

Choose a reason for hiding this comment

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

Only small nits, overall it looks very good

…xternal resource

Downloading a test file from external urls is very unreliable and it often caused problems whilst running in the github runner. A local http server offers more control over the download process

Signed-off-by: Reuben Miller <reuben.d.miller@gmail.com>
@reubenmiller reubenmiller force-pushed the test-improve-software-interrupt-reliability branch from 491cc70 to 6f7198f Compare July 21, 2023 12:09
@reubenmiller reubenmiller temporarily deployed to Test Pull Request July 21, 2023 12:17 — with GitHub Actions Inactive
…p server

Signed-off-by: Reuben Miller <reuben.d.miller@gmail.com>
@reubenmiller reubenmiller temporarily deployed to Test Pull Request July 21, 2023 13:31 — with GitHub Actions Inactive
@reubenmiller reubenmiller merged commit 973821c into thin-edge:main Jul 25, 2023
16 checks passed
@reubenmiller reubenmiller deleted the test-improve-software-interrupt-reliability branch July 25, 2023 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci/cd Repository management and pipeline topics theme:testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants