Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .config/dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ collectonly
confest
devfile
devspaces
geckodriver
kubedock
libonig
lightspeed
Expand Down
7 changes: 5 additions & 2 deletions selenium/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ curl -sSfL -C - https://github.com/SeleniumHQ/selenium/releases/download/seleniu
-o ${SELENIUM_PATH} && \
curl -sSfL -C - https://repo1.maven.org/maven2/org/seleniumhq/selenium/selenium-http-jdk-client/${SELENIUM_HTTP_JDK_CLIENT_VERSION}/selenium-http-jdk-client-${SELENIUM_HTTP_JDK_CLIENT_VERSION}.jar \
-o ${SELENIUM_HTTP_JDK_CLIENT_PATH} && \
curl -sSfL https://download-installer.cdn.mozilla.net/pub/firefox/releases/140.7.0esr/linux-$(arch)/en-US/firefox-140.7.0esr.tar.xz -o firefox.tar.xz && tar --xz -x -f firefox.tar.xz && rm firefox.tar.xz && \
curl -sSfL https://download-installer.cdn.mozilla.net/pub/firefox/releases/140.7.0esr/linux-$(arch)/en-US/firefox-140.7.0esr.tar.xz -o firefox.tar.xz && tar --xz -x -f firefox.tar.xz -C ${SELENIUM_HOME} && \
curl -sSfL -C - -O https://github.com/mozilla/geckodriver/releases/download/${GECKODRIVER_VERSION}/geckodriver-${GECKODRIVER_VERSION}-${GECKODRIVER_ARCH}.tar.gz && \
tar -C /usr/bin/ -xvf geckodriver-${GECKODRIVER_VERSION}-${GECKODRIVER_ARCH}.tar.gz && \
cd ${SELENIUM_HOME} && \
Expand All @@ -146,6 +146,8 @@ echo "session.screen0.toolbar.autoHide: true" > .fluxbox/init && \
touch .Xauthority .vnc/config && \
curl -fsSL https://code-server.dev/install.sh | sh

COPY selenium-node.toml /home/selenium/selenium-node.toml

RUN \
code-server --install-extension ms-python.vscode-python-envs --install-extension redhat.vscode-yaml --install-extension redhat.vscode-redhat-account && \
mkdir -p workspace && touch workspace/playbook.yaml && \
Expand All @@ -159,8 +161,9 @@ code-server --version && \
Xvnc -version && \
fluxbox --version && \
java -version && \
firefox --version && \
if [ "$(arch)" = "aarch64" ]; then export JAVA_TOOL_OPTIONS=-XX:UseSVE=0; fi && \
java -Dwebdriver.http.factory=jdk-http-client -jar ${SELENIUM_PATH} -ext ${SELENIUM_HTTP_JDK_CLIENT_PATH} info
java -Dwebdriver.http.factory=jdk-http-client -jar ${SELENIUM_PATH} --ext ${SELENIUM_HTTP_JDK_CLIENT_PATH} info

USER 1001

Expand Down
7 changes: 7 additions & 0 deletions selenium/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ func printSeleniumCombinedOutput(seleniumStdout io.ReadCloser) {

func startSelenium() *exec.Cmd {
fmt.Println("Starting selenium standalone")
configPath := os.Getenv("SELENIUM_HOME") + "/selenium-node.toml"
selenium := exec.Command(
"java",
"-Dwebdriver.http.factory=jdk-http-client",
Expand All @@ -76,10 +77,16 @@ func startSelenium() *exec.Cmd {
"--ext",
os.Getenv("SELENIUM_HTTP_JDK_CLIENT_PATH"),
"standalone",
"--allow-cors",
"true",
"--host",
"0.0.0.0", // Allow remote access (containers too)
"--port",
os.Getenv("SELENIUM_PORT"),
"--session-timeout",
os.Getenv("SELENIUM_SESSION_TIMEOUT"),
"--config",
configPath,
)
seleniumStdout, _ := selenium.StdoutPipe()
selenium.Stderr = selenium.Stdout
Expand Down
10 changes: 10 additions & 0 deletions selenium/selenium-node.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Explicit driver configuration so the node finds geckodriver and Firefox
# without relying on PATH detection (which can fail in container env).
[node]
detect-drivers = false

[[node.driver-configuration]]
display-name = "firefox"
max-sessions = 4
webdriver-executable = "/usr/bin/geckodriver"
stereotype = '{"browserName": "firefox", "platformName": "Linux", "moz:firefoxOptions": {"binary": "/home/selenium/firefox/firefox"}}'
20 changes: 20 additions & 0 deletions tools/selenium.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,26 @@ fi

$BUILD_CMD -f selenium/Containerfile selenium/ --tag "${IMAGE_NAME}"

# Verify the container starts and Selenium server comes up; run for 1 minute then stop
CONTAINER_NAME="selenium-adt-verify-$$"
cleanup_verify_container() {
${ADT_CONTAINER_ENGINE} rm -f "${CONTAINER_NAME}" 2>/dev/null || true
}
trap cleanup_verify_container EXIT

echo "Starting container to verify Selenium server..."
SELENIUM_PORT=4444
${ADT_CONTAINER_ENGINE} run -d -p ${SELENIUM_PORT}:${SELENIUM_PORT} --name "${CONTAINER_NAME}" "${IMAGE_NAME}"

# Wait for Selenium to be ready (status endpoint on port 4444) using curl retries
echo "Waiting for Selenium server to be ready..."
if ! curl -sSf -o /dev/null --retry-all-errors --retry 30 --retry-delay 2 --connect-timeout 2 "http://localhost:${SELENIUM_PORT}/status"; then
echo "Selenium server did not become ready in time."
${ADT_CONTAINER_ENGINE} logs "${CONTAINER_NAME}"
exit 1
fi
echo "Selenium server is ready."

if [[ -n "${GITHUB_SHA:-}" && "${GITHUB_EVENT_NAME:-}" != "pull_request" ]]; then
FQ_IMAGE_NAME="ghcr.io/ansible/selenium-adt-tmp:${GITHUB_SHA}-$ARCH"
$ADT_CONTAINER_ENGINE tag $IMAGE_NAME "${FQ_IMAGE_NAME}"
Expand Down
Loading