]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Allow welcome and storage status pages to display a non-ASCII node nickname. fixes...
authorDavid-Sarah Hopwood <david-sarah@jacaranda.org>
Thu, 27 Dec 2012 05:08:53 +0000 (05:08 +0000)
committerDavid-Sarah Hopwood <david-sarah@jacaranda.org>
Thu, 27 Dec 2012 05:08:53 +0000 (05:08 +0000)
Signed-off-by: David-Sarah Hopwood <davidsarah@jacaranda.org>
src/allmydata/storage_client.py
src/allmydata/test/test_web.py
src/allmydata/web/introducer.xhtml
src/allmydata/web/storage_status.xhtml
src/allmydata/web/welcome.xhtml

index 4390baba2cfa3527cf06510da289ef470fb7dc77..a0cd7ddad810dab97be2c8fffb77654b96d08416 100644 (file)
@@ -252,7 +252,7 @@ class NativeStorageServer:
         return self._tubid
 
     def get_nickname(self):
-        return self.announcement["nickname"].decode("utf-8")
+        return self.announcement["nickname"]
     def get_announcement(self):
         return self.announcement
     def get_remote_host(self):
index 146fdf2cb39fd57cd2040e82df9b0aee3d115d16..2c6c0ceb4c998a144ff9cb60e7c9e45ba13fcd89 100644 (file)
@@ -166,6 +166,59 @@ class FakeHistory:
     def list_all_helper_statuses(self):
         return []
 
+class FakeDisplayableServer(StubServer):
+    def __init__(self, serverid, nickname):
+        StubServer.__init__(self, serverid)
+        self.announcement = {"my-version": "allmydata-tahoe-fake",
+                             "service-name": "storage",
+                             "nickname": nickname}
+    def is_connected(self):
+        return True
+    def get_permutation_seed(self):
+        return ""
+    def get_remote_host(self):
+        return ""
+    def get_last_loss_time(self):
+        return None
+    def get_announcement_time(self):
+        return None
+    def get_announcement(self):
+        return self.announcement
+    def get_nickname(self):
+        return self.announcement["nickname"]
+
+class FakeBucketCounter(object):
+    def get_state(self):
+        return {"last-complete-bucket-count": 0}
+    def get_progress(self):
+        return {"estimated-time-per-cycle": 0,
+                "cycle-in-progress": False,
+                "remaining-wait-time": 0}
+
+class FakeLeaseChecker(object):
+    def __init__(self):
+        self.expiration_enabled = False
+        self.mode = "age"
+        self.override_lease_duration = None
+        self.sharetypes_to_expire = {}
+    def get_state(self):
+        return {"history": None}
+    def get_progress(self):
+        return {"estimated-time-per-cycle": 0,
+                "cycle-in-progress": False,
+                "remaining-wait-time": 0}
+
+class FakeStorageServer(service.MultiService):
+    name = 'storage'
+    def __init__(self, nodeid, nickname):
+        service.MultiService.__init__(self)
+        self.my_nodeid = nodeid
+        self.nickname = nickname
+        self.bucket_counter = FakeBucketCounter()
+        self.lease_checker = FakeLeaseChecker()
+    def get_stats(self):
+        return {"storage_server.accepting_immutable_shares": False}
+
 class FakeClient(Client):
     def __init__(self):
         # don't upcall to Client.__init__, since we only want to initialize a
@@ -173,13 +226,16 @@ class FakeClient(Client):
         service.MultiService.__init__(self)
         self.all_contents = {}
         self.nodeid = "fake_nodeid"
-        self.nickname = "fake_nickname"
+        self.nickname = u"fake_nickname \u263A"
         self.introducer_furl = "None"
         self.stats_provider = FakeStatsProvider()
         self._secret_holder = SecretHolder("lease secret", "convergence secret")
         self.helper = None
         self.convergence = "some random string"
         self.storage_broker = StorageFarmBroker(None, permute_peers=True)
+        # fake knowledge of another server
+        self.storage_broker.test_add_server("other_nodeid",
+                                            FakeDisplayableServer("other_nodeid", u"other_nickname \u263B"))
         self.introducer_client = None
         self.history = FakeHistory()
         self.uploader = FakeUploader()
