Changeset 55ec994 in trunk


Ignore:
Timestamp:
2020-11-06T16:40:34Z (4 years ago)
Author:
Itamar Turner-Trauring <itamar@…>
Branches:
master
Children:
9dd0faf
Parents:
2e6f8ca
Message:

Tests pass on Python 3.

Location:
src/allmydata
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified src/allmydata/mutable/retrieve.py

    r2e6f8ca r55ec994  
     1from past.builtins import unicode
     2
    13import time
    24
     
    907909
    908910    def notify_server_corruption(self, server, shnum, reason):
     911        if isinstance(reason, unicode):
     912            reason = reason.encode("utf-8")
    909913        storage_server = server.get_storage_server()
    910914        storage_server.advise_corrupt_share(
    911             "mutable",
     915            b"mutable",
    912916            self._storage_index,
    913917            shnum,
  • TabularUnified src/allmydata/mutable/servermap.py

    r2e6f8ca r55ec994  
    11from __future__ import print_function
     2
     3from past.builtins import unicode
    24
    35import sys, time, copy
     
    801803
    802804    def notify_server_corruption(self, server, shnum, reason):
     805        if isinstance(reason, unicode):
     806            reason = reason.encode("utf-8")
    803807        ss = server.get_storage_server()
    804808        ss.advise_corrupt_share(
    805             "mutable",
     809            b"mutable",
    806810            self._storage_index,
    807811            shnum,
  • TabularUnified src/allmydata/test/mutable/test_problems.py

    r2e6f8ca r55ec994  
    5757        self.set_up_grid()
    5858        nm = self.g.clients[0].nodemaker
    59         d = nm.create_mutable_file(MutableData("contents 1"),
     59        d = nm.create_mutable_file(MutableData(b"contents 1"),
    6060                                    version=version)
    6161        def _created(n):
     
    6868            # then modify the file, leaving the old map untouched
    6969            d.addCallback(lambda res: log.msg("starting winning write"))
    70             d.addCallback(lambda res: n.overwrite(MutableData("contents 2")))
     70            d.addCallback(lambda res: n.overwrite(MutableData(b"contents 2")))
    7171            # now attempt to modify the file with the old servermap. This
    7272            # will look just like an uncoordinated write, in which every
     
    7777                                          "test_publish_surprise", None,
    7878                                          n.upload,
    79                                           MutableData("contents 2a"), self.old_map))
     79                                          MutableData(b"contents 2a"), self.old_map))
    8080            return d
    8181        d.addCallback(_created)
     
    9292        self.set_up_grid()
    9393        nm = self.g.clients[0].nodemaker
    94         d = nm.create_mutable_file(MutableData("contents 1"*4000))
     94        d = nm.create_mutable_file(MutableData(b"contents 1"*4000))
    9595        def _created(n):
    9696            d = defer.succeed(None)
     
    102102            # then modify the file, leaving the old map untouched
    103103            d.addCallback(lambda res: log.msg("starting winning write"))
    104             d.addCallback(lambda res: n.overwrite(MutableData("contents 2")))
     104            d.addCallback(lambda res: n.overwrite(MutableData(b"contents 2")))
    105105            # now attempt to retrieve the old version with the old servermap.
    106106            # This will look like someone has changed the file since we
     
    129129        self.set_up_grid()
    130130        nm = self.g.clients[0].nodemaker
    131         d = nm.create_mutable_file(MutableData("contents 1"))
     131        d = nm.create_mutable_file(MutableData(b"contents 1"))
    132132        def _created(n):
    133133            d = defer.succeed(None)
     
    141141                # then modify the file, leaving the old map untouched
    142142                log.msg("starting winning write")
    143                 return n.overwrite(MutableData("contents 2"))
     143                return n.overwrite(MutableData(b"contents 2"))
    144144            d.addCallback(_got_smap1)
    145145            # now attempt to modify the file with the old servermap. This
     
    151151                                          "test_surprise", None,
    152152                                          n.upload,
    153                                           MutableData("contents 2a"), self.old_map))
     153                                          MutableData(b"contents 2a"), self.old_map))
    154154            return d
    155155        d.addCallback(_created)
     
    160160        self.set_up_grid()
    161161        nm = self.g.clients[0].nodemaker
    162         d = nm.create_mutable_file(MutableData("contents 1"))
     162        d = nm.create_mutable_file(MutableData(b"contents 1"))
    163163        # remove one of the servers and reupload the file.
    164164        def _created(n):
     
    227227        # now "create" the file, using the pre-established key, and let the
    228228        # initial publish finally happen
    229         d.addCallback(lambda res: nm.create_mutable_file(MutableData("contents 1")))
     229        d.addCallback(lambda res: nm.create_mutable_file(MutableData(b"contents 1")))
    230230        # that ought to work
    231231        def _got_node(n):
    232232            d = n.download_best_version()
    233             d.addCallback(lambda res: self.failUnlessEqual(res, "contents 1"))
     233            d.addCallback(lambda res: self.failUnlessEqual(res, b"contents 1"))
    234234            # now break the second peer
    235235            def _break_peer1(res):
    236236                self.g.break_server(self.server1.get_serverid())
    237237            d.addCallback(_break_peer1)
    238             d.addCallback(lambda res: n.overwrite(MutableData("contents 2")))
     238            d.addCallback(lambda res: n.overwrite(MutableData(b"contents 2")))
    239239            # that ought to work too
    240240            d.addCallback(lambda res: n.download_best_version())
    241             d.addCallback(lambda res: self.failUnlessEqual(res, "contents 2"))
     241            d.addCallback(lambda res: self.failUnlessEqual(res, b"contents 2"))
    242242            def _explain_error(f):
    243243                print(f)
     
    268268        self.g.break_server(peerids[0])
    269269
    270         d = nm.create_mutable_file(MutableData("contents 1"))
     270        d = nm.create_mutable_file(MutableData(b"contents 1"))
    271271        def _created(n):
    272272            d = n.download_best_version()
    273             d.addCallback(lambda res: self.failUnlessEqual(res, "contents 1"))
     273            d.addCallback(lambda res: self.failUnlessEqual(res, b"contents 1"))
    274274            # now break one of the remaining servers
    275275            def _break_second_server(res):
    276276                self.g.break_server(peerids[1])
    277277            d.addCallback(_break_second_server)
    278             d.addCallback(lambda res: n.overwrite(MutableData("contents 2")))
     278            d.addCallback(lambda res: n.overwrite(MutableData(b"contents 2")))
    279279            # that ought to work too
    280280            d.addCallback(lambda res: n.download_best_version())
    281             d.addCallback(lambda res: self.failUnlessEqual(res, "contents 2"))
     281            d.addCallback(lambda res: self.failUnlessEqual(res, b"contents 2"))
    282282            return d
    283283        d.addCallback(_created)
     
    295295                            "test_publish_all_servers_bad",
    296296                            "ran out of good servers",
    297                             nm.create_mutable_file, MutableData("contents"))
     297                            nm.create_mutable_file, MutableData(b"contents"))
    298298        return d
    299299
     
    307307                            "test_publish_no_servers",
    308308                            "Ran out of non-bad servers",
    309                             nm.create_mutable_file, MutableData("contents"))
     309                            nm.create_mutable_file, MutableData(b"contents"))
    310310        return d
    311311
     
    323323        # we need some contents that are large enough to push the privkey out
    324324        # of the early part of the file
    325         LARGE = "These are Larger contents" * 2000 # about 50KB
     325        LARGE = b"These are Larger contents" * 2000 # about 50KB
    326326        LARGE_uploadable = MutableData(LARGE)
    327327        d = nm.create_mutable_file(LARGE_uploadable)
     
    360360        self.set_up_grid(num_servers=20)
    361361        nm = self.g.clients[0].nodemaker
    362         LARGE = "These are Larger contents" * 2000 # about 50KiB
     362        LARGE = b"These are Larger contents" * 2000 # about 50KiB
    363363        LARGE_uploadable = MutableData(LARGE)
    364364        nm._node_cache = DevNullDictionary() # disable the nodecache
     
    386386        self.set_up_grid(num_servers=20)
    387387        nm = self.g.clients[0].nodemaker
    388         CONTENTS = "contents" * 2000
     388        CONTENTS = b"contents" * 2000
    389389        CONTENTS_uploadable = MutableData(CONTENTS)
    390390        d = nm.create_mutable_file(CONTENTS_uploadable)
     
    452452
    453453
    454 TEST_1654_CAP = "URI:SSK:6jthysgozssjnagqlcxjq7recm:yxawei54fmf2ijkrvs2shs6iey4kpdp6joi7brj2vrva6sp5nf3a"
    455 
    456 TEST_1654_SH0 = """\
     454TEST_1654_CAP = b"URI:SSK:6jthysgozssjnagqlcxjq7recm:yxawei54fmf2ijkrvs2shs6iey4kpdp6joi7brj2vrva6sp5nf3a"
     455
     456TEST_1654_SH0 = b"""\
    457457VGFob2UgbXV0YWJsZSBjb250YWluZXIgdjEKdQlEA46m9s5j6lnzsOHytBTs2JOo
    458458AkWe8058hyrDa8igfBSqZMKO3aDOrFuRVt0ySYZ6oihFqPJRAAAAAAAAB8YAAAAA
     
    50850872mXGlqyLyWYuAAAAAA="""
    509509
    510 TEST_1654_SH1 = """\
     510TEST_1654_SH1 = b"""\
    511511VGFob2UgbXV0YWJsZSBjb250YWluZXIgdjEKdQlEA45R4Y4kuV458rSTGDVTqdzz
    5125129Fig3NQ3LermyD+0XLeqbC7KNgvv6cNzMZ9psQQ3FseYsIR1AAAAAAAAB8YAAAAA
Note: See TracChangeset for help on using the changeset viewer.