Browse Source

Regression tests now work on Rocky Linux with Postfix.

master
Dianne Skoll 3 months ago
parent
commit
b28129b9ea
Signed by: dianne GPG Key ID: 685A5A5E511D30E2
  1. 4
      docker/Dockerfile.rocky.postfix
  2. 43
      docker/docker-testfiles/setup-tests.sh
  3. 12
      docker/run-regression-tests-on-docker
  4. 3
      regression-tests/t/18-greylist.t
  5. 48
      regression-tests/t/19-rspamd.t

4
docker/Dockerfile.rocky.postfix

@ -10,7 +10,7 @@ RUN dnf -y install epel-release
RUN dnf config-manager --set-enabled powertools
RUN dnf -y install perl-MIME-tools perl-Sys-Syslog sendmail-milter postfix perl-ExtUtils-MakeMaker sendmail-milter-devel perl-Test perl-Test-Simple perl-Test-Deep perl-HTML-Parser perl-Net-DNS perl-File-Find-Rule spamassassin perl-JSON-Any perl-DBD-SQLite perl-Test-Pod perl-Test-Pod-Coverage clamav clamav-data clamd perl-App-cpanminus rsyslog
RUN dnf -y install perl-MIME-tools perl-Sys-Syslog sendmail-milter postfix perl-ExtUtils-MakeMaker sendmail-milter-devel perl-Test perl-Test-Simple perl-Test-Deep perl-HTML-Parser perl-Net-DNS perl-File-Find-Rule spamassassin perl-JSON-Any perl-DBD-SQLite perl-Test-Pod perl-Test-Pod-Coverage clamav clamav-data clamd perl-App-cpanminus syslog-ng
RUN curl https://rspamd.com/rpm-stable/centos-8/rspamd.repo > /etc/yum.repos.d/rspamd.repo
@ -20,6 +20,8 @@ RUN dnf -y update
RUN dnf -y install rspamd
RUN cpanm -n File::VirusScan
RUN adduser --system --home /var/spool/mailmunge mailmunge
RUN mkdir /var/run/rspamd

43
docker/docker-testfiles/setup-tests.sh

@ -3,6 +3,16 @@
# Set up Docker machine for tests
#
# Figure out what OS we're on
if test -f /etc/debian_version ; then
OS=debian
elif test -f /etc/redhat-release ; then
OS=rocky
else
echo "**** COULD NOT DETERMINE LINUX DISTRO... BAILING"
exit 1
fi
# Change into this directory so we can find files
cd `dirname $0` || exit 1
@ -10,7 +20,11 @@ cd `dirname $0` || exit 1
rm -f /usr/share/spamassassin/20_compensate.cf
# Restart rsyslog
/etc/init.d/rsyslog restart
if test "$OS" = "debian" ; then
/etc/init.d/rsyslog restart
else
/usr/sbin/rsyslogd
fi
# Fix up /etc/hosts
grep 'example.com' /etc/hosts > /dev/null 2>&1
@ -35,6 +49,10 @@ if test -d /etc/postfix ; then
RESTART_POSTFIX=1
fi
# On Rocky Linux only
if test "$OS" = "rocky" ; then
sed -i -e 's/^inet_interfaces = localhost/#inet_interfaces = localhost/' /etc/postfix/main.cf
fi
# Fix mydestination
fgrep example.com /etc/postfix/main.cf > /dev/null 2>&1
if test $? != 0 ; then
@ -83,6 +101,12 @@ else
fi
fi
# Fix locale on Rocky
if test "$OS" = "rocky" ; then
echo "LANG=C" > /etc/locale.conf
export LANG=C
fi
# For postfix, alias file is /etc/aliases. For Sendmail,
# it is /etc/mail/aliases
if test -d /etc/postfix ; then
@ -121,7 +145,20 @@ cp etc-default-mailmunge /etc/default/mailmunge || exit 1
cp mailmunge-test-savemail.pl /usr/local/bin && chmod 755 /usr/local/bin/mailmunge-test-savemail.pl
# Get virus database
freshclam || true
/etc/init.d/clamav-daemon restart
if test "$OS" = "debian" ; then
freshclam || true
/etc/init.d/clamav-daemon restart
else
sed -i -e 's|^#LocalSocket .*|LocalSocket /var/run/clamav/clamd.ctl|' /etc/clamd.d/scan.conf
mkdir /var/run/clamav
chown clamscan /var/run/clamav
mkdir /var/run/rspamd
chown _rspamd /var/run/rspamd
mkdir /tmp/mailmunge-drop
chmod 777 /tmp/mailmunge-drop
groupmems -g mailmunge -a clamscan
clamd || true
rspamd -u _rspamd -g _rspamd
fi
exit 0

