Fix failing tests.

This commit is contained in:
Itamar Turner-Trauring 2020-09-16 14:37:16 -04:00
parent bea1d657f3
commit e8743a607f
2 changed files with 17 additions and 13 deletions

View File

@ -6,10 +6,11 @@ from __future__ import absolute_import
from __future__ import print_function from __future__ import print_function
from __future__ import unicode_literals from __future__ import unicode_literals
from future.utils import bytes_to_native_str, PY2 from future.utils import bytes_to_native_str, PY2, native_str_to_bytes
if PY2: if PY2:
# Omit open() to get native behavior where open("w") always accepts native strings. # Omit open() to get native behavior where open("w") always accepts native
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, pow, round, super, bytes, dict, list, object, range, str, max, min # noqa: F401 # strings. Omit bytes so we don't leak future's custom bytes.
from future.builtins import filter, map, zip, ascii, chr, hex, input, next, oct, pow, round, super, dict, list, object, range, str, max, min # noqa: F401
import os, re, struct, time import os, re, struct, time
@ -241,16 +242,18 @@ class StorageServer(service.MultiService, Referenceable):
# We're on a platform that has no API to get disk stats. # We're on a platform that has no API to get disk stats.
remaining_space = 2**64 remaining_space = 2**64
version = { "http://allmydata.org/tahoe/protocols/storage/v1" : # Unicode strings might be nicer, but for now sticking to bytes since
{ "maximum-immutable-share-size": remaining_space, # this is what the wire protocol has always been.
"maximum-mutable-share-size": MAX_MUTABLE_SHARE_SIZE, version = { b"http://allmydata.org/tahoe/protocols/storage/v1" :
"available-space": remaining_space, { b"maximum-immutable-share-size": remaining_space,
"tolerates-immutable-read-overrun": True, b"maximum-mutable-share-size": MAX_MUTABLE_SHARE_SIZE,
"delete-mutable-shares-with-zero-length-writev": True, b"available-space": remaining_space,
"fills-holes-with-zero-bytes": True, b"tolerates-immutable-read-overrun": True,
"prevents-read-past-end-of-share-data": True, b"delete-mutable-shares-with-zero-length-writev": True,
b"fills-holes-with-zero-bytes": True,
b"prevents-read-past-end-of-share-data": True,
}, },
"application-version": str(allmydata.__full_version__), b"application-version": allmydata.__full_version__.encode("utf-8"),
} }
return version return version

View File

@ -1,3 +1,4 @@
from future.utils import native_str
import os, json, urllib import os, json, urllib
from twisted.trial import unittest from twisted.trial import unittest
@ -945,7 +946,7 @@ class DeepCheckWebBad(DeepCheckBase, unittest.TestCase):
def _corrupt_some_shares(self, node): def _corrupt_some_shares(self, node):
for (shnum, serverid, sharefile) in self.find_uri_shares(node.get_uri()): for (shnum, serverid, sharefile) in self.find_uri_shares(node.get_uri()):
if shnum in (0,1): if shnum in (0,1):
yield run_cli("debug", "corrupt-share", sharefile) yield run_cli("debug", "corrupt-share", native_str(sharefile))
def _delete_most_shares(self, node): def _delete_most_shares(self, node):
self.delete_shares_numbered(node.get_uri(), range(1,10)) self.delete_shares_numbered(node.get_uri(), range(1,10))