def init_client(self):
helper_furl = self.get_config("client", "helper.furl", None)
+ if helper_furl in ("None", ""):
+ helper_furl = None
+
DEP = self.DEFAULT_ENCODING_PARAMETERS
DEP["k"] = int(self.get_config("client", "shares.needed", DEP["k"]))
DEP["n"] = int(self.get_config("client", "shares.total", DEP["n"]))
self.failUnless("node.uptime" in stats)
self.failUnless(isinstance(stats["node.uptime"], float))
+ def test_helper_furl(self):
+ basedir = "test_client.Basic.test_helper_furl"
+ os.mkdir(basedir)
+
+ def _check(config, expected_furl):
+ fileutil.write(os.path.join(basedir, "tahoe.cfg"),
+ BASECONFIG + config)
+ c = client.Client(basedir)
+ uploader = c.getServiceNamed("uploader")
+ furl, connected = uploader.get_helper_info()
+ self.failUnlessEqual(furl, expected_furl)
+
+ _check("", None)
+ _check("helper.furl =\n", None)
+ _check("helper.furl = \n", None)
+ _check("helper.furl = None", None)
+ _check("helper.furl = pb://blah\n", "pb://blah")
+
@mock.patch('allmydata.util.log.msg')
@mock.patch('allmydata.frontends.drop_upload.DropUploader')
def test_create_drop_uploader(self, mock_drop_uploader, mock_log_msg):
class FakeUploader(service.Service):
name = "uploader"
+ helper_furl = None
+ helper_connected = False
+
def upload(self, uploadable):
d = uploadable.get_size()
d.addCallback(lambda size: uploadable.read(size))
return ur
d.addCallback(_got_data)
return d
+
def get_helper_info(self):
- return (None, False)
+ return (self.helper_furl, self.helper_connected)
+
def build_one_ds():
ds = DownloadStatus("storage_index", 1234)
d.addCallback(_check)
return d
+ def test_helper_status(self):
+ d = defer.succeed(None)
+
+ # set helper furl to None
+ def _set_helper_not_configured2(ign):
+ self.s.uploader.helper_furl = None
+ return self.GET("/")
+ d.addCallback(_set_helper_not_configured2)
+ d.addCallback(lambda res:
+ self.failUnlessIn('Connected to helper?: <span>not configured</span>', res))
+
+ # enable helper, not connected
+ def _set_helper_not_connected(ign):
+ self.s.uploader.helper_furl = "pb://someHelper"
+ self.s.uploader.helper_connected = False
+ return self.GET("/")
+ d.addCallback(_set_helper_not_connected)
+ d.addCallback(lambda res:
+ self.failUnlessIn('Connected to helper?: <span>no</span>', res))
+
+ # enable helper, connected
+ def _set_helper_connected(ign):
+ self.s.uploader.helper_furl = "pb://someHelper"
+ self.s.uploader.helper_connected = True
+ return self.GET("/")
+ d.addCallback(_set_helper_connected)
+ d.addCallback(lambda res:
+ self.failUnlessIn('Connected to helper?: <span>yes</span>', res))
+ return d
+
def test_storage(self):
d = self.GET("/storage")
def _check(res):
def data_introducer_furl(self, ctx, data):
return self.client.introducer_furl
+
def data_connected_to_introducer(self, ctx, data):
if self.client.connected_to_introducer():
return "yes"
return None
furl, connected = uploader.get_helper_info()
return furl
+
+ def data_connected_to_helper_description(self, ctx, data):
+ return self.data_connected_to_helper(ctx, data).replace('-', ' ')
+
def data_connected_to_helper(self, ctx, data):
try:
uploader = self.client.getServiceNamed("uploader")
except KeyError:
return "no" # we don't even have an Uploader
furl, connected = uploader.get_helper_info()
+
+ if furl is None:
+ return "not-configured"
if connected:
return "yes"
return "no"
padding: .25em;
overflow: auto;
}
-
+
/* ----------------------------------------------------------------------- */
/* colors borrowed from the Allmydata logo */
.table-headings-top th {
text-align: center;
-
}
.table-headings-left th {
text-align: right;
border: 1px solid #F00;
background-color: #FBB;
}
+.connected-not-configured {
+ border: 1px solid #AAA;
+ background-color: #FFF;
+}
.encoded, .nodeid {
font-family: monospace;
<div>
<n:attr name="class">connected-<n:invisible n:render="string" n:data="connected_to_helper" /></n:attr>
<div>Helper: <span n:render="string" n:data="helper_furl" /></div>
- <div>Connected to helper?: <span n:render="string" n:data="connected_to_helper" /></div>
+ <div>Connected to helper?: <span n:render="string" n:data="connected_to_helper_description" /></div>
</div>
<p>Connected to <span n:render="string" n:data="connected_storage_servers" />