12
docker/run-regression-tests-on-docker

@ -90,7 +90,11 @@ if test "$REBUILD" = 1 ; then
docker cp ../mailmunge-$VERSION.tar.gz "$CONTAINER:/root/" || bailout "docker cp failed"
docker exec "$CONTAINER" /bin/sh -c "cd /root && rm -f *.deb && rm -rf mailmunge-$VERSION && tar xf mailmunge-$VERSION.tar.gz && cd /root/mailmunge-$VERSION && ./configure && dpkg-buildpackage --no-sign && dpkg -i ../libmailmunge-action-boilerplate-perl_${VERSION}_all.deb ../libmailmunge-perl_${VERSION}_all.deb ../libmailmunge-test-getmx-perl_${VERSION}_all.deb ../libmailmunge-test-smtpforward-perl_${VERSION}_all.deb ../libmailmunge-test-spamassassin-perl_${VERSION}_all.deb ../libmailmunge-test-rspamd-perl_${VERSION}_all.deb ../libmailmunge-test-greylist-perl_${VERSION}_all.deb ../libtest-mailmunge-perl_${VERSION}_all.deb ../mailmunge-base_${VERSION}_amd64.deb ../mailmunge_${VERSION}_all.deb" || bailout "docker exec failed"
else
false
# Create a tarball of mailmunge and copy it to the container
make -C .. dist || bailout "make dist failed" || bailout "docker exec failed"
docker exec "$CONTAINER" /bin/sh -c "cd /root && rm -rf mailmunge*"
docker cp ../mailmunge-$VERSION.tar.gz "$CONTAINER:/root/" || bailout "docker cp failed"
docker exec "$CONTAINER" /bin/sh -c "cd /root && tar xf mailmunge-$VERSION.tar.gz && cd /root/mailmunge-$VERSION && ./configure --prefix=/usr && make && make install" || bailot "docker exec failed"
fi
fi
@ -109,7 +113,11 @@ docker exec "$CONTAINER" /bin/sh -c "/etc/init.d/rsyslog start"
docker exec "$CONTAINER" /bin/sh -c "/etc/init.d/rspamd start"
if test "$MTA" = "postfix" ; then
docker exec "$CONTAINER" /bin/sh -c "/etc/init.d/postfix restart"
if test "$OS" = "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"
fi
else
docker exec "$CONTAINER" /bin/sh /root/docker-testfiles/qualify-hostname.sh
docker exec "$CONTAINER" /bin/sh -c "pkill sendmail"

3
regression-tests/t/18-greylist.t

@ -6,6 +6,9 @@ use Test::Mailmunge::RegressionUtils;
my $ans;
# Force a filter reread to clear old data from in-memory sqlite DB
system("mm-mx-ctrl reread");
my $ip = get_smtp_server_ip();
my $msg = make_msg('nothing-fancy', 'generic-msg', 'greylistfile');

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

@ -45,20 +45,40 @@ while(defined($_ = $io->getline())) {
$io->close();
my $hash = JSON::Any->jsonToObj($json);
cmp_deeply($hash, {
response => {delay => 0, status => 'CONTINUE', message => 'ok' },
results => {
is_skipped => ignore(),
'message-id' => ignore(),
messages => { smtp_message => 'Gtube pattern' },
required_score => re('^\d+$'),
action => 'reject',
symbols => { GTUBE => { score => 0, name => 'GTUBE', metric_score => 0 }},
time_virtual => ignore(),
time_real => ignore(),
score => re('^\d+$'),
}},
"Got expected rspamd results");
# The default rspamd setup on Red Hat is different from
# Debian, so we expect different results.
if (-f '/etc/redhat-release') {
cmp_deeply($hash, {
response => {delay => 0, status => 'CONTINUE', message => 'ok' },
results => {
is_skipped => ignore(),
'message-id' => ignore(),
messages => { smtp_message => 'Gtube pattern' },
required_score => re('^\d+$'),
action => 'reject',
symbols => { GTUBE => { score => 0, name => 'GTUBE', metric_score => 0 }},
time_real => ignore(),
score => re('^\d+$'),
milter => ignore(),
}},
"Got expected rspamd results");
} else {
cmp_deeply($hash, {
response => {delay => 0, status => 'CONTINUE', message => 'ok' },
results => {
is_skipped => ignore(),
'message-id' => ignore(),
messages => { smtp_message => 'Gtube pattern' },
required_score => re('^\d+$'),
action => 'reject',
symbols => { GTUBE => { score => 0, name => 'GTUBE', metric_score => 0 }},
time_virtual => ignore(),
time_real => ignore(),
score => re('^\d+$'),
}},
"Got expected rspamd results");
}

Loading…
Cancel
Save