mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-03 01:30:58 +00:00
stats: don't return booleans: it violates the schema. Add a test.
This commit is contained in:
parent
7cfc74bcc9
commit
7c4edac582
@ -866,6 +866,8 @@ class StorageServer(service.MultiService, Referenceable):
|
|||||||
fileutil.rm_dir(self.incomingdir)
|
fileutil.rm_dir(self.incomingdir)
|
||||||
|
|
||||||
def get_stats(self):
|
def get_stats(self):
|
||||||
|
# remember: RIStatsProvider requires that our return dict
|
||||||
|
# contains numeric values.
|
||||||
stats = { 'storage_server.allocated': self.allocated_size(), }
|
stats = { 'storage_server.allocated': self.allocated_size(), }
|
||||||
for category,ld in self.get_latencies().items():
|
for category,ld in self.get_latencies().items():
|
||||||
for name,v in ld.items():
|
for name,v in ld.items():
|
||||||
@ -896,7 +898,7 @@ class StorageServer(service.MultiService, Referenceable):
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
# os.statvfs is only available on unix
|
# os.statvfs is only available on unix
|
||||||
pass
|
pass
|
||||||
stats["storage_server.accepting_immutable_shares"] = writeable
|
stats["storage_server.accepting_immutable_shares"] = int(writeable)
|
||||||
return stats
|
return stats
|
||||||
|
|
||||||
|
|
||||||
|
@ -403,6 +403,28 @@ class SystemTest(SystemTestMixin, unittest.TestCase):
|
|||||||
return d
|
return d
|
||||||
d.addCallback(_upload_resumable)
|
d.addCallback(_upload_resumable)
|
||||||
|
|
||||||
|
def _grab_stats(ignored):
|
||||||
|
# the StatsProvider doesn't normally publish a FURL:
|
||||||
|
# instead it passes a live reference to the StatsGatherer
|
||||||
|
# (if and when it connects). To exercise the remote stats
|
||||||
|
# interface, we manually publish client0's StatsProvider
|
||||||
|
# and use client1 to query it.
|
||||||
|
sp = self.clients[0].stats_provider
|
||||||
|
sp_furl = self.clients[0].tub.registerReference(sp)
|
||||||
|
d = self.clients[1].tub.getReference(sp_furl)
|
||||||
|
d.addCallback(lambda sp_rref: sp_rref.callRemote("get_stats"))
|
||||||
|
def _got_stats(stats):
|
||||||
|
#print "STATS"
|
||||||
|
#from pprint import pprint
|
||||||
|
#pprint(stats)
|
||||||
|
s = stats["stats"]
|
||||||
|
self.failUnlessEqual(s["storage_server.accepting_immutable_shares"], 1)
|
||||||
|
c = stats["counters"]
|
||||||
|
self.failUnlessEqual(c["storage_server.allocate"], 2)
|
||||||
|
d.addCallback(_got_stats)
|
||||||
|
return d
|
||||||
|
d.addCallback(_grab_stats)
|
||||||
|
|
||||||
return d
|
return d
|
||||||
|
|
||||||
def _find_shares(self, basedir):
|
def _find_shares(self, basedir):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user