Skip to content

Local docker run - #1338

Open
sonic16x wants to merge 7 commits into
masterfrom
local-docker-run
Open

sonic16x wants to merge 7 commits into
masterfrom
local-docker-run

Conversation

@sonic16x

Copy link
Copy Markdown
Contributor

No description provided.

@sonic16x
sonic16x force-pushed the local-docker-run branch 2 times, most recently from 31261e5 to 4b60012 Compare October 1, 2026 03:17
@pkg-pr-new

pkg-pr-new Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/gemini-testing/testplane@1338

commit: 2fce926

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

✅ Testplane browser-env run succeed

Report

@github-actions

github-actions Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

✅ Testplane E2E run succeed

Report

@sonic16x
sonic16x force-pushed the local-docker-run branch 2 times, most recently from 0cdb86f to d364192 Compare October 1, 2026 05:05

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.

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.

Comment thread src/browser/docker-cdp-proxy.ts Outdated

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.

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.

Comment thread src/browser/docker.ts

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.

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.

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.

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.

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.

Added forwarding of options.docker to the browser configuration. This makes Docker mode available through launchBrowser() without running the test runner.

@DudaGod DudaGod left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Я посмотрел локальный запуск браузеров в 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)) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Я бы не делал подготовку CDP обязательной при создании WebDriver-сессии. Пользовательский Chrome-образ может вернуть debuggerAddress, но не иметь devtools-адаптера, которого ожидает prepareCdp(). Тогда даже тест, использующий только WebDriver, не стартует. Можно ли инициализировать CDP только при первом обращении к нему?

Comment thread src/browser/docker.ts
import { prepareDockerBrowserImage } from "./docker-image";
import { timeDockerOperation } from "./docker-timing";

const PLATFORM = "linux/amd64";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Здесь жёстко задан linux/amd64, поэтому на Apple Silicon нативный arm64-образ будет отвергнут, а multi-platform образ запустится через эмуляцию. Я бы выбирал архитектуру текущего Docker-движка, сохранив возможность явно запросить другую платформу.

Comment thread src/browser/docker.ts
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]));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Я бы проверил IPv6 именно в создаваемой здесь сети. Включённый IPv6 у стандартного bridge не означает, что новая пользовательская сеть тоже получит IPv6. Сейчас браузерный контейнер может не открыть IPv6-only сайт, хотя сама VM имеет к нему доступ.

Comment thread src/browser/docker.ts
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",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/var/run/docker.sock — путь на стороне Docker-демона, а не сокет из выбранного локального Docker context. У rootless Podman он обычно находится в другом месте, поэтому описанный в документации сценарий может не запустить Selenoid. Я бы добавил настройку способа подключения контроллера к движку и проверку этого сценария.

Comment thread src/browser/docker.ts
...controllerSecurityArgs,
selenoidImage,
"-conf",
"/browsers.json",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Я бы передавал Selenoid -disable-privileged по умолчанию. Без этого флага он запускает браузерные контейнеры в privileged-режиме, а здесь пользователь может указать произвольный образ. Если отдельным образам нужны дополнительные привилегии, лучше включать их явно.

Comment thread src/browser/docker.ts
}

const { selenoidImage } = config || {};
if (typeof selenoidImage !== "string" || !selenoidImage.trim()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Я бы не требовал от пользователя выбирать selenoidImage для базового сценария. Его цель — указать свой совместимый браузерный образ и запустить тесты; образ контроллера выглядит внутренней деталью Testplane. Можно ли дать публичный закреплённый default и оставить это поле для переопределения?

const manager = runs.get(owner);
if (manager) return manager.acquire(browserId, config, options, closeBrowser);

await standaloneStopping;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Если 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",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Я бы заменил адрес внутреннего registry в публичном тесте на нейтральный фикстурный адрес. Для проверки маршрута /wd/hub конкретный реестр не нужен.

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