[PATCH 2/3] adt-run: add --upgrade-to option for upgrade tests
Antonio Terceiro
terceiro at debian.org
Sat Jun 28 00:17:20 UTC 2014
---
debian/changelog | 2 ++
runner/adt-run | 19 +++++++++++++++++++
runner/adt-run.1 | 7 +++++++
3 files changed, 28 insertions(+)
diff --git a/debian/changelog b/debian/changelog
index 6c7ae24..330d8b6 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -38,6 +38,8 @@ autopkgtest (3.0) UNRELEASED; urgency=medium
[ Antonio Terceiro ]
* adt-run: add --tests-dir option for selecting a tests directory other then
debian/tests
+ * adt-run: add --upgrade-to option for upgrade tests. The system will be
+ upgraded after installing test dependencies, but before running the test.
-- Martin Pitt <mpitt at debian.org> Wed, 25 Jun 2014 07:43:32 +0200
diff --git a/runner/adt-run b/runner/adt-run
index 16f5091..9bd50e8 100755
--- a/runner/adt-run
+++ b/runner/adt-run
@@ -349,6 +349,9 @@ def parse_args():
parser.add_option('--apt-pocket', metavar='POCKETNAME', action='append',
default=[],
help='Enable additional apt source for POCKETNAME')
+ parser.add_option('--upgrade-to', dest='upgrade_to', metavar='SUITE',
+ default=None,
+ help='Upgrades to SUITE after installing test dependencies.')
parser.add_option('--tests-dir', metavar='TESTSDIR', dest='tests_dir',
default='debian/tests',
help='Read test specifications from TESTSDIR instead of '
@@ -709,6 +712,22 @@ class Testbed:
self.reset(deps_new)
self.install_deps(deps_new, recommends)
+ if opts.upgrade_to:
+ self.upgrade_to(opts.upgrade_to)
+
+ def upgrade_to(self, suite):
+ adtlog.info('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ upgrade to %s' % suite)
+
+ add_sources = '''awk 'BEGIN { done = 0 } /^deb / { if (done==0) { $3 = "%s"; print; done=1 }}' ''' \
+ '''/etc/apt/sources.list > /etc/apt/sources.list.d/%s.list''' % (suite, suite)
+ self.check_exec(['sh', '-ec', add_sources])
+
+ upgrade = '((apt-get update || (sleep 15; apt-get update)) && apt-get dist-upgrade -y -o Dpkg::Options::="--force-confnew") 2>&1'
+ self.check_exec(['sh', '-ec', upgrade], kind='install')
+
+ global testbed
+ testbed.needs_reset()
+
def needs_reset(self):
# show what caused a reset
(fname, lineno, function, code) = traceback.extract_stack(limit=2)[0]
diff --git a/runner/adt-run.1 b/runner/adt-run.1
index 8f6357b..277f835 100644
--- a/runner/adt-run.1
+++ b/runner/adt-run.1
@@ -299,6 +299,13 @@ Note that this does not imply calling
.BI \-\-tests\-dir= DIR
Read tests specifications from DIR instead of \fIdebian/tests\fR.
+.TP
+.BI \-\-upgrade\-to= SUITE
+Upgrades to SUITE
+.B after installing test dependencies, but before running tests.
+This is useful for doing upgrade tests, since your tests will run on the
+upgraded system. The testbed will be reset after each test.
+
.SH VIRTUALIZATION SERVER
.TP
--
2.0.0
More information about the autopkgtest-devel
mailing list