]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
test_cli.Backup: capture stderr when sqlite is unavailable
authorBrian Warner <warner@lothar.com>
Sat, 7 Feb 2009 22:14:40 +0000 (15:14 -0700)
committerBrian Warner <warner@lothar.com>
Sat, 7 Feb 2009 22:14:40 +0000 (15:14 -0700)
src/allmydata/scripts/tahoe_backup.py
src/allmydata/test/test_cli.py

index 6d44ee69d1450bb80e1dc487d94e5e377b91904c..c38dd4550e918a1419001904b52740b7d0ebb6dc 100644 (file)
@@ -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)
index 67e65a620850faa4ebdd2729ea5d9cd8d9f2e8df..6bb855a70587a91619ec8539e0fc8928d56ece20 100644 (file)
@@ -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)