From ad0a7a6fba5a5f123897d37c3e37e3bd45082b00 Mon Sep 17 00:00:00 2001 From: Diego Molina Date: Wed, 22 Nov 2023 16:31:31 +0100 Subject: [PATCH] Setting driver and browser path via configuration (#2017) [deploy] --- .github/workflows/build-test.yml | 8 ++++++-- Distributor/start-selenium-grid-distributor.sh | 7 ++++--- EventBus/start-selenium-grid-eventbus.sh | 7 ++++--- Hub/start-selenium-grid-hub.sh | 7 ++++--- NodeBase/generate_config | 11 +++-------- NodeBase/start-selenium-node.sh | 14 +++++++++++--- NodeChrome/Dockerfile | 10 ++++++---- NodeDocker/start-selenium-grid-docker.sh | 7 ++++--- NodeEdge/Dockerfile | 4 +++- NodeFirefox/Dockerfile | 7 ++++--- Router/start-selenium-grid-router.sh | 7 ++++--- SessionQueue/start-selenium-grid-session-queue.sh | 7 ++++--- Sessions/start-selenium-grid-sessions.sh | 7 ++++--- Standalone/generate_config | 11 +++-------- Standalone/start-selenium-standalone.sh | 14 +++++++++++--- StandaloneDocker/start-selenium-grid-docker.sh | 7 ++++--- tests/test.py | 5 ++++- 17 files changed, 83 insertions(+), 57 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 954ed42f9..4323c521b 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -41,7 +41,11 @@ jobs: - name: Build Docker images run: VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make build - name: Test Docker images - run: USE_RANDOM_USER_ID=${USE_RANDOM_USER} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make test + uses: nick-invision/retry@v2.8.3 + with: + timeout_minutes: 20 + max_attempts: 3 + command: | + USE_RANDOM_USER_ID=${USE_RANDOM_USER} VERSION=${BRANCH} BUILD_DATE=${BUILD_DATE} make test env: USE_RANDOM_USER: ${{ matrix.use-random-user }} - diff --git a/Distributor/start-selenium-grid-distributor.sh b/Distributor/start-selenium-grid-distributor.sh index 0a653e81e..81d498cea 100755 --- a/Distributor/start-selenium-grid-distributor.sh +++ b/Distributor/start-selenium-grid-distributor.sh @@ -54,10 +54,11 @@ if [ ! -z "$SE_DISTRIBUTOR_PORT" ]; then PORT_CONFIG="--port ${SE_DISTRIBUTOR_PORT}" fi -EXTRA_LIBS="/opt/selenium/selenium-http-jdk-client.jar" +EXTRA_LIBS="" if [ ! -z "$SE_ENABLE_TRACING" ]; then EXTERNAL_JARS=$(> "$FILENAME" SE_NODE_BROWSER_NAME=$(cat /opt/selenium/browser_name) -if [[ "${SE_NODE_BROWSER_NAME}" == "chrome" ]]; then - SE_NODE_BROWSER_VERSION=$(short_version $(google-chrome --version | awk '{print $3}')) -elif [[ "${SE_NODE_BROWSER_NAME}" == "firefox" ]]; then - SE_NODE_BROWSER_VERSION=$(short_version $(firefox --version | awk '{print $3}')) -elif [[ "${SE_NODE_BROWSER_NAME}" == "MicrosoftEdge" ]]; then - SE_NODE_BROWSER_VERSION=$(short_version $(microsoft-edge --version | awk '{print $3}')) -fi +SE_NODE_BROWSER_VERSION=$(short_version $(cat /opt/selenium/browser_version)) +SE__BROWSER_BINARY_LOCATION=$(cat /opt/selenium/browser_binary_location) if [[ -z "$SE_NODE_STEREOTYPE" ]]; then -SE_NODE_STEREOTYPE="{\"browserName\": \"${SE_NODE_BROWSER_NAME}\", \"browserVersion\": \"${SE_NODE_BROWSER_VERSION}\", \"platformName\": \"Linux\"}" +SE_NODE_STEREOTYPE="{\"browserName\": \"${SE_NODE_BROWSER_NAME}\", \"browserVersion\": \"${SE_NODE_BROWSER_VERSION}\", \"platformName\": \"Linux\", ${SE__BROWSER_BINARY_LOCATION}}" else SE_NODE_STEREOTYPE="$SE_NODE_STEREOTYPE" fi diff --git a/NodeBase/start-selenium-node.sh b/NodeBase/start-selenium-node.sh index fc5dc2f55..6a50d9069 100755 --- a/NodeBase/start-selenium-node.sh +++ b/NodeBase/start-selenium-node.sh @@ -36,10 +36,11 @@ if [ "$GENERATE_CONFIG" = true ]; then /opt/bin/generate_config fi -EXTRA_LIBS="/opt/selenium/selenium-http-jdk-client.jar" +EXTRA_LIBS="" if [ ! -z "$SE_ENABLE_TRACING" ]; then EXTERNAL_JARS=$( /opt/selenium/browser_name +RUN google-chrome --version | awk '{print $3}' > /opt/selenium/browser_version +RUN echo "\"goog:chromeOptions\": {\"binary\": \"/usr/bin/google-chrome\"}" > /opt/selenium/browser_binary_location diff --git a/NodeDocker/start-selenium-grid-docker.sh b/NodeDocker/start-selenium-grid-docker.sh index 760c34a85..b13474c6b 100755 --- a/NodeDocker/start-selenium-grid-docker.sh +++ b/NodeDocker/start-selenium-grid-docker.sh @@ -29,10 +29,11 @@ if [ ! -z "$SE_NODE_GRID_URL" ]; then SE_GRID_URL="--grid-url ${SE_NODE_GRID_URL}" fi -EXTRA_LIBS="/opt/selenium/selenium-http-jdk-client.jar" +EXTRA_LIBS="" if [ ! -z "$SE_ENABLE_TRACING" ]; then EXTERNAL_JARS=$( /opt/selenium/browser_name +RUN microsoft-edge --version | awk '{print $3}' > /opt/selenium/browser_version +RUN echo "\"ms:edgeOptions\": {\"binary\": \"/usr/bin/microsoft-edge\"}" > /opt/selenium/browser_binary_location diff --git a/NodeFirefox/Dockerfile b/NodeFirefox/Dockerfile index 698fe6338..48d83bdb8 100644 --- a/NodeFirefox/Dockerfile +++ b/NodeFirefox/Dockerfile @@ -12,11 +12,10 @@ USER root ARG FIREFOX_VERSION=latest RUN FIREFOX_DOWNLOAD_URL=$(if [ $FIREFOX_VERSION = "latest" ] || [ $FIREFOX_VERSION = "beta-latest" ] || [ $FIREFOX_VERSION = "nightly-latest" ] || [ $FIREFOX_VERSION = "devedition-latest" ] || [ $FIREFOX_VERSION = "esr-latest" ]; then echo "https://download.mozilla.org/?product=firefox-$FIREFOX_VERSION-ssl&os=linux64&lang=en-US"; else echo "https://download-installer.cdn.mozilla.net/pub/firefox/releases/$FIREFOX_VERSION/linux-x86_64/en-US/firefox-$FIREFOX_VERSION.tar.bz2"; fi) \ && apt-get update -qqy \ - && apt-get -qqy --no-install-recommends install firefox libavcodec-extra \ + && apt-get -qqy --no-install-recommends install libavcodec-extra \ libgtk-3-dev libdbus-glib-1-dev \ && rm -rf /var/lib/apt/lists/* /var/cache/apt/* \ && wget --no-verbose -O /tmp/firefox.tar.bz2 $FIREFOX_DOWNLOAD_URL \ - && apt-get -y purge firefox \ && rm -rf /opt/firefox \ && tar -C /opt -xjf /tmp/firefox.tar.bz2 \ && rm /tmp/firefox.tar.bz2 \ @@ -40,6 +39,8 @@ RUN GK_VERSION=$(if [ ${GECKODRIVER_VERSION:-latest} = "latest" ]; then echo "0. USER 1200 #============================================ -# Dumping Browser name and version for config +# Dumping Browser information for config #============================================ RUN echo "firefox" > /opt/selenium/browser_name +RUN firefox --version | awk '{print $3}' > /opt/selenium/browser_version +RUN echo "\"moz:firefoxOptions\": {\"binary\": \"/usr/bin/firefox\"}" > /opt/selenium/browser_binary_location diff --git a/Router/start-selenium-grid-router.sh b/Router/start-selenium-grid-router.sh index b99f675e5..b64c83d0e 100755 --- a/Router/start-selenium-grid-router.sh +++ b/Router/start-selenium-grid-router.sh @@ -54,10 +54,11 @@ if [ ! -z "$SE_ROUTER_PORT" ]; then PORT_CONFIG="--port ${SE_ROUTER_PORT}" fi -EXTRA_LIBS="/opt/selenium/selenium-http-jdk-client.jar" +EXTRA_LIBS="" if [ ! -z "$SE_ENABLE_TRACING" ]; then EXTERNAL_JARS=$(> "$FILENAME" SE_NODE_BROWSER_NAME=$(cat /opt/selenium/browser_name) -if [[ "${SE_NODE_BROWSER_NAME}" == "chrome" ]]; then - SE_NODE_BROWSER_VERSION=$(short_version $(google-chrome --version | awk '{print $3}')) -elif [[ "${SE_NODE_BROWSER_NAME}" == "firefox" ]]; then - SE_NODE_BROWSER_VERSION=$(short_version $(firefox --version | awk '{print $3}')) -elif [[ "${SE_NODE_BROWSER_NAME}" == "MicrosoftEdge" ]]; then - SE_NODE_BROWSER_VERSION=$(short_version $(microsoft-edge --version | awk '{print $3}')) -fi +SE_NODE_BROWSER_VERSION=$(short_version $(cat /opt/selenium/browser_version)) +SE__BROWSER_BINARY_LOCATION=$(cat /opt/selenium/browser_binary_location) if [[ -z "$SE_NODE_STEREOTYPE" ]]; then -SE_NODE_STEREOTYPE="{\"browserName\": \"${SE_NODE_BROWSER_NAME}\", \"browserVersion\": \"${SE_NODE_BROWSER_VERSION}\", \"platformName\": \"Linux\"}" +SE_NODE_STEREOTYPE="{\"browserName\": \"${SE_NODE_BROWSER_NAME}\", \"browserVersion\": \"${SE_NODE_BROWSER_VERSION}\", \"platformName\": \"Linux\", ${SE__BROWSER_BINARY_LOCATION}}" else SE_NODE_STEREOTYPE="$SE_NODE_STEREOTYPE" fi diff --git a/Standalone/start-selenium-standalone.sh b/Standalone/start-selenium-standalone.sh index 7af58b6e8..f1bf641a8 100755 --- a/Standalone/start-selenium-standalone.sh +++ b/Standalone/start-selenium-standalone.sh @@ -17,10 +17,11 @@ echo "Selenium Grid Standalone configuration: " cat /opt/selenium/config.toml echo "Starting Selenium Grid Standalone..." -EXTRA_LIBS="/opt/selenium/selenium-http-jdk-client.jar" +EXTRA_LIBS="" if [ ! -z "$SE_ENABLE_TRACING" ]; then EXTERNAL_JARS=$( %s" % random_user_id) + if 'firefox' in image.lower(): + logger.info("Firefox has issues when running with a random user ID. Skipping until it gets fixed.") + exit(0) standalone = 'standalone' in image.lower()