RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  j...@rpm5.org
  Module: mancoosi                         Date:   04-Apr-2011 18:10:09
  Branch: HEAD                             Handle: 2011040416100800

  Modified files:
    mancoosi/framework      Makefile.am rpmtest.py
    mancoosi/framework/manifests
                            mag2011-medium.i586.manifest

  Log:
    - WIP.

  Summary:
    Revision    Changes     Path
    1.6         +1  -1      mancoosi/framework/Makefile.am
    1.2         +1  -0      
mancoosi/framework/manifests/mag2011-medium.i586.manifest
    1.3         +141 -69    mancoosi/framework/rpmtest.py
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: mancoosi/framework/Makefile.am
  ============================================================================
  $ cvs diff -u -r1.5 -r1.6 Makefile.am
  --- mancoosi/framework/Makefile.am    23 Mar 2011 16:39:40 -0000      1.5
  +++ mancoosi/framework/Makefile.am    4 Apr 2011 16:10:08 -0000       1.6
  @@ -323,7 +323,7 @@
          -D '_hrmib_path /var/cache/hrmib/%{___NVRA}' \
          -D '_solve_A $(<D)/solve' \
          ${__noparentdirs} --replacefiles --nosignature \
  -       `cat $(<D)/todo.random` 2>&1 | tee -a $(<D)/install
  +       `cat $(<D)/todo` 2>&1 | tee -a $(<D)/install
   #    @-sudo umount $(<D)/ROOT/dev/pts
   #    @-sudo umount $(<D)/ROOT/dev
   #    @-sudo umount $(<D)/ROOT/sys 
  @@ .
  patch -p0 <<'@@ .'
  Index: mancoosi/framework/manifests/mag2011-medium.i586.manifest
  ============================================================================
  $ cvs diff -u -r1.1 -r1.2 mag2011-medium.i586.manifest
  --- mancoosi/framework/manifests/mag2011-medium.i586.manifest 23 Mar 2011 
16:40:55 -0000      1.1
  +++ mancoosi/framework/manifests/mag2011-medium.i586.manifest 4 Apr 2011 
16:10:08 -0000       1.2
  @@ -604,6 +604,7 @@
   
file:///home/i586-mageia-2011.0/i586/media/core/release/psutils-p17-16.mga1.i586.rpm
   
file:///home/i586-mageia-2011.0/i586/media/core/release/pulseaudio-client-config-0.9.22-4.mga1.i586.rpm
   
file:///home/i586-mageia-2011.0/i586/media/core/release/python-2.7.1-1.mga1.i586.rpm
  
+file:///home/i586-mageia-2011.0/i586/media/core/release/python-rpm-4.8.1-8.mga1.i586.rpm
   
file:///home/i586-mageia-2011.0/i586/media/core/release/rarian-0.8.1-7.mga1.i586.rpm
   
file:///home/i586-mageia-2011.0/i586/media/core/release/resolvconf-1.46-1.mga1.noarch.rpm
   
