-
Notifications
You must be signed in to change notification settings - Fork 12
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
feat: Sync skip deletes <do not merge> #2131
base: trunk
Are you sure you want to change the base?
Changes from 3 commits
e577b31
2187883
1a05096
5714380
e9a6356
6d706a7
0c53be2
832f142
b5bac00
38b11da
e949f00
2b9285b
8e3f568
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -840,6 +840,33 @@ void main() async { | |
expect(commitEntriesMap.containsKey('public:phone.wavi@alice'), false); | ||
expect(commitEntriesMap.containsKey('public:location@alice'), true); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add another test which both uses a regex and sets skipDeletes: true There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
test( | ||
'A test to verify delete commit entries are NOT returned when skipDeletes is true', | ||
() async { | ||
var commitLogInstance = | ||
await (AtCommitLogManagerImpl.getInstance().getCommitLog('@alice')); | ||
var commitLogKeystore = commitLogInstance!.commitLogKeyStore; | ||
await commitLogKeystore.add(CommitEntry( | ||
'test_key_true_1@alice', CommitOp.UPDATE, DateTime.now())); | ||
await commitLogKeystore.add(CommitEntry( | ||
'test_key_true_2@alice', CommitOp.DELETE, DateTime.now())); | ||
await commitLogKeystore.add(CommitEntry( | ||
'test_key_true_3@alice', CommitOp.DELETE, DateTime.now())); | ||
await commitLogKeystore.add(CommitEntry( | ||
'test_key_true_4@alice', CommitOp.UPDATE, DateTime.now())); | ||
Iterator<MapEntry<String, CommitEntry>>? changes = commitLogInstance | ||
.commitLogKeyStore | ||
.getEntries(-1, skipDeletes: true); | ||
Map<String?, CommitEntry> commitEntriesMap = {}; | ||
while (changes.moveNext()) { | ||
var commitEntry = changes.current.value; | ||
commitEntriesMap[commitEntry.atKey] = commitEntry; | ||
} | ||
expect(commitEntriesMap.containsKey('test_key_true_1@alice'), true); | ||
expect(commitEntriesMap.containsKey('test_key_true_2@alice'), false); | ||
expect(commitEntriesMap.containsKey('test_key_true_3@alice'), false); | ||
expect(commitEntriesMap.containsKey('test_key_true_4@alice'), true); | ||
}); | ||
}); | ||
tearDown(() async => await tearDownFunc()); | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,7 +43,8 @@ class SyncProgressiveVerbHandler extends AbstractVerbHandler { | |
// Get entries to sync | ||
var commitEntryIterator = atCommitLog!.getEntries( | ||
int.parse(verbParams[AtConstants.fromCommitSequence]!) + 1, | ||
regex: verbParams['regex']); | ||
regex: verbParams['regex'], | ||
skipDeletes: verbParams['skipDeletes'] == 'true'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. VerbSyntax also needs this parameter, otherwise regex validation would fail. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes. those changes are in at_commons |
||
|
||
List<KeyStoreEntry> syncResponse = []; | ||
await prepareResponse(capacity, syncResponse, commitEntryIterator, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -469,6 +469,39 @@ void main() { | |
expect(syncResponse[3]['operation'], '*'); | ||
}); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add another test which both uses a regex and sets skipDeletes: true There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
test( | ||
'test to verify delete commit entries are not sent when skipDeletes is true', | ||
() async { | ||
await secondaryPersistenceStore! | ||
.getSecondaryKeyStore() | ||
?.put('test_key_1@alice', AtData()..data = 'alice'); | ||
await secondaryPersistenceStore! | ||
.getSecondaryKeyStore() | ||
?.remove('test_key_1@alice'); | ||
await secondaryPersistenceStore! | ||
.getSecondaryKeyStore() | ||
?.put('test_key_2@alice', AtData()..data = 'alice'); | ||
await secondaryPersistenceStore! | ||
.getSecondaryKeyStore() | ||
?.remove('test_key_2@alice'); | ||
var syncProgressiveVerbHandler = SyncProgressiveVerbHandler( | ||
secondaryPersistenceStore!.getSecondaryKeyStore()!); | ||
var response = Response(); | ||
var inBoundSessionId = '_6665436c-29ff-481b-8dc6-129e89199718'; | ||
var atConnection = InboundConnectionImpl(mockSocket, inBoundSessionId); | ||
atConnection.metaData.isAuthenticated = true; | ||
var syncVerbParams = HashMap<String, String>(); | ||
syncVerbParams.putIfAbsent(AtConstants.fromCommitSequence, () => '-1'); | ||
syncVerbParams.putIfAbsent('skipDeletes', () => 'true'); | ||
await syncProgressiveVerbHandler.processVerb( | ||
response, syncVerbParams, atConnection); | ||
List syncResponse = jsonDecode(response.data!); | ||
for (var entry in syncResponse) { | ||
expect(entry['atKey'] != 'test_key_1@alice', true); | ||
expect(entry['atKey'] != 'test_key_2@alice', true); | ||
} | ||
}); | ||
|
||
test( | ||
'test to verify only entries matching the regex are added to sync response', | ||
() async { | ||
|
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.
I think we can make this a strategy.. where FetchAllKeysStrategy is to get all and SkipDeletesStrategy is to skip deletes, instead of if-else code might look more readable.