homework_7: add dual emulator run and cleanup
This commit is contained in:
@@ -5,7 +5,3 @@ build/
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
allure-results/
|
allure-results/
|
||||||
logcat.txt
|
logcat.txt
|
||||||
apk/
|
|
||||||
jobs/
|
|
||||||
scripts/
|
|
||||||
wiremock/__files/
|
|
||||||
|
|||||||
@@ -18,7 +18,8 @@
|
|||||||
## Инфраструктура
|
## Инфраструктура
|
||||||
`docker-compose.yml` поднимает:
|
`docker-compose.yml` поднимает:
|
||||||
- `wiremock` для раздачи `wishlist.apk`;
|
- `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.
|
Приложение не маунтится в эмулятор и не ставится через ADB.
|
||||||
APK скачивается Appium по capability `app`.
|
APK скачивается Appium по capability `app`.
|
||||||
@@ -50,7 +51,7 @@ $env:DB_PASSWORD="student"
|
|||||||
docker compose up -d
|
docker compose up -d
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Дождаться статуса `healthy` у `wiremock` и `android-emulator`:
|
2. Дождаться статуса `healthy` у `wiremock`, `android-emulator-1`, `android-emulator-2`:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker compose ps
|
docker compose ps
|
||||||
@@ -64,5 +65,13 @@ docker compose ps
|
|||||||
mvn test
|
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.
|
После выполнения тестов logcat сохраняется в файл `logcat.txt` в корне проекта через Selenium/Appium logs API.
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
|
|
||||||
+25
-1
@@ -10,7 +10,7 @@ services:
|
|||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 12
|
retries: 12
|
||||||
|
|
||||||
android-emulator:
|
android-emulator-1:
|
||||||
image: budtmo/docker-android:emulator_13.0
|
image: budtmo/docker-android:emulator_13.0
|
||||||
depends_on:
|
depends_on:
|
||||||
- wiremock
|
- wiremock
|
||||||
@@ -33,3 +33,27 @@ services:
|
|||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 40
|
retries: 40
|
||||||
start_period: 30s
|
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
|
||||||
|
|||||||
@@ -108,6 +108,13 @@
|
|||||||
<version>${surefire.version}</version>
|
<version>${surefire.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<useModulePath>false</useModulePath>
|
<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>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
|||||||
@@ -8,12 +8,6 @@ import java.net.MalformedURLException;
|
|||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
public final class MobileDriverFactory {
|
public final class MobileDriverFactory {
|
||||||
private final MobileConfig config;
|
|
||||||
|
|
||||||
public MobileDriverFactory(MobileConfig config) {
|
|
||||||
this.config = config;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AndroidDriver create(MobileConfig.Emulator emulator) {
|
public AndroidDriver create(MobileConfig.Emulator emulator) {
|
||||||
UiAutomator2Options options = new UiAutomator2Options()
|
UiAutomator2Options options = new UiAutomator2Options()
|
||||||
.setPlatformName("Android")
|
.setPlatformName("Android")
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ public final class CoreModule extends AbstractModule {
|
|||||||
String rawEmulators = value(
|
String rawEmulators = value(
|
||||||
"mobile.emulators",
|
"mobile.emulators",
|
||||||
"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);
|
List<MobileConfig.Emulator> emulators = MobileConfig.Emulator.parse(rawEmulators, appUrl);
|
||||||
return new MobileConfig(appPackage, appUrl, reservationOwner, emulators);
|
return new MobileConfig(appPackage, appUrl, reservationOwner, emulators);
|
||||||
@@ -55,8 +56,8 @@ public final class CoreModule extends AbstractModule {
|
|||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
MobileDriverFactory mobileDriverFactory(MobileConfig config) {
|
MobileDriverFactory mobileDriverFactory() {
|
||||||
return new MobileDriverFactory(config);
|
return new MobileDriverFactory();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
|
|||||||
Reference in New Issue
Block a user