test: fix assorted tests broken by MDMF changes
authorKevan Carstensen <kevan@isnotajoke.com>
Sun, 7 Aug 2011 00:44:59 +0000 (17:44 -0700)
committerKevan Carstensen <kevan@isnotajoke.com>
Sun, 7 Aug 2011 00:44:59 +0000 (17:44 -0700)
src/allmydata/test/common.py
src/allmydata/test/test_checker.py
src/allmydata/test/test_cli.py
src/allmydata/test/test_deepcheck.py
src/allmydata/test/test_hung_server.py
src/allmydata/test/test_system.py

index 8e6157bdc9ade690e1dfbd6c96467089b437170b..33678a004a44984db5e8c7ac5245834b0c6fc7f9 100644 (file)
@@ -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
index c3851285cc441e626cec287320cc630c568e0ca3..6ca51139f09962888ab6f644d00a63aa781c4592 100644 (file)
@@ -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)
index 51735630affc45bdd9c782dee958c0a1fc539162..38c84ccdca0d060bd6022aaf8a4b1a8e5d1df4bb 100644 (file)
@@ -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")
 
index 4bcfe28951dda6954fc77fce31903d63176b3b12..669a6d5a0bf00f21fc67f3dbb2a30467478d13e0 100644 (file)
@@ -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)
index abed967a5f45b6a15a3faa2451c549810a3e77f3..fbb2df4d9d6b267959515f9ac088b5b732808947 100644 (file)
@@ -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)
index 51ce3f62aeb2501de8e7939c8c91c3da634831ce..89169ef6dfc57464ed430b644f7cb32c0dbcd858 100644 (file)
@@ -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)