Skip to content

Commit

Permalink
Move test scripts to installers module. Use maven resource filtering …
Browse files Browse the repository at this point in the history
…to replace version and paths to installers in test scripts.

git-svn-id: https://svn.apache.org/repos/asf/directory/apacheds/trunk@1676025 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
seelmann committed Apr 25, 2015
1 parent 42665df commit 0119bc7
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 52 deletions.
29 changes: 29 additions & 0 deletions installers/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,35 @@
</build>
</profile>

<profile>
<id>docker</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<resources>
<resource>
<directory>src/test/docker</directory>
<filtering>true</filtering>
</resource>
</resources>
<outputDirectory>${project.build.directory}/docker</outputDirectory>
</configuration>
<executions>
<execution>
<phase>generate-test-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

</profiles>

<build>
Expand Down
24 changes: 8 additions & 16 deletions resources/docker/bin.test → installers/src/test/docker/bin.test
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,8 @@
#
# Script to test binary installer within Docker container.
#
#
# Run with official Java image (Debian 8, OpenJDK 8):
#
# cat bin.test | docker run -i --rm -e URL="<URL to .bin>" -e VERSION="<ApacheDS version>" java:8
#


NAME="apacheds-${VERSION}"
NAME="apacheds-${project.version}"
DIRNAME="${NAME}"
SERVICE_NAME="${NAME}-default"

Expand All @@ -41,17 +35,11 @@ set -e
# trace commands
set -x

# install ldapsearch and tools
apt-get -qq update && apt-get -qq -y install ldap-utils netcat

# download
wget -q -O apacheds.bin ${URL}

# install
chmod +x apacheds.bin
chmod +x /apacheds.bin
# skip license text
export MORE="\+10000"
# agreee to license terms and accept default install options
#export MORE="-10000"
# agree to license terms and accept default install options
./apacheds.bin << END_OF_RESPONSES
yes
Expand All @@ -70,6 +58,10 @@ test -d /var/lib/${DIRNAME}/default
# assert not running
service ${SERVICE_NAME} status | grep "ApacheDS - default is not running"

# install ldapsearch and tools
apt-get -qq update
apt-get -qq -y install ldap-utils netcat

# start
service ${SERVICE_NAME} start
wait_for_apacheds
Expand Down
30 changes: 6 additions & 24 deletions resources/docker/deb.test → installers/src/test/docker/deb.test
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,8 @@
#
# Script to test Debian installer within Docker container.
#
#
# Run with official Java image (Debian 8, OpenJDK 8):
#
# cat deb.test | docker run -i --rm -e URL="<URL to .deb>" -e VERSION="<ApacheDS version>" java:8
#
#
# Run with 'dockerfile' Java image (Ubuntu 14.04, Oracle Java 7):
#
# cat deb.test | docker run -i --rm -e URL="<URL to .deb>" -e VERSION="<ApacheDS version>" dockerfile/java:oracle-java7
#
#
# Run with 32-bit Java image (Ubuntu 14.04 i386, OpenJDK 7):
#
# cat deb.test | docker run -i --rm -e URL="<URL to .deb>" -e VERSION="<ApacheDS version>" cato1971/java-32bit:7-jre
#


NAME="apacheds-${VERSION}"
NAME="apacheds-${project.version}"
DIRNAME="${NAME}"
SERVICE_NAME="${NAME}-default"

Expand All @@ -51,14 +35,8 @@ set -e
# trace commands
set -x

# install ldapsearch and tools
apt-get -qq update && apt-get -qq -y install ldap-utils netcat

# download
wget -q -O apacheds.deb ${URL}

# install
dpkg -i apacheds.deb
dpkg -i /apacheds.deb

# assert installed
dpkg -l | grep apacheds
Expand All @@ -71,6 +49,10 @@ test -d /var/lib/${DIRNAME}/default
# assert not running
service ${SERVICE_NAME} status | grep "ApacheDS - default is not running"

# install required tools
apt-get -qq update
apt-get -qq -y install ldap-utils netcat

# start
service ${SERVICE_NAME} start
wait_for_apacheds
Expand Down
20 changes: 8 additions & 12 deletions resources/docker/rpm.test → installers/src/test/docker/rpm.test
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,23 @@
# Please note to replace dashes '-' by underscores '_' in VERSION.
#

# stop execution if any command fails (i.e. exits with status code > 0)
set -e

# trace commands
set -x

NAME="apacheds-${VERSION}"
RPM_VERSION=$(echo "${project.version}" | tr - _)
NAME="apacheds-${RPM_VERSION}"
DIRNAME="${NAME}"
SERVICE_NAME="${NAME}-default"

wait_for_apacheds() {
timeout 15 sh -c "while ! nmap -Pn -p 10389 localhost | grep "10389.*open"; do sleep 1; done"
}

# stop execution if any command fails (i.e. exits with status code > 0)
set -e

# trace commands
set -x

# install packages
yum -y -q update
yum -y -q install wget java-1.8.0-openjdk openldap-clients nmap

# download
wget -q -O apacheds.rpm ${URL}
yum -y -q install java-1.8.0-openjdk openldap-clients nmap

# install
rpm -Uvh apacheds.rpm
Expand Down
66 changes: 66 additions & 0 deletions installers/src/test/docker/run-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#!/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

# Debian installer 64bit
DEB64="${project.build.directory}/installers/apacheds-${project.version}-amd64.deb"
if [ -f ${DEB64} ]
then
# Run deb installer with official Java image (Debian 8, OpenJDK 8, 64bit):
docker run -i --rm \
-v ${DEB64}:/apacheds.deb \
-v ${project.build.directory}/docker/deb.test:/deb.test \
java:8 bash /deb.test

# Run deb installer with 'dockerfile' Java image (Ubuntu 14.04, Oracle Java 7, 64bit):
docker run -i --rm \
-v ${DEB64}:/apacheds.deb \
-v ${project.build.directory}/docker/deb.test:/deb.test \
dockerfile/java:oracle-java7 bash /deb.test
fi

# Binary Installer 64bit
BIN64="${project.build.directory}/installers/apacheds-${project.version}-64bit.bin"
if [ -f ${BIN64} ]
then
# Run bin installer with official Java image (Debian 8, OpenJDK 8, 64bit):
docker run -i --rm \
-v ${BIN64}:/apacheds.bin \
-v ${project.build.directory}/docker/bin.test:/bin.test \
java:8 bash /bin.test
fi

# RPM installer 64bit
RPM64="${project.build.directory}/installers/apacheds-${project.version}-x86_64.rpm"
if [ -f ${RPM64} ]
then
# Run rpm installer with official Fedora (Fedora 21, OpenJDK 8)
#docker run -i --rm \
# -v ${RPM64}:/apacheds.rpm \
# -v ${project.build.directory}/docker/rpm.test:/rpm.test \
# fedora:latest bash /rpm.test

# Run rpm installer with official Centos (CentOS 7, OpenJDK 8)
docker run -i --rm \
-v ${RPM64}:/apacheds.rpm \
-v ${project.build.directory}/docker/rpm.test:/rpm.test \
centos:7 bash /rpm.test
fi

0 comments on commit 0119bc7

Please sign in to comment.