realm-kotlin
realm-kotlin copied to clipboard
Client Reset - automatic recover
Closes #925 Replaces https://github.com/realm/realm-kotlin/pull/933
Added RecoverUnsycedChangesStrategy and RecoverOrDiscardUnsyncedChangesStrategy and lifted restrictions on strategies depending on the Sync mode.
Similarly to the Java implementation (https://github.com/realm/realm-java/pull/7698) the API for RecoverOrDiscardUnsyncedChangesStrategy has
public fun onAfterRecovery(before: TypedRealm, after: MutableRealm)
public fun onAfterDiscard(before: TypedRealm, after: MutableRealm)
instead of the standard onAfter callback.
Changes from previous implementations:
DiscardUnsynced.onErroris deprecated in favour ofonManualFallbackas per alignment across SDKs.
Note:
Removing the Command Server has uncovered some defective configuration in the server apps in some cases. It appears we are configuring our test apps in some way that makes some tests non-deterministic and messes executions around across runs and platforms. We will need to revisit the app configuration framework at some point but for now I introduced the following changes:
- Created a test app for each Client Reset test and delete it after each test
- For some reason some JVM tests timed out so it was necessary to increase the timeout setting in the HttpClient for Client Reset tests, not all others. In fact, the client's timeout can now be configured ad-hoc. This increases the execution time, but it seems to be sufficient to avoid timeouts. Overall the execution time has increased by 2-3 minutes, but that was also expected as a few new client reset tests had been added.
- In addition two new client reset apps with recovery disabled have been added to avoid conflicts with existing apps which also get deleted after the execution of their respective tests has finished.
TODO:
- [x] decide whether we should change the default strategy to be
RecoverOrDiscardUnsycedChangesto avoid breaking changes? Ask other SDKs about this.
Wait with merging this until https://github.com/realm/realm-core/issues/5705 is dealt with.