From: Brian Warner Date: Sat, 7 Feb 2009 22:14:40 +0000 (-0700) Subject: test_cli.Backup: capture stderr when sqlite is unavailable X-Git-Tag: allmydata-tahoe-1.3.0~64 X-Git-Url: https://git.rkrishnan.org/?a=commitdiff_plain;h=d8e00c37b574cfbfd60f91f5ffea89c31fcb625d;p=tahoe-lafs%2Ftahoe-lafs.git test_cli.Backup: capture stderr when sqlite is unavailable --- diff --git a/src/allmydata/scripts/tahoe_backup.py b/src/allmydata/scripts/tahoe_backup.py index 6d44ee69..c38dd455 100644 --- a/src/allmydata/scripts/tahoe_backup.py +++ b/src/allmydata/scripts/tahoe_backup.py @@ -144,7 +144,7 @@ class BackerUpper: bdbfile = os.path.join(options["node-directory"], "private", "backupdb.sqlite") bdbfile = os.path.abspath(bdbfile) - self.backupdb = backupdb.get_backupdb(bdbfile) + self.backupdb = backupdb.get_backupdb(bdbfile, stderr) rootcap, path = get_alias(options.aliases, options.to_dir, DEFAULT_ALIAS) to_url = nodeurl + "uri/%s/" % urllib.quote(rootcap) diff --git a/src/allmydata/test/test_cli.py b/src/allmydata/test/test_cli.py index 67e65a62..6bb855a7 100644 --- a/src/allmydata/test/test_cli.py +++ b/src/allmydata/test/test_cli.py @@ -636,6 +636,13 @@ class Backup(SystemTestMixin, CLITestMixin, unittest.TestCase): mo = re.search(r"(\d)+ files checked, (\d+) directories checked, (\d+) directories read", out) return [int(s) for s in mo.groups()] + def nosqlite_is_ok(self, err, have_bdb): + if have_bdb: + self.failUnlessEqual(err, "") + else: + self.failUnlessEqual(err.strip(), + "sqlite unavailable, not using backupdb") + def test_backup(self): self.basedir = os.path.dirname(self.mktemp()) @@ -656,7 +663,7 @@ class Backup(SystemTestMixin, CLITestMixin, unittest.TestCase): d.addCallback(lambda res: self.do_cli("create-alias", "tahoe")) d.addCallback(lambda res: self.do_cli("backup", source, "tahoe:backups")) def _check0((rc, out, err)): - self.failUnlessEqual(err, "") + self.nosqlite_is_ok(err, have_bdb) self.failUnlessEqual(rc, 0) fu, fr, dc, dr = self.count_output(out) # foo.txt, bar.txt, blah.txt @@ -704,7 +711,7 @@ class Backup(SystemTestMixin, CLITestMixin, unittest.TestCase): def _check4a((rc, out, err)): # second backup should reuse everything, if the backupdb is # available - self.failUnlessEqual(err, "") + self.nosqlite_is_ok(err, have_bdb) self.failUnlessEqual(rc, 0) if have_bdb: fu, fr, dc, dr = self.count_output(out) @@ -734,7 +741,7 @@ class Backup(SystemTestMixin, CLITestMixin, unittest.TestCase): def _check4b((rc, out, err)): # we should check all files, and re-use all of them. None of # the directories should have been changed. - self.failUnlessEqual(err, "") + self.nosqlite_is_ok(err, have_bdb) self.failUnlessEqual(rc, 0) fu, fr, dc, dr = self.count_output(out) fchecked, dchecked, dread = self.count_output2(out) @@ -780,7 +787,7 @@ class Backup(SystemTestMixin, CLITestMixin, unittest.TestCase): def _check5a((rc, out, err)): # second backup should reuse bar.txt (if backupdb is available), # and upload the rest. None of the directories can be reused. - self.failUnlessEqual(err, "") + self.nosqlite_is_ok(err, have_bdb) self.failUnlessEqual(rc, 0) if have_bdb: fu, fr, dc, dr = self.count_output(out)