Skip to content
Permalink
Browse files
Closes #77
A Docker container to run integration tests in

Run with:
```
docker run --rm -v $(pwd):/build \
  -v ~/.m2/repository/:/maven-repo  \
  -e DOCKER_USER_ID=$(id -u) -e DOCKER_GROUP_ID=$(id -g)  \  --> use this line only on linux machines
  brooklyn-itest \
  mvn -B clean install -PIntegration -Dmaven.test.failure.ignore=true --fail-never
```
  • Loading branch information
neykov committed Mar 2, 2017
2 parents f6eeb70 + a8c74bb commit 56994e2aae75197a411082404cd09ce192269c6b
Showing 2 changed files with 103 additions and 0 deletions.
@@ -0,0 +1,56 @@
# 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.
#

FROM maven:3.3.9-jdk-7
MAINTAINER Svetoslav Neykov "svetoslav.neykov@cloudsoft.io"

# For Alpine:
# FROM maven:3.3.9-jdk-8-alpine
# RUN apk add --update --no-cache bash netcat-openbsd sudo wget openssh
# RUN ssh-keygen -A
# This is missing knife - adding it would grow the image size considerably
# making it on par with the full debian image. Also some tests fail
# because of differences in the accepted arguments of the busybox provided tools.

RUN apt-get update && \
apt-get install -y --no-install-recommends net-tools ssh sudo wget && \
rm -rf /var/lib/apt/lists/*
RUN mkdir /etc/skel/.m2 && \
echo "<settings xmlns='http://maven.apache.org/SETTINGS/1.0.0'>" > /etc/skel/.m2/settings.xml && \
echo " <localRepository>/maven-repo</localRepository>" >> /etc/skel/.m2/settings.xml && \
echo "</settings>" >> /etc/skel/.m2/settings.xml && \
: The following are integration tests requirements && \
echo "127.0.0.1 localhost1 localhost2 localhost3 localhost4" >> /etc/hosts && \
mkdir /etc/skel/.brooklyn && \
cd /etc/skel/.brooklyn && \
wget -q http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz && \
gunzip GeoLite2-City.mmdb.gz && \
echo "brooklyn.location.named.localhost-passphrase=localhost" >> brooklyn.properties && \
echo "brooklyn.location.named.localhost-passphrase.privateKeyFile=~/.ssh/id_rsa_with_passphrase" >> brooklyn.properties && \
echo "brooklyn.location.named.localhost-passphrase.privateKeyPassphrase=mypassphrase" >> brooklyn.properties && \
chmod 600 brooklyn.properties

# Add the brooklyn user at runtime so that we can set its USER_ID same as the user that's calling "docker run"
# We need them the same so that the mounted /build volume is accessible from inside the container.
COPY entrypoint.sh /usr/local/bin/entrypoint.sh

VOLUME /build
VOLUME /maven-repo

ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["mvn -B clean install -PIntegration"]
@@ -0,0 +1,47 @@
#!/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.
#

set -e
if [ "$(id -u)" = "0" ]; then
echo "Setting up system"
echo "brooklyn ALL = (ALL) NOPASSWD: ALL" > /etc/sudoers.d/brooklyn
chmod 0440 /etc/sudoers.d/brooklyn
GROUP_ID=${DOCKER_GROUP_ID:-1000}
USER_ID=${DOCKER_USER_ID:-1000}
#(alpine): addgroup -g $GROUP_ID brooklyn
#(alpine): adduser -g "brooklyn" -s /bin/bash -G brooklyn -u $USER_ID -D brooklyn
groupadd -g $GROUP_ID brooklyn
echo "Creating user"
useradd --shell /bin/bash -u $USER_ID -o -c "" -m -k /etc/skel -g brooklyn brooklyn
chown brooklyn:brooklyn /home/brooklyn
sudo service ssh start
exec sudo -H -u brooklyn -i /usr/local/bin/entrypoint.sh $@
else
echo "Setting up Brooklyn"
# Integration tests requirements
ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
ssh-keygen -t rsa -N "mypassphrase" -f ~/.ssh/id_rsa_with_passphrase
cat ~/.ssh/id_rsa_with_passphrase.pub >> ~/.ssh/authorized_keys

cd /build
echo "Available entropy in container: $(cat /proc/sys/kernel/random/entropy_avail)"
exec $@
fi

0 comments on commit 56994e2

Please sign in to comment.