Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions docker/images/Dockerfile.perl-testsuite
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,30 @@ RUN apt-get update && apt-get -y dist-upgrade && \
unzip wget && \
rm -rf /var/lib/apt/lists/*

# Copy the source code
COPY . /app/
# Copy just enough to get the list of dependencies
COPY Bugzilla.pm Makefile.PL gen-cpanfile.pl /app/

# Run Makefile.PL and install dependencies
RUN perl Makefile.PL && \
cpanm --notest --quiet --local-lib="/app/local" Module::CPANfile && \
make cpanfile GEN_CPANFILE_ARGS='-A -U oracle -U mariadb -U pg -U mysql' && \
cpanm --notest --quiet --local-lib="/app/local" -f --installdeps .

# Now copy all of the source. Splitting it from the dependency-related files
# above allows Docker to cache the dependency install step unless the
# dependencies change, saving a *lot* of build time when you just want to run
# tests
COPY . /app/

# Run checksetup
RUN perl checksetup.pl --no-database --default-localconfig --no-templates

# Set the default command to run tests
ENTRYPOINT ["prove", "-Ilocal/lib/perl5", "t"]
CMD []
# Support both prove (default) and perl commands via a dispatcher script.
# the perl option is so you can do `perl -c` on a file in the container
# to make sure it compiles when you don't have dependencies on the host
# machine.
COPY docker/images/perl-testsuite-entrypoint.sh /usr/local/bin/perl-testsuite-entrypoint
RUN chmod +x /usr/local/bin/perl-testsuite-entrypoint

ENTRYPOINT ["/usr/local/bin/perl-testsuite-entrypoint"]
CMD ["t"]
20 changes: 20 additions & 0 deletions docker/images/perl-testsuite-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/sh
set -eu

if [ "$#" -eq 0 ]; then
exec prove -Ilocal/lib/perl5 t
fi

case "$1" in
prove)
shift
exec prove -Ilocal/lib/perl5 "$@"
;;
perl)
shift
exec perl -I/app -I/app/local/lib/perl5 "$@"
;;
*)
exec prove -Ilocal/lib/perl5 "$@"
;;
esac
31 changes: 23 additions & 8 deletions docker/run-tests-in-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export CIRCLE_BUILD_URL=""

TEST_NAME="test_bmo"
DOCKER_COMPOSE_FILE=docker-compose.test-mysql.yml
DEFAULT_TEST_ARGS=(-q -f t/bmo/*.t)
SUITE_ARGS=()
if [ "$#" -eq 0 ]; then
echo "Available test options:"
echo " 1) sanity - Run sanity tests"
Expand All @@ -36,28 +38,41 @@ if [ "$#" -eq 0 ]; then
*) echo "Invalid choice. Using default (mysql)"; set -- "mysql" ;;
esac
fi
if [ "$1" == "sanity" ]; then
SUITE="$1"
shift
SUITE_ARGS=("$@")

if [ "$SUITE" == "sanity" ]; then
DOCKER_COMPOSE_FILE=docker-compose.test-mysql.yml
TEST_NAME="test_sanity"
elif [ "$1" == "mysql" ]; then
elif [ "$SUITE" == "mysql" ]; then
DOCKER_COMPOSE_FILE=docker-compose.test-mysql.yml
elif [ "$1" == "pg" ]; then
elif [ "$SUITE" == "pg" ]; then
DOCKER_COMPOSE_FILE=docker-compose.test-pg.yml
elif [ "$1" == "sqlite" ]; then
elif [ "$SUITE" == "sqlite" ]; then
DOCKER_COMPOSE_FILE=docker-compose.test-sqlite.yml
elif [ "$1" == "mariadb" ]; then
elif [ "$SUITE" == "mariadb" ]; then
DOCKER_COMPOSE_FILE=docker-compose.test-mariadb.yml
elif [ "$1" == "release" ]; then
elif [ "$SUITE" == "release" ]; then
DOCKER_FILE=docker/images/Dockerfile.perl-testsuite
if $DOCKER build -t bugzilla-release-test -f "$DOCKER_FILE" .; then
$DOCKER run --rm bugzilla-release-test
$DOCKER run --rm bugzilla-release-test "${SUITE_ARGS[@]}"
else
echo "docker build failed."
fi
exit $?
else
echo "Unknown test suite: $SUITE"
echo "Usage: $0 [sanity|mysql|pg|sqlite|mariadb|release] [suite args...]"
exit 1
fi

if [ "${#SUITE_ARGS[@]}" -eq 0 ]; then
SUITE_ARGS=("${DEFAULT_TEST_ARGS[@]}")
fi

if $DOCKER compose -f "$DOCKER_COMPOSE_FILE" build; then
if $DOCKER compose -f "$DOCKER_COMPOSE_FILE" run --rm --name bugzilla6.test bugzilla6.test "$TEST_NAME" -q -f t/bmo/*.t; then
if $DOCKER compose -f "$DOCKER_COMPOSE_FILE" run --rm --name bugzilla6.test bugzilla6.test "$TEST_NAME" "${SUITE_ARGS[@]}"; then
$DOCKER compose -f "$DOCKER_COMPOSE_FILE" down
else
echo "docker compose run failed."
Expand Down
Loading