From Mageia wiki
Jump to: navigation, search


Drakconf multiflag.png
Other languages
English ; français ;

Introduction

Before committing any changes in perl-URPM (the low level librpm C binding) or in urpmi, it's important to run their testsuite:

  • when altering perl-URPM: run both perl-URPM & urpmi testsuite
  • when altering urpmi: only run urpmi testsuite

Rationale:

  • perl-URPM has a minimal testsuite that will just check some basic sanity checks
  • urpmi testsuite is fairly complete, testing both rpm, perl-URPM & urpmi.
    • It often catch bugs in new rpm versions that weren't caught by upstream rpm's testsuite (such as rpm v3 support regression & the like)

Debugging urpmi

If there's an issue when testing urpmi, one can make debugging urpmi easier by using the following options:

  • urpmi -vv make it more verbose
  • urpmi --debug enables lot of debuging info (more useful)
  • urpmi --debug-librpm make librpm quite a lot more verbose, useful when debuging an issue with librpm (similar to rpm -vv)
  • urpmi --deploops make librpm prints info about dep loops (and where it break dep cycles)

If there's an issue while running the testsuite, one can uncomment the following line in t/helper.pm:

#$urpmi_debug_opt = '-v --debug';

Running urpmi testsuite

As usual with all perl modules, the proper way to run perl-URPM or urpmi testsuite is to run:

perl Makefile.PL
make
sudo make test
Warning!
The more interesting tests need to be run as root.

Thus the sudo above. Else all t/super-*.t tests will be skipped and you will basically only test that the code is sane and that rpmbuild works.

The testsuite layout is :

t/
  *.t the tests
  helper.pm common stuff for the tests
  data/  data for the tests
     SPECS/ spec files for generating test rpms
     rpm-*/ some old rpm v3 pkgs & some buggy rpms in order to check rpmlib itself
  media/ where test rpms & test repos are generated

Faster urpmi testsuite

perl-URPM testsuite is fast to run. urpmi testsuite is quite slower due to its extensive testing. The slowest part is the actual creation of the rpms dataset (in t/media).

I've a small script that makes it faster by:

  • skiping recreating rpms once created (I make sure to recreate them when testing with a new rpm version though)
  • using eatmydata for skiping all sync() calls
  • running tests on a tmpfs mount for even faster I/O
  • pointing to a local nginx server for faster remote media testing

Script: (collapsed by default)

#!/bin/sh

LOGS=../ULOG.14

export LC_ALL=C


if systemctl status nginx.service; then
        echo "OK: nginx is good :-)"
else
        echo "Not really relevant but…"
        echo "KO: nginx is down :-( !"
        echo "Please run sudo systemctl restart nginx.service "
        exit 1
fi

[[ -f Makefile ]] || perl Makefile.PL

# better not rebuild the packages...:
if [[ -d t/media ]]; then
        mv -f t/02create_pkgs.t{,.i}
elif [[ ! -e t/02create_pkgs.t ]]; then
        mv -f t/02create_pkgs.t{.i,}
fi

# Faster (no real writes or fsync()s):
if ! df t|grep -q none; then    # FIXME: use overlayfs instead?
   #mv t t2; mkdir t
   rm -fr t2; cp -al t t2
   sudo mount -t tmpfs none t
   cp -a t2/* t
fi

# LOCAL MIRRORLIST (TODO: point to local api.mga.org instead):
perl -pi -e 's!..MIRRORLIST!http://192.168.1.10/mageia/stable/x86_64!' t/superuser--mirrorlist.t


# Even faster (no fsync() at all)
AUTHOR_TESTING=1 sudo /usr/bin/time -v nohup eatmydata make test &> $LOGS
#sudo /usr/bin/time -v nohup eatmydata strace -f make test &> $LOGS
#sudo /usr/bin/time -v strace -e file,process -f nohup eatmydata make test &> $LOGS
RC=$?
echo "Logs are in $LOGS, exit code is $RC"
exit $RC

Obviously, the URL needs to be adjusted to your local mirror (or the "perl -pi -e" command must be commented out in order to test Mageia servers)

Further urpmi testing

For further urpmi testing, I upload it on CPAN using Pause, then watch for any damage on cpantesters. Currently, we support rpm-4.9 to 4.17, perl-5.8 to 5.34. So the testsuite is run on various Linux & FreeBSD distributions, with different perl & rpm versions.

I usually run perl-URPM & urpmi testsuite using echo test T/TV/TVIGNAUD/urpmi-v8.127.tgz | eatmydata cpan myself on mga[2-9] chroots. (This needs configuring cpan agent vs cpan testers)

One can upload a test version to CPAN by switching release_status => 'stable', to release_status => 'testing', in Makefile.PL.

Configuring CPAN for uploading testing reports

Run cpan & accept local::lib if not root

Install needed deps:

On Mageia:

sudo urpmi 'perl(Term::ReadLine::Perl)'
sudo urpmi 'perl(CPAN::Reporter)' perl-Metabase-Fact 'perl(Test::Reporter::Transport::Metabase)'

On Fedora or CentOS:

sudo yum install perl-File-HomeDir perl-File-Which-1.09-12.el7.noarch
echo install CPAN::Reporter|eatmydata  cpan 2>&1|tee LOG.CPAN-Reporter
echo install Test::Reporter::Transport::Metabase  cpan 2>&1|tee LOG.CPAN-Reporter2
echo install Metabase-Fact  |cpan 2>&1|tee LOG.CPAN-Reporter3
echo install D/DA/DAGOLDEN/Metabase-Fact-0.025.tar.gz |cpan
#echo 'force install Test::Reporter::Transport::Metabase'|cpan (as root or after chown -R tvignaud /usr/local)
echo 'force install Config::Perl-V'|cpan
echo 'install CPAN::Testers::Report'|cpan
echo 'install Metabase::Client::Simple'|cpan
cp -a ~/.cpan/build/Metabase-Fact-0.025-0/bin/metabase-profile /bin/
chmod +x /bin/metabase-profile

Run metabase-profile and answer with your name & email. Eg input:

Foo Bar
foo.bar@gmail.com
Foo Bar <foo.bar@gmail.com>
metabase-profile
mkdir ~/.cpantesters
cp metabase_id.json ~/.cpantesters/
chmod 400 ~/.cpantesters/metabase_id.json

Then configure cpan properly by running cpan and typing:

$ cpan
cpan> o conf init test_report
-> yes, <enter>, Foo Bar <foo.bar@gmail.com>, <enter> x4
cpan> o conf commit
cpan> force test CPAN::Reporter
cpan> force test T/TV/TVIGNAUD/URPM-5.125.tgz
cpan> force test TVIGNAUD/urpmi-8.127.tgz
cpan> q

References