try:
from allmydata import reliability
- f = [T.div[T.href(a="reliability.html")["Reliability Math"]], f]
+ # we import this just to test to see if the page is available
+ _hush_pyflakes = reliability
+ f = [T.div[T.a(href="reliability.html")["Reliability Math"]], f]
except ImportError:
pass
#for i in range(v1.shape[1]):
return Numeric.sum(Numeric.sum(v1*v2))
-def yandm(seconds):
- return "%dy.%dm" % (int(seconds/YEAR), int( (seconds%YEAR)/MONTH))
-
class ReliabilityModel:
"""Generate a model of system-wide reliability, given several input
parameters.
cumulative_number_of_new_shares,
P_dead_unmaintained, P_dead_maintained)
+ #def yandm(seconds):
+ # return "%dy.%dm" % (int(seconds/YEAR), int( (seconds%YEAR)/MONTH))
#needed_repairs_total = sum(needed_repairs)
#needed_new_shares_total = sum(needed_new_shares)
#print "at 2y:"
from twisted.trial import unittest
-from allmydata.provisioning import ProvisioningTool
-#from nevow.context import PageContext, RequestContext
+from allmydata import provisioning
+ReliabilityModel = None
+try:
+ from allmydata.reliability import ReliabilityModel
+except ImportError:
+ pass # might not be importable, since it needs Numeric
+
from nevow import inevow
from zope.interface import implements
return None
def test_load(self):
- pt = ProvisioningTool()
+ pt = provisioning.ProvisioningTool()
self.fields = {}
#r = MyRequest()
#r.fields = self.fields
more_stan = pt.do_forms(self.getarg)
self.fields["ownership_mode"] = "E"
more_stan = pt.do_forms(self.getarg)
+
+ def test_provisioning_math(self):
+ self.failUnlessEqual(provisioning.binomial(10, 0), 1)
+ self.failUnlessEqual(provisioning.binomial(10, 1), 10)
+ self.failUnlessEqual(provisioning.binomial(10, 2), 45)
+ self.failUnlessEqual(provisioning.binomial(10, 9), 10)
+ self.failUnlessEqual(provisioning.binomial(10, 10), 1)
+
+DAY=24*60*60
+MONTH=31*DAY
+YEAR=365*DAY
+
+class Reliability(unittest.TestCase):
+ def test_basic(self):
+ if ReliabilityModel is None:
+ raise unittest.SkipTest("reliability model requires Numeric")
+ r = ReliabilityModel.run(delta=100000,
+ report_period=3*MONTH,
+ report_span=5*YEAR)
+ self.failUnlessEqual(len(r.samples), 20)
from twisted.internet import defer, reactor
from twisted.web import client, error, http
from twisted.python import failure, log
-from allmydata import interfaces, provisioning, uri, webish
+from allmydata import interfaces, uri, webish
from allmydata.immutable import upload, download
from allmydata.web import status, common
from allmydata.util import fileutil, base32
d.addCallback(_check)
return d
- def test_provisioning_math(self):
- self.failUnlessEqual(provisioning.binomial(10, 0), 1)
- self.failUnlessEqual(provisioning.binomial(10, 1), 10)
- self.failUnlessEqual(provisioning.binomial(10, 2), 45)
- self.failUnlessEqual(provisioning.binomial(10, 9), 10)
- self.failUnlessEqual(provisioning.binomial(10, 10), 1)
-
def test_provisioning(self):
d = self.GET("/provisioning/")
def _check(res):
d.addCallback(_check4)
return d
+ def test_reliability_tool(self):
+ try:
+ from allmydata import reliability
+ _hush_pyflakes = reliability
+ except:
+ raise unittest.SkipTest("reliability tool requires Numeric")
+
+ d = self.GET("/reliability/")
+ def _check(res):
+ self.failUnless('Tahoe Reliability Tool' in res)
+ fields = {'drive_lifetime': "8Y",
+ "k": "3",
+ "R": "7",
+ "N": "10",
+ "delta": "100000",
+ "check_period": "1M",
+ "report_period": "3M",
+ "report_span": "5Y",
+ }
+ return self.POST("/reliability/", **fields)
+
+ d.addCallback(_check)
+ def _check2(res):
+ self.failUnless('Tahoe Reliability Tool' in res)
+ r = r'Probability of loss \(no maintenance\):\s+<span>0.033591'
+ self.failUnless(re.search(r, res), res)
+ d.addCallback(_check2)
+ return d
+
def test_status(self):
dl_num = self.s.list_all_download_statuses()[0].get_counter()
ul_num = self.s.list_all_upload_statuses()[0].get_counter()
return parameters
def renderHTTP(self, ctx):
- print "renderHTTP"
- print "two"
self.parameters = self.get_parameters(ctx)
- print "parms", self.parameters
self.results = reliability.ReliabilityModel.run(**self.parameters)
- print "got results"
return rend.Page.renderHTTP(self, ctx)
def make_input(self, name, old_value):