[Collab-qa-commits] r1862 - debcluster/scripts/tasks
Lucas Nussbaum
lucas at alioth.debian.org
Sat Dec 11 21:16:52 UTC 2010
Author: lucas
Date: 2010-12-11 21:16:52 +0000 (Sat, 11 Dec 2010)
New Revision: 1862
Modified:
debcluster/scripts/tasks/instest.rb
Log:
various instest improvements
Modified: debcluster/scripts/tasks/instest.rb
===================================================================
--- debcluster/scripts/tasks/instest.rb 2010-12-11 21:16:37 UTC (rev 1861)
+++ debcluster/scripts/tasks/instest.rb 2010-12-11 21:16:52 UTC (rev 1862)
@@ -22,6 +22,7 @@
$chroots << chr
return chr
end
+ system("schroot -c #{chr} -r -- cp /proc/mounts /etc/mtab 2>&1")
end
def form(s)
@@ -69,6 +70,7 @@
$tstart = Time::now
at_exit do
$chroots.each do |chr|
+ STDOUT.flush
system("schroot -c #{chr} -e")
if $?.exitstatus != 0
puts "Cleanup of chroot #{chr} failed. Running processes:"
@@ -85,6 +87,7 @@
system("schroot -c #{chr} -e")
if $?.exitstatus != 0
puts "Cleanup of chroot still failed. Stopping there."
+ STDOUT.flush
sleep 86400
end
end
@@ -121,7 +124,8 @@
s = `schroot -c #{chr} -r -- apt-cache show #{$package} 2>&1`.chomp
unstable_version = s.split(/\n/).grep(/^Version: /)[0].split(' ')[1]
puts unstable_version
-print "-- Finding depends: "
+STDOUT.flush
+print "-- Finding depends and recommends: "
s = `schroot -c #{chr} -r -- apt-get -o Debug::pkgProblemResolver=true -s install #{$package} 2>&1`.chomp
if $?.exitstatus != 0
puts "FAILED\n#{form(s)}"
@@ -131,7 +135,7 @@
pkgs = (s.split(/\n/).grep(/^Inst /).map { |e| e.split(' ')[1] } - [$package])
if pkgs != []
puts pkgs.join(' ')
- print "-- Installing depends: "
+ print "-- Installing depends and recommends: "
s = `schroot -c #{chr} -r -- apt-get -o Debug::pkgProblemResolver=true -y install #{pkgs.join(' ')} 2>&1`
if $?.exitstatus != 0
puts "FAILED\n#{form(s)}"
@@ -144,94 +148,177 @@
else
puts "-- No depends to install, skipping dependencies installation."
end
-print "-- Installing the package after its depends: "
-s = `schroot -c #{chr} -r -- apt-get -o Debug::pkgProblemResolver=true -y install #{$package} 2>&1`
-if $?.exitstatus != 0
- puts "FAILED\n#{form(s)}"
- $tests_failed << 'inst-after-deps'
- exit(0)
-else
- puts "OK\n#{form(s)}"
- if $tests_failed.include?('inst-deps')
+STDOUT.flush
+
+$use_workaround_db = false
+def test_install_package(chr, testname, pkgm, instrecs)
+ if pkgm == :apt
+ if instrecs
+ cmd = "schroot -c #{chr} -r -- apt-get -o Debug::pkgProblemResolver=true -o APT::Install-Recommends=true -y install #{$package} 2>&1"
+ else
+ cmd = "schroot -c #{chr} -r -- apt-get -o Debug::pkgProblemResolver=true -o APT::Install-Recommends=false -y install #{$package} 2>&1"
+ end
+ elsif pkgm == :aptitude
+ cmd = "schroot -c #{chr} -r -- aptitude -y install #{$package} 2>&1"
+ end
+ s = `#{cmd}`
+ if $?.exitstatus == 0
+ puts "OK\n#{form(s)}"
+ else
+ puts "FAILED\n#{form(s)}"
+ if s =~ /Is the server running locally and accepting connections on Unix domain socket "\/var\/run\/postgresql\// or
+ s =~ /psql: could not connect to server: No such file or directory/ or
+ s =~ /connections on Unix domain socket "\/var\/run\/postgresql\// or
+ s =~ /Can't connect to local MySQL server through socket/ or
+ s =~ /warning: database package not installed\?/ or
+ $use_workaround_db
+ # postgresql hack
+ puts "-- Failed, maybe because postgresql or mysql was not running. Let's try after starting them."
+ file = File::new('/tmp/instest-pg-lock', 'w')
+ file.flock(File::LOCK_EX)
+ print "-- Installing postgresql and mysql, ignoring result: "
+ s = `schroot -c #{chr} -r -- apt-get -y install postgresql mysql-server 2>&1`
+ puts "\n#{form(s)}"
+ print "-- Starting postgresql: "
+ #system("schroot -c #{chr} -r -- sed -i \"s/#listen_addresses = 'localhost'/listen_addresses = ''/\" /etc/postgresql/8.4/main/postgresql.conf")
+ s = `schroot -c #{chr} -r -- /etc/init.d/postgresql start 2>&1`
+ if $?.exitstatus != 0
+ puts "FAILED\n#{form(s)}"
+ $tests_failed << testname
+ $tests_failed << 'start-postgresql'
+ exit(0)
+ end
+ puts "OK\n#{form(s)}"
+ print "-- Starting mysql: "
+ system("schroot -c #{chr} -r -- sed -i \"s/^bind-address.*/skip-networking/\" /etc/mysql/my.cnf")
+ s = `schroot -c #{chr} -r -- /etc/init.d/mysql start 2>&1`
+ if $?.exitstatus != 0
+ puts "FAILED\n#{form(s)}"
+ $tests_failed << testname
+ $tests_failed << 'start-mysql'
+ exit(0)
+ end
+ puts "OK\n#{form(s)}"
+
+ print "-- Retrying to install package: "
+ s = `#{cmd}`
+ if $?.exitstatus != 0
+ puts "FAILED\n#{form(s)}"
+ $tests_failed << testname
+ $tests_failed << 'inst-after-postgresql'
+ print "-- Stopping postgresql anyway: "
+ s = `schroot -c #{chr} -r -- /etc/init.d/postgresql stop 2>&1`
+ if $?.exitstatus != 0
+ puts "FAILED\n#{form(s)}"
+ $tests_failed << 'stop-postgresql'
+ else
+ puts "OK\n#{form(s)}"
+ end
+ print "-- Stopping mysql anyway: "
+ s = `schroot -c #{chr} -r -- /etc/init.d/mysql stop 2>&1`
+ if $?.exitstatus != 0
+ puts "FAILED\n#{form(s)}"
+ $tests_failed << 'stop-mysql'
+ else
+ puts "OK\n#{form(s)}"
+ end
+ exit(0)
+ end
+ puts "OK\n#{form(s)}"
+ $use_workaround_db = true
+ print "-- Stopping postgresql: "
+ s = `schroot -c #{chr} -r -- /etc/init.d/postgresql stop 2>&1`
+ if $?.exitstatus != 0
+ puts "FAILED\n#{form(s)}"
+ $tests_failed << testname
+ $tests_failed << 'stop-postgresql'
+ exit(0)
+ end
+ file.flock(File::LOCK_UN)
+ puts "OK\n#{form(s)}"
+ print "-- Stopping mysql: "
+ s = `schroot -c #{chr} -r -- /etc/init.d/mysql stop 2>&1`
+ if $?.exitstatus != 0
+ puts "FAILED\n#{form(s)}"
+ $tests_failed << testname
+ $tests_failed << 'stop-mysql'
+ exit(0)
+ end
+ puts "OK\n#{form(s)}"
+ else
+ $tests_failed << testname
+ exit(0)
+ end
+ end
+ if testname == 'inst-after-deps' and $tests_failed.include?('inst-deps')
# installing the deps failed for some reason, but installing the package
# worked. it might be caused by suboptimal apt choices. ignoring the inst-deps
# error.
$tests_failed.delete('inst-deps')
end
- $tests_ok << 'inst-after-deps'
+ $tests_ok << testname
end
-chr = create_chroot
-print "-- Installing the package together with its depends: "
-s = `schroot -c #{chr} -r -- apt-get -o Debug::pkgProblemResolver=true -y install #{$package} 2>&1`
+print "-- Installing the package after its depends and recommends: "
+test_install_package(chr, 'inst-after-deps', :apt, true)
+STDOUT.flush
+
+dchr = create_chroot
+print "-- Installing the package together with its depends, without recommends: "
+test_install_package(dchr, 'inst-with-deps', :apt, false)
+STDOUT.flush
+
+print "-- Creating new chroot and installing aptitude: "
+achr = create_chroot
+s = `schroot -c #{achr} -r -- apt-get -o Debug::pkgProblemResolver=true -y install aptitude 2>&1`
if $?.exitstatus != 0
- puts "FAILED\n#{form(s)}"
- $tests_failed << 'inst-with-deps'
+ puts "FAILED while installing aptitude\n#{form(s)}"
+ $tests_failed << 'inst-aptitude'
exit(0)
else
- $tests_ok << 'inst-with-deps'
puts "OK\n#{form(s)}"
end
+print "-- Installing the package with aptitude: "
+test_install_package(achr, 'inst-aptitude', :aptitude, true)
+STDOUT.flush
chr = create_chroot
-print "-- Installing the package with aptitude: "
-s = `schroot -c #{chr} -r -- apt-get -o Debug::pkgProblemResolver=true -y install aptitude 2>&1`
-if $?.exitstatus != 0
- puts "FAILED while installing aptitude\n#{form(s)}"
- $tests_failed << 'inst-aptitude'
+print "-- Installing the package together with its depends and recommends: "
+pkgs_before = `schroot -c #{chr} -r -- dpkg -l 2>&1`.split(/\n/).grep(/^ii /).map { |e| e.split(/\s+/)[1] }
+test_install_package(chr, 'inst-with-recs', :apt, true)
+STDOUT.flush
+
+if $defaultinst
+ puts "-- Package in default install, not testing removal."
else
- s = `schroot -c #{chr} -r -- aptitude -y install #{$package} 2>&1`
+ pkgs_after = `schroot -c #{chr} -r -- dpkg -l 2>&1`.split(/\n/).grep(/^ii /).map { |e| e.split(/\s+/)[1] }
+ print "-- Removing the package: "
+ s = `schroot -c #{chr} -r -- apt-get -o Debug::pkgProblemResolver=true -y --force-yes remove #{$package} 2>&1`
if $?.exitstatus != 0
puts "FAILED\n#{form(s)}"
- $tests_failed << 'inst-aptitude'
+ $tests_failed << 'rm-pkg'
else
- $tests_ok << 'inst-aptitude'
puts "OK\n#{form(s)}"
- end
-end
-
-chr = create_chroot
-print "-- Installing the package together with its depends and recommends: "
-pkgs_before = `schroot -c #{chr} -r -- dpkg -l 2>&1`.split(/\n/).grep(/^ii /).map { |e| e.split(/\s+/)[1] }
-s = `schroot -c #{chr} -r -- apt-get -o Debug::pkgProblemResolver=true -y install -o APT::Install-Recommends=true #{$package} 2>&1`
-if $?.exitstatus != 0
- puts "FAILED\n#{form(s)}"
- $tests_failed << 'inst-with-recs'
-else
- puts "OK\n#{form(s)}"
- $tests_ok << 'inst-with-recs'
- if $defaultinst
- puts "-- Package in default install, not testing removal."
- else
- pkgs_after = `schroot -c #{chr} -r -- dpkg -l 2>&1`.split(/\n/).grep(/^ii /).map { |e| e.split(/\s+/)[1] }
- print "-- Removing the package: "
- s = `schroot -c #{chr} -r -- apt-get -o Debug::pkgProblemResolver=true -y --force-yes remove #{$package} 2>&1`
+ $tests_ok << 'rm-pkg'
+ print "-- Removing all dependencies: "
+ # ignore problems with adduser and ucf at this point
+ # also about install-info, for now (bug filed against apt)
+ deps = (pkgs_after - pkgs_before - [$package, 'adduser', 'ucf', 'update-inetd', 'perl-modules', 'install-info'])
+ s = `schroot -c #{chr} -r -- apt-get -o Debug::pkgProblemResolver=true -y --force-yes remove #{deps.join(' ')} 2>&1`
if $?.exitstatus != 0
puts "FAILED\n#{form(s)}"
- $tests_failed << 'rm-pkg'
+ $tests_failed << 'rm-deps'
else
puts "OK\n#{form(s)}"
- $tests_ok << 'rm-pkg'
- print "-- Removing all dependencies: "
- # ignore problems with adduser and ucf at this point
- # also about install-info, for now (bug filed against apt)
- deps = (pkgs_after - pkgs_before - [$package, 'adduser', 'ucf', 'update-inetd', 'perl-modules', 'install-info'])
- s = `schroot -c #{chr} -r -- apt-get -o Debug::pkgProblemResolver=true -y --force-yes remove #{deps.join(' ')} 2>&1`
+ $tests_ok << 'rm-deps'
+ print "-- Purging package: "
+ s = `schroot -c #{chr} -r -- dpkg --purge #{$package} 2>&1`
if $?.exitstatus != 0
puts "FAILED\n#{form(s)}"
- $tests_failed << 'rm-deps'
+ $tests_failed << 'purge-pkg'
else
puts "OK\n#{form(s)}"
- $tests_ok << 'rm-deps'
- print "-- Purging package: "
- s = `schroot -c #{chr} -r -- dpkg --purge #{$package} 2>&1`
- if $?.exitstatus != 0
- puts "FAILED\n#{form(s)}"
- $tests_failed << 'purge-pkg'
- else
- puts "OK\n#{form(s)}"
- $tests_ok << 'purge-pkg'
- end
+ $tests_ok << 'purge-pkg'
end
end
end
More information about the Collab-qa-commits
mailing list