file:///home/i586-mageia-2011.0/i586/media/core/release/rmt-0.4b42-2.mga1.i586.rpm
  @@ .
  patch -p0 <<'@@ .'
  Index: mancoosi/framework/rpmtest.py
  ============================================================================
  $ cvs diff -u -r1.2 -r1.3 rpmtest.py
  --- mancoosi/framework/rpmtest.py     1 Apr 2011 18:22:34 -0000       1.2
  +++ mancoosi/framework/rpmtest.py     4 Apr 2011 16:10:08 -0000       1.3
  @@ -43,10 +43,15 @@
            self.niters = niters
        if maxdelay:
            self.maxdelay = maxdelay
  +         self.erase_maxdelay = maxdelay
  +         self.install_maxdelay = maxdelay
           self.ts = None
           self.killtimes = []
           self.success_cases = 0
        self.details = [0,0] # (no. of transactions, no. of nop transactions)
  +     self.stats = {}
  +     self.stats['stale_lock'] = 0
  +     self.stats['recover_failed'] = 0
   
        self.warning_pat = '.*warning: (.*)$'
        self.error_pat = '.*error: (.*)$'
  @@ -58,6 +63,7 @@
   #    liblber-2.4.so.2 is needed by openldap-clients-2.4.22-2mdv2010.1.i586
   #    libldap-2.4.so.2 is needed by openldap-clients-2.4.22-2mdv2010.1.i586
        self.unsatisfied_deps = '^Unsatisfied dependencies for (.*):'
  +     self.failed_deps = '^error: Failed dependencies:'
        self.is_needed_by = '(.*) is needed by (.*)'
   # warning: /etc/sysconfig/ldap created as /etc/sysconfig/ldap.rpmnew
        self.created_as = '.*warning: (.*) created as (.*)'
  @@ -68,18 +74,20 @@
       def good(self, args):
           print colored(args, 'green')
   
  +    # Run a command.
       def run(self, args):
           print 'Running: ' + str(args)
           po = subprocess.Popen(args, stdout=None, stderr=None)
           res = po.wait() == 0
           return res
   
  +    # Run a command with a watchdog timer.
       def timed(self, args, delay):
           print 'Running(' + str(delay) + '): ' + str(args)
           po = subprocess.Popen(args, stdout=None, stderr=None)
           pid = po.pid
           time.sleep(delay)
  -        res = subprocess.Popen.poll(po) == 0
  +        res = subprocess.Popen.poll(po)
           if not res:
              try:
                   po.kill()
  @@ -88,45 +96,101 @@
              sys.stderr.write('Killed pid('+str(pid)+') after %f\n' % delay)
           return res
   
  +    # Run a command capturing stdout/stderr.
       def communicate(self, args):
           print 'Running: ' + str(args)
  -        xx = subprocess.Popen(args, stdout=subprocess.PIPE).communicate()
  +        xx = subprocess.Popen(args, stdout=subprocess.PIPE, 
stderr=subprocess.PIPE).communicate()
        return xx
   
  -    def erase_allmatches(self, erase_list):
  -        args = [bin_rpm, '-e', '--allmatches', '--nodeps' ] + erase_list
  -        xx = self.run(args)
  +    # Filter newline separated text.
  +    def filter(self, text):
  +     a = []
  +     if text:
  +         for l in text.split('\n'):
  +             if l == "":
  +                 continue
  +             mo = re.match(self.package_not_installed, l)
  +             if mo:
  +                 continue
  +                mo = re.match(self.failed_deps, l)
  +             if mo:
  +                 continue
  +                mo = re.match(self.unsatisfied_deps, l)
  +             if mo:
  +                 continue
  +                mo = re.match(self.is_needed_by, l)
  +             if mo:
  +                 continue
  +             a.append(l)
  +     res = '\n'.join(a)
  +     return res
  +
  +    # Print filtered stdout/stderr.
  +    def print_filter(self, operation, pkg, stdout, stderr):
  +     xx = True
  +     spew = self.filter(stdout)
  +     if spew:
  +            print '=== ' + operation + '(%s) stdout ===' % pkg
  +            print spew
  +     spew = self.filter(stderr)
  +        if spew:
  +            print '=== ' + operation + '(%s) stderr ===' % pkg
  +            print spew
  +     return xx
  +
  +    # Erase the pkg set.
  +    def erase_pkgset(self):
  +     xx = True
  +     for pkg in self.pkgs:
  +            args = [bin_rpm, '-e', '--allmatches', '--nodeps', pkg]
  +            (stdout, stderr) = self.communicate(args)
  +         xx = self.print_filter("erase", pkg, stdout, stderr)
        return xx
   
  -    def install_forced(self, install_list):
  -        args = [bin_rpm, '-Uvh', '--force' ] + install_list
  -        xx = self.run(args)
  +    # Install the pkg set.
  +    def install_pkgset(self):
  +     xx = True
  +     for pkg in self.rpms:
  +            args = [bin_rpm, '-Uvh', pkg]
  +            (stdout, stderr) = self.communicate(args)
  +                 xx = self.print_filter("install", pkg, stdout, stderr)
        return xx
   
  -    # Calibrate maxdelay from actual install time
  +    # Calibrate maxdelay from pkg set install/erase times.
       def calibrate(self):
  -     xx = self.erase_allmatches(self.pkgs)
  +     xx = self.erase_pkgset()
  +     bgn = time.time()
  +     args = [bin_rpm, '-U' ] + self.rpms
  +     xx = self.run(args)
  +     self.install_maxdelay = (time.time() - bgn) * 1000.
        bgn = time.time()
  -     self.install_forced(self.rpms)
  -     self.maxdelay = (time.time() - bgn) * 1000.
  -     xx = self.erase_allmatches(self.pkgs)
  +     args = [bin_rpm, '-e' ] + self.pkgs
  +     xx = self.run(args)
  +     self.erase_maxdelay = (time.time() - bgn) * 1000.
        return xx
   
       def rollback(self, rollback_list):
           print "--> rollback(" + str(rollback_list) + ")"
   
           # rollback_list must be really a list !!
  -        if not self.install_forced(rollback_list):
  +        if not self.install_pkgset():
               self.bad('Rollback failed!')
   
  +    # Run an rpm command with a drop dead timer for kill -9 termination.
       def test_case(self, opts):
  -        args = [bin_rpm, opts, '--force' ] \
  -             + random.sample(self.rpms, self.npkgs)
  +     if opts != '-Uvh':
  +         maxdelay = self.erase_maxdelay
  +            alist = random.sample(self.pkgs, self.npkgs)
  +     else:
  +         maxdelay = self.install_maxdelay
  +            alist = random.sample(self.rpms, self.npkgs)
  +
  +        args = [bin_rpm, opts ] + alist
   
           print 'Running: ' + str(args)
           po = subprocess.Popen(args, stdout=sys.stdout, stderr=sys.stderr)
           pid = po.pid
  -        delay = (random.random() * self.maxdelay) / 1000.
  +        delay = (random.random() * maxdelay) / 1000.
           self.killtimes.append(delay)
           time.sleep(delay)
           po.kill()
  @@ -135,7 +199,7 @@
        return xx
   
       def test_case_single_pkg(self, pkg):
  -        args = [bin_rpm, '-Uvh', '--force' ]
  +        args = [bin_rpm, '-Uvh', ]
           (p, filename) = pkg
           args.append(filename)
   
  @@ -177,54 +241,40 @@
           return res
   
       # Start with known pre-conditions.
  -    def prenatal(self):
  -        return self.erase_allmatches(self.pkgs)
  +    def prenatal(self, opts):
  +     if opts != '-Uvh':
  +            return self.install_pkgset()
  +     else:
  +            return self.erase_pkgset()
   
       # See if a stale lock stops rpmdb queries (must be run as root).
       def check_query(self):
  -        args = [bin_rpm, '-q'] + self.pkgs
           watchdog_delay = 2.0
  +        args = [bin_rpm, '-q'] + self.pkgs
           xx = self.timed(args, watchdog_delay)
        return xx
   
  -    # See if rpmdb access is recoverable. Remove stale locks to proceed.
  +    # See if rpmdb access is recoverable.
       def check_recover(self):
           watchdog_delay = 2.0
           args = [usr_bin_dbrecover, '-h', var_lib_rpm]
           xx = self.timed(args, watchdog_delay)
  -        if not xx:
  -            args = [usr_bin_dbstat, '-Cl', '-h', var_lib_rpm]
  -            self.run(args)
  -            args = ['/bin/rm', '-f', var_lib_rpm + '__db*']
  -            self.run(args)
        return xx
   
  -    # Verify a single package file contents
  -    def verify(self, opts, pkgname):
  -        args = [bin_rpm, opts, pkgname]
  -        (vfyout, vfyerr) = self.communicate(args)
  -     if vfyout:
  -         while True:
  -             mo = re.match(self.package_not_installed, vfyout)
  -             if mo:
  -                 break
  -             mo = re.match(self.unsatisfied_deps, vfyout)
  -             if mo:
  -                 break
  -                print '=== verify(%s) stdout ===' % pkgname
  -                print vfyout
  -             break
  -        if vfyerr:
  -            print '=== verify(%s) stderr ===' % pkgname
  -            print vfyerr
  -        if (vfyout and len(vfyout)) or (vfyerr and len(vfyerr)):
  +    # Verify a single package's file contents.
  +    def verify(self, opts, pkg):
  +        args = [bin_rpm, opts, pkg]
  +        (stdout, stderr) = self.communicate(args)
  +     xx = self.print_filter("verify", pkg, stdout, stderr)
  +     # XXX checking for non-filtered output is feeble
  +        if (stdout and len(stdout)) or (stderr and len(stderr)):
               res = False
           else:
               res = True
           return res
   
  -    # Post-mortem test results analysis
  -    def postmortem(self):
  +    # Post-mortem test results analysis.
  +    def postmortem(self, opts):
   
           version_wrong = 0
           files_wrong = 0
  @@ -232,10 +282,22 @@
           not_updated = 0
   
           # See if a stale lock stops rpmdb queries.
  -        xx = self.check_query()
  +     xx = self.check_query()
  +     if not xx:
  +         self.stats['stale_lock'] += 1
   
  -        # See if rpmdb access is recoverable. Remove stale locks to proceed.
  -        xx = self.check_recover()
  +         # Display the stale lock.
  +            args = [usr_bin_dbstat, '-Cl', '-h', var_lib_rpm]
  +            self.run(args)
  +
  +            # Try db_recover to remove the dbenv.
  +            xx = self.check_recover()
  +         if not xx:
  +             self.stats['recover_failed'] += 1
  +
  +                # Remove __db* files to proceed.
  +                args = ['/bin/rm', '-f', var_lib_rpm + '__db*']
  +                xx = self.run(args)
   
           for (p, file) in self.pkgset:
               iniNEVRA = initial_versions[p]
  @@ -509,7 +571,7 @@
               print str(check_fs_consistency(p[0]))
           sys.exit(0)
   
  -    n_iters = (int(args[2]) if len(args) > 2 else 2)
  +    n_iters = (int(args[2]) if len(args) > 2 else 10)
       max_delay = (args[1] if len(args) > 1 else 3000.)
   
       uut = Uut(to_upgrade_multi, niters=n_iters, maxdelay=max_delay)
  @@ -527,32 +589,40 @@
              # to_upgrade.remove(pkg_test) #Avoid repeating the choice
   
               (p, filename) = pkg_test
  -         xx = uut.erase_allmatches(p)
  +         xx = uut.erase_pkgset(p)
               uut.test_case_single_pkg(pkg_test)
               if checkResultsSinglePkg(uut, p):
                   uut.success_cases += 1
  -            to_rollback = []
  -         if initial_versions[p]:
  -                to_rollback.append(precondition_dir
  -                            + initial_versions[p] + '.rpm')
  -         if to_rollback:
  -                uut.rollback(to_rollback)
  +
  +#            to_rollback = []
  +#        if initial_versions[p]:
  +#                to_rollback.append(precondition_dir
  +#                            + initial_versions[p] + '.rpm')
  +#        if to_rollback:
  +#                uut.rollback(to_rollback)
   
           else:
   
               if uut.npkgs > 0:
  -             xx = uut.prenatal()
  -                xx = uut.test_case('-Uvh')
  -                xx = uut.postmortem()
   
  -                to_rollback = []
  -                for (p, filename) in uut.pkgset:
  -                 if initial_versions[p]:
  -                        to_rollback.append(precondition_dir
  -                            + initial_versions[p] + '.rpm')
  +             # Run an install test
  +             xx = uut.prenatal('-Uvh')
  +                xx = uut.test_case('-Uvh')
  +                xx = uut.postmortem('-Uvh')
   
  -             if to_rollback:
  -                    uut.rollback(to_rollback)
  +             # Run an erase test
  +                xx = uut.prenatal('-ev')
  +                xx = uut.test_case('-ev')
  +                xx = uut.postmortem('-ev')
  +
  +#                to_rollback = []
  +#                for (p, filename) in uut.pkgset:
  +#                if initial_versions[p]:
  +#                        to_rollback.append(precondition_dir
  +#                            + initial_versions[p] + '.rpm')
  +#
  +#            if to_rollback:
  +#                    uut.rollback(to_rollback)
   
       print 'Test aggregate results: %d/%d pkgs' \
            % (uut.success_cases, uut.niters)
  @@ -562,4 +632,6 @@
   
       print 'Average killtimes: %f' % (sum(uut.killtimes) / len(uut.killtimes))
   
  +    print uut.stats
  +
       # dumpResultsToCsv(global_results, output_file)
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                rpm-cvs@rpm5.org

Reply via email to