mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-20 09:46:18 +00:00
test_system.mutable: add test coverage for the 'dump-share' debug command
This commit is contained in:
parent
bc8605ad39
commit
ddf4d23bef
@ -139,19 +139,20 @@ def dump_mutable_share(config, out, err):
|
||||
f.close()
|
||||
|
||||
print >>out
|
||||
print >>out, "write_enabler: %s" % idlib.b2a(WE)
|
||||
print >>out, "WE for nodeid: %s" % idlib.nodeid_b2a(nodeid)
|
||||
print >>out, "num_extra_leases: %d" % num_extra_leases
|
||||
print >>out, "data_length: %d" % data_length
|
||||
print >>out, "Mutable slot found:"
|
||||
print >>out, " write_enabler: %s" % idlib.b2a(WE)
|
||||
print >>out, " WE for nodeid: %s" % idlib.nodeid_b2a(nodeid)
|
||||
print >>out, " num_extra_leases: %d" % num_extra_leases
|
||||
print >>out, " data_length: %d" % data_length
|
||||
if leases:
|
||||
for (leasenum, (oid,et,rs,cs,anid)) in leases:
|
||||
print >>out, "Lease #%d:" % leasenum
|
||||
print >>out, " ownerid: %d" % oid
|
||||
print >>out, " Lease #%d:" % leasenum
|
||||
print >>out, " ownerid: %d" % oid
|
||||
when = format_expiration_time(et)
|
||||
print >>out, " expires in %s" % when
|
||||
print >>out, " renew_secret: %s" % idlib.b2a(rs)
|
||||
print >>out, " cancel_secret: %s" % idlib.b2a(cs)
|
||||
print >>out, " secrets are for nodeid: %s" % idlib.nodeid_b2a(anid)
|
||||
print >>out, " expires in %s" % when
|
||||
print >>out, " renew_secret: %s" % idlib.b2a(rs)
|
||||
print >>out, " cancel_secret: %s" % idlib.b2a(cs)
|
||||
print >>out, " secrets are for nodeid: %s" % idlib.nodeid_b2a(anid)
|
||||
else:
|
||||
print >>out, "No leases."
|
||||
print >>out
|
||||
|
@ -8,7 +8,7 @@ from twisted.internet import threads # CLI tests use deferToThread
|
||||
from twisted.application import service
|
||||
from allmydata import client, uri, download, upload
|
||||
from allmydata.introducer_and_vdrive import IntroducerAndVdrive
|
||||
from allmydata.util import fileutil, testutil, deferredutil
|
||||
from allmydata.util import fileutil, testutil, deferredutil, idlib
|
||||
from allmydata.scripts import runner
|
||||
from allmydata.interfaces import IDirectoryNode, IFileNode, IFileURI
|
||||
from allmydata.dirnode import NotMutableError
|
||||
@ -257,6 +257,43 @@ class SystemTest(testutil.SignalMixin, unittest.TestCase):
|
||||
return d1
|
||||
d.addCallback(_create_mutable)
|
||||
|
||||
def _test_debug(res):
|
||||
# find a share. It is important to run this while there is only
|
||||
# one slot in the grid.
|
||||
for (dirpath, dirnames, filenames) in os.walk(self.basedir):
|
||||
if "storage" not in dirpath:
|
||||
continue
|
||||
if not filenames:
|
||||
continue
|
||||
pieces = dirpath.split(os.sep)
|
||||
if pieces[-3] == "storage" and pieces[-2] == "shares":
|
||||
# we're sitting in .../storage/shares/$SINDEX , and there
|
||||
# are sharefiles here
|
||||
assert pieces[-4].startswith("client")
|
||||
client_num = int(pieces[-4][-1])
|
||||
filename = os.path.join(dirpath, filenames[0])
|
||||
break
|
||||
else:
|
||||
self.fail("unable to find any share files in %s"
|
||||
% self.basedir)
|
||||
log.msg("test_system.SystemTest.test_mutable._test_debug using %s"
|
||||
% filename)
|
||||
log.msg(" for clients[%d]" % client_num)
|
||||
|
||||
out,err = StringIO(), StringIO()
|
||||
rc = runner.runner(["dump-share",
|
||||
filename],
|
||||
stdout=out, stderr=err)
|
||||
output = out.getvalue()
|
||||
self.failUnlessEqual(rc, 0)
|
||||
self.failUnless("Mutable slot found:\n" in output)
|
||||
peerid = idlib.nodeid_b2a(self.clients[client_num].nodeid)
|
||||
self.failUnless(" WE for nodeid: %s\n" % peerid in output)
|
||||
self.failUnless(" num_extra_leases: 0\n" in output)
|
||||
self.failUnless(" data_length: 381\n" in output)
|
||||
self.failUnless(" secrets are for nodeid: %s\n" % peerid in output)
|
||||
d.addCallback(_test_debug)
|
||||
|
||||
return d
|
||||
|
||||
def flip_bit(self, good):
|
||||
|
Loading…
x
Reference in New Issue
Block a user