From: Kevan Carstensen Date: Sun, 7 Aug 2011 00:44:59 +0000 (-0700) Subject: test: fix assorted tests broken by MDMF changes X-Git-Tag: trac-5200~12 X-Git-Url: https://git.rkrishnan.org/listings/%22news.html/running.html?a=commitdiff_plain;h=47eab03c6c6ebb5d8910df95b59d4798be9517e8;p=tahoe-lafs%2Ftahoe-lafs.git test: fix assorted tests broken by MDMF changes --- diff --git a/src/allmydata/test/common.py b/src/allmydata/test/common.py index 8e6157bd..33678a00 100644 --- a/src/allmydata/test/common.py +++ b/src/allmydata/test/common.py @@ -17,10 +17,10 @@ from allmydata.check_results import CheckResults, CheckAndRepairResults, \ from allmydata.mutable.common import CorruptShareError from allmydata.mutable.layout import unpack_header from allmydata.mutable.publish import MutableData -from allmydata.storage.server import storage_index_to_dir from allmydata.storage.mutable import MutableShareFile from allmydata.util import hashutil, log, fileutil, pollmixin from allmydata.util.assertutil import precondition +from allmydata.util.consumer import download_to_data from allmydata.stats import StatsGathererService from allmydata.key_generator import KeyGeneratorService import allmydata.test.common_util as testutil diff --git a/src/allmydata/test/test_checker.py b/src/allmydata/test/test_checker.py index c3851285..6ca51139 100644 --- a/src/allmydata/test/test_checker.py +++ b/src/allmydata/test/test_checker.py @@ -9,6 +9,7 @@ from allmydata.monitor import Monitor from allmydata.test.no_network import GridTestMixin from allmydata.immutable.upload import Data from allmydata.test.common_web import WebRenderingMixin +from allmydata.mutable.publish import MutableData class FakeClient: def get_storage_broker(self): @@ -288,7 +289,8 @@ class AddLease(GridTestMixin, unittest.TestCase): def _stash_immutable(ur): self.imm = c0.create_node_from_uri(ur.uri) d.addCallback(_stash_immutable) - d.addCallback(lambda ign: c0.create_mutable_file("contents")) + d.addCallback(lambda ign: + c0.create_mutable_file(MutableData("contents"))) def _stash_mutable(node): self.mut = node d.addCallback(_stash_mutable) diff --git a/src/allmydata/test/test_cli.py b/src/allmydata/test/test_cli.py index 51735630..38c84ccd 100644 --- a/src/allmydata/test/test_cli.py +++ b/src/allmydata/test/test_cli.py @@ -10,6 +10,8 @@ from mock import patch from allmydata.util import fileutil, hashutil, base32 from allmydata import uri from allmydata.immutable import upload +from allmydata.interfaces import MDMF_VERSION, SDMF_VERSION +from allmydata.mutable.publish import MutableData from allmydata.dirnode import normalize # Test that the scripts can be imported. @@ -2145,7 +2147,7 @@ class Cp(GridTestMixin, CLITestMixin, unittest.TestCase): self.do_cli("cp", replacement_file_path, "tahoe:test_file.txt")) def _check_error_message((rc, out, err)): self.failUnlessEqual(rc, 1) - self.failUnlessIn("need write capability to publish", err) + self.failUnlessIn("replace or update requested with read-only cap", err) d.addCallback(_check_error_message) # Make extra sure that that didn't work. d.addCallback(lambda ignored: @@ -2707,7 +2709,8 @@ class Check(GridTestMixin, CLITestMixin, unittest.TestCase): self.set_up_grid() c0 = self.g.clients[0] DATA = "data" * 100 - d = c0.create_mutable_file(DATA) + DATA_uploadable = MutableData(DATA) + d = c0.create_mutable_file(DATA_uploadable) def _stash_uri(n): self.uri = n.get_uri() d.addCallback(_stash_uri) @@ -2808,7 +2811,8 @@ class Check(GridTestMixin, CLITestMixin, unittest.TestCase): upload.Data("literal", convergence=""))) d.addCallback(_stash_uri, "small") - d.addCallback(lambda ign: c0.create_mutable_file(DATA+"1")) + d.addCallback(lambda ign: + c0.create_mutable_file(MutableData(DATA+"1"))) d.addCallback(lambda fn: self.rootnode.set_node(u"mutable", fn)) d.addCallback(_stash_uri, "mutable") diff --git a/src/allmydata/test/test_deepcheck.py b/src/allmydata/test/test_deepcheck.py index 4bcfe289..669a6d5a 100644 --- a/src/allmydata/test/test_deepcheck.py +++ b/src/allmydata/test/test_deepcheck.py @@ -6,6 +6,7 @@ from twisted.internet import defer from twisted.internet import threads # CLI tests use deferToThread from allmydata.immutable import upload from allmydata.mutable.common import UnrecoverableFileError +from allmydata.mutable.publish import MutableData from allmydata.util import idlib from allmydata.util import base32 from allmydata.scripts import runner @@ -34,7 +35,8 @@ class MutableChecker(GridTestMixin, unittest.TestCase, ErrorMixin): self.basedir = "deepcheck/MutableChecker/good" self.set_up_grid() CONTENTS = "a little bit of data" - d = self.g.clients[0].create_mutable_file(CONTENTS) + CONTENTS_uploadable = MutableData(CONTENTS) + d = self.g.clients[0].create_mutable_file(CONTENTS_uploadable) def _created(node): self.node = node self.fileurl = "uri/" + urllib.quote(node.get_uri()) @@ -56,7 +58,8 @@ class MutableChecker(GridTestMixin, unittest.TestCase, ErrorMixin): self.basedir = "deepcheck/MutableChecker/corrupt" self.set_up_grid() CONTENTS = "a little bit of data" - d = self.g.clients[0].create_mutable_file(CONTENTS) + CONTENTS_uploadable = MutableData(CONTENTS) + d = self.g.clients[0].create_mutable_file(CONTENTS_uploadable) def _stash_and_corrupt(node): self.node = node self.fileurl = "uri/" + urllib.quote(node.get_uri()) @@ -93,7 +96,8 @@ class MutableChecker(GridTestMixin, unittest.TestCase, ErrorMixin): self.basedir = "deepcheck/MutableChecker/delete_share" self.set_up_grid() CONTENTS = "a little bit of data" - d = self.g.clients[0].create_mutable_file(CONTENTS) + CONTENTS_uploadable = MutableData(CONTENTS) + d = self.g.clients[0].create_mutable_file(CONTENTS_uploadable) def _stash_and_delete(node): self.node = node self.fileurl = "uri/" + urllib.quote(node.get_uri()) @@ -216,7 +220,8 @@ class DeepCheckWebGood(DeepCheckBase, unittest.TestCase): self.root = n self.root_uri = n.get_uri() d.addCallback(_created_root) - d.addCallback(lambda ign: c0.create_mutable_file("mutable file contents")) + d.addCallback(lambda ign: + c0.create_mutable_file(MutableData("mutable file contents"))) d.addCallback(lambda n: self.root.set_node(u"mutable", n)) def _created_mutable(n): self.mutable = n @@ -957,7 +962,8 @@ class DeepCheckWebBad(DeepCheckBase, unittest.TestCase): def create_mangled(self, ignored, name): nodetype, mangletype = name.split("-", 1) if nodetype == "mutable": - d = self.g.clients[0].create_mutable_file("mutable file contents") + mutable_uploadable = MutableData("mutable file contents") + d = self.g.clients[0].create_mutable_file(mutable_uploadable) d.addCallback(lambda n: self.root.set_node(unicode(name), n)) elif nodetype == "large": large = upload.Data("Lots of data\n" * 1000 + name + "\n", None) diff --git a/src/allmydata/test/test_hung_server.py b/src/allmydata/test/test_hung_server.py index abed967a..fbb2df4d 100644 --- a/src/allmydata/test/test_hung_server.py +++ b/src/allmydata/test/test_hung_server.py @@ -7,6 +7,7 @@ from allmydata import uri from allmydata.util.consumer import download_to_data from allmydata.immutable import upload from allmydata.mutable.common import UnrecoverableFileError +from allmydata.mutable.publish import MutableData from allmydata.storage.common import storage_index_to_dir from allmydata.test.no_network import GridTestMixin from allmydata.test.common import ShouldFailMixin @@ -106,7 +107,8 @@ class HungServerDownloadTest(GridTestMixin, ShouldFailMixin, PollMixin, self.servers = self.servers[5:] + self.servers[:5] if mutable: - d = nm.create_mutable_file(mutable_plaintext) + uploadable = MutableData(mutable_plaintext) + d = nm.create_mutable_file(uploadable) def _uploaded_mutable(node): self.uri = node.get_uri() self.shares = self.find_uri_shares(self.uri) diff --git a/src/allmydata/test/test_system.py b/src/allmydata/test/test_system.py index 51ce3f62..89169ef6 100644 --- a/src/allmydata/test/test_system.py +++ b/src/allmydata/test/test_system.py @@ -23,6 +23,7 @@ from allmydata.interfaces import IDirectoryNode, IFileNode, \ from allmydata.monitor import Monitor from allmydata.mutable.common import NotWriteableError from allmydata.mutable import layout as mutable_layout +from allmydata.mutable.publish import MutableData from foolscap.api import DeadReferenceError from twisted.python.failure import Failure from twisted.web.client import getPage @@ -463,15 +464,18 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase): def test_mutable(self): self.basedir = "system/SystemTest/test_mutable" DATA = "initial contents go here." # 25 bytes % 3 != 0 + DATA_uploadable = MutableData(DATA) NEWDATA = "new contents yay" + NEWDATA_uploadable = MutableData(NEWDATA) NEWERDATA = "this is getting old" + NEWERDATA_uploadable = MutableData(NEWERDATA) d = self.set_up_nodes(use_key_generator=True) def _create_mutable(res): c = self.clients[0] log.msg("starting create_mutable_file") - d1 = c.create_mutable_file(DATA) + d1 = c.create_mutable_file(DATA_uploadable) def _done(res): log.msg("DONE: %s" % (res,)) self._mutable_node_1 = res @@ -558,7 +562,7 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase): self.failUnlessEqual(res, DATA) # replace the data log.msg("starting replace1") - d1 = newnode.overwrite(NEWDATA) + d1 = newnode.overwrite(NEWDATA_uploadable) d1.addCallback(lambda res: newnode.download_best_version()) return d1 d.addCallback(_check_download_3) @@ -572,7 +576,7 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase): newnode2 = self.clients[3].create_node_from_uri(uri) self._newnode3 = self.clients[3].create_node_from_uri(uri) log.msg("starting replace2") - d1 = newnode1.overwrite(NEWERDATA) + d1 = newnode1.overwrite(NEWERDATA_uploadable) d1.addCallback(lambda res: newnode2.download_best_version()) return d1 d.addCallback(_check_download_4) @@ -642,7 +646,7 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase): def _check_empty_file(res): # make sure we can create empty files, this usually screws up the # segsize math - d1 = self.clients[2].create_mutable_file("") + d1 = self.clients[2].create_mutable_file(MutableData("")) d1.addCallback(lambda newnode: newnode.download_best_version()) d1.addCallback(lambda res: self.failUnlessEqual("", res)) return d1 @@ -673,7 +677,8 @@ class SystemTest(SystemTestMixin, RunBinTahoeMixin, unittest.TestCase): self.key_generator_svc.key_generator.pool_size + size_delta) d.addCallback(check_kg_poolsize, 0) - d.addCallback(lambda junk: self.clients[3].create_mutable_file('hello, world')) + d.addCallback(lambda junk: + self.clients[3].create_mutable_file(MutableData('hello, world'))) d.addCallback(check_kg_poolsize, -1) d.addCallback(lambda junk: self.clients[3].create_dirnode()) d.addCallback(check_kg_poolsize, -2)