From 411f578c19280a4d4a3a8d3decf9247da272c14c Mon Sep 17 00:00:00 2001
From: Brian Warner <warner@allmydata.com>
Date: Thu, 8 May 2008 16:49:27 -0700
Subject: [PATCH] check_memory: don't use fixed webports, they cause occasional
 test failures

---
 src/allmydata/test/check_memory.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/allmydata/test/check_memory.py b/src/allmydata/test/check_memory.py
index b6293a5c..5dfc7c94 100644
--- a/src/allmydata/test/check_memory.py
+++ b/src/allmydata/test/check_memory.py
@@ -229,14 +229,12 @@ this file are ignored.
         f = open(os.path.join(clientdir, "introducer.furl"), "w")
         f.write(self.introducer_furl + "\n")
         f.close()
+
+        # set webport=0 and then ask the node what port it picked.
         f = open(os.path.join(clientdir, "webport"), "w")
-        # TODO: ideally we would set webport=0 and then ask the node what
-        # port it picked. But at the moment it is not convenient to do this,
-        # so we just pick a relatively unique one.
-        webport = max(os.getpid(), 2000)
-        f.write("tcp:%d:interface=127.0.0.1\n" % webport)
+        f.write("tcp:0:interface=127.0.0.1\n")
         f.close()
-        self.webish_url = "http://localhost:%d" % webport
+
         if self.mode in ("upload-self", "receive"):
             # accept and store shares, to trigger the memory consumption bugs
             pass
@@ -269,6 +267,7 @@ this file are ignored.
         # now we wait for the client to get started. we're looking for the
         # control.furl file to appear.
         furl_file = os.path.join(clientdir, "private", "control.furl")
+        url_file = os.path.join(clientdir, "node.url")
         def _check():
             if pp.ended and pp.ended.value.status != 0:
                 # the twistd process ends normally (with rc=0) if the child
@@ -288,6 +287,8 @@ this file are ignored.
             return d2
         d.addCallback(_stall)
         def _read(res):
+            # read the node's URL
+            self.webish_url = open(url_file, "r").read().strip()
             f = open(furl_file, "r")
             furl = f.read()
             return furl.strip()
-- 
2.45.2