Repository navigation
Local docker run - #1338
Local docker run#1338sonic16x wants to merge 7 commits into
Conversation
31261e5 to
4b60012
Compare
commit: |
✅ Testplane browser-env run succeed
|
✅ Testplane E2E run succeed
|
0cdb86f to
d364192
Compare
There was a problem hiding this comment.
Extended WdProcess to allow asynchronous free and kill methods and optional methods for retrieving logs, saving session logs, and starting the CDP proxy. This lets Docker environments use the existing WebDriver process interface while ensuring cleanup completes before execution continues.
There was a problem hiding this comment.
Added a Python proxy that runs inside the browser container and forwards HTTP and WebSocket requests to Chrome’s CDP endpoint. It connects Selenoid’s expected port 7070 to the browser’s actual debugger port and resolves the correct browser WebSocket path.
There was a problem hiding this comment.
Added browser startup through Docker and Selenoid. The implementation checks Docker availability and image architecture, downloads missing images, generates browsers.json, creates a dedicated network and Selenoid container for each session, and waits for WebDriver readiness. It starts the CDP proxy inside the browser container when needed, collects startup diagnostics, saves session logs to <os.tmpdir()>/testplane-logs/<sessionId>.log, and removes the resources it created when the session ends.
There was a problem hiding this comment.
Added support for gridUrl: "docker", including creating the Docker environment and connecting to its WebDriver endpoint. After a Chrome session starts, it prepares the CDP proxy; before deleting the session, it saves the logs once. Session cleanup now awaits asynchronous container removal. Startup errors include diagnostic logs, and cleanup failures are reported as warnings.
There was a problem hiding this comment.
Added forwarding of options.docker to the browser configuration. This makes Docker mode available through launchBrowser() without running the test runner.
d364192 to
98520eb
Compare
b7b963c to
84dc6a5
Compare
DudaGod
left a comment
There was a problem hiding this comment.
Я посмотрел локальный запуск браузеров в Docker. Ниже построчные замечания по совместимости образов, сети, безопасности и удобству запуска.
| this._sessionIdForLogs = session.sessionId; | ||
| this._wdProcess?.setSessionId?.(session.sessionId); | ||
| const debuggerAddress = session.capabilities["goog:chromeOptions"]?.debuggerAddress; | ||
| if (debuggerAddress && !("browserWSEndpoint" in this._config && this._config.browserWSEndpoint)) { |
There was a problem hiding this comment.
Я бы не делал подготовку CDP обязательной при создании WebDriver-сессии. Пользовательский Chrome-образ может вернуть debuggerAddress, но не иметь devtools-адаптера, которого ожидает prepareCdp(). Тогда даже тест, использующий только WebDriver, не стартует. Можно ли инициализировать CDP только при первом обращении к нему?
| import { prepareDockerBrowserImage } from "./docker-image"; | ||
| import { timeDockerOperation } from "./docker-timing"; | ||
|
|
||
| const PLATFORM = "linux/amd64"; |
There was a problem hiding this comment.
Здесь жёстко задан linux/amd64, поэтому на Apple Silicon нативный arm64-образ будет отвергнут, а multi-platform образ запустится через эмуляцию. Я бы выбирал архитектуру текущего Docker-движка, сохранив возможность явно запросить другую платформу.
| await writeFile(configPath, JSON.stringify(browsers)); | ||
| // Set before creation to also clean up when the CLI times out after creating the network. | ||
| networkCreated = true; | ||
| await timeDockerOperation(name, "create network", () => docker(["network", "create", network])); |
There was a problem hiding this comment.
Я бы проверил IPv6 именно в создаваемой здесь сети. Включённый IPv6 у стандартного bridge не означает, что новая пользовательская сеть тоже получит IPv6. Сейчас браузерный контейнер может не открыть IPv6-only сайт, хотя сама VM имеет к нему доступ.
| network, | ||
| // This is the socket path on the daemon's Linux host, including Docker Desktop/Colima. | ||
| "--volume", | ||
| "/var/run/docker.sock:/var/run/docker.sock", |
There was a problem hiding this comment.
/var/run/docker.sock — путь на стороне Docker-демона, а не сокет из выбранного локального Docker context. У rootless Podman он обычно находится в другом месте, поэтому описанный в документации сценарий может не запустить Selenoid. Я бы добавил настройку способа подключения контроллера к движку и проверку этого сценария.
| ...controllerSecurityArgs, | ||
| selenoidImage, | ||
| "-conf", | ||
| "/browsers.json", |
There was a problem hiding this comment.
Я бы передавал Selenoid -disable-privileged по умолчанию. Без этого флага он запускает браузерные контейнеры в privileged-режиме, а здесь пользователь может указать произвольный образ. Если отдельным образам нужны дополнительные привилегии, лучше включать их явно.
| } | ||
|
|
||
| const { selenoidImage } = config || {}; | ||
| if (typeof selenoidImage !== "string" || !selenoidImage.trim()) { |
There was a problem hiding this comment.
Я бы не требовал от пользователя выбирать selenoidImage для базового сценария. Его цель — указать свой совместимый браузерный образ и запустить тесты; образ контроллера выглядит внутренней деталью Testplane. Можно ли дать публичный закреплённый default и оставить это поле для переопределения?
| const manager = runs.get(owner); | ||
| if (manager) return manager.acquire(browserId, config, options, closeBrowser); | ||
|
|
||
| await standaloneStopping; |
There was a problem hiding this comment.
Если state.manager.stop() отклонится, standaloneStopping навсегда останется отклонённым Promise. После временного сбоя Docker любой следующий standalone-запуск упадёт на этом await. Я бы очищал состояние после ошибки и добавил тест на повторный запуск.
|
|
||
| it("should route Firefox sessions through /wd/hub inside the browser container", async () => { | ||
| const driver = await start( | ||
| "registry.yandex.net/selenium/firefox:148.0", |
There was a problem hiding this comment.
Я бы заменил адрес внутреннего registry в публичном тесте на нейтральный фикстурный адрес. Для проверки маршрута /wd/hub конкретный реестр не нужен.
No description provided.