mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-02-22 10:20:59 +00:00
dump_uri_extension: improve test coverage of runner.py
This commit is contained in:
parent
a505560bbe
commit
de24d3cd94
@ -325,7 +325,7 @@ def stop(basedir, config):
|
|||||||
print "never saw process go away"
|
print "never saw process go away"
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
def dump_uri_extension(config):
|
def dump_uri_extension(config, output=sys.stdout):
|
||||||
from allmydata import uri
|
from allmydata import uri
|
||||||
|
|
||||||
filename = config['filename']
|
filename = config['filename']
|
||||||
@ -338,23 +338,23 @@ def dump_uri_extension(config):
|
|||||||
"share_root_hash")
|
"share_root_hash")
|
||||||
for k in keys1:
|
for k in keys1:
|
||||||
if k in unpacked:
|
if k in unpacked:
|
||||||
print "%19s: %s" % (k, unpacked[k])
|
print >>output, "%19s: %s" % (k, unpacked[k])
|
||||||
print
|
print >>output
|
||||||
for k in keys2:
|
for k in keys2:
|
||||||
if k in unpacked:
|
if k in unpacked:
|
||||||
print "%19s: %s" % (k, unpacked[k])
|
print >>output, "%19s: %s" % (k, unpacked[k])
|
||||||
print
|
print >>output
|
||||||
for k in keys3:
|
for k in keys3:
|
||||||
if k in unpacked:
|
if k in unpacked:
|
||||||
print "%19s: %s" % (k, unpacked[k])
|
print >>output, "%19s: %s" % (k, unpacked[k])
|
||||||
|
|
||||||
leftover = set(unpacked.keys()) - set(keys1 + keys2 + keys3)
|
leftover = set(unpacked.keys()) - set(keys1 + keys2 + keys3)
|
||||||
if leftover:
|
if leftover:
|
||||||
print
|
print >>output
|
||||||
for k in sorted(leftover):
|
for k in sorted(leftover):
|
||||||
print "%s: %s" % (k, unpacked[k])
|
print >>output, "%s: %s" % (k, unpacked[k])
|
||||||
|
|
||||||
print
|
print >>output
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def dump_root_dirnode(basedir, config, output=sys.stdout):
|
def dump_root_dirnode(basedir, config, output=sys.stdout):
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
from cStringIO import StringIO
|
||||||
from twisted.trial import unittest
|
from twisted.trial import unittest
|
||||||
from twisted.internet import defer, reactor
|
from twisted.internet import defer, reactor
|
||||||
from twisted.application import service
|
from twisted.application import service
|
||||||
from allmydata import client, uri, download, upload
|
from allmydata import client, uri, download, upload
|
||||||
from allmydata.introducer_and_vdrive import IntroducerAndVdrive
|
from allmydata.introducer_and_vdrive import IntroducerAndVdrive
|
||||||
from allmydata.util import idlib, fileutil, testutil
|
from allmydata.util import idlib, fileutil, testutil
|
||||||
|
from allmydata.scripts import runner
|
||||||
from foolscap.eventual import flushEventualQueue
|
from foolscap.eventual import flushEventualQueue
|
||||||
from twisted.python import log
|
from twisted.python import log
|
||||||
from twisted.python.failure import Failure
|
from twisted.python.failure import Failure
|
||||||
@ -259,6 +261,7 @@ class SystemTest(testutil.SignalMixin, unittest.TestCase):
|
|||||||
self.failUnlessEqual(data, DATA)
|
self.failUnlessEqual(data, DATA)
|
||||||
d.addCallback(_get_done)
|
d.addCallback(_get_done)
|
||||||
d.addCallback(self._test_web)
|
d.addCallback(self._test_web)
|
||||||
|
d.addCallback(self._test_runner)
|
||||||
return d
|
return d
|
||||||
test_vdrive.timeout = 1100
|
test_vdrive.timeout = 1100
|
||||||
|
|
||||||
@ -360,3 +363,38 @@ class SystemTest(testutil.SignalMixin, unittest.TestCase):
|
|||||||
|
|
||||||
return d
|
return d
|
||||||
|
|
||||||
|
def _test_runner(self, res):
|
||||||
|
# exercise some of the diagnostic tools in runner.py
|
||||||
|
|
||||||
|
# find a uri_extension file
|
||||||
|
for (dirpath, dirnames, filenames) in os.walk(self.basedir):
|
||||||
|
if "uri_extension" in filenames:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
self.fail("unable to find any uri_extension files in %s"
|
||||||
|
% self.basedir)
|
||||||
|
log.msg("test_system.SystemTest._test_runner using %s" % dirpath)
|
||||||
|
|
||||||
|
filename = os.path.join(dirpath, "uri_extension")
|
||||||
|
s = StringIO()
|
||||||
|
rc = runner.dump_uri_extension({'filename': filename}, s)
|
||||||
|
output = s.getvalue()
|
||||||
|
self.failUnlessEqual(rc, 0)
|
||||||
|
|
||||||
|
# we only upload a single file, so we can assert some things about
|
||||||
|
# its size and shares
|
||||||
|
self.failUnless("size: %d\n" % len(self.data) in output)
|
||||||
|
self.failUnless("num_segments: 1\n" in output)
|
||||||
|
# segment_size is always a multiple of needed_shares
|
||||||
|
self.failUnless("segment_size: 50\n" in output)
|
||||||
|
self.failUnless("total_shares: 100\n" in output)
|
||||||
|
# keys which are supposed to be present
|
||||||
|
for key in ("size", "num_segments", "segment_size",
|
||||||
|
"needed_shares", "total_shares",
|
||||||
|
"codec_name", "codec_params", "tail_codec_params",
|
||||||
|
"plaintext_hash", "plaintext_root_hash",
|
||||||
|
"crypttext_hash", "crypttext_root_hash",
|
||||||
|
"share_root_hash",
|
||||||
|
):
|
||||||
|
self.failUnless("%s: " % key in output, key)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user