-from base64 import b32encode
import os, re, sys, time, simplejson
from cStringIO import StringIO
from allmydata.util import idlib, mathutil
from allmydata.util import log, base32
from allmydata.util.verlib import NormalizedVersion
-from allmydata.util.encodingutil import quote_output, unicode_to_argv, get_filesystem_encoding
+from allmydata.util.encodingutil import quote_output, unicode_to_argv
from allmydata.util.fileutil import abspath_expanduser_unicode
from allmydata.util.consumer import MemoryConsumer, download_to_data
from allmydata.scripts import runner
d = self.set_up_nodes()
def _check_connections(res):
for c in self.clients:
- c.DEFAULT_ENCODING_PARAMETERS['happy'] = 5
+ c.encoding_params['happy'] = 5
all_peerids = c.get_storage_broker().get_all_serverids()
self.failUnlessEqual(len(all_peerids), self.numclients)
sb = c.storage_broker
add_to_sparent=True))
def _added(extra_node):
self.extra_node = extra_node
- self.extra_node.DEFAULT_ENCODING_PARAMETERS['happy'] = 5
+ self.extra_node.encoding_params['happy'] = 5
d.addCallback(_added)
def _has_helper():
d = self.set_up_nodes(use_stats_gatherer=True)
def _new_happy_semantics(ign):
for c in self.clients:
- c.DEFAULT_ENCODING_PARAMETERS['happy'] = 1
+ c.encoding_params['happy'] = 1
d.addCallback(_new_happy_semantics)
d.addCallback(self._test_introweb)
d.addCallback(self.log, "starting publish")
{"storage": 5})
self.failUnlessEqual(data["announcement_summary"],
{"storage": 5})
- self.failUnlessEqual(data["announcement_distinct_hosts"],
- {"storage": 1})
except unittest.FailTest:
print
print "GET %s?t=json output was:" % self.introweb_url
d = getPage(base)
def _got_welcome(page):
html = page.replace('\n', ' ')
- connected_re = "Connected to <span>%d</span>[ ]*of <span>%d</span> known storage servers" % (self.numclients, self.numclients)
+ connected_re = r'Connected to <span>%d</span>\s*of <span>%d</span> known storage servers' % (self.numclients, self.numclients)
self.failUnless(re.search(connected_re, html),
"I didn't see the right '%s' message in:\n%s" % (connected_re, page))
- nodeid_re = "<th>Node ID:</th>[ ]*<td>%s</td>" % (re.escape(b32encode(self.clients[0].nodeid).lower()),)
+ # nodeids/tubids don't have any regexp-special characters
+ nodeid_re = r'<th>Node ID:</th>\s*<td title="TubID: %s">%s</td>' % (
+ self.clients[0].get_long_tubid(), self.clients[0].get_long_nodeid())
self.failUnless(re.search(nodeid_re, html),
"I didn't see the right '%s' message in:\n%s" % (nodeid_re, page))
self.failUnless("Helper: 0 active uploads" in page)
d.addCallback(lambda res: getPage(self.helper_webish_url))
def _got_welcome_helper(page):
html = page.replace('\n', ' ')
- self.failUnless(re.search('<div class="status-indicator connected-yes"></div>[ ]*<div>Helper</div>', html), page)
+ self.failUnless(re.search('<img src="img/connected-yes.png" alt="Connected" />', html), page)
self.failUnlessIn("Not running helper", page)
d.addCallback(_got_welcome_helper)
def _new_happy_semantics(ign):
for c in self.clients:
# these get reset somewhere? Whatever.
- c.DEFAULT_ENCODING_PARAMETERS['happy'] = 1
+ c.encoding_params['happy'] = 1
d.addCallback(_new_happy_semantics)
d.addCallback(lambda res: self.PUT(public + "/subdir3/big.txt",
"big" * 500000)) # 1.5MB
d.addCallback(self._test_control2, control_furl_file)
return d
def _test_control2(self, rref, filename):
- d = rref.callRemote("upload_from_file_to_uri",
- filename.encode(get_filesystem_encoding()), convergence=None)
- downfile = os.path.join(self.basedir, "control.downfile").encode(get_filesystem_encoding())
- d.addCallback(lambda uri:
- rref.callRemote("download_from_uri_to_file",
- uri, downfile))
- def _check(res):
- self.failUnlessEqual(res, downfile)
- data = open(downfile, "r").read()
- expected_data = open(filename, "r").read()
- self.failUnlessEqual(data, expected_data)
- d.addCallback(_check)
+ d = defer.succeed(None)
d.addCallback(lambda res: rref.callRemote("speed_test", 1, 200, False))
if sys.platform in ("linux2", "linux3"):
d.addCallback(lambda res: rref.callRemote("get_memory_usage"))
def run(ignored, verb, *args, **kwargs):
stdin = kwargs.get("stdin", "")
- newargs = [verb] + nodeargs + list(args)
+ newargs = nodeargs + [verb] + list(args)
return self._run_cli(newargs, stdin=stdin)
def _check_ls((out,err), expected_children, unexpected_children=[]):
open(os.path.join(sdn2, "rfile5"), "wb").write("rfile5")
# from disk into tahoe
- d.addCallback(run, "cp", "-r", dn, "tahoe:dir1")
+ d.addCallback(run, "cp", "-r", dn, "tahoe:")
d.addCallback(run, "ls")
d.addCallback(_check_ls, ["dir1"])
d.addCallback(run, "ls", "dir1")
def _check_cp_r_out((out,err)):
def _cmp(name):
old = open(os.path.join(dn, name), "rb").read()
- newfn = os.path.join(dn_copy, name)
+ newfn = os.path.join(dn_copy, "dir1", name)
self.failUnless(os.path.exists(newfn))
new = open(newfn, "rb").read()
self.failUnlessEqual(old, new)
d.addCallback(run, "cp", "-r", "--caps-only", "tahoe:dir1", dn_copy2)
def _check_capsonly((out,err)):
# these should all be LITs
- x = open(os.path.join(dn_copy2, "subdir2", "rfile4")).read()
+ x = open(os.path.join(dn_copy2, "dir1", "subdir2", "rfile4")).read()
y = uri.from_string_filenode(x)
self.failUnlessEqual(y.data, "rfile4")
d.addCallback(_check_capsonly)
d.addCallback(run, "cp", "-r", "tahoe:dir1", "tahoe:dir1-copy")
d.addCallback(run, "ls")
d.addCallback(_check_ls, ["dir1", "dir1-copy"])
- d.addCallback(run, "ls", "dir1-copy")
+ d.addCallback(run, "ls", "dir1-copy/dir1")
d.addCallback(_check_ls, ["rfile1", "rfile2", "rfile3", "subdir2"],
["rfile4", "rfile5"])
- d.addCallback(run, "ls", "tahoe:dir1-copy/subdir2")
+ d.addCallback(run, "ls", "tahoe:dir1-copy/dir1/subdir2")
d.addCallback(_check_ls, ["rfile4", "rfile5"],
["rfile1", "rfile2", "rfile3"])
- d.addCallback(run, "get", "dir1-copy/subdir2/rfile4")
+ d.addCallback(run, "get", "dir1-copy/dir1/subdir2/rfile4")
d.addCallback(_check_stdout_against, data="rfile4")
# and copy it a second time, which ought to overwrite the same files
# tahoe_ls doesn't currently handle the error correctly: it tries to
# JSON-parse a traceback.
## def _ls_missing(res):
-## argv = ["ls"] + nodeargs + ["bogus"]
+## argv = nodeargs + ["ls", "bogus"]
## return self._run_cli(argv)
## d.addCallback(_ls_missing)
## def _check_ls_missing((out,err)):
d = self.set_up_nodes()
def _new_happy_semantics(ign):
for c in self.clients:
- c.DEFAULT_ENCODING_PARAMETERS['happy'] = 1
+ c.encoding_params['happy'] = 1
d.addCallback(_new_happy_semantics)
def _run_in_subprocess(ignored, verb, *args, **kwargs):
stdin = kwargs.get("stdin")
env = kwargs.get("env")
- newargs = [verb, "--node-directory", self.getdir("client0")] + list(args)
+ newargs = ["--node-directory", self.getdir("client0"), verb] + list(args)
return self.run_bintahoe(newargs, stdin=stdin, env=env)
def _check_succeeded(res, check_stderr=True):