Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update NodeChrome support latest version from GoogleChromeLabs #2018

Merged
merged 2 commits into from
Nov 27, 2023
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
92 changes: 65 additions & 27 deletions NodeChrome/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,58 +6,96 @@ LABEL authors=${AUTHORS}

USER root

RUN apt-get update -qqy \
&& apt-get -qqy --no-install-recommends install libatk1.0-0 libatk-bridge2.0-0 \
libxkbcommon-x11-0 libgbm1 libpango-1.0-0 \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*

#============================================
# Google Chrome
#============================================
# can specify versions by CHROME_VERSION;
# e.g. google-chrome-stable
# google-chrome-beta
# google-chrome-unstable
#============================================
ARG CHROME_VERSION="google-chrome-stable"
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list \
&& apt-get update -qqy \
&& apt-get -qqy install \
${CHROME_VERSION:-google-chrome-stable} \
&& rm /etc/apt/sources.list.d/google-chrome.list \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*
# Support these inputs (following https://github.com/GoogleChromeLabs/chrome-for-testing):
# LATEST_RELEASE_STABLE
# LATEST_RELEASE_BETA
# LATEST_RELEASE_DEV
# LATEST_RELEASE_CANARY
# 121 (specific major version)
# 119.0.6045.105 (specific full version)
#============================================
ARG DOWNLOAD_HOST="https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing"
ARG VERSION_HOST="https://googlechromelabs.github.io/chrome-for-testing"
ARG CHROME_VERSION="LATEST_RELEASE_STABLE"
ARG CHROME_PLATFORM="linux64"
RUN if [ ! -z "$CHROME_VERSION" ]; \
then GET_VERSION_URL=$VERSION_HOST/$CHROME_VERSION \
&& if [ $(curl -I -s -o /dev/null -w "%{http_code}" $GET_VERSION_URL) -eq 200 ]; \
then echo "Getting Chrome version from "$GET_VERSION_URL \
&& CHROME_VERSION=$(wget -qO- $VERSION_HOST"/"$CHROME_VERSION | sed 's/\r$//') ; \
fi \
else echo "Getting Chrome version "$CHROME_DRIVER_VERSION ; \
fi \
&& CHROME_URL=$DOWNLOAD_HOST/$CHROME_VERSION/$CHROME_PLATFORM/chrome-$CHROME_PLATFORM.zip \
&& if [ $(curl -I -s -o /dev/null -w "%{http_code}" $CHROME_URL) -ne 200 ]; \
then CHROME_MAJOR_VERSION=$(echo $CHROME_VERSION | sed -E "s/([0-9]+).*/\1/") \
&& echo "Getting Chrome latest major version from "$VERSION_HOST"/LATEST_RELEASE_"$CHROME_MAJOR_VERSION \
&& CHROME_VERSION=$(wget -qO- $VERSION_HOST/LATEST_RELEASE_${CHROME_MAJOR_VERSION} | sed 's/\r$//') \
&& CHROME_URL=$DOWNLOAD_HOST/$CHROME_VERSION/$CHROME_PLATFORM/chrome-$CHROME_PLATFORM.zip ; \
fi \
&& echo "Using Chrome from: "$CHROME_URL \
&& wget --no-verbose -O /tmp/chrome-$CHROME_PLATFORM.zip $CHROME_URL \
&& rm -rf /opt/google/chrome \
&& unzip /tmp/chrome-$CHROME_PLATFORM.zip -d /opt/google \
&& mv /opt/google/chrome-$CHROME_PLATFORM /opt/google/chrome \
&& rm /tmp/chrome-$CHROME_PLATFORM.zip \
&& mv /opt/google/chrome/chrome-wrapper /opt/google/chrome/google-chrome \
&& chmod +x /opt/google/chrome/google-chrome \
&& ln -fs /opt/google/chrome/google-chrome /usr/bin/google-chrome

#=================================
# Chrome Launch Script Wrapper
#=================================
COPY wrap_chrome_binary /opt/bin/wrap_chrome_binary
RUN /opt/bin/wrap_chrome_binary

USER 1200

