Skip to content

test(e2e): upgrade-with-history test — server must answer while legacy data migrates - #264

Merged
ErikBjare merged 2 commits into
ActivityWatch:masterfrom
TimeToBuildBob:test/upgrade-with-history
Sep 14, 2026
Merged

ErikBjare merged 2 commits into
ActivityWatch:masterfrom
TimeToBuildBob:test/upgrade-with-history

Conversation

@TimeToBuildBob

Copy link
Copy Markdown
Contributor

Regression guard for #261, the CI gap behind the v0.14.0 incident.

Every instrumented test started from a fresh install, so the legacy-bucket migration path (both aw-watcher-android-test_<host> and aw-watcher-android_<host> present, six-figure history) never ran in CI and an O(n²) merge shipped to production.

What it does: before the native datastore opens, seeds a v5-schema sqlite.db into filesDir with 100k legacy + 10k current five-minute events and one heartbeat straddling the cutover, marks onboarding/hostname migration done, launches MainActivity, then asserts:

  • GET /api/0/info answers within 20 s of launch
  • the merge completes within 60 s (destination bucket reaches 100k − 1 + 10k events via /events/count)
  • exactly the overlapping cutover pair stays in the legacy bucket

How it runs: in its own instrumentation process (the datastore is opened once per process), via the new make test-e2e-upgrade; make test-e2e now runs the main suite first and this test after, so the existing CI E2E job picks it up without workflow changes.

Expected result on this PR as-is: red at "server did not answer /api/0/info", because master still pins the aw-server-rust with the quadratic merge. That failure is the demonstration. Green after #263 (submodule bump) merges; I'll rebase then.

@greptile-apps

greptile-apps Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

The PR appears safe to merge, with no outstanding correctness or repository-rule issues.

Findings

  1. P1 Usage access remains disabled ▶

Summary

  • Splits the E2E suite so the upgrade test runs in a fresh instrumentation process.
  • Seeds legacy and destination buckets with overlapping cutover events.
  • Grants and restores usage access through AppOps before launching the activity.
  • Confirms API readiness, migration completion, and preservation of the overlapping legacy events.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    MainSuite[Run main instrumentation suite] --> UpgradeProcess[Start separate upgrade-test process]
    UpgradeProcess --> Grant[Grant usage access through AppOps]
    Grant --> Seed[Seed v5 SQLite database]
    Seed --> Launch[Launch MainActivity]
    Launch --> Ready[Poll server info endpoint]
    Ready --> Migrate[Poll destination event count]
    Migrate --> Verify[Verify overlapping events remain in legacy bucket]
    Verify --> Restore[Restore original AppOps mode]
Loading

Reviews (2) · Last reviewed commit: "test(e2e): grant usage AppOp so upgrade ..."

*/
@RunWith(AndroidJUnit4::class)
class UpgradeWithHistoryTest {
@get:Rule

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Usage access remains disabled

PACKAGE_USAGE_STATS is controlled by AppOps, and the repository's existing instrumentation setup documents that GrantPermissionRule cannot enable it on a fresh CI emulator. This test can therefore start without usage access, causing MainActivity to redirect to onboarding instead of starting the server. The readiness check then times out without exercising the migration.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 4cebe1c.

Replaced GrantPermissionRule with the AppOps grant NativeWindowInsetsTest already uses (appops set … GET_USAGE_STATS allow). PACKAGE_USAGE_STATS is not a runtime permission, so the old rule left usage access off on a fresh emulator and MainActivity would have redirected to onboarding before the server started.

Retriggering Greptile on this commit.

…y data migrates

Regression guard for ActivityWatch#261. Every instrumented test
started from a fresh install, so the legacy-bucket migration path (both
buckets present, six-figure history) never ran in CI and an O(n^2) merge
shipped to production.

Seeds a v5-schema sqlite.db with 100k legacy + 10k current events and one
overlapping cutover heartbeat before the datastore opens, launches
MainActivity, and asserts /api/0/info answers within 20 s and the merge
completes within 60 s (only the overlapping pair stays behind). Runs in
its own instrumentation process via make test-e2e-upgrade; make test-e2e
now runs the main suite first and this test after.

Git-Session-Id: 70b6
GrantPermissionRule cannot enable PACKAGE_USAGE_STATS on a fresh CI
emulator. MainActivity then redirects to onboarding and /api/0/info
never answers, so the regression never exercises the migration.

Use the same AppOps grant NativeWindowInsetsTest already uses.

Git-Session-Id: 3824146
@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

@greptileai review

@TimeToBuildBob

Copy link
Copy Markdown
Contributor Author

CI-green and mergeable (Greptile 5/5) — waiting only on a maintainer click.

This PR is ready to merge, but the bot has pull-only access to this repo and can't self-merge — surfacing it here so it isn't lost. The monitoring loop will stop re-flagging it now that this note is posted.

@ErikBjare
ErikBjare merged commit 6806996 into ActivityWatch:master Sep 14, 2026
8 checks passed
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.

2 participants