Browse Source

Add support for running regression tests in Bullseye-based docker images.

master
Dianne Skoll 2 weeks ago
parent
commit
7c6e12bdcb
Signed by: dianne GPG Key ID: 685A5A5E511D30E2
  1. 53
      docker/Dockerfile.bullseye.postfix
  2. 55
      docker/Dockerfile.bullseye.sendmail
  3. 6
      docker/build-docker-container
  4. 2
      docker/run-all-regression-tests
  5. 24
      docker/run-regression-tests-on-docker
  6. 29
      regression-tests/t/19-rspamd.t

53
docker/Dockerfile.bullseye.postfix

@ -0,0 +1,53 @@
FROM debian:bullseye
LABEL maintainer="Dianne Skoll <dianne@skollsoft.com>"
ARG APT_PROXY
COPY docker-testfiles/ /root/docker-testfiles/
COPY docker-testfiles/waiter.pl /usr/bin
RUN /bin/bash /root/docker-testfiles/set-apt-proxy "$APT_PROXY"
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential \
clamav-daemon \
cpanminus \
debhelper \
iproute2 \
perl \
perl-modules-5.32 \
postfix \
procps \
psmisc \
libbsd-dev \
libjson-any-perl \
libmilter-dev \
libmilter1.0.1 \
libmime-tools-perl \
libio-socket-ssl-perl \
libhtml-parser-perl \
libtest-deep-perl \
libfile-find-rule-perl \
libdigest-sha-perl \
libperl-dev \
libdbd-sqlite3-perl \
net-tools \
rspamd \
rsyslog \
spamassassin
RUN adduser --system --group --home /var/spool/mailmunge mailmunge
RUN addgroup --system mailmunge
# Add clamav to "mailmunge" group so we can do virus-scanning
RUN addgroup clamav mailmunge
RUN adduser --home /home/testuser --gecos 'Test User' --disabled-password testuser
# Install File::VirusScan from cpan - not packaged in Debian
RUN cpanm -n File::VirusScan
CMD /usr/bin/waiter.pl

55
docker/Dockerfile.bullseye.sendmail

@ -0,0 +1,55 @@
FROM debian:bullseye
LABEL maintainer="Dianne Skoll <dianne@skollsoft.com>"
ARG APT_PROXY
COPY docker-testfiles/ /root/docker-testfiles/
COPY docker-testfiles/waiter.pl /usr/bin
RUN /bin/bash /root/docker-testfiles/set-apt-proxy "$APT_PROXY"
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
build-essential \
clamav-daemon \
cpanminus \
debhelper \
iproute2 \
perl \
perl-modules-5.32 \
procps \
psmisc \
libbsd-dev \
libjson-any-perl \
libmilter-dev \
libmilter1.0.1 \
libmime-tools-perl \
libio-socket-ssl-perl \
libhtml-parser-perl \
libtest-deep-perl \
libfile-find-rule-perl \
libdigest-sha-perl \
libperl-dev \
libdbd-sqlite3-perl \
net-tools \
rspamd \
rsyslog \
spamassassin \
sendmail \
sendmail-bin \
sendmail-cf
RUN adduser --system --group --home /var/spool/mailmunge mailmunge
RUN addgroup --system mailmunge
# Add clamav to "mailmunge" group so we can do virus-scanning
RUN addgroup clamav mailmunge
RUN adduser --home /home/testuser --gecos 'Test User' --disabled-password testuser
# Install File::VirusScan from cpan - not packaged in Debian
RUN cpanm -n File::VirusScan
CMD /usr/bin/waiter.pl

6
docker/build-docker-container

@ -1,11 +1,11 @@
#!/bin/sh
if test "$1" != "sendmail" -a "$1" != "postfix" ; then
echo "Usage: $0 sendmail|postfix debian|rocky"
echo "Usage: $0 sendmail|postfix debian|rocky|bullseye"
exit 1
fi
if test "$2" != "debian" -a "$2" != "rocky" ; then
echo "Usage: $0 sendmail|postfix debian|rocky"
if test "$2" != "debian" -a "$2" != "rocky" -a "$2" != "bullseye"; then
echo "Usage: $0 sendmail|postfix debian|rocky|bullseye"
exit 1
fi

2
docker/run-all-regression-tests

@ -1,7 +1,7 @@
#!/bin/sh
cd `dirname $0`
for os in debian rocky ; do
for os in debian rocky bullseye; do
for mta in postfix sendmail; do
./run-regression-tests-on-docker $mta $os "$@"
done

24
docker/run-regression-tests-on-docker

