MT#15071 Docker setup for api-rest tests

For usage instructions please look at the bottom of the Dockerfile,
usage similar to what we already have for the docker selenium tests.

Known problems:

1) In t/api-rest/api-journals.t there's a failure, though all the tests
   actually seem to run fine then:

| encountered object 'true', but neither allow_blessed nor convert_blessed settings are enabled at /usr/share/perl5/JSON.pm line 154.
| # Tests were run but no plan was declared and done_testing() was not seen.
| # Looks like your test exited with 255 just after 1130.
| [...]
| t/api-rest/api-journals.t               (Wstat: 65280 Tests: 1130 Failed: 0)
|   Non-zero exit status: 255
|   Parse errors: No plan found in TAP output
| Files=25, Tests=8363, 347 wallclock secs ( 1.14 usr  0.11 sys + 32.59 cusr  2.23 csys = 36.07 CPU)

2) Failures in t/api-rest/api-balanceintervals.t, might be caused by
   timing issues/rerunning them, needs investigation though:

| t/api-rest/api-balanceintervals.t (Wstat: 65024 Tests: 1875 Failed: 318)
|   Failed tests:  51, 56-59, 62, 67, 70, 75-80, 83, 88, 108-109
|  [...]

Change-Id: I5d697cab4a1a4c6697857fc63c03b8d3fd8965d2
changes/72/2672/3
Michael Prokop 10 years ago
parent 7dfc5fda21
commit 968ed762e6

@ -0,0 +1,68 @@
# TODO - switch to sipwise internal one
FROM debian:jessie
# Important! Update this no-op ENV variable when this Dockerfile
# is updated with the current date. It will force refresh of all
# of the base images and things like `apt-get update` won't be using
# old cached versions when the Dockerfile is built.
ENV REFRESHED_AT 2015-09-15
# mirrors behind httpredir randomly throw `Error reading from server. Remote end closed connection`
# and we want to be independent from any external services anyway
# TODO - the release-trunk-jessie is too dynamic yet, though required for some build/test dependencies
RUN apt-get update && apt-get -y install apt-transport-https wget
RUN echo "# generated by Dockerfile from ngcp-panel at $(date)\n\
deb https://debian.sipwise.com/debian jessie main\n\
deb https://debian.sipwise.com/debian jessie-updates main\n\
deb https://debian-security.sipwise.com/debian-security jessie-security main contrib non-free\n\
deb https://deb.sipwise.com/autobuild/ release-trunk-jessie main\n" > /etc/apt/sources.list
RUN wget -O /etc/apt/trusted.gpg.d/sipwise.gpg https://deb.sipwise.com/spce/sipwise.gpg
RUN apt-get update
RUN apt-get install --assume-yes \
devscripts \
git \
libtap-formatter-junit-perl \
lsof \
net-tools \
vim-tiny \
wget
RUN adduser --disabled-password --gecos="REST-API Testuser" testuser
WORKDIR /tmp/
COPY control /tmp/
RUN mk-build-deps /tmp/control
RUN dpkg --force-depends -i /tmp/ngcp-panel-tests-rest-api-build-deps_1.0_all.deb
RUN apt-get --assume-yes -f install
# for prove execution
RUN wget http://deb.sipwise.com/files/libtest-pretty-perl_0.31-1~bpo80+1_all.deb
RUN dpkg --force-depends -i libtest-pretty-perl_0.31-1~bpo80+1_all.deb
RUN apt-get --assume-yes -f install
# useful for debugging tests
RUN apt-get -y install libdata-printer-perl
RUN apt-get clean
RUN echo "cd /code && ./t/api-rest/testrunner 1.2.3.4" > /home/testuser/.bash_history
RUN echo "su - testuser" > /root/.bash_history
WORKDIR /home/testuser
################################################################################
# Instructions for usage
# ----------------------
# When you want to build the base image from scratch (jump to the next section if you don't want to build yourself!):
# % docker build --tag="ngcp-panel-tests-rest-api-jessie" .
# % docker run --rm -i -t -v $(pwd)/../..:/code:rw ngcp-panel-tests-rest-api-jessie:latest bash
#
# Use the existing docker image:
# % docker pull docker1.mgm.sipwise.com/ngcp-panel-tests-rest-api-jessie
# % docker run --rm -i -t -v $(pwd)/../..:/code:rw docker1.mgm.sipwise.com/ngcp-panel-tests-rest-api-jessie:latest bash
#
# Inside docker:
# su - testuser
# cd /code && ./t/api-rest/testrunner $IP_OF_NGCP_SYSTEM # IP_OF_NGCP_SYSTEM can be e.g. IP of a `vagrant up ce-trunk` system (eth1)
################################################################################

@ -0,0 +1,20 @@
Source: ngcp-panel-tests-rest-api
Build-Depends: libboolean-perl,
libdata-hal-perl,
libdata-validate-ip-perl,
libdatetime-format-iso8601-perl,
libdatetime-format-strptime-perl,
libdbix-class-perl,
libemail-sender-perl,
libhtml-formhandler-perl,
libjson-perl,
libnetaddr-ip-perl,
libsereal-decoder-perl,
libsereal-encoder-perl,
libsipwise-base-perl,
libstring-mkpasswd-perl,
libtap-harness-archive-perl,
libtext-table-perl,
libtime-warp-perl,
libtrycatch-perl,
libuuid-perl

@ -0,0 +1,33 @@
#!/bin/bash
if ! [ -f /.dockerinit ]; then
echo "Not running inside docker, exiting to avoid data damage." >&2
exit 1
fi
set -e
set -u
if [ -z "${1:-}" ] ; then
echo "Usage: $0 <testsystem>" >&2
echo
echo "Usage example: $0 192.168.88.162"
exit 1
fi
SERVER="${1}"
echo "################################################################################"
echo "Finished main setup, now running tests ..."
RC=0
# api-threads.t and api-balanceintervals.t are failing with the "-Pretty option" :(
CATALYST_SERVER="https://${SERVER}:1443" prove -v --color -l -It/lib \
t/api-rest/*.t | tee -a /code/api-rest.pretty || RC=$?
#CATALYST_SERVER="https://${SERVER}:1443" prove --formatter TAP::Formatter::JUnit -l -It/lib t/api-rest/*.t | tee -a /code/api-rest.xml || RC=$?
echo "Finished test execution, test execution returned with exit code ${RC}."
for file in /code/api-rest.pretty /code/api-rest.xml ; do
if [ -f "$file" ] ; then
echo "Test results available at ${file}"
fi
done
echo "################################################################################"
Loading…
Cancel
Save