#============================================
# Chrome webdriver
#============================================
# can specify versions by CHROME_DRIVER_VERSION
# Latest released version will be used by default
# Latest released version (following browser version) will be used by default
#============================================
ARG CHROME_DRIVER_VERSION
ARG CHROME_DRIVER_VERSION=$CHROME_VERSION
RUN if [ ! -z "$CHROME_DRIVER_VERSION" ]; \
then CHROME_DRIVER_URL=https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/$CHROME_DRIVER_VERSION/linux64/chromedriver-linux64.zip ; \
else echo "Geting ChromeDriver latest version from https://googlechromelabs.github.io/chrome-for-testing/LATEST_RELEASE_" \
&& CHROME_MAJOR_VERSION=$(google-chrome --version | sed -E "s/.* ([0-9]+)(\.[0-9]+){3}.*/\1/") \
&& CHROME_DRIVER_VERSION=$(wget -qO- https://googlechromelabs.github.io/chrome-for-testing/LATEST_RELEASE_${CHROME_MAJOR_VERSION} | sed 's/\r$//') \
&& CHROME_DRIVER_URL=https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/$CHROME_DRIVER_VERSION/linux64/chromedriver-linux64.zip ; \
then GET_VERSION_URL=$VERSION_HOST/$CHROME_DRIVER_VERSION \
&& if [ $(curl -I -s -o /dev/null -w "%{http_code}" $GET_VERSION_URL) -eq 200 ]; \
then echo "Getting ChromeDriver version from "$GET_VERSION_URL \
&& CHROME_DRIVER_VERSION=$(wget -qO- $VERSION_HOST"/"$CHROME_DRIVER_VERSION | sed 's/\r$//') ; \
fi \
else CHROME_DRIVER_VERSION=$(google-chrome --version | sed -E "s/.* ([0-9]+(\.[0-9]+)+).*/\1/") \
&& echo "Getting ChromeDriver same as browser version "$CHROME_DRIVER_VERSION ; \
fi \
&& CHROME_DRIVER_URL=$DOWNLOAD_HOST/$CHROME_DRIVER_VERSION/$CHROME_PLATFORM/chromedriver-$CHROME_PLATFORM.zip \
&& if [ $(curl -I -s -o /dev/null -w "%{http_code}" $CHROME_DRIVER_URL) -ne 200 ]; \
then CHROME_MAJOR_VERSION=$(echo $CHROME_DRIVER_VERSION | sed -E "s/([0-9]+).*/\1/") \
&& echo "Getting ChromeDriver latest major version from "$VERSION_HOST"/LATEST_RELEASE_"$CHROME_MAJOR_VERSION \
&& CHROME_DRIVER_VERSION=$(wget -qO- $VERSION_HOST/LATEST_RELEASE_${CHROME_MAJOR_VERSION} | sed 's/\r$//') \
&& CHROME_DRIVER_URL=$DOWNLOAD_HOST/$CHROME_DRIVER_VERSION/$CHROME_PLATFORM/chromedriver-$CHROME_PLATFORM.zip ; \
fi \
&& echo "Using ChromeDriver from: "$CHROME_DRIVER_URL \
&& echo "Using ChromeDriver version: "$CHROME_DRIVER_VERSION \
&& wget --no-verbose -O /tmp/chromedriver_linux64.zip $CHROME_DRIVER_URL \
&& wget --no-verbose -O /tmp/chromedriver_$CHROME_PLATFORM.zip $CHROME_DRIVER_URL \
&& rm -rf /opt/selenium/chromedriver \
&& unzip /tmp/chromedriver_linux64.zip -d /opt/selenium \
&& rm /tmp/chromedriver_linux64.zip \
&& mv /opt/selenium/chromedriver-linux64/chromedriver /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION \
&& unzip /tmp/chromedriver_$CHROME_PLATFORM.zip -d /opt/selenium \
&& rm /tmp/chromedriver_$CHROME_PLATFORM.zip \
&& mv /opt/selenium/chromedriver-$CHROME_PLATFORM/chromedriver /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION \
&& chmod 755 /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION \
&& sudo ln -fs /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION /usr/bin/chromedriver
&& ln -fs /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION /usr/bin/chromedriver

USER 1200

#============================================
# Dumping Browser information for config
#============================================
RUN echo "chrome" > /opt/selenium/browser_name
RUN google-chrome --version | awk '{print $3}' > /opt/selenium/browser_version
RUN google-chrome --version | awk '{print $5}' > /opt/selenium/browser_version
VietND96 marked this conversation as resolved.
Show resolved Hide resolved
RUN echo "\"goog:chromeOptions\": {\"binary\": \"/usr/bin/google-chrome\"}" > /opt/selenium/browser_binary_location
8 changes: 4 additions & 4 deletions NodeEdge/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ USER root
# e.g. microsoft-edge-beta=88.0.692.0-1
#============================================
ARG EDGE_VERSION="microsoft-edge-stable"
RUN wget -q -O - https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
RUN wget -q -O - https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | tee /etc/apt/trusted.gpg.d/microsoft.gpg >/dev/null \
&& echo "deb https://packages.microsoft.com/repos/edge stable main" >> /etc/apt/sources.list.d/microsoft-edge.list \
&& apt-get update -qqy \
&& apt-get -qqy install ${EDGE_VERSION} \
Expand All @@ -26,8 +26,6 @@ RUN wget -q -O - https://packages.microsoft.com/keys/microsoft.asc | apt-key add
COPY wrap_edge_binary /opt/bin/wrap_edge_binary
RUN /opt/bin/wrap_edge_binary

USER 1200

#============================================
# Edge webdriver
#============================================
Expand All @@ -46,7 +44,9 @@ RUN if [ -z "$EDGE_DRIVER_VERSION" ]; \
&& rm /tmp/msedgedriver_linux64.zip \
&& mv /opt/selenium/msedgedriver /opt/selenium/msedgedriver-$EDGE_DRIVER_VERSION \
&& chmod 755 /opt/selenium/msedgedriver-$EDGE_DRIVER_VERSION \
&& sudo ln -fs /opt/selenium/msedgedriver-$EDGE_DRIVER_VERSION /usr/bin/msedgedriver
&& ln -fs /opt/selenium/msedgedriver-$EDGE_DRIVER_VERSION /usr/bin/msedgedriver

USER 1200

#============================================
# Dumping Browser information for config
Expand Down
10 changes: 10 additions & 0 deletions NodeFirefox/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,18 @@ RUN GK_VERSION=$(if [ ${GECKODRIVER_VERSION:-latest} = "latest" ]; then echo "0.
&& chmod 755 /opt/geckodriver-$GK_VERSION \
&& ln -fs /opt/geckodriver-$GK_VERSION /usr/bin/geckodriver

# Workaround for issue launch Firefox Webdriver "Failed to read marionette port"
RUN mkdir -p /home/seluser/.cache /home/seluser/.mozilla /.cache \
&& chmod 777 /home/seluser/.cache /home/seluser/.mozilla /.cache

USER 1200

RUN if ! whoami &> /dev/null; then \
if [ -w /tmp/passwd ]; then \
echo "${USER_NAME:-default}:x:$(id -u):0:${USER_NAME:-default} user:/home/seluser:/tmp:/bin/bash" >> /tmp/passwd; \
fi \
fi

#============================================
# Dumping Browser information for config
#============================================
Expand Down
2 changes: 1 addition & 1 deletion Standalone/start-selenium-standalone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ java ${JAVA_OPTS:-$SE_JAVA_OPTS} \
--bind-host ${SE_BIND_HOST} \
--config /opt/selenium/config.toml \
${SUB_PATH_CONFIG} \
${SE_OPTS}
${SE_OPTS}
52 changes: 52 additions & 0 deletions charts/selenium-grid/ci/customIngressPath-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
ingress:
annotations:
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: /$2
nginx.ingress.kubernetes.io/app-root: &gridAppRoot "/selenium"
hostname: ""
paths:
- path: /selenium(/|$)(.*)
pathType: Prefix
backend:
service:
name: '{{ template "seleniumGrid.router.fullname" $ }}'
port:
number: 4444
- path: /(/?)(session/.*/se/vnc)
pathType: Prefix
backend:
service:
name: '{{ template "seleniumGrid.router.fullname" $ }}'
port:
number: 4444

basicAuth:
enabled: false
isolateComponents: true

hub:
subPath: *gridAppRoot

components:
subPath: *gridAppRoot

chromeNode:
enabled: true
extraEnvironmentVariables:
- name: SE_NODE_OVERRIDE_MAX_SESSIONS
value: "true"
- name: SE_NODE_MAX_SESSIONS
value: "5"
startupProbe:
exec:
command:
- bash
- -c
- if [ $(curl --write-out %{http_code} --silent --output /dev/null http://selenium-router:4444/selenium/wd/hub/status) -ne 200 ]; then exit 1; fi
failureThreshold: 15
periodSeconds: 5

edgeNode:
enabled: false
firefoxNode:
enabled: false
3 changes: 0 additions & 3 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,6 @@ def standalone_browser_container_matches(container):

if use_random_user_id:
logger.info("Running tests with a random user ID -> %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()

Expand Down