Skip to content

Bug 1548535 - Cancel any pending workers when ping upload disabled#235

Merged
travis79 merged 1 commit into
mozilla:masterfrom
travis79:cancel-workers-with-clear-metrics
Aug 12, 2019
Merged

Bug 1548535 - Cancel any pending workers when ping upload disabled#235
travis79 merged 1 commit into
mozilla:masterfrom
travis79:cancel-workers-with-clear-metrics

Conversation

@travis79
Copy link
Copy Markdown
Member

@travis79 travis79 commented Aug 8, 2019

This cancels any pending PingUploadWorkers or MetricsPingWorkers when upload is disabled.

Pull Request checklist

  • Quality: This PR builds and tests run cleanly
    • make test runs without emitting any warnings
    • make lint runs without emitting any errors
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Changelog: This PR includes a changelog entry or an explanation of why it does not need one
    • Any breaking changes to language binding APIs are noted explicitly

@codecov-io
Copy link
Copy Markdown

codecov-io commented Aug 8, 2019

Codecov Report

Merging #235 into master will increase coverage by 0.08%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #235      +/-   ##
============================================
+ Coverage     70.47%   70.55%   +0.08%     
- Complexity      187      188       +1     
============================================
  Files            51       51              
  Lines          3062     3067       +5     
  Branches        453      454       +1     
============================================
+ Hits           2158     2164       +6     
  Misses          579      579              
+ Partials        325      324       -1
Impacted Files Coverage Δ Complexity Δ
...oid/src/main/java/mozilla/telemetry/glean/Glean.kt 85.35% <100%> (+0.28%) 1 <0> (ø) ⬇️
...illa/telemetry/glean/scheduler/PingUploadWorker.kt 88.88% <100%> (+0.65%) 2 <0> (ø) ⬇️
.../telemetry/glean/scheduler/MetricsPingScheduler.kt 96.15% <100%> (+1.34%) 24 <0> (+1) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e74e9d0...c6b8236. Read the comment docs.

Copy link
Copy Markdown
Contributor

@Dexterp37 Dexterp37 left a comment

Choose a reason for hiding this comment

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

Thanks for taking care of this! It looks good overall, I have a few design considerations below. My "biggest concern" is testing: let's try to make these tests more "unit" and less "integration"

Comment thread glean-core/android/src/main/java/mozilla/telemetry/glean/Glean.kt Outdated
Comment thread glean-core/android/src/main/java/mozilla/telemetry/glean/Glean.kt

@Test
fun `Workers should be cancelled when disabling uploading`() {
// Force the MetricsPingScheduler to schedule the MetricsPingWorker
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think I'd like to see this being more "unit" and less "integration": if we have two cancel functions, then we can test each one independently in their modules using the workmanager. Here, we'd just stub out and make sure that cancel is called when setUploadEnabled is called.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

If I'm going to make the cancel functions static members of their respective classes, it's not really practical to stub out a static method using Mockito so I propose to leave this test as it is and file a follow up bug to investigate the best way to approach this. I did add unit tests for the cancel functions in each of the test classes associated with the workers.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good point, makes sense.

@travis79 travis79 merged commit 16e14bb into mozilla:master Aug 12, 2019
@travis79 travis79 deleted the cancel-workers-with-clear-metrics branch August 12, 2019 12:41
travis79 added a commit to travis79/android-components that referenced this pull request Aug 12, 2019
This updates the cancel functions that were recently added to cancel WorkManager workers when the metrics were disabled.  This keeps glean-ac in line with the change requests for [this PR](mozilla/glean#235) in Glean-Core.
travis79 added a commit to mozilla-mobile/android-components that referenced this pull request Aug 12, 2019
This updates the cancel functions that were recently added to cancel WorkManager workers when the metrics were disabled.  This keeps glean-ac in line with the change requests for [this PR](mozilla/glean#235) in Glean-Core.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants