homework_7: add dual emulator run and cleanup

This commit is contained in:
2026-04-12 17:23:43 +03:00
parent 8857b4feff
commit ea52943000
7 changed files with 47 additions and 17 deletions
-4
View File
@@ -5,7 +5,3 @@ build/
.DS_Store
allure-results/
logcat.txt
apk/
jobs/
scripts/
wiremock/__files/
+11 -2
View File
@@ -18,7 +18,8 @@
## Инфраструктура
`docker-compose.yml` поднимает:
- `wiremock` для раздачи `wishlist.apk`;
- `android-emulator` с Appium и VNC.
- `android-emulator-1` (Android 13, Appium `:4723`, VNC `:6080`);
- `android-emulator-2` (Android 12, Appium `:4725`, VNC `:6081`).
Приложение не маунтится в эмулятор и не ставится через ADB.
APK скачивается Appium по capability `app`.
@@ -50,7 +51,7 @@ $env:DB_PASSWORD="student"
docker compose up -d
```
2. Дождаться статуса `healthy` у `wiremock` и `android-emulator`:
2. Дождаться статуса `healthy` у `wiremock`, `android-emulator-1`, `android-emulator-2`:
```bash
docker compose ps
@@ -64,5 +65,13 @@ docker compose ps
mvn test
```
По умолчанию тесты запускаются параллельно на уровне классов (2 потока), а сессии распределяются по эмуляторам через `BlockingQueue`.
Опционально можно явно задать пул эмуляторов:
```powershell
$env:MOBILE_EMULATORS="android-emulator-1|http://localhost:4723|Android Emulator,android-emulator-2|http://localhost:4725|Android Emulator"
```
## Логи
После выполнения тестов logcat сохраняется в файл `logcat.txt` в корне проекта через Selenium/Appium logs API.
-1
View File
@@ -1 +0,0 @@
+25 -1
View File
@@ -10,7 +10,7 @@ services:
timeout: 5s
retries: 12
android-emulator:
android-emulator-1:
image: budtmo/docker-android:emulator_13.0
depends_on:
- wiremock
@@ -33,3 +33,27 @@ services:
timeout: 5s
retries: 40
start_period: 30s
android-emulator-2:
image: budtmo/docker-android:emulator_12.0
depends_on:
- wiremock
devices:
- /dev/kvm:/dev/kvm
ports:
- "4725:4723"
- "6081:6080"
environment:
- DEVICE=Pixel_4
- APPIUM=true
- WEB_VNC=true
- ENABLE_VNC=true
- AUTO_GRANT_PERMISSIONS=true
- EMULATOR_PARAMS=-no-window -no-audio -gpu swiftshader_indirect -no-snapshot -no-boot-anim
shm_size: 2gb
healthcheck:
test: ["CMD-SHELL", "[ \"$(cat /home/androidusr/device_status 2>/dev/null)\" = \"READY\" ]"]
interval: 15s
timeout: 5s
retries: 40
start_period: 30s
+7
View File
@@ -108,6 +108,13 @@
<version>${surefire.version}</version>
<configuration>
<useModulePath>false</useModulePath>
<systemPropertyVariables>
<junit.jupiter.execution.parallel.enabled>true</junit.jupiter.execution.parallel.enabled>
<junit.jupiter.execution.parallel.mode.default>same_thread</junit.jupiter.execution.parallel.mode.default>
<junit.jupiter.execution.parallel.mode.classes.default>concurrent</junit.jupiter.execution.parallel.mode.classes.default>
<junit.jupiter.execution.parallel.config.strategy>fixed</junit.jupiter.execution.parallel.config.strategy>
<junit.jupiter.execution.parallel.config.fixed.parallelism>2</junit.jupiter.execution.parallel.config.fixed.parallelism>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
@@ -8,12 +8,6 @@ import java.net.MalformedURLException;
import java.net.URI;
public final class MobileDriverFactory {
private final MobileConfig config;
public MobileDriverFactory(MobileConfig config) {
this.config = config;
}
public AndroidDriver create(MobileConfig.Emulator emulator) {
UiAutomator2Options options = new UiAutomator2Options()
.setPlatformName("Android")
@@ -26,7 +26,8 @@ public final class CoreModule extends AbstractModule {
String rawEmulators = value(
"mobile.emulators",
"MOBILE_EMULATORS",
"emulator-1|http://localhost:4723|Android Emulator"
"android-emulator-1|http://localhost:4723|Android Emulator,"
+ "android-emulator-2|http://localhost:4725|Android Emulator"
);
List<MobileConfig.Emulator> emulators = MobileConfig.Emulator.parse(rawEmulators, appUrl);
return new MobileConfig(appPackage, appUrl, reservationOwner, emulators);
@@ -55,8 +56,8 @@ public final class CoreModule extends AbstractModule {
@Provides
@Singleton
MobileDriverFactory mobileDriverFactory(MobileConfig config) {
return new MobileDriverFactory(config);
MobileDriverFactory mobileDriverFactory() {
return new MobileDriverFactory();
}
@Provides