]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blobdiff - src/allmydata/test/test_runner.py
tests: bump up the timeout in this test that fails on FreeStorm's CentOS in order...
[tahoe-lafs/tahoe-lafs.git] / src / allmydata / test / test_runner.py
index 70327eda4b6ae72990411484e3f3996c2028e90f..b2b57dfd57e877b831f05fea8920d32019b7e3da 100644 (file)
@@ -128,6 +128,9 @@ class BinTahoe(common_util.SignalMixin, unittest.TestCase, RunBinTahoeMixin):
             self._check_right_code(lines[1])
         d.addCallback(_cb)
         return d
+    # The timeout was exceeded on FreeStorm's CentOS:
+    # http://tahoe-lafs.org/buildbot/builders/FreeStorm%20CentOS5-i386/builds/503/steps/test/logs/stdio
+    test_import_in_repl.timeout = 480
 
     def test_path(self):
         d = self.run_bintahoe(["--version-and-path"])
@@ -253,6 +256,8 @@ class CreateNode(unittest.TestCase):
                 self.failUnless(re.search(r"\n\[storage\]\n#.*\nenabled = true\n", content), content)
                 self.failUnless("\nreserved_space = 1G\n" in content)
 
+            self.failUnless(re.search(r"\n\[drop_upload\]\n#.*\nenabled = false\n", content), content)
+
         # creating the node a second time should be rejected
         rc, out, err = self.run_tahoe(argv)
         self.failIfEqual(rc, 0, str((out, err, rc)))
@@ -322,10 +327,6 @@ class CreateNode(unittest.TestCase):
                               run_by_human=False)
 
 
-BASECONFIG_I = ("[client]\n"
-                "introducer.furl = %s\n"
-                )
-
 class RunNode(common_util.SignalMixin, unittest.TestCase, pollmixin.PollMixin,
               RunBinTahoeMixin):
     # exercise "tahoe start", for both introducer, client node, and
