class NoNetworkGrid(service.MultiService):
- def __init__(self, basedir, num_clients=1, num_servers=10):
+ def __init__(self, basedir, num_clients=1, num_servers=10,
+ client_config_hooks={}):
service.MultiService.__init__(self)
self.basedir = basedir
fileutil.make_dirs(basedir)
f.write("[storage]\n")
f.write("enabled = false\n")
f.close()
- c = NoNetworkClient(clientdir)
+ c = None
+ if i in client_config_hooks:
+ # this hook can either modify tahoe.cfg, or return an
+ # entirely new Client instance
+ c = client_config_hooks[i](clientdir)
+ if not c:
+ c = NoNetworkClient(clientdir)
c.nodeid = clientid
c.short_nodeid = b32encode(clientid).lower()[:8]
c._servers = self.all_servers # can be updated later
def tearDown(self):
return self.s.stopService()
- def set_up_grid(self):
+ def set_up_grid(self, client_config_hooks={}):
# self.basedir must be set
- self.g = NoNetworkGrid(self.basedir)
+ self.g = NoNetworkGrid(self.basedir,
+ client_config_hooks=client_config_hooks)
self.g.setServiceParent(self.s)
def get_clientdir(self, i=0):
from allmydata.interfaces import IFileURI, FileTooLargeError, NotEnoughSharesError
from allmydata.util.assertutil import precondition
from allmydata.util.deferredutil import DeferredListShouldSucceed
-from common import SystemTestMixin
+from no_network import GridTestMixin
from common_util import ShouldFailMixin
MiB = 1024*1024
d.addCallback(_done)
return d
-class EncodingParameters(SystemTestMixin, unittest.TestCase):
+class EncodingParameters(GridTestMixin, unittest.TestCase):
def test_configure_parameters(self):
self.basedir = self.mktemp()
+ hooks = {0: self._set_up_nodes_extra_config}
+ self.set_up_grid(client_config_hooks=hooks)
+ c0 = self.g.clients[0]
+
DATA = "data" * 100
u = upload.Data(DATA, convergence="")
- d = self.set_up_nodes()
- d.addCallback(lambda res: self.clients[0].upload(u))
- d.addCallback(lambda ur: self.clients[0].create_node_from_uri(ur.uri))
+ d = c0.upload(u)
+ d.addCallback(lambda ur: c0.create_node_from_uri(ur.uri))
m = monitor.Monitor()
d.addCallback(lambda fn: fn.check(m))
def _check(cr):
d.addCallback(_check)
return d
- def _set_up_nodes_extra_config(self):
- f = open(os.path.join(self.getdir("client0"), "tahoe.cfg"), "wt")
+ def _set_up_nodes_extra_config(self, clientdir):
+ cfgfn = os.path.join(clientdir, "tahoe.cfg")
+ oldcfg = open(cfgfn, "r").read()
+ f = open(cfgfn, "wt")
+ f.write(oldcfg)
f.write("\n")
f.write("[client]\n")
f.write("shares.needed = 7\n")
f.write("shares.total = 12\n")
f.write("\n")
f.close()
+ return None
# TODO:
# upload with exactly 75 peers (shares_of_happiness)