From e74387f4f15e6839f1afaf857b8518afd82c002e Mon Sep 17 00:00:00 2001
From: david-sarah <david-sarah@jacaranda.org>
Date: Tue, 2 Aug 2011 18:27:04 -0700
Subject: [PATCH] test_runner.py: modify RunNode.test_introducer to test that
 starting an introducer works when the introducer.furl file already exists.
 refs #1385

---
 src/allmydata/test/test_runner.py | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/allmydata/test/test_runner.py b/src/allmydata/test/test_runner.py
index 048e19d7..6dfa7ee2 100644
--- a/src/allmydata/test/test_runner.py
+++ b/src/allmydata/test/test_runner.py
@@ -394,8 +394,7 @@ class RunNode(common_util.SignalMixin, unittest.TestCase, pollmixin.PollMixin,
         def _started(res):
             open(HOTLINE_FILE, "w").write("")
             self.failUnless(os.path.exists(TWISTD_PID_FILE))
-            # rm this so we can detect when the second incarnation is ready
-            os.unlink(INTRODUCER_FURL_FILE)
+            self.stash_mtime = os.stat(INTRODUCER_FURL_FILE).st_mtime
             return self.run_bintahoe(["--quiet", "restart", c1])
         d.addCallback(_started)
 
@@ -409,8 +408,13 @@ class RunNode(common_util.SignalMixin, unittest.TestCase, pollmixin.PollMixin,
         d.addCallback(_then)
 
         # again, the second incarnation of the node might not be ready yet,
-        # so poll until it is
-        d.addCallback(lambda res: self.poll(_node_has_started))
+        # so poll until it is. This time the INTRODUCER_FURL_FILE already
+        # existed (and we couldn't delete it because we wanted to check whether
+        # its existence caused an error), so we check whether its mtime has
+        # changed.
+        def _node_has_restarted():
+            return os.stat(INTRODUCER_FURL_FILE).st_mtime != self.stash_mtime
+        d.addCallback(lambda res: self.poll(_node_has_restarted))
 
         # now we can kill it. TODO: On a slow machine, the node might kill
         # itself before we get a chance too, especially if spawning the
-- 
2.45.2