@@ -370,7 +371,7 @@ class RunNode(common_util.SignalMixin, unittest.TestCase, pollmixin.PollMixin,
             # by writing this file, we get ten seconds before the node will
             # exit. This insures that even if the test fails (and the 'stop'
             # command doesn't work), the client should still terminate.
-            open(HOTLINE_FILE, "w").write("")
+            fileutil.write(HOTLINE_FILE, "")
             # now it's safe to start the node
         d.addCallback(_cb)
 
@@ -381,7 +382,7 @@ class RunNode(common_util.SignalMixin, unittest.TestCase, pollmixin.PollMixin,
         def _cb2(res):
             out, err, rc_or_sig = res
 
-            open(HOTLINE_FILE, "w").write("")
+            fileutil.write(HOTLINE_FILE, "")
             errstr = "rc=%d, OUT: '%s', ERR: '%s'" % (rc_or_sig, out, err)
             self.failUnlessEqual(rc_or_sig, 0, errstr)
             self.failUnlessEqual(out, "", errstr)
@@ -408,7 +409,7 @@ class RunNode(common_util.SignalMixin, unittest.TestCase, pollmixin.PollMixin,
             self.failUnless(os.path.exists(PORTNUM_FILE))
             self.portnum = fileutil.read(PORTNUM_FILE)
 
-            open(HOTLINE_FILE, "w").write("")
+            fileutil.write(HOTLINE_FILE, "")
             self.failUnless(os.path.exists(TWISTD_PID_FILE))
             self.failUnless(os.path.exists(NODE_URL_FILE))
 
@@ -419,7 +420,7 @@ class RunNode(common_util.SignalMixin, unittest.TestCase, pollmixin.PollMixin,
 
         def _then(res):
             out, err, rc_or_sig = res
-            open(HOTLINE_FILE, "w").write("")
+            fileutil.write(HOTLINE_FILE, "")
             errstr = "rc=%d, OUT: '%s', ERR: '%s'" % (rc_or_sig, out, err)
             self.failUnlessEqual(rc_or_sig, 0, errstr)
             self.failUnlessEqual(out, "", errstr)
@@ -430,13 +431,12 @@ class RunNode(common_util.SignalMixin, unittest.TestCase, pollmixin.PollMixin,
         # so poll until it is. This time INTRODUCER_FURL_FILE already
         # exists, so we check for the existence of NODE_URL_FILE instead.
         def _node_has_restarted():
-            return os.path.exists(NODE_URL_FILE)
+            return os.path.exists(NODE_URL_FILE) and os.path.exists(PORTNUM_FILE)
         d.addCallback(lambda res: self.poll(_node_has_restarted))
 
         def _check_same_furl_and_port(res):
             self.failUnless(os.path.exists(INTRODUCER_FURL_FILE))
             self.failUnlessEqual(self.furl, fileutil.read(INTRODUCER_FURL_FILE))
-            self.failUnless(os.path.exists(PORTNUM_FILE))
             self.failUnlessEqual(self.portnum, fileutil.read(PORTNUM_FILE))
         d.addCallback(_check_same_furl_and_port)
 
@@ -444,7 +444,7 @@ class RunNode(common_util.SignalMixin, unittest.TestCase, pollmixin.PollMixin,
         # itself before we get a chance to, especially if spawning the
         # 'tahoe stop' command takes a while.
         def _stop(res):
-            open(HOTLINE_FILE, "w").write("")
+            fileutil.write(HOTLINE_FILE, "")
             self.failUnless(os.path.exists(TWISTD_PID_FILE))
 
             return self.run_bintahoe(["--quiet", "stop", c1])
@@ -452,7 +452,7 @@ class RunNode(common_util.SignalMixin, unittest.TestCase, pollmixin.PollMixin,
 
         def _after_stopping(res):
             out, err, rc_or_sig = res
-            open(HOTLINE_FILE, "w").write("")
+            fileutil.write(HOTLINE_FILE, "")
             # the parent has exited by now
             errstr = "rc=%d, OUT: '%s', ERR: '%s'" % (rc_or_sig, out, err)
             self.failUnlessEqual(rc_or_sig, 0, errstr)
@@ -463,11 +463,7 @@ class RunNode(common_util.SignalMixin, unittest.TestCase, pollmixin.PollMixin,
             # gone by now.
             self.failIf(os.path.exists(TWISTD_PID_FILE))
         d.addCallback(_after_stopping)
-
-        def _remove_hotline(res):
-            os.unlink(HOTLINE_FILE)
-            return res
-        d.addBoth(_remove_hotline)
+        d.addBoth(self._remove, HOTLINE_FILE)
         return d
     test_introducer.timeout = 960
 
@@ -499,7 +495,7 @@ class RunNode(common_util.SignalMixin, unittest.TestCase, pollmixin.PollMixin,
             # By writing this file, we get two minutes before the client will exit. This ensures
             # that even if the 'stop' command doesn't work (and the test fails), the client should
             # still terminate.
-            open(HOTLINE_FILE, "w").write("")
+            fileutil.write(HOTLINE_FILE, "")
             # now it's safe to start the node
         d.addCallback(_cb)
 
@@ -510,7 +506,7 @@ class RunNode(common_util.SignalMixin, unittest.TestCase, pollmixin.PollMixin,
         def _cb2(res):
             out, err, rc_or_sig = res
             errstr = "cc=%d, OUT: '%s', ERR: '%s'" % (rc_or_sig, out, err)
-            open(HOTLINE_FILE, "w").write("")
+            fileutil.write(HOTLINE_FILE, "")
             self.failUnlessEqual(rc_or_sig, 0, errstr)
             self.failUnlessEqual(out, "", errstr) # If you emit noise, you fail this test.
             errlines = err.split("\n")
@@ -540,6 +536,7 @@ class RunNode(common_util.SignalMixin, unittest.TestCase, pollmixin.PollMixin,
             self.failUnless(os.path.exists(TWISTD_PID_FILE), (TWISTD_PID_FILE, os.listdir(os.path.dirname(TWISTD_PID_FILE))))
             return self.run_bintahoe(["--quiet", "stop", c1])
         d.addCallback(_stop)
+        d.addBoth(self._remove, HOTLINE_FILE)
         return d
 
     def test_client(self):
@@ -564,7 +561,7 @@ class RunNode(common_util.SignalMixin, unittest.TestCase, pollmixin.PollMixin,
             # By writing this file, we get two minutes before the client will exit. This ensures
             # that even if the 'stop' command doesn't work (and the test fails), the client should
             # still terminate.
-            open(HOTLINE_FILE, "w").write("")
+            fileutil.write(HOTLINE_FILE, "")
             # now it's safe to start the node
         d.addCallback(_cb)
 
@@ -574,7 +571,7 @@ class RunNode(common_util.SignalMixin, unittest.TestCase, pollmixin.PollMixin,
 
         def _cb2(res):
             out, err, rc_or_sig = res
-            open(HOTLINE_FILE, "w").write("")
+            fileutil.write(HOTLINE_FILE, "")
             errstr = "rc=%d, OUT: '%s', ERR: '%s'" % (rc_or_sig, out, err)
             self.failUnlessEqual(rc_or_sig, 0, errstr)
             self.failUnlessEqual(out, "", errstr)
@@ -591,7 +588,7 @@ class RunNode(common_util.SignalMixin, unittest.TestCase, pollmixin.PollMixin,
         d.addCallback(_cb2)
 
         def _node_has_started():
-            return os.path.exists(NODE_URL_FILE)
+            return os.path.exists(NODE_URL_FILE) and os.path.exists(PORTNUM_FILE)
         d.addCallback(lambda res: self.poll(_node_has_started))
 
         def _started(res):
@@ -599,7 +596,7 @@ class RunNode(common_util.SignalMixin, unittest.TestCase, pollmixin.PollMixin,
             # don't change on restart
             self.portnum = fileutil.read(PORTNUM_FILE)
 
-            open(HOTLINE_FILE, "w").write("")
+            fileutil.write(HOTLINE_FILE, "")
             self.failUnless(os.path.exists(TWISTD_PID_FILE))
 
             # rm this so we can detect when the second incarnation is ready
@@ -610,7 +607,7 @@ class RunNode(common_util.SignalMixin, unittest.TestCase, pollmixin.PollMixin,
         def _cb3(res):
             out, err, rc_or_sig = res
 
-            open(HOTLINE_FILE, "w").write("")
+            fileutil.write(HOTLINE_FILE, "")
             errstr = "rc=%d, OUT: '%s', ERR: '%s'" % (rc_or_sig, out, err)
             self.failUnlessEqual(rc_or_sig, 0, errstr)
             self.failUnlessEqual(out, "", errstr)
@@ -629,7 +626,7 @@ class RunNode(common_util.SignalMixin, unittest.TestCase, pollmixin.PollMixin,
         # itself before we get a chance to, especially if spawning the
         # 'tahoe stop' command takes a while.
         def _stop(res):
-            open(HOTLINE_FILE, "w").write("")
+            fileutil.write(HOTLINE_FILE, "")
             self.failUnless(os.path.exists(TWISTD_PID_FILE), (TWISTD_PID_FILE, os.listdir(os.path.dirname(TWISTD_PID_FILE))))
             return self.run_bintahoe(["--quiet", "stop", c1])
         d.addCallback(_stop)
@@ -637,7 +634,7 @@ class RunNode(common_util.SignalMixin, unittest.TestCase, pollmixin.PollMixin,
         def _cb4(res):
             out, err, rc_or_sig = res
 
-            open(HOTLINE_FILE, "w").write("")
+            fileutil.write(HOTLINE_FILE, "")
             # the parent has exited by now
             errstr = "rc=%d, OUT: '%s', ERR: '%s'" % (rc_or_sig, out, err)
             self.failUnlessEqual(rc_or_sig, 0, errstr)
@@ -648,12 +645,13 @@ class RunNode(common_util.SignalMixin, unittest.TestCase, pollmixin.PollMixin,
             # gone by now.
             self.failIf(os.path.exists(TWISTD_PID_FILE))
         d.addCallback(_cb4)
-        def _remove_hotline(res):
-            os.unlink(HOTLINE_FILE)
-            return res
-        d.addBoth(_remove_hotline)
+        d.addBoth(self._remove, HOTLINE_FILE)
         return d
 
+    def _remove(self, res, file):
+        fileutil.remove(file)
+        return res
+
     def test_baddir(self):
         self.skip_if_cannot_daemonize()
         basedir = self.workdir("test_baddir")