@ -1,15 +1,21 @@
#!/bin/sh
if test "$1" != "sendmail" -a "$1" != "postfix" ; then
echo "Usage: $0 sendmail|postfix debian|rocky [-f] [-v] [-c]"
echo "Usage: $0 sendmail|postfix debian|rocky|bullseye [-f] [-v] [-c]"
exit 1
fi
if test "$2" != "debian" -a "$2" != "rocky" ; then
echo "Usage: $0 sendmail|postfix debian|rocky [-f] [-v] [-c]"
if test "$2" != "debian" -a "$2" != "rocky" -a "$2" != "bullseye"; then
echo "Usage: $0 sendmail|postfix debian|rocky|bullseye [-f] [-v] [-c]"
exit 1
fi
MTA="$1"
OS="$2"
if test "$OS" = "debian" -o "$OS" = "bullseye" ; then
FLAVOR=debian
else
FLAVOR=rocky
fi
IMAGE=mm-$MTA-$OS-image
CONTAINER=mm-$MTA-$OS
FORCE_REBUILD=0
@ -66,7 +72,7 @@ REBUILD=1
docker exec "$CONTAINER" test -d "/root/mailmunge-$VERSION"
if test $? = 0 ; then
if test "$OS" = "debian" ; then
if test "$FLAVOR" = "debian" ; then
docker exec "$CONTAINER" dpkg -l mailmunge-base
else
false
@ -81,7 +87,7 @@ if test $? = 0 ; then
fi
if test "$REBUILD" = 1 ; then
if test "$OS" = "debian" ; then
if test "$FLAVOR" = "debian" ; then
# Purge any existing .debs
docker exec "$CONTAINER" /bin/sh -c "dpkg -l mailmunge > /dev/null 2>&1 && apt --assume-yes purge mailmunge mailmunge-base libmailmunge-perl"
# Create a tarball of mailmunge and copy it to the container
@ -105,13 +111,13 @@ docker cp docker-testfiles "$CONTAINER:/root/"
docker exec "$CONTAINER" /bin/sh -c "mkdir -p /etc/mailmunge"
docker cp ../regression-tests/filter/mailmunge-filter.pl "$CONTAINER:/etc/mailmunge/"
docker exec "$CONTAINER" /bin/sh -c "chmod a+rx /etc/mailmunge/mailmunge-filter.pl"
if test "$OS" = "debian" ; then
if test "$FLAVOR" = "debian" ; then
docker exec "$CONTAINER" /bin/sh -c "addgroup clamav mailmunge"
fi
docker exec "$CONTAINER" /bin/sh -c "cp /root/docker-testfiles/etc-default-mailmunge /etc/default/mailmunge"
docker exec "$CONTAINER" /bin/sh -c "/etc/init.d/mailmunge restart"
if test "$OS" = "debian" ; then
if test "$FLAVOR" = "debian" ; then
docker exec "$CONTAINER" /bin/sh -c "/etc/init.d/clamav-daemon restart; /etc/init.d/rsyslog start; /etc/init.d/rspamd start"
else
echo "Starting services..."
@ -127,7 +133,7 @@ else
fi
if test "$MTA" = "postfix" ; then
if test "$OS" = "debian" ; then
if test "$FLAVOR" = "debian" ; then
docker exec "$CONTAINER" /bin/sh -c "/etc/init.d/postfix restart"
else
docker exec "$CONTAINER" /bin/sh -c "postfix reload || postfix start || true"
@ -135,7 +141,7 @@ if test "$MTA" = "postfix" ; then
else
docker exec "$CONTAINER" /bin/sh /root/docker-testfiles/qualify-hostname.sh
docker exec "$CONTAINER" /bin/sh -c "pkill sendmail"
if test "$OS" = "debian" ; then
if test "$FLAVOR" = "debian" ; then
docker exec "$CONTAINER" /bin/sh -c "/etc/init.d/sendmail restart"
else
docker exec "$CONTAINER" /bin/sh -c "/usr/sbin/sendmail -bd"

29
regression-tests/t/19-rspamd.t

@ -21,10 +21,10 @@ my $msg = make_msg('rspamd', 'gtube-msg');
my $ans = smtp_send($ip, 'continue', 'continue@example.com', ['user1@example.com'], $msg);
cmp_deeply($ans, {
code => 200,
dsn => '2.0.0',
txt => "OK",
stage => 'quit'}, 'Got expected success');
code => 200,
dsn => '2.0.0',
txt => "OK",
stage => 'quit'}, 'Got expected success');
wait_for_files($outfile);
@ -62,6 +62,24 @@ if (-f '/etc/redhat-release') {
milter => ignore(),
}},
"Got expected rspamd results") or diag(explain($hash));
} elsif (`cat /etc/debian_version` =~ /^11/) {
cmp_deeply($hash, {
response => {delay => 0, message => 'ok', status => 'CONTINUE'},
results => {
action => 'reject',
is_skipped => ignore(),
'message-id' => ignore(),
messages => {smtp_message => 'Gtube pattern'},
milter => ignore(),
required_score => re('^\d+$'),
score => re('^\d+$'),
symbols => {GTUBE => {metric_score => '0',
name => 'GTUBE',
score => '0'
}
},
time_real => ignore()}},
'Got expected rspamd results') or diag(explain($hash));
} else {
cmp_deeply($hash, {
response => {delay => 0, status => 'CONTINUE', message => 'ok' },
@ -79,7 +97,4 @@ if (-f '/etc/redhat-release') {
"Got expected rspamd results") or diag(explain($hash));
}
done_testing;

Loading…
Cancel
Save