mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-27 00:21:07 +00:00
5399395c27
By writing something like "25 75 100" into a file named 'encoding_parameters' in the central Introducer's base directory, all clients which use that introducer will be advised to use 25-out-of-100 encoding for files (i.e. 100 shares will be produced, 25 are required to reconstruct, and the upload process will be happy if it can find homes for at least 75 shares). The default values are "3 7 10". For small meshes, the defaults are probably good, but for larger ones it may be appropriate to increase the number of shares.
43 lines
1.6 KiB
Python
43 lines
1.6 KiB
Python
|
|
import os
|
|
from twisted.trial import unittest
|
|
from foolscap.eventual import fireEventually, flushEventualQueue
|
|
|
|
from allmydata import introducer_and_vdrive
|
|
from allmydata.util import testutil
|
|
|
|
class Basic(testutil.SignalMixin, unittest.TestCase):
|
|
def test_loadable(self):
|
|
basedir = "introducer_and_vdrive.Basic.test_loadable"
|
|
os.mkdir(basedir)
|
|
q = introducer_and_vdrive.IntroducerAndVdrive(basedir)
|
|
d = fireEventually(None)
|
|
d.addCallback(lambda res: q.startService())
|
|
d.addCallback(lambda res: q.when_tub_ready())
|
|
def _check_parameters(res):
|
|
i = q.getServiceNamed("introducer")
|
|
self.failUnlessEqual(i._encoding_parameters, (3, 7, 10))
|
|
d.addCallback(_check_parameters)
|
|
d.addCallback(lambda res: q.stopService())
|
|
d.addCallback(flushEventualQueue)
|
|
return d
|
|
|
|
def test_set_parameters(self):
|
|
basedir = "introducer_and_vdrive.Basic.test_set_parameters"
|
|
os.mkdir(basedir)
|
|
f = open(os.path.join(basedir, "encoding_parameters"), "w")
|
|
f.write("25 75 100")
|
|
f.close()
|
|
q = introducer_and_vdrive.IntroducerAndVdrive(basedir)
|
|
d = fireEventually(None)
|
|
d.addCallback(lambda res: q.startService())
|
|
d.addCallback(lambda res: q.when_tub_ready())
|
|
def _check_parameters(res):
|
|
i = q.getServiceNamed("introducer")
|
|
self.failUnlessEqual(i._encoding_parameters, (25, 75, 100))
|
|
d.addCallback(_check_parameters)
|
|
d.addCallback(lambda res: q.stopService())
|
|
d.addCallback(flushEventualQueue)
|
|
return d
|
|
|