| |
@@ -0,0 +1,197 @@
|
| |
+ #!/bin/bash
|
| |
+ # vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
|
| |
+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| |
+ #
|
| |
+ # runtest.sh of /CoreOS/cyrus-imapd/Sanity/cassandane
|
| |
+ # Description: Cassandane is a Perl-based integration test suite for Cyrus.
|
| |
+ # Author: Martin Osvald <mosvald@redhat.com>
|
| |
+ #
|
| |
+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| |
+ #
|
| |
+ # Copyright (c) 2022 Red Hat, Inc.
|
| |
+ #
|
| |
+ # This program is free software: you can redistribute it and/or
|
| |
+ # modify it under the terms of the GNU General Public License as
|
| |
+ # published by the Free Software Foundation, either version 2 of
|
| |
+ # the License, or (at your option) any later version.
|
| |
+ #
|
| |
+ # This program is distributed in the hope that it will be
|
| |
+ # useful, but WITHOUT ANY WARRANTY; without even the implied
|
| |
+ # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
| |
+ # PURPOSE. See the GNU General Public License for more details.
|
| |
+ #
|
| |
+ # You should have received a copy of the GNU General Public License
|
| |
+ # along with this program. If not, see http://www.gnu.org/licenses/.
|
| |
+ #
|
| |
+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
| |
+
|
| |
+ # Include Beaker environment
|
| |
+ . /usr/share/beakerlib/beakerlib.sh || exit 1
|
| |
+
|
| |
+ PACKAGE="cyrus-imapd"
|
| |
+
|
| |
+ export CYRUS_USER=cyrus
|
| |
+ CYRUS_SRC_PATH=""
|
| |
+
|
| |
+ #
|
| |
+ # Variables that can be exported through 1minutetip -p parameter, i.e.: -p "VAR1=foo" -p "VAR2=bar" -p "VAR3=..."
|
| |
+ #
|
| |
+ # Download cyrus-imapd (and acompanying cassandane tests) from upstream git repo (if set to 1):
|
| |
+ #
|
| |
+ if [ -z "$UPSTREAM" ]; then
|
| |
+ UPSTREAM=0
|
| |
+ fi
|
| |
+ #
|
| |
+ # You can set location of *.rpm packages on koji by hand:
|
| |
+ #UPDATERPMS=https://kojipkgs.fedoraproject.org//work/tasks/8286/87158286/
|
| |
+ #
|
| |
+ # You can set location of .src.rpm on koji by hand (.src.rpm's koji task id is different from the rest of .rpm packages):
|
| |
+ #UPDATESRPM=https://kojipkgs.fedoraproject.org//work/tasks/8281/87158281/
|
| |
+ #
|
| |
+ # Don't keep the downloaded files between consecutive test runs (usefull when debugging some problem to conserve time and bandwidth):
|
| |
+ if [ -z "$KEEP_TMP_FILES" ]; then
|
| |
+ KEEP_TMP_FILES=0
|
| |
+ fi
|
| |
+ #
|
| |
+ # Example usage:
|
| |
+ #
|
| |
+ # Extract cassandane tests from provided .src.rpm and test binary packages from scratch build on it:
|
| |
+ #
|
| |
+ # $ 1minutetip -p "UPSTREAM=0" -p "KEEP_TMP_FILES=1" \
|
| |
+ # -p "UPDATESRPM=https://kojipkgs.fedoraproject.org//work/tasks/8281/87158281/" \
|
| |
+ # -p "UPDATERPMS=https://kojipkgs.fedoraproject.org//work/tasks/8286/87158286/" \
|
| |
+ # 1MT-Fedora-Rawhide 2>&1 | tee test.log
|
| |
+ #
|
| |
+
|
| |
+ rlJournalStart
|
| |
+ rlPhaseStartSetup
|
| |
+ rlAssertRpm $PACKAGE
|
| |
+ TESTDIR=`pwd`
|
| |
+ if [ $KEEP_TMP_FILES -eq 1 ] && [ -d /cymap* ]; then
|
| |
+ TmpDir=`echo /cymap*`
|
| |
+ else
|
| |
+ rlRun "TmpDir=\$(mktemp -d -p / cymapXXX)" 0 "Creating tmp directory"
|
| |
+ fi
|
| |
+ rlRun "pushd $TmpDir"
|
| |
+ if [ ! -f cassandane-testdata-ca669d4b.tar.gz ]; then
|
| |
+ rlRun "wget https://github.com/brong/Net-CalDAVTalk/archive/ca669d4b76c71cbeb4fa840e263e2c031e19ea88/cassandane-testdata-ca669d4b.tar.gz" 0 "Fetching testdata"
|
| |
+ fi
|
| |
+ if [ $UPSTREAM -eq 0 ]; then
|
| |
+ if [ ! -f $TmpDir/rpms/cyrus-imapd*.src.rpm ]; then
|
| |
+ if [ -z "$UPDATESRPM" ]; then
|
| |
+ rlRun "mkdir -p $TmpDir/rpms"
|
| |
+ rlRun "pushd $TmpDir/rpms"
|
| |
+ rlRun "rlFetchSrcForInstalled --quiet $PACKAGE" 0 "Downloading cyrus-imapd srpm"
|
| |
+ rlRun "popd"
|
| |
+ else
|
| |
+ rlRun "wget -r -l1 --no-parent --directory-prefix $TmpDir/rpms --no-directories -A '.src.rpm' \"$UPDATESRPM/\"" 0 "Downloading provided cyrus-imapd srpm"
|
| |
+ fi
|
| |
+ # Cassandane uses unix sockets to test the behaviour, but PATH to that sockets
|
| |
+ # is maximally 108bytes long (man unix(7)), thus restraining the length by
|
| |
+ # installing the source code close to '/' to prevent tests failure.
|
| |
+ rlRun "rpm -i --define \"_topdir $TmpDir\" $TmpDir/rpms/cyrus-imapd-*.src.rpm" 0 "Installing srpm"
|
| |
+ rlRun "rpmbuild -bp --define \"_topdir $TmpDir\" $TmpDir/SPECS/cyrus-imapd.spec" 0 "Preprocessing source code"
|
| |
+ # Dnf doesn't support specifying rpm macros:
|
| |
+ # https://bugzilla.redhat.com/show_bug.cgi?id=1673333
|
| |
+ # This activates a build conditional for cassandane's BuildRequires
|
| |
+ rlRun "echo '%_with_cassandane 1' > ~/.rpmmacros"
|
| |
+ rlRun "dnf -q builddep \"$TmpDir/SPECS/cyrus-imapd.spec\" -y" 0 "Installing build dependencies"
|
| |
+ fi
|
| |
+ CYRUS_SRC_PATH=`echo /$TmpDir/BUILD/cyrus-imapd-*/`
|
| |
+ else
|
| |
+ if [ ! -f $TmpDir/rpms/cyrus-imapd-3.4.3.tar.gz ]; then
|
| |
+ rlRun "wget --directory-prefix $TmpDir/rpms https://github.com/cyrusimap/cyrus-imapd/releases/download/cyrus-imapd-3.4.3/cyrus-imapd-3.4.3.tar.gz" 0 "Downoading upstream cyrus-imapd source code"
|
| |
+ # Cassandane uses unix sockets to test the behaviour, but PATH to that sockets
|
| |
+ # is maximally 108bytes long (man unix(7)), thus restraining the length by
|
| |
+ # installing the source code close to '/' to prevent tests failure.
|
| |
+ rlRun "tar -xf $TmpDir/rpms/cyrus-imapd-3.4.3.tar.gz -C $TmpDir" 0 "Decompressing upstream cyrus-imapd source code"
|
| |
+ rlRun "dnf -q builddep https://src.fedoraproject.org/rpms/cyrus-imapd/raw/rawhide/f/cyrus-imapd.spec -y" 0 "Installing build dependencies"
|
| |
+ fi
|
| |
+ CYRUS_SRC_PATH=`echo $TmpDir/cyrus-imapd-*/`
|
| |
+ fi
|
| |
+ if [ ! -f "$CYRUS_SRC_PATH/initialized" ]; then
|
| |
+ rlRun "pushd \"/$CYRUS_SRC_PATH/cassandane/\""
|
| |
+ rlRun "mkdir -p work" 0 "Creating cassandane working directory"
|
| |
+ rlRun "tar -xf \"$TmpDir/cassandane-testdata-ca669d4b.tar.gz\"" 0 "Decompressing testdata"
|
| |
+ # --forward is for when .src.rpm/UPSTREAM=0 gets used and it still calls Cassandane by default (it applies these patches)
|
| |
+ patch -p1 --forward < "$TESTDIR/patch-cassandane-no-syslog"
|
| |
+ patch -p1 --forward < "$TESTDIR/patch-cassandane-fix-annotator"
|
| |
+ patch -p1 --forward < "$TESTDIR/patch-cassandane-xapian-delve-path"
|
| |
+ rlRun "cp \"$TESTDIR/cassandane.ini\" ." 0 "Installing cassandane config template"
|
| |
+ rlRun "sed -i -e \"s#CASSDIR#$(pwd)#\" -e \"s#BUILDROOT#/#\" cassandane.ini" 0 "Patching cassandane config template"
|
| |
+ rlRun "mkdir -p imaptest/src" 0 "Creating imaptest/src"
|
| |
+ rlRun "ln -s /usr/bin/imaptest imaptest/src" 0 "Creating necessary symbolic links 1"
|
| |
+ rlRun "ln -s /usr/share/imaptest/tests imaptest/src" 0 "Creating necessary symbolic links 2"
|
| |
+ #rlRun "export NOCYRUS=1"
|
| |
+ rlRun "make" 0 "Building cassandane"
|
| |
+ if [ ! -z "$UPDATERPMS" ]; then
|
| |
+ rlRun "wget -r -l1 --no-parent --directory-prefix $TmpDir/rpms --no-directories -A \".rpm\" \"$UPDATERPMS/\"" 0 "Downloading specified cyrus-imapd version"
|
| |
+ rlRun "dnf -q update $TmpDir/rpms/*.rpm -y" 0 "Installing specified cyrus-imapd version"
|
| |
+ fi
|
| |
+ rlRun "touch \"$CYRUS_SRC_PATH/initialized\"" 0 "Cassandane initialization finished"
|
| |
+ # The whole $TmpDir needs to be owned by cyrus:mail otherwise Perl's abs_path() fails to locate cassandane.ini
|
| |
+ rlRun "chown -R cyrus:mail \"$TmpDir\"" 0 "Fixing \"$TmpDir\" permissions"
|
| |
+ else
|
| |
+ rlRun "pushd \"/$CYRUS_SRC_PATH/cassandane/\""
|
| |
+ fi
|
| |
+ rlPhaseEnd
|
| |
+
|
| |
+ rlPhaseStartTest
|
| |
+ # Construct the set of excluded tests to pass to Cassandane
|
| |
+ # ---------------------------------------------------------
|
| |
+ exclude=()
|
| |
+ tests=(
|
| |
+ # This exclusion list was verified on 2021-08-11.
|
| |
+
|
| |
+ # This tests coredumping and won't work on a machine where systemd
|
| |
+ # intercepts coredumps, which includes our builders.
|
| |
+ Cassandane::Test::Core
|
| |
+
|
| |
+ # Can't currently be run at build time because of compiled-in paths. See
|
| |
+ # https://github.com/cyrusimap/cyrus-imapd/issues/2386
|
| |
+ Admin.imap_admins
|
| |
+
|
| |
+ Rename.intermediate_cleanup
|
| |
+
|
| |
+ # TODO check this one, fails with:
|
| |
+ # expected '16', got undef at Cassandane/Cyrus/List.pm line 2188.
|
| |
+ # Cassandane::Cyrus::List::test_no_tombstones(Cassandane::Cyrus::List=HASH(0x55f00fa1e408)) called at /usr/share/perl5/vendor_perl/Test/Unit/TestCase.pm line 75
|
| |
+ Cyrus::List.no_tombstones
|
| |
+ # TODO run tests outside the build process:
|
| |
+ # https://bugzilla.redhat.com/show_bug.cgi?id=1887674
|
| |
+ # The below tests try to search in syslog file which we don't allow due to mock,
|
| |
+ # happenes for:
|
| |
+ # $ grep -R "assert.*@lines" cyrus-imapd-*/cassandane/
|
| |
+ Reconstruct.reconstruct_snoozed
|
| |
+ SearchSquat.simple
|
| |
+ SearchSquat.skip_unmodified
|
| |
+ )
|
| |
+ for i in ${tests[@]}; do exclude+=("!$i"); done
|
| |
+
|
| |
+ # If you interrupt the tests (by ictrl+c) while they are running (e.g. you notice some failing tests)
|
| |
+ # there might remain some processes that could influence the next re-run, so kill them first:
|
| |
+ killall master imapd fakesaslauthd &> /dev/null
|
| |
+
|
| |
+ # Set minimal number of tests that can run concurrently:
|
| |
+ J_OPTION="`rpm --eval %{_smp_mflags}`"
|
| |
+ if [ ${J_OPTION:2} -lt 4 ]; then
|
| |
+ J_OPTION=-j4
|
| |
+ fi
|
| |
+
|
| |
+ # Add -vvv for too much output
|
| |
+ time sudo -u cyrus ./testrunner.pl "$J_OPTION" -v -f pretty ${exclude[@]} 2>&1 | tee "$TmpDir/cassandane.log"
|
| |
+
|
| |
+ if [ -s "/$CYRUS_SRC_PATH/cassandane/work/failed" ]; then
|
| |
+ rlFail "FAIL: Some tests failed"
|
| |
+ rlRun "cat \"/$CYRUS_SRC_PATH/cassandane/work/failed\""
|
| |
+ fi
|
| |
+ rlPhaseEnd
|
| |
+
|
| |
+ rlPhaseStartCleanup
|
| |
+ if [ $KEEP_TMP_FILES -eq 0 ]; then
|
| |
+ rlRun "popd; popd"
|
| |
+ rlRun "rm -rf $TmpDir ~/.rpmmacros" 0 "Removing tmp directory"
|
| |
+ fi
|
| |
+ rlPhaseEnd
|
| |
+ rlJournalPrintText
|
| |
+ rlJournalEnd
|
| |