From db20142ad18a19b5213ce15b38c7e41b63845b4c Mon Sep 17 00:00:00 2001 From: Matthew Smith Date: Tue, 18 Nov 2014 12:11:24 -0700 Subject: [PATCH] Change Chrome Node to run Selenium Node Directly Remove init script for running Selenium node in favor of running the jar directly. Part of #3 --- Makefile | 7 +-- NodeBase/Dockerfile | 57 ++++--------------- NodeBase/entry_point.sh | 20 +++++++ NodeBase/etc/service/fluxbox/run | 8 --- NodeBase/etc/service/sel-node-emulator/run | 5 -- NodeBase/etc/service/sel-node/run | 20 ------- NodeBase/etc/service/service-emulator/run | 4 -- NodeBase/etc/service/x11vnc/run | 10 ---- NodeBase/etc/service/xvfb/run | 7 --- NodeChrome/Dockerfile | 41 +++++++++++++ .../chrome => NodeChrome}/chrome_launcher.sh | 0 {build/chrome => NodeChrome}/config.json | 0 bin/vncview | 6 -- build/chrome/install.sh | 43 -------------- 14 files changed, 74 insertions(+), 154 deletions(-) create mode 100644 NodeBase/entry_point.sh delete mode 100644 NodeBase/etc/service/fluxbox/run delete mode 100644 NodeBase/etc/service/sel-node-emulator/run delete mode 100644 NodeBase/etc/service/sel-node/run delete mode 100644 NodeBase/etc/service/service-emulator/run delete mode 100644 NodeBase/etc/service/x11vnc/run delete mode 100644 NodeBase/etc/service/xvfb/run create mode 100644 NodeChrome/Dockerfile rename {build/chrome => NodeChrome}/chrome_launcher.sh (100%) rename {build/chrome => NodeChrome}/config.json (100%) delete mode 100755 bin/vncview delete mode 100644 build/chrome/install.sh diff --git a/Makefile b/Makefile index db667fd675..b08a5c8c90 100644 --- a/Makefile +++ b/Makefile @@ -22,12 +22,7 @@ nodebase: base cd ./NodeBase && docker build -t $(NAME)/node-base:$(VERSION) . chrome: nodebase - rm -rf chrome_image - mkdir -p chrome_image/build/chrome - cp build/Dockerfile chrome_image/Dockerfile - cp build/install.sh chrome_image/build/install.sh - cp $(COPYARGS) build/chrome chrome_image/build/ - cd ./chrome_image && docker build -t $(NAME)/node-chrome:$(VERSION) . + cd ./NodeChrome && docker build -t $(NAME)/node-chrome:$(VERSION) . firefox: nodebase rm -rf firefox_image diff --git a/NodeBase/Dockerfile b/NodeBase/Dockerfile index b1f342be83..c6bc4b2ee4 100644 --- a/NodeBase/Dockerfile +++ b/NodeBase/Dockerfile @@ -1,17 +1,8 @@ -FROM elgalu/selenium-base:2.44.0 +FROM selenium/base:2.44.0 MAINTAINER Selenium -#================= -# Locale settings -#================= -ENV LANGUAGE en_US.UTF-8 -ENV LANG en_US.UTF-8 -RUN locale-gen en_US.UTF-8 \ - && dpkg-reconfigure --frontend noninteractive locales \ - && apt-get update -qqy \ - && apt-get -qqy --no-install-recommends install \ - language-pack-en \ - && rm -rf /var/lib/apt/lists/* +ENV DEBIAN_FRONTEND noninteractive +ENV DEBCONF_NONINTERACTIVE_SEEN true #=================== # Timezone settings @@ -26,40 +17,14 @@ RUN echo "US/Pacific" | sudo tee /etc/timezone \ #============== RUN apt-get update -qqy \ && apt-get -qqy install \ - x11vnc \ xvfb \ - && rm -rf /var/lib/apt/lists/* \ - && mkdir -p /home/seluser/.vnc \ - && x11vnc -storepasswd secret /home/seluser/.vnc/passwd \ - && chmod +r /home/seluser/.vnc/passwd - -#======= -# Fonts -#======= -RUN apt-get update -qqy \ - && apt-get -qqy --no-install-recommends install \ - fonts-ipafont-gothic \ - xfonts-100dpi \ - xfonts-75dpi \ - xfonts-cyrillic \ - xfonts-scalable \ && rm -rf /var/lib/apt/lists/* -#========= -# fluxbox -# A fast, lightweight and responsive window manager -#========= -RUN apt-get update -qqy \ - && apt-get -qqy --no-install-recommends install \ - fluxbox \ - && rm -rf /var/lib/apt/lists/* - -#=================================================================================== -# Scripts to run Xvfb, x11vnc, fluxbox, selenium hub, and selenium node as services -#=================================================================================== -COPY ./etc /etc -RUN chmod +x /etc/my_init.d/*.sh \ - && chmod +x /etc/service/**/run +#============================== +# Scripts to run Selenium Node +#============================== +COPY entry_point.sh /opt/bin/entry_point.sh +RUN chmod +x /opt/bin/entry_point.sh #============================ # Some configuration options @@ -67,6 +32,8 @@ RUN chmod +x /etc/my_init.d/*.sh \ ENV SCREEN_WIDTH 1360 ENV SCREEN_HEIGHT 1020 ENV SCREEN_DEPTH 24 -ENV DISPLAY :20.0 +ENV DISPLAY :99.0 + +USER seluser -EXPOSE 5900 +CMD /opt/bin/entry_point.sh diff --git a/NodeBase/entry_point.sh b/NodeBase/entry_point.sh new file mode 100644 index 0000000000..f2e0dbd891 --- /dev/null +++ b/NodeBase/entry_point.sh @@ -0,0 +1,20 @@ +#!/bin/bash +export GEOMETRY="$SCREEN_WIDTH""x""$SCREEN_HEIGHT""x""$SCREEN_DEPTH" + +if [ ! -e /opt/selenium/config.json ]; then + echo No Selenium Node configuration file, the node-base image is not intended to be run directly. 1>&2 + exit 1 +fi + +if [ -z "$HUB_PORT_4444_TCP_ADDR" ]; then + echo Not linked with a running Hub container 1>&2 + exit 1 +fi + +# TODO: Look into http://www.seleniumhq.org/docs/05_selenium_rc.jsp#browser-side-logs + +exec xvfb-run --server-args="$DISPLAY -screen 0 $GEOMETRY -ac +extension RANDR" \ + java -jar /opt/selenium/selenium-server-standalone.jar \ + -role node \ + -hub http://hub:4444/grid/register \ + -nodeConfig /opt/selenium/config.json diff --git a/NodeBase/etc/service/fluxbox/run b/NodeBase/etc/service/fluxbox/run deleted file mode 100644 index e6d4da5605..0000000000 --- a/NodeBase/etc/service/fluxbox/run +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash -export FLUXBOX_LOG="/tmp/fluxbox_manager.log" - -# Give Xvfb a moment to get running -sleep 1 - -# A fast, lightweight and responsive window manager -fluxbox -display $DISPLAY | tee $FLUXBOX_LOG diff --git a/NodeBase/etc/service/sel-node-emulator/run b/NodeBase/etc/service/sel-node-emulator/run deleted file mode 100644 index 485be538ad..0000000000 --- a/NodeBase/etc/service/sel-node-emulator/run +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -export HUB_NODE="/tmp/sel-node.log" - -# Start a GUI xTerm to easily debug the headless instance -x-terminal-emulator -geometry 100x30-10-20 -ls -title "selenium node log" -e "tail -f $HUB_NODE" diff --git a/NodeBase/etc/service/sel-node/run b/NodeBase/etc/service/sel-node/run deleted file mode 100644 index 2079eca527..0000000000 --- a/NodeBase/etc/service/sel-node/run +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash -export NODE_LOG="/tmp/sel-node.log" - -ADDR=localhost -PORT=4444 - -if [ -n "$HUB_PORT_4444_TCP_ADDR" ]; then - ADDR=$HUB_PORT_4444_TCP_ADDR -fi - -if [ -n "$HUB_PORT_4444_TCP_PORT" ]; then - PORT=$HUB_PORT_4444_TCP_PORT -fi - -sudo -E -i -u seluser \ - java -jar /opt/selenium/selenium-server-standalone.jar \ - -role node \ - -hub http://$ADDR:$PORT/grid/register \ - -nodeConfig /opt/selenium/config.json \ - | tee $NODE_LOG diff --git a/NodeBase/etc/service/service-emulator/run b/NodeBase/etc/service/service-emulator/run deleted file mode 100644 index 24fe6bb497..0000000000 --- a/NodeBase/etc/service/service-emulator/run +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -# Start a GUI xTerm to help debugging when VNC into the container -x-terminal-emulator -geometry 120x40+10+10 -ls -title "x-terminal-emulator" diff --git a/NodeBase/etc/service/x11vnc/run b/NodeBase/etc/service/x11vnc/run deleted file mode 100644 index 850f136c10..0000000000 --- a/NodeBase/etc/service/x11vnc/run +++ /dev/null @@ -1,10 +0,0 @@ -#!/usr/bin/env bash -export VNC_PORT=5900 -export VNC_LOG="/tmp/x11vnc_forever.log" - -# Give Xvfb and Fluxbox a moment to get running -sleep 1 - -# Start VNC server to enable viewing what's going on but not mandatory -sudo -E -i -u seluser \ - x11vnc -forever -usepw -shared -rfbport $VNC_PORT -display $DISPLAY | tee $VNC_LOG diff --git a/NodeBase/etc/service/xvfb/run b/NodeBase/etc/service/xvfb/run deleted file mode 100644 index 882f3b8658..0000000000 --- a/NodeBase/etc/service/xvfb/run +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -export GEOMETRY="$SCREEN_WIDTH""x""$SCREEN_HEIGHT""x""$SCREEN_DEPTH" -export XVFB_LOG="/tmp/Xvfb_headless.log" - -# Start the X server that can run on machines with no display -# hardware and no physical input devices -/usr/bin/Xvfb $DISPLAY -screen 0 $GEOMETRY -ac | tee $XVFB_LOG diff --git a/NodeChrome/Dockerfile b/NodeChrome/Dockerfile new file mode 100644 index 0000000000..cd252b8301 --- /dev/null +++ b/NodeChrome/Dockerfile @@ -0,0 +1,41 @@ +FROM selenium/node-base:2.44.0 +MAINTAINER Selenium + +USER root + +#=============== +# Google Chrome +#=============== +# TODO: IronPort (My Corporate Firewall) - Remove --no-check-certificate flag +RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub --no-check-certificate | 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 \ + google-chrome-stable \ + && rm /etc/apt/sources.list.d/google-chrome.list \ + && rm -rf /var/lib/apt/lists/* + +#================== +# Chrome webdriver +#================== +ENV CHROME_DRIVER_VERSION 2.12 +RUN wget --no-verbose -O /tmp/chromedriver_linux64.zip http://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip \ + && rm -rf /opt/selenium/chromedriver \ + && unzip /tmp/chromedriver_linux64.zip -d /opt/selenium \ + && rm /tmp/chromedriver_linux64.zip \ + && mv /opt/selenium/chromedriver /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION \ + && chmod 755 /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION \ + && ln -fs /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION /usr/bin/chromedriver + +#======================== +# Selenium Configuration +#======================== +COPY config.json /opt/selenium/config.json + +#================================= +# Chrome Launch Script Modication +#================================= +COPY chrome_launcher.sh /opt/google/chrome/google-chrome +RUN chmod +x /opt/google/chrome/google-chrome + +USER seluser diff --git a/build/chrome/chrome_launcher.sh b/NodeChrome/chrome_launcher.sh similarity index 100% rename from build/chrome/chrome_launcher.sh rename to NodeChrome/chrome_launcher.sh diff --git a/build/chrome/config.json b/NodeChrome/config.json similarity index 100% rename from build/chrome/config.json rename to NodeChrome/config.json diff --git a/bin/vncview b/bin/vncview deleted file mode 100755 index 7e8c615def..0000000000 --- a/bin/vncview +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -echo You need RealVNC client to use this script -echo - -vnc -WarnUnencrypted=0 -SendKeyEvents=0 -GrabKeyboard=0 SendPointerEvents=0 $@ diff --git a/build/chrome/install.sh b/build/chrome/install.sh deleted file mode 100644 index fdc03edcaa..0000000000 --- a/build/chrome/install.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -set -e -set -x - -#=============== -# Google Chrome -#=============== -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 --no-install-recommends install \ - google-chrome-stable - -rm /etc/apt/sources.list.d/google-chrome.list - -#================== -# Chrome webdriver -#================== -CHROME_DRIVER_VERSION=2.12 - -wget --no-verbose -O /tmp/chromedriver_linux64.zip http://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip - -rm -rf /opt/selenium/chromedriver -unzip /tmp/chromedriver_linux64.zip -d /opt/selenium -rm /tmp/chromedriver_linux64.zip - -mv /opt/selenium/chromedriver /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION -chmod 755 /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION -ln -fs /opt/selenium/chromedriver-$CHROME_DRIVER_VERSION /usr/bin/chromedriver - -#======================== -# Selenium Configuration -#======================== -cp /tmp/build/chrome/config.json /opt/selenium/config.json - -#================================= -# Chrome Launch Script Modication -#================================= -chmod +x /tmp/build/chrome/chrome_launcher.sh -cp /tmp/build/chrome/chrome_launcher.sh /opt/google/chrome/google-chrome