libremesh / lime-packages

LibreMesh packages configuring OpenWrt for wireless mesh networking
https://libremesh.org/
GNU Affero General Public License v3.0
281 stars 96 forks source link

Shrared state Async ubus interface #1086

Closed javierbrk closed 8 months ago

javierbrk commented 9 months ago

This pull request adds shrare-state-async ubus interface. Get method returns sharedstate "get" json data or reported error in case no json is found. Errors are bubbled up as they come from sharedstate inside a json structure with the name "error".

Since there is no Shared State async binary available in the testing environment, testing possibilities are reduced. Manual testing can be done on a router with bat-hosts package using this commands:

Get bat-hosts

# ubus -S call shared-state-async get "{'data_type': 'bat-hosts'}"
{"a8:40:41:1f:73:ab":"lrsegundo_eth1_2","02:95:39:1f:73:aa":"lrsegundo_eth0_250","a8:40:41:1c:85:c3":"lrsegundo_wlan2_mesh","a8:40:41:1c:85:16":"lrsegundo_wlan1_mesh","02:bb:ed:1f:73:aa":"lrsegundo_eth1_250","a8:40:41:1f:73:a8":"lrsegundo_wlan0_ap","aa:40:41:1f:73:a8":"lrsegundo_wlan0_apname","02:db:d6:1f:73:aa":"lrsegundo_eth0_1_250","02:29:0f:1f:73:aa":"lrsegundo_eth1_2_250","c2:10:20:5e:7f:b3":"lrsegundo_bat0","a8:40:41:1f:73:aa":"lrsegundo_eth0"}

Get an invalid data type

# ubus -S call shared-state-async get "{'data_type': 'bat-hosss'}"
{"error":53248}

Sync valid data type

# ubus -S call shared-state-async sync "{'data_type': 'bat-hosts'}"
{"error":0}

Sync invalid data type

ubus -S call shared-state-async sync "{'data_type': 'bat-hoss' }"
{"error":53248}

Sync valid data type with unreachable ipv4 addresses

# ubus -S call shared-state-async sync "{'data_type': 'bat-hosts' ,'peers_ip':['10.0.0.1','10.0.0.2']}'"
{"error":32768}

Sync valid data type with invalid ipv4 address

# ubus -S call shared-state-async sync "{'data_type': 'bat-hosts' ,'peers_ip':['10.0.0.1','10.0.2']}'"
{"error":61952}

Sync invalid data type with specified ipv4 address

ubus -S call shared-state-async sync "{'data_type': 'bat-hosdts' ,'peers_ip':['127.0.0.1','127.0.0.1']}'"
{"error":53248}

Sync valid data type with reachable ipv4 addresses

# ubus -S call shared-state-async sync "{'data_type': 'bat-hosts' ,'peers_ip':['127.0.0.1','127.0.0.1']}'"
{"error":0}
codecov-commenter commented 8 months ago

Codecov Report

Attention: Patch coverage is 87.50000% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 79.64%. Comparing base (63242c2) to head (5336c53). Report is 44 commits behind head on master.

:exclamation: Current head 5336c53 differs from pull request most recent head 5356cbd. Consider uploading reports for the commit 5356cbd to get more accurate results

Files Patch % Lines
...s/lime-system/files/usr/lib/lua/lime/proto/lan.lua 87.50% 2 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1086 +/- ## ========================================== + Coverage 79.55% 79.64% +0.08% ========================================== Files 53 53 Lines 4564 4579 +15 ========================================== + Hits 3631 3647 +16 + Misses 933 932 -1 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.