From c014714b925c61f68160d0089452bb1d3ba3fea6 Mon Sep 17 00:00:00 2001 From: Dave Miller Date: Sun, 5 Jul 2026 23:28:41 -0400 Subject: [PATCH 1/3] Bug 2052751: run tests from docker FASTER --- docker/images/Dockerfile.perl-testsuite | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/docker/images/Dockerfile.perl-testsuite b/docker/images/Dockerfile.perl-testsuite index a3b2b2964..2a729828f 100644 --- a/docker/images/Dockerfile.perl-testsuite +++ b/docker/images/Dockerfile.perl-testsuite @@ -29,8 +29,8 @@ 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 && \ @@ -38,6 +38,12 @@ RUN perl Makefile.PL && \ 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 From ccd0c52195bb4e97edcb4eb6aad8b5effac4fb0e Mon Sep 17 00:00:00 2001 From: Dave Miller Date: Sun, 5 Jul 2026 23:50:03 -0400 Subject: [PATCH 2/3] Let me pick tests to run from the command line --- docker/images/Dockerfile.perl-testsuite | 6 ++--- docker/run-tests-in-docker.sh | 31 ++++++++++++++++++------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/docker/images/Dockerfile.perl-testsuite b/docker/images/Dockerfile.perl-testsuite index 2a729828f..7452b6cdf 100644 --- a/docker/images/Dockerfile.perl-testsuite +++ b/docker/images/Dockerfile.perl-testsuite @@ -47,6 +47,6 @@ 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 [] +# Set a default test target but allow callers to override/append prove args. +ENTRYPOINT ["prove", "-Ilocal/lib/perl5"] +CMD ["t"] diff --git a/docker/run-tests-in-docker.sh b/docker/run-tests-in-docker.sh index 1b3d5f219..844b050d4 100644 --- a/docker/run-tests-in-docker.sh +++ b/docker/run-tests-in-docker.sh @@ -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" @@ -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." From 6f0f046c1fea03dd7126b31801f374950bc169cb Mon Sep 17 00:00:00 2001 From: Dave Miller Date: Mon, 6 Jul 2026 00:08:36 -0400 Subject: [PATCH 3/3] Allow perl -c to be invoked in Docker from the command line for testing --- docker/images/Dockerfile.perl-testsuite | 10 ++++++++-- docker/images/perl-testsuite-entrypoint.sh | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 docker/images/perl-testsuite-entrypoint.sh diff --git a/docker/images/Dockerfile.perl-testsuite b/docker/images/Dockerfile.perl-testsuite index 7452b6cdf..2df452541 100644 --- a/docker/images/Dockerfile.perl-testsuite +++ b/docker/images/Dockerfile.perl-testsuite @@ -47,6 +47,12 @@ COPY . /app/ # Run checksetup RUN perl checksetup.pl --no-database --default-localconfig --no-templates -# Set a default test target but allow callers to override/append prove args. -ENTRYPOINT ["prove", "-Ilocal/lib/perl5"] +# 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"] diff --git a/docker/images/perl-testsuite-entrypoint.sh b/docker/images/perl-testsuite-entrypoint.sh new file mode 100644 index 000000000..900c50f2c --- /dev/null +++ b/docker/images/perl-testsuite-entrypoint.sh @@ -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