mirror of https://github.com/apache/archiva.git
Adding docker scripts for ci browser testing
This commit is contained in:
parent
48e76b64bd
commit
f7b57a974d
|
@ -0,0 +1,77 @@
|
|||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# Author: Martin Stockhammer <martin_s@apache.org>
|
||||
# Date: 2017-04-16
|
||||
#
|
||||
# Dockerfile for ci testing of the web modules.
|
||||
# Currently only chrome browser is installed into the image.
|
||||
# Uses selenium version 2.53.1
|
||||
|
||||
FROM ubuntu:yakkety
|
||||
MAINTAINER Apache Archiva <dev@archiva.apache.org>
|
||||
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
ENV DEBCONF_NONINTERACTIVE_SEEN true
|
||||
|
||||
ARG CHROME_VERSION=google-chrome-stable
|
||||
RUN apt-get -qqy update
|
||||
RUN apt-get -qqy install apt-utils >/dev/null 2>&1
|
||||
RUN apt-get -qqy install wget unzip >/dev/null
|
||||
RUN apt-get -qqy upgrade
|
||||
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 -qqy update \
|
||||
&& apt-get -qqy install \
|
||||
$CHROME_VERSION \
|
||||
>/dev/null
|
||||
|
||||
|
||||
ARG CHROME_DRIVER_VERSION=2.29
|
||||
RUN wget --no-verbose -O /tmp/chromedriver_linux64.zip https://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 \
|
||||
>/dev/null
|
||||
|
||||
RUN apt-get -qqy install openjdk-8-jdk xvfb dbus locales >/dev/null \
|
||||
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/* \
|
||||
>/dev/null
|
||||
|
||||
ARG SELENIUM_VERSION=2.53.1
|
||||
RUN mkdir -p /opt/bin && wget --no-verbose -O /opt/bin/selenium-server-standalone.jar https://selenium-release.storage.googleapis.com/2.53/selenium-server-standalone-$SELENIUM_VERSION.jar \
|
||||
&& chmod 644 /opt/bin/selenium-server-standalone.jar
|
||||
|
||||
COPY entry_point.sh /opt/bin/entry_point.sh
|
||||
COPY chrome_launcher.sh /usr/bin/google-chrome
|
||||
RUN chmod +x /opt/bin/entry_point.sh
|
||||
RUN chmod +x /usr/bin/google-chrome
|
||||
|
||||
ENV SCREEN_WIDTH 1360
|
||||
ENV SCREEN_HEIGHT 1020
|
||||
ENV SCREEN_DEPTH 24
|
||||
ENV X_START_NUM=3
|
||||
|
||||
RUN echo "DBUS_SESSION_BUS_ADDRESS=/dev/null" >> /etc/environment
|
||||
|
||||
CMD ["/opt/bin/entry_point.sh"]
|
||||
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# Author: Martin Stockhammer <martin_s@apache.org>
|
||||
# Date: 2017-04-16
|
||||
#
|
||||
# Starts the chrome browser from the chrome installation path.
|
||||
#
|
||||
|
||||
export GNOME_DISABLE_CRASH_DIALOG=SET_BY_GOOGLE_CHROME
|
||||
export DBUS_SESSION_BUS_ADDRESS=/dev/null
|
||||
|
||||
# Make sure that the profile directory specified in the environment, if any,
|
||||
# overrides the default.
|
||||
if [[ -n "$CHROME_USER_DATA_DIR" ]]; then
|
||||
PROFILE_DIRECTORY_FLAG="--user-data-dir=$CHROME_USER_DATA_DIR"
|
||||
fi
|
||||
|
||||
# Sanitize std{in,out,err} because they'll be shared with untrusted child
|
||||
# processes (http://crbug.com/376567).
|
||||
exec < /dev/null
|
||||
exec > >(exec cat)
|
||||
exec 2> >(exec cat >&2)
|
||||
|
||||
exec /opt/google/chrome/chrome --no-sandbox "$@"
|
|
@ -0,0 +1,51 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# Author: Martin Stockhammer <martin_s@apache.org>
|
||||
# Date: 2017-04-16
|
||||
#
|
||||
# This is the start script for the docker image that runs the
|
||||
# selenium standalone server.
|
||||
# Starts a Xvfb framebuffer server for the browser display.
|
||||
# Uses the automatic display number determination from the xvfb-run script.
|
||||
|
||||
|
||||
# Set the number for the xserver display to start
|
||||
: ${X_START_NUM:-1}
|
||||
|
||||
export GEOMETRY="$SCREEN_WIDTH""x""$SCREEN_HEIGHT""x""$SCREEN_DEPTH"
|
||||
|
||||
function shutdown {
|
||||
kill -s SIGTERM $NODE_PID
|
||||
wait $NODE_PID
|
||||
}
|
||||
|
||||
if [ ! -z "$SE_OPTS" ]; then
|
||||
echo "appending selenium options: ${SE_OPTS}"
|
||||
fi
|
||||
|
||||
rm -f /tmp/.X*lock
|
||||
|
||||
xvfb-run -a -n $X_START_NUM --server-args="-screen 0 $GEOMETRY -ac +extension RANDR" \
|
||||
java ${JAVA_OPTS} -jar /opt/bin/selenium-server-standalone.jar \
|
||||
${SE_OPTS} &
|
||||
NODE_PID=$!
|
||||
|
||||
trap shutdown SIGTERM SIGINT
|
||||
wait $NODE_PID
|
|
@ -0,0 +1,92 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
# Author: Martin Stockhammer <martin_s@apache.org>
|
||||
# Date: 2017-04-16
|
||||
#
|
||||
# Builds and runs a container
|
||||
#
|
||||
# Tries to find the docker configuration in ../docker/${DOCKER_CFG}
|
||||
#
|
||||
|
||||
# Always change the version, if your Dockerfile or scripts of the container change
|
||||
CONTAINER_VERSION="1.0"
|
||||
CONTAINER_NAME="archiva/selenium"
|
||||
DOCKER_CFG="webtest"
|
||||
INSTANCE_NAME="archiva-webtest"
|
||||
PORT_MAPPING="4444:4444"
|
||||
NETWORK_TYPE="host"
|
||||
|
||||
HERE=`dirname $0`
|
||||
|
||||
TAG="${CONTAINER_NAME}:${CONTAINER_VERSION}"
|
||||
|
||||
START_ARG="$1"
|
||||
|
||||
function stop_instance() {
|
||||
CONT=`docker ps -q --filter=name=${INSTANCE_NAME}`
|
||||
if [ "${CONT}" != "" ]; then
|
||||
echo "Stopping container ${INSTANCE_NAME}"
|
||||
docker stop "${INSTANCE_NAME}"
|
||||
fi
|
||||
# We remove the instance always
|
||||
CONT=`docker ps -a -q --filter=name=${INSTANCE_NAME}`
|
||||
if [ "${CONT}" != "" ]; then
|
||||
echo "Removing container ${INSTANCE_NAME}"
|
||||
docker rm "${INSTANCE_NAME}"
|
||||
fi
|
||||
}
|
||||
|
||||
function start_instance() {
|
||||
echo "Starting container ${INSTANCE_NAME}"
|
||||
docker run -d --network="${NETWORK_TYPE}" -p "${PORT_MAPPING}" --name "${INSTANCE_NAME}" "${TAG}"
|
||||
}
|
||||
|
||||
function print_usage() {
|
||||
echo "container_webtest start|stop"
|
||||
echo "Starts or stops the container. Builds the images if necessary"
|
||||
}
|
||||
|
||||
if [ "${START_ARG}" == "start" ]; then
|
||||
IMG=`docker images -q ${TAG}`
|
||||
# Build the image, if it does not exist
|
||||
if [ "${IMG}" == "" ]; then
|
||||
echo "Building image ${TAG}"
|
||||
DOCKER_DIR="${HERE}/../docker/${DOCKER_CFG}"
|
||||
MY_PWD=`pwd`
|
||||
cd ${DOCKER_DIR} || { echo "Could not change to docker directory ${DOCKER_CFG}"; exit 1; }
|
||||
docker build --force-rm -t "${TAG}" .
|
||||
if [ $? -ne 0 ]; then
|
||||
cd ${MY_PWD}
|
||||
echo "Could not build docker image"
|
||||
exit 1
|
||||
fi
|
||||
cd ${MY_PWD}
|
||||
IMG=`docker images -q ${TAG}`
|
||||
fi
|
||||
# Removing old instances
|
||||
stop_instance
|
||||
# Starting
|
||||
start_instance
|
||||
elif [ "${START_ARG}" == "stop" ]; then
|
||||
stop_instance
|
||||
else
|
||||
print_usage
|
||||
fi
|
||||
|
Loading…
Reference in New Issue