@@ -191,6 +247,7 @@ class FakeClient(Client):
                                        None, None, None)
         self.nodemaker.all_contents = self.all_contents
         self.mutable_file_default = SDMF_VERSION
+        self.addService(FakeStorageServer(self.nodeid, self.nickname))
 
     def startService(self):
         return service.MultiService.startService(self)
@@ -541,6 +598,9 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
             self.failUnlessIn('Welcome to Tahoe-LAFS', res)
             self.failUnlessIn(FAVICON_MARKUP, res)
             self.failUnlessIn('href="https://tahoe-lafs.org/"', res)
+            res_u = res.decode('utf-8')
+            self.failUnlessIn(u'<th>My nickname:</th> <td class="nickname mine">fake_nickname \u263A</td></tr>', res_u)
+            self.failUnlessIn(u'<div class="nickname">other_nickname \u263B</div>', res_u)
 
             self.s.basedir = 'web/test_welcome'
             fileutil.make_dirs("web/test_welcome")
@@ -549,6 +609,16 @@ class Web(WebMixin, WebErrorMixin, testutil.StallMixin, testutil.ReallyEqualMixi
         d.addCallback(_check)
         return d
 
+    def test_storage(self):
+        d = self.GET("/storage")
+        def _check(res):
+            self.failUnlessIn('Storage Server Status', res)
+            self.failUnlessIn(FAVICON_MARKUP, res)
+            res_u = res.decode('utf-8')
+            self.failUnlessIn(u'<li>Server Nickname: <span class="nickname mine">fake_nickname \u263A</span></li>', res_u)
+        d.addCallback(_check)
+        return d
+
     def test_status(self):
         h = self.s.get_history()
         dl_num = h.list_all_download_statuses()[0].get_counter()
index 6738a29055ec074fc7da5317336a2492b6bb27a0..9be4388f41b4284693aae7743cfd5e45786c8880 100644 (file)
@@ -13,7 +13,7 @@
   <table class="node-info table-headings-left">
     <tr><th>My nodeid:</th> <td class="nodeid mine data-chars" n:render="string" n:data="my_nodeid" /></tr>
     <tr><th>My versions:</th> <td n:render="string" n:data="version" /></tr>
-    <tr><th>Tahoe-LAFS code imported from:</th> <td n:render="string" n:data="import_path" /></tr>
+    <tr><th>Tahoe-LAFS code imported from:</th> <td n:render="data" n:data="import_path" /></tr>
   </table>
 </div>
 
index 19860a499b307c11b612ac404af017f67e7198fc..d97daf9afccf0edc72ba08e8919e53f77a4673f6 100644 (file)
@@ -55,7 +55,7 @@
   </table>
 
   <ul>
-    <li>Server Nickname: <span class="nickname mine" n:render="string" n:data="nickname" /></li>
+    <li>Server Nickname: <span class="nickname mine" n:render="data" n:data="nickname" /></li>
     <li>Server Nodeid: <span class="nodeid mine data-chars" n:render="string" n:data="nodeid" /></li>
     <li n:data="stats">Accepting new shares:
      <span n:render="bool" n:data="accepting_immutable_shares" /></li>
index 16f2cb7efc5dc6f1869da49309b8cbef5832acbb..b493ee79d30308af2b5a72c54588e98a44bac89f 100644 (file)
   </p>
 
   <table class="node-info table-headings-left">
-    <tr><th>My nickname:</th> <td class="nickname mine" n:render="string" n:data="my_nickname" /></tr>
+    <tr><th>My nickname:</th> <td class="nickname mine" n:render="data" n:data="my_nickname" /></tr>
     <tr><th>My nodeid:</th> <td class="nodeid mine data-chars" n:render="string" n:data="my_nodeid" /></tr>
     <tr><th>My versions:</th> <td n:render="string" n:data="version" /></tr>
-    <tr><th>Tahoe-LAFS code imported from:</th> <td n:render="string" n:data="import_path" /></tr>
+    <tr><th>Tahoe-LAFS code imported from:</th> <td n:render="data" n:data="import_path" /></tr>
     <tr><th>Services running:</th> <td n:render="services" /></tr>
   </table>
 </div>