You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 235673d
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: tests/README.md
+8-4Lines changed: 8 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -556,13 +556,17 @@ Tests on device replace installed app and clear its data, so they must never run
556
556
557
557
## Test accounts
558
558
559
-
* Tests and checks run on production servers of Telegram with real test accounts. Messages can be sent only to **Saved Messages** or to the users authorized in `snapshot.zip`, and groups and channels created by them can include only these users. Their ids are returned by `getSnapshotUserIds()`: when there is only one, messages are sent only to **Saved Messages**.
559
+
* Tests and checks run on production servers of Telegram with real test accounts. Messages can be sent only to **Saved Messages** or to the users authorized in the [snapshot](#session-snapshot), and groups and channels created by them can include only these users. Their ids are returned by `getSnapshotUserIds()`: when there is only one, messages are sent only to **Saved Messages**.
560
560
* Be careful with TDLib requests that load data over network: don't send them in loops or more often than a user could. Requests answered locally are not limited.
561
561
562
562
### Session snapshot
563
563
564
-
Authorized tests restore sessions from `tests/core/src/main/assets/snapshot.zip`. It is ignored by git and must never be committed: it gives access to the accounts. Use dedicated test accounts. Snapshot includes all accounts added to the app, so several accounts can be authorized to test interaction between them: messages, groups, channels, notifications.
564
+
Authorized tests restore sessions from a snapshot of accounts, a zip file outside the clone that the build takes by its full path: `-PsnapshotFile=<path>`, e.g. `./gradlew :tests:ui:connectedLatestNonMinifiedReleaseAndroidTest -PsnapshotFile=$HOME/tgx-snapshots/pixel.zip`. Without it, authorized tests fail. The snapshot gives access to the accounts: keep it out of repositories and don't make copies of it. Use dedicated test accounts. Snapshot includes all accounts added to the app, so several accounts can be authorized to test interaction between them: messages, groups, channels, notifications.
565
565
566
-
Sessions from the snapshot must not be used by several apps at once, otherwise Telegram may terminate them as leaked. That's why build runs tests on device one at a time and only on one device, and fails when another Gradle build on the machine is already running tests with the same accounts. Builds with snapshots of other accounts can run tests at the same time.
566
+
The build adds the snapshot to assets of test APKs by a link and keeps their assets out of the build cache, so that the sessions stay only in the snapshot and in the build folders of the clone. `tests/core/src/main/assets/snapshot.zip`, where the snapshot was kept before, is no longer read: a build that finds it there fails.
567
567
568
-
To create the snapshot, open **Saved Messages** of the test account → attach menu → **Files** → **Session Snapshot** (available in builds with test hooks enabled or in developer mode). The snapshot is sent to the chat: download it and save as `tests/core/src/main/assets/snapshot.zip`. Then clear data of the app where the snapshot was created, so it stops using the same sessions. Don't log out instead: it terminates sessions in the snapshot too.
568
+
Sessions from the snapshot must not be used by several apps at once, otherwise Telegram may terminate them as leaked. Each device can have its own snapshot of the same accounts: a snapshot made in another app has other sessions, so devices run tests at the same time, each with its own snapshot. A build runs tests on one device only, and waits while another Gradle build on the machine runs tests on the same device or with the same snapshot, found by its path.
569
+
570
+
A script that runs builds one at a time on the machine can let others build while tests run on a device: when it holds a lock of builds, a folder, it names it by `TGX_BUILD_LOCK` and its process by `TGX_BUILD_LOCK_PID`, written into `pid` in that folder. Tests on a device build nothing, so they remove the folder when they start, if it still has that `pid`.
571
+
572
+
To create the snapshot, open **Saved Messages** of the test account → attach menu → **Files** → **Session Snapshot** (available in builds with test hooks enabled or in developer mode). The snapshot is sent to the chat: download it and save it outside the clone. Then clear data of the app where the snapshot was created, so it stops using the same sessions. Don't log out instead: it terminates sessions in the snapshot too.
0 commit comments