-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Migrations manager #5546
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
Migrations manager #5546
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5546 +/- ##
=========================================
Coverage ? 24.52%
Complexity ? 3
=========================================
Files ? 402
Lines ? 34032
Branches ? 4731
=========================================
Hits ? 8347
Misses ? 24398
Partials ? 1287
|
c3ed1f4 to
bf3f398
Compare
e34999b to
c930137
Compare
|
Screenshot test failed, but no output was generated. Maybe a preliminary stage failed. |
|
IT test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/12844-IT |
c930137 to
553a52e
Compare
|
Screenshot test failed, but no output was generated. Maybe a preliminary stage failed. |
|
@tobiasKaminsky I looks like screenshots cannot be uploaded and the build fails because of it. |
|
Screenshot test failed, but no output was generated. Maybe a preliminary stage failed. |
553a52e to
e51b8e7
Compare
|
IT test failed: https://www.kaminsky.me/nc-dev/android-integrationTests/12877-IT |
When a migration fails it is a serious problem. We then should redirect to github for bug reporting , stop the app and recommend to reinstall it (after all only some settings are lost, but no data). I know this is a rough step, but if we would allow to continue the app, it might lead to hard reproducable bugs. |
|
Regarding tests: |
|
@tobiasKaminsky I added flag to mark migrations mandatory or not. Optional migrations will not cause application failure. The use case is the exisitng account migration procedure that can fail, but will try again on subsequent run. This change will preserve existing app behaviour which has been deployed in the field for long time and seems to be working. Could you please clarify what we do with the tests? I think we had some confusing email exchange and I'm not confident we're on the same page. We have 2 options:
If option 1 is desired, can we investigate the issues I found during the development, mentioned in the PR description? |
As we currently do not have any hard-failing migrations (existing one is restarted and ignores failures), shall we address this separately, when such issue arises? My #5482 PR will add a migration that is "bulletproof", so no need to over-implement at this stage as there will be no need for it now. On the other hand, having a complete solution up front has it's benefits as well. Let me know what strategy will be best here. |
947d5fe to
e80c2a0
Compare
|
@tobiasKaminsky @AndyScherzinger
I guess it's shippable stage now let's do a final review with that intention. |
|
Screenshot test failed, but no output was generated. Maybe a preliminary stage failed. |
|
@tobiasKaminsky User id migration returns error when any account migration fails. Previous implementation was returning succeess if any account succeeded. This was ok assuming migration being re-run on every start. From now on, once migration succeeds for all accounts, we mark it as applied and no longer re-try. This has an important implication. Could you tell me if the user id is set properly on account creation? If the purpose of this migration was to fix legacy accounts only - this implementation is correct. But in case it was intentedd to continuously patch new accounts - we need a to fix authentication flow as well. |
62407e5 to
22c9c7a
Compare
|
Screenshot test failed, but no output was generated. Maybe a preliminary stage failed. |
|
Screenshot test failed, but no output was generated. Maybe a preliminary stage failed. |
Let us tackle failing migrations, once this might occur. |
Yes this is only for legacy accounts, as we save this for every new account: android/src/main/java/com/owncloud/android/authentication/AuthenticatorActivity.java Line 1777 in f8ff0e1
|
22c9c7a to
7d4f446
Compare
Signed-off-by: Chris Narkiewicz <hello@ezaquarii.com>
Optional migrations care not causing migration failure and can be applied again on next application run. Signed-off-by: Chris Narkiewicz <hello@ezaquarii.com>
Robolectric tests are removed as we don't want to emulate platform. Renamed instrumentation tests to match expected naming. Updated detekt rule to allow human readable test function names in kt files. This naming convention was adopted in test code to enable human-readable test reports, but DEX does not support spaces in names. Underscore _ is a good replacement providnig similar level of readability. Signed-off-by: Chris Narkiewicz <hello@ezaquarii.com>
Migration manager added to DI. Migration manager called in place of legacy migration code. Signed-off-by: Chris Narkiewicz <hello@ezaquarii.com>
Previous implementation was returning success status when *any* account was migrated, despite possible failures. Return error when any account fails to be migrated. The migration remines idempotent and can be re-run again, until if finally succeeds. Signed-off-by: Chris Narkiewicz <hello@ezaquarii.com>
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
7d4f446 to
5872a97
Compare
|
APK file: https://www.kaminsky.me/nc-dev/android-artifacts/12942.apk |
Codacy375Lint
SpotBugs (new)
SpotBugs (master)
|
|
Screenshot test failed, but no output was generated. Maybe a preliminary stage failed. |

Migrations now
Currently there is no centrilized migration logic. We have 1 ad-hoc user model migration launched
in
MainApp.java:264that performs some account changes, but:Although we didn't have much problems with this simple solution, it is no longer scaling given the upcoming needs in
WorkManager(#5482) migration and upcoming refactoring work.Migrations manager
Changes
This PR provides a migration manager extracted from PR #5482 with few modifications done to satisfy
androidTestsenvironment. Changes are for the better anyway, so those changes will stay.MigrationManagerruns and keeps track of past migrations and failuresMigrationsis a dumping ground for all sort of migration code for today and the future (Migrate contacts backup job to new background job manager API #5482) and supplies migraiton procedures for manager to runtestsare still usingRobolectric, butandroidTestare supplied as well so we can compare and make an informed decision about; see section below about problems discovered during implementation.mockito-androidforandroidTestsdependenciesCapabilities
Issues with test environment
Things are not straightforward, unfortunately and I discovered some problems with
androidTestenvironment.spy()didn't work at all for me; this could be related to spy call real method for doReturn when mockito/mockito-kotlin#374invoke()(so can't use mocked functions)finalto discourageinheritance abuse and must be
opened for mocking.androidTestsin QA/Dev build due to incompatible user ID (somehting related to screenshots); capability to run tests in non-GPlay variant is important for contributors who use their phone and don't want to overwrite their gplay daily driver app with development build.camelCaseNameswhich are imo less readable as test titles (this is easily solvable byDetektconfig).TODO
androidTestfor it; in the context of mocking troubles, it's not so black-white anymoreMainApp.java:264call with a call to migration managerbuild.gradlecleanup@AndyScherzinger @tobiasKaminsky review pls
Signed-off-by: Chris Narkiewicz hello@ezaquarii.com