-
Notifications
You must be signed in to change notification settings - Fork 70
feat: Add max persistence age override option [TRIAGE-608] #698
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
Closed
junias-rokt
wants to merge
5
commits into
mParticle:main
from
junias-rokt:TRIAGE-608_Add_persistenceMaxAgeSeconds
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d435760
TRIAGE-608: Add max persistence age override option
junias-rokt 5f38996
Merge branch 'main' into TRIAGE-608_Add_persistenceMaxAgeSeconds
junias-rokt 676f3ae
TRIAGE-608: Update throttl ts on success + tests
junias-rokt c588b67
TRIAGE-608: Make properties @VisibleForTesting
junias-rokt efe31bb
TRIAGE-608: Fix retry-on-failure throttle logic
junias-rokt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...core/src/androidTest/kotlin/com.mparticle/internal/database/services/UploadServiceTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| package com.mparticle.internal.database.services | ||
|
|
||
| import com.mparticle.internal.Constants | ||
| import com.mparticle.internal.database.UploadSettings | ||
| import com.mparticle.networking.NetworkOptions | ||
| import org.json.JSONException | ||
| import org.json.JSONObject | ||
| import org.junit.Assert.assertEquals | ||
| import org.junit.Test | ||
|
|
||
| class UploadServiceTest : BaseMPServiceTest() { | ||
|
|
||
| @Test | ||
| @Throws(JSONException::class) | ||
| fun testDeleteUploadsOlderThan() { | ||
| val now = System.currentTimeMillis() | ||
| val oneDayMillis = 24L * 60L * 60L * 1000L | ||
| val uploadSettings = UploadSettings( | ||
| "apiKey", | ||
| "secret", | ||
| NetworkOptions.builder().build(), | ||
| "", | ||
| "", | ||
| ) | ||
|
|
||
| // Insert 5 uploads dated 10 days ago and 5 uploads dated 1 hour ago. | ||
| // insertUpload reads CREATED_AT from the message's TIMESTAMP ("ct") key. | ||
| for (i in 0 until 5) { | ||
| UploadService.insertUpload(database, uploadJson(now - 10L * oneDayMillis), uploadSettings) | ||
| } | ||
| for (i in 0 until 5) { | ||
| UploadService.insertUpload(database, uploadJson(now - 60L * 60L * 1000L), uploadSettings) | ||
| } | ||
| assertEquals(10, UploadService.getReadyUploads(database).size) | ||
|
|
||
| // Cut off at 7 days ago - the 5 old uploads should be removed and the 5 recent kept. | ||
| val cutoffMillis = now - 7L * oneDayMillis | ||
| val deleted = UploadService.deleteUploadsOlderThan(database, cutoffMillis) | ||
| assertEquals(5, deleted) | ||
| assertEquals(5, UploadService.getReadyUploads(database).size) | ||
|
|
||
| // Rows whose CREATED_AT is exactly at the cutoff must not be removed (strict `<` predicate). | ||
| UploadService.insertUpload(database, uploadJson(cutoffMillis), uploadSettings) | ||
| assertEquals(0, UploadService.deleteUploadsOlderThan(database, cutoffMillis)) | ||
| assertEquals(6, UploadService.getReadyUploads(database).size) | ||
| } | ||
|
|
||
| @Throws(JSONException::class) | ||
| private fun uploadJson(timestampMillis: Long): JSONObject = JSONObject() | ||
| .put(Constants.MessageKey.TIMESTAMP, timestampMillis) | ||
| .put("payload", "test") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we check for the upper bound? Something like
or not set it at all of not in the range?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey good callout! This is intentional as the main aim for these changes was to have feature parity with the other SDKs. Changing this would diverge from the other ones. This also matches all the other validators in the file and large values basically just disable the sweep.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, fair enough