aws-greengrass / aws-greengrass-shadow-manager

A GreengrassV2 Component that provides offline device shadow documents and optional synchronization to the IoT device shadow service.
Apache License 2.0
9 stars 6 forks source link

fix: Check local and cloud to determine if update is actually necessary #58

Closed rbattle closed 3 years ago

rbattle commented 3 years ago

Issue #, if available: Shadow-2

Description of changes: Update request objects to check if the update will actually make a change before executing.

Why is this change necessary: When a local update is made, a sync request is created to update the cloud. When the cloud update occurs, a notification is received that there was a cloud update. This triggers a local update for the same content.

In order to break the cycle, when executing the request, a check is made of the local or last synced cloud to determine if the change needs to actually occur.

How was this change tested: Unit + integ test

Any additional information or context required to review the change:

Checklist:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

github-actions[bot] commented 3 years ago

Unit Tests Coverage Report

File Coverage Lines Branches
All files 84% 90% 78% :white_check_mark:
com.aws.greengrass.shadowmanager.sync.model.LocalUpdateSyncRequest 90% 100% 80% :white_check_mark:
com.aws.greengrass.shadowmanager.sync.model.LocalDeleteSyncRequest 100% 100% 100% :white_check_mark:
com.aws.greengrass.shadowmanager.sync.model.FullShadowSyncRequest 82% 97% 68% :white_check_mark:
com.aws.greengrass.shadowmanager.sync.model.CloudDeleteSyncRequest 83% 83% 0% :white_check_mark:
com.aws.greengrass.shadowmanager.sync.model.BaseSyncRequest 66% 82% 50% :white_check_mark:
com.aws.greengrass.shadowmanager.sync.model.CloudUpdateSyncRequest 95% 91% 100% :white_check_mark:
com.aws.greengrass.shadowmanager.ipc.model.Operation 100% 100% 0% :white_check_mark:
com.aws.greengrass.shadowmanager.ipc.model.PubSubRequest 100% 100% 0% :white_check_mark:
com.aws.greengrass.shadowmanager.sync.IotDataPlaneClientFactory 45% 79% 12% :x:
com.aws.greengrass.shadowmanager.sync.RequestBlockingQueue 96% 99% 93% :white_check_mark:
com.aws.greengrass.shadowmanager.sync.SyncHandler 87% 91% 82% :white_check_mark:
com.aws.greengrass.shadowmanager.sync.RequestMerger 79% 82% 75% :white_check_mark:
com.aws.greengrass.shadowmanager.sync.CloudDataClient$1 20% 20% 0% :x:
com.aws.greengrass.shadowmanager.sync.CloudDataClient 77% 77% 77% :white_check_mark:
com.aws.greengrass.shadowmanager.model.configuration.ShadowSyncConfiguration 92% 100% 84% :white_check_mark:
com.aws.greengrass.shadowmanager.ShadowManagerDatabase 0% 0% 0% :x:
com.aws.greengrass.shadowmanager.ShadowManager 48% 61% 35% :x:
com.aws.greengrass.shadowmanager.ShadowManagerDAOImpl 92% 94% 90% :white_check_mark:
com.aws.greengrass.shadowmanager.AuthorizationHandlerWrapper 100% 100% 100% :white_check_mark:
com.aws.greengrass.shadowmanager.ShadowManager$1 0% 0% 0% :x:
software.amazon.awssdk.aws.greengrass.GeneratedAbstractDeleteThingShadowOperationHandler 67% 67% 0% :white_check_mark:
software.amazon.awssdk.aws.greengrass.GeneratedAbstractListNamedShadowsForThingOperationHandler 67% 67% 0% :white_check_mark:
software.amazon.awssdk.aws.greengrass.GeneratedAbstractUpdateThingShadowOperationHandler 67% 67% 0% :white_check_mark:
software.amazon.awssdk.aws.greengrass.GeneratedAbstractGetThingShadowOperationHandler 67% 67% 0% :white_check_mark:
com.aws.greengrass.shadowmanager.util.JsonMerger 96% 100% 92% :white_check_mark:
com.aws.greengrass.shadowmanager.util.SyncNodeMerger 91% 98% 84% :white_check_mark:
com.aws.greengrass.shadowmanager.util.DataOwner 100% 100% 0% :white_check_mark:
com.aws.greengrass.shadowmanager.util.ShadowWriteSynchronizeHelper 100% 100% 0% :white_check_mark:
com.aws.greengrass.shadowmanager.util.Validator 100% 100% 100% :white_check_mark:
com.aws.greengrass.shadowmanager.util.JsonUtil 88% 93% 83% :white_check_mark:
com.aws.greengrass.shadowmanager.model.ResponseMessageBuilder 100% 100% 0% :white_check_mark:
com.aws.greengrass.shadowmanager.model.ShadowDocument 82% 91% 73% :white_check_mark:
com.aws.greengrass.shadowmanager.model.ShadowStateMetadata 95% 98% 92% :white_check_mark:
com.aws.greengrass.shadowmanager.model.ErrorMessage 75% 100% 50% :white_check_mark:
com.aws.greengrass.shadowmanager.model.ShadowRequest 86% 71% 100% :white_check_mark:
com.aws.greengrass.shadowmanager.model.ShadowState 84% 87% 81% :white_check_mark:
com.aws.greengrass.shadowmanager.model.LogEvents 100% 100% 0% :white_check_mark:
com.aws.greengrass.shadowmanager.ipc.PubSubClientWrapper 100% 100% 0% :white_check_mark:
com.aws.greengrass.shadowmanager.ipc.UpdateThingShadowIPCHandler 100% 100% 0% :white_check_mark:
com.aws.greengrass.shadowmanager.ipc.DeleteThingShadowRequestHandler 94% 88% 100% :white_check_mark:
com.aws.greengrass.shadowmanager.ipc.UpdateThingShadowRequestHandler 92% 91% 93% :white_check_mark:
com.aws.greengrass.shadowmanager.ipc.DeleteThingShadowIPCHandler 100% 100% 0% :white_check_mark:
com.aws.greengrass.shadowmanager.ipc.GetThingShadowIPCHandler 96% 93% 100% :white_check_mark:
com.aws.greengrass.shadowmanager.ipc.ListNamedShadowsForThingIPCHandler 100% 100% 100% :white_check_mark:

Minimum allowed coverage is 65%

Generated by :monkey: cobertura-action against bc51c1e706108c88dd8b6e30380ccbbe7df54c40

github-actions[bot] commented 3 years ago

Integration Tests Coverage Report

File Coverage Lines Branches
All files 54% 60% 47% :white_check_mark:
com.aws.greengrass.shadowmanager.sync.model.LocalUpdateSyncRequest 0% 0% 0% :x:
com.aws.greengrass.shadowmanager.sync.model.LocalDeleteSyncRequest 0% 0% 0% :x:
com.aws.greengrass.shadowmanager.sync.model.FullShadowSyncRequest 20% 26% 15% :x:
com.aws.greengrass.shadowmanager.sync.model.CloudDeleteSyncRequest 10% 10% 0% :x:
com.aws.greengrass.shadowmanager.sync.model.BaseSyncRequest 66% 82% 50% :white_check_mark:
com.aws.greengrass.shadowmanager.sync.model.CloudUpdateSyncRequest 39% 28% 50% :x:
com.aws.greengrass.shadowmanager.ipc.model.Operation 100% 100% 0% :white_check_mark:
com.aws.greengrass.shadowmanager.ipc.model.PubSubRequest 100% 100% 0% :white_check_mark:
com.aws.greengrass.shadowmanager.sync.IotDataPlaneClientFactory 72% 95% 50% :white_check_mark:
com.aws.greengrass.shadowmanager.sync.RequestBlockingQueue 38% 50% 25% :x:
com.aws.greengrass.shadowmanager.sync.SyncHandler 68% 63% 73% :white_check_mark:
com.aws.greengrass.shadowmanager.sync.RequestMerger 11% 11% 0% :x:
com.aws.greengrass.shadowmanager.sync.CloudDataClient$1 20% 20% 0% :x:
com.aws.greengrass.shadowmanager.sync.CloudDataClient 64% 63% 65% :white_check_mark:
com.aws.greengrass.shadowmanager.model.configuration.ShadowSyncConfiguration 46% 55% 37% :white_check_mark:
com.aws.greengrass.shadowmanager.ShadowManagerDatabase 95% 91% 100% :white_check_mark:
com.aws.greengrass.shadowmanager.ShadowManager 86% 87% 85% :white_check_mark:
com.aws.greengrass.shadowmanager.ShadowManagerDAOImpl 82% 88% 75% :white_check_mark:
com.aws.greengrass.shadowmanager.AuthorizationHandlerWrapper 100% 100% 100% :white_check_mark:
com.aws.greengrass.shadowmanager.ShadowManager$1 17% 17% 0% :x:
software.amazon.awssdk.aws.greengrass.GeneratedAbstractDeleteThingShadowOperationHandler 100% 100% 0% :white_check_mark:
software.amazon.awssdk.aws.greengrass.GeneratedAbstractListNamedShadowsForThingOperationHandler 100% 100% 0% :white_check_mark:
software.amazon.awssdk.aws.greengrass.GeneratedAbstractUpdateThingShadowOperationHandler 100% 100% 0% :white_check_mark:
software.amazon.awssdk.aws.greengrass.GeneratedAbstractGetThingShadowOperationHandler 100% 100% 0% :white_check_mark:
com.aws.greengrass.shadowmanager.util.JsonMerger 38% 40% 36% :x:
com.aws.greengrass.shadowmanager.util.SyncNodeMerger 0% 0% 0% :x:
com.aws.greengrass.shadowmanager.util.DataOwner 0% 0% 0% :x:
com.aws.greengrass.shadowmanager.util.ShadowWriteSynchronizeHelper 100% 100% 0% :white_check_mark:
com.aws.greengrass.shadowmanager.util.Validator 58% 61% 55% :white_check_mark:
com.aws.greengrass.shadowmanager.util.JsonUtil 75% 82% 67% :white_check_mark:
com.aws.greengrass.shadowmanager.model.ResponseMessageBuilder 91% 91% 0% :white_check_mark:
com.aws.greengrass.shadowmanager.model.ShadowDocument 82% 91% 73% :white_check_mark:
com.aws.greengrass.shadowmanager.model.ShadowStateMetadata 88% 91% 85% :white_check_mark:
com.aws.greengrass.shadowmanager.model.ErrorMessage 97% 94% 100% :white_check_mark:
com.aws.greengrass.shadowmanager.model.ShadowRequest 86% 71% 100% :white_check_mark:
com.aws.greengrass.shadowmanager.model.ShadowState 87% 89% 84% :white_check_mark:
com.aws.greengrass.shadowmanager.model.LogEvents 100% 100% 0% :white_check_mark:
com.aws.greengrass.shadowmanager.ipc.PubSubClientWrapper 80% 80% 0% :white_check_mark:
com.aws.greengrass.shadowmanager.ipc.UpdateThingShadowIPCHandler 88% 88% 0% :white_check_mark:
com.aws.greengrass.shadowmanager.ipc.DeleteThingShadowRequestHandler 85% 70% 100% :white_check_mark:
com.aws.greengrass.shadowmanager.ipc.UpdateThingShadowRequestHandler 68% 73% 64% :white_check_mark:
com.aws.greengrass.shadowmanager.ipc.DeleteThingShadowIPCHandler 86% 86% 0% :white_check_mark:
com.aws.greengrass.shadowmanager.ipc.GetThingShadowIPCHandler 86% 73% 100% :white_check_mark:
com.aws.greengrass.shadowmanager.ipc.ListNamedShadowsForThingIPCHandler 62% 57% 67% :white_check_mark:

Minimum allowed coverage is 45%

Generated by :monkey: cobertura-action against bc51c1e706108c88dd8b6e30380ccbbe7df54c40