fixed some minor things in tests that pyflakes complained about
Change-Id: Ifeab56a964630bcf941e932fcbe39e6572e62975
This commit is contained in:
parent
d2d9a15ddf
commit
44f00a23c1
@ -4,8 +4,6 @@
|
|||||||
import __builtin__
|
import __builtin__
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
from ConfigParser import MissingSectionHeaderError
|
|
||||||
from StringIO import StringIO
|
|
||||||
|
|
||||||
from swift.common.utils import readconf
|
from swift.common.utils import readconf
|
||||||
|
|
||||||
|
@ -447,8 +447,8 @@ class Container(Base):
|
|||||||
raise ResponseError(self.conn.response)
|
raise ResponseError(self.conn.response)
|
||||||
|
|
||||||
def info(self, hdrs={}, parms={}, cfg={}):
|
def info(self, hdrs={}, parms={}, cfg={}):
|
||||||
status = self.conn.make_request('HEAD', self.path, hdrs=hdrs,
|
self.conn.make_request('HEAD', self.path, hdrs=hdrs,
|
||||||
parms=parms, cfg=cfg)
|
parms=parms, cfg=cfg)
|
||||||
|
|
||||||
if self.conn.response.status == 204:
|
if self.conn.response.status == 204:
|
||||||
fields = [['bytes_used', 'x-container-bytes-used'],
|
fields = [['bytes_used', 'x-container-bytes-used'],
|
||||||
|
@ -470,7 +470,6 @@ class TestContainer(Base):
|
|||||||
prefixs = ['alpha/', 'beta/', 'kappa/']
|
prefixs = ['alpha/', 'beta/', 'kappa/']
|
||||||
prefix_files = {}
|
prefix_files = {}
|
||||||
|
|
||||||
all_files = []
|
|
||||||
for prefix in prefixs:
|
for prefix in prefixs:
|
||||||
prefix_files[prefix] = []
|
prefix_files[prefix] = []
|
||||||
|
|
||||||
@ -746,7 +745,7 @@ class TestContainerPathsEnv:
|
|||||||
stored_files.add(f)
|
stored_files.add(f)
|
||||||
cls.stored_files = sorted(stored_files)
|
cls.stored_files = sorted(stored_files)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TestContainerPaths(Base):
|
class TestContainerPaths(Base):
|
||||||
@ -1186,7 +1185,6 @@ class TestFile(Base):
|
|||||||
def testRangedGetsWithLWSinHeader(self):
|
def testRangedGetsWithLWSinHeader(self):
|
||||||
#Skip this test until webob 1.2 can tolerate LWS in Range header.
|
#Skip this test until webob 1.2 can tolerate LWS in Range header.
|
||||||
file_length = 10000
|
file_length = 10000
|
||||||
range_size = file_length / 10
|
|
||||||
file = self.env.container.file(Utils.create_name())
|
file = self.env.container.file(Utils.create_name())
|
||||||
data = file.write_random(file_length)
|
data = file.write_random(file_length)
|
||||||
|
|
||||||
|
@ -13,13 +13,10 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import errno
|
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
import sys
|
import sys
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from nose import SkipTest
|
|
||||||
from ConfigParser import MissingSectionHeaderError
|
|
||||||
|
|
||||||
from test import get_config
|
from test import get_config
|
||||||
|
|
||||||
@ -153,10 +150,10 @@ def retry(func, *args, **kwargs):
|
|||||||
if attempts > retries:
|
if attempts > retries:
|
||||||
raise
|
raise
|
||||||
parsed[use_account] = conn[use_account] = None
|
parsed[use_account] = conn[use_account] = None
|
||||||
except AuthError, err:
|
except AuthError:
|
||||||
url[use_account] = token[use_account] = None
|
url[use_account] = token[use_account] = None
|
||||||
continue
|
continue
|
||||||
except InternalServerError, err:
|
except InternalServerError:
|
||||||
pass
|
pass
|
||||||
if attempts <= retries:
|
if attempts <= retries:
|
||||||
sleep(backoff)
|
sleep(backoff)
|
||||||
|
@ -19,12 +19,8 @@ import unittest
|
|||||||
from nose import SkipTest
|
from nose import SkipTest
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
from swift.common.constraints import MAX_META_COUNT, MAX_META_NAME_LENGTH, \
|
|
||||||
MAX_META_OVERALL_SIZE, MAX_META_VALUE_LENGTH
|
|
||||||
|
|
||||||
from swift_testing import check_response, retry, skip, skip3, \
|
from swift_testing import check_response, retry, skip, skip3, \
|
||||||
swift_test_perm, web_front_end
|
swift_test_perm, web_front_end
|
||||||
from test import get_config
|
|
||||||
|
|
||||||
|
|
||||||
class TestObject(unittest.TestCase):
|
class TestObject(unittest.TestCase):
|
||||||
@ -112,7 +108,7 @@ class TestObject(unittest.TestCase):
|
|||||||
'X-Copy-From': source})
|
'X-Copy-From': source})
|
||||||
return check_response(conn)
|
return check_response(conn)
|
||||||
resp = retry(put)
|
resp = retry(put)
|
||||||
contents = resp.read()
|
resp.read()
|
||||||
self.assertEquals(resp.status, 201)
|
self.assertEquals(resp.status, 201)
|
||||||
|
|
||||||
# contents of dest should be the same as source
|
# contents of dest should be the same as source
|
||||||
@ -146,7 +142,7 @@ class TestObject(unittest.TestCase):
|
|||||||
'Destination': dest})
|
'Destination': dest})
|
||||||
return check_response(conn)
|
return check_response(conn)
|
||||||
resp = retry(copy)
|
resp = retry(copy)
|
||||||
contents = resp.read()
|
resp.read()
|
||||||
self.assertEquals(resp.status, 201)
|
self.assertEquals(resp.status, 201)
|
||||||
|
|
||||||
# contents of dest should be the same as source
|
# contents of dest should be the same as source
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
from httplib import HTTPConnection
|
from httplib import HTTPConnection
|
||||||
from os import kill
|
from os import kill
|
||||||
from signal import SIGTERM
|
from signal import SIGTERM
|
||||||
from subprocess import Popen, PIPE, STDOUT
|
from subprocess import Popen, PIPE
|
||||||
from time import sleep, time
|
from time import sleep, time
|
||||||
|
|
||||||
from swiftclient import get_auth, head_account
|
from swiftclient import get_auth, head_account
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
from subprocess import call, Popen
|
from subprocess import call
|
||||||
from unittest import main, TestCase
|
from unittest import main, TestCase
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
""" Swift tests """
|
""" Swift tests """
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
import os
|
||||||
import copy
|
import copy
|
||||||
import logging
|
import logging
|
||||||
@ -12,13 +11,11 @@ from eventlet.green import socket
|
|||||||
from tempfile import mkdtemp
|
from tempfile import mkdtemp
|
||||||
from shutil import rmtree
|
from shutil import rmtree
|
||||||
from test import get_config
|
from test import get_config
|
||||||
from ConfigParser import MissingSectionHeaderError
|
from swift.common.utils import config_true_value
|
||||||
from StringIO import StringIO
|
|
||||||
from swift.common.utils import readconf, config_true_value
|
|
||||||
from logging import Handler
|
|
||||||
from hashlib import md5
|
from hashlib import md5
|
||||||
from eventlet import sleep, spawn, Timeout
|
from eventlet import sleep, Timeout
|
||||||
import logging.handlers
|
import logging.handlers
|
||||||
|
from httplib import HTTPException
|
||||||
|
|
||||||
|
|
||||||
def readuntil2crlfs(fd):
|
def readuntil2crlfs(fd):
|
||||||
|
@ -1097,7 +1097,6 @@ class TestAccountController(unittest.TestCase):
|
|||||||
self.assertEquals(outbuf.getvalue()[:4], '412 ')
|
self.assertEquals(outbuf.getvalue()[:4], '412 ')
|
||||||
|
|
||||||
def test_invalid_method_doesnt_exist(self):
|
def test_invalid_method_doesnt_exist(self):
|
||||||
inbuf = StringIO()
|
|
||||||
errbuf = StringIO()
|
errbuf = StringIO()
|
||||||
outbuf = StringIO()
|
outbuf = StringIO()
|
||||||
|
|
||||||
@ -1111,7 +1110,6 @@ class TestAccountController(unittest.TestCase):
|
|||||||
self.assertEquals(outbuf.getvalue()[:4], '405 ')
|
self.assertEquals(outbuf.getvalue()[:4], '405 ')
|
||||||
|
|
||||||
def test_invalid_method_is_not_public(self):
|
def test_invalid_method_is_not_public(self):
|
||||||
inbuf = StringIO()
|
|
||||||
errbuf = StringIO()
|
errbuf = StringIO()
|
||||||
outbuf = StringIO()
|
outbuf = StringIO()
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ class TestUntar(unittest.TestCase):
|
|||||||
{'base_fails1': [{'sub_dir1': ['sub1_file1']},
|
{'base_fails1': [{'sub_dir1': ['sub1_file1']},
|
||||||
{'sub_dir2': ['sub2_file1', 'sub2_file2']},
|
{'sub_dir2': ['sub2_file1', 'sub2_file2']},
|
||||||
{'sub_dir3': [{'sub4_dir1': 'sub4_file1'}]}]}]
|
{'sub_dir3': [{'sub4_dir1': 'sub4_file1'}]}]}]
|
||||||
tar = self.build_tar(dir_tree)
|
self.build_tar(dir_tree)
|
||||||
req = Request.blank('/tar_works/acc/',
|
req = Request.blank('/tar_works/acc/',
|
||||||
headers={'Accept': 'application/json'})
|
headers={'Accept': 'application/json'})
|
||||||
req.environ['wsgi.input'] = open(os.path.join(self.testdir,
|
req.environ['wsgi.input'] = open(os.path.join(self.testdir,
|
||||||
@ -265,7 +265,7 @@ class TestUntar(unittest.TestCase):
|
|||||||
self.assertEquals(resp_data['Number Files Created'], 4)
|
self.assertEquals(resp_data['Number Files Created'], 4)
|
||||||
|
|
||||||
def test_extract_tar_fail_cont_401(self):
|
def test_extract_tar_fail_cont_401(self):
|
||||||
tar = self.build_tar()
|
self.build_tar()
|
||||||
req = Request.blank('/unauth/acc/')
|
req = Request.blank('/unauth/acc/')
|
||||||
req.environ['wsgi.input'] = open(os.path.join(self.testdir,
|
req.environ['wsgi.input'] = open(os.path.join(self.testdir,
|
||||||
'tar_fails.tar'))
|
'tar_fails.tar'))
|
||||||
@ -274,7 +274,7 @@ class TestUntar(unittest.TestCase):
|
|||||||
self.assertEquals(resp.status_int, 401)
|
self.assertEquals(resp.status_int, 401)
|
||||||
|
|
||||||
def test_extract_tar_fail_obj_401(self):
|
def test_extract_tar_fail_obj_401(self):
|
||||||
tar = self.build_tar()
|
self.build_tar()
|
||||||
req = Request.blank('/create_obj_unauth/acc/cont/')
|
req = Request.blank('/create_obj_unauth/acc/cont/')
|
||||||
req.environ['wsgi.input'] = open(os.path.join(self.testdir,
|
req.environ['wsgi.input'] = open(os.path.join(self.testdir,
|
||||||
'tar_fails.tar'))
|
'tar_fails.tar'))
|
||||||
@ -283,7 +283,7 @@ class TestUntar(unittest.TestCase):
|
|||||||
self.assertEquals(resp.status_int, 401)
|
self.assertEquals(resp.status_int, 401)
|
||||||
|
|
||||||
def test_extract_tar_fail_obj_name_len(self):
|
def test_extract_tar_fail_obj_name_len(self):
|
||||||
tar = self.build_tar()
|
self.build_tar()
|
||||||
req = Request.blank('/tar_works/acc/cont/',
|
req = Request.blank('/tar_works/acc/cont/',
|
||||||
headers={'Accept': 'application/json'})
|
headers={'Accept': 'application/json'})
|
||||||
req.environ['wsgi.input'] = open(os.path.join(self.testdir,
|
req.environ['wsgi.input'] = open(os.path.join(self.testdir,
|
||||||
@ -296,7 +296,7 @@ class TestUntar(unittest.TestCase):
|
|||||||
'/tar_works/acc/cont/base_fails1/' + ('f' * 101))
|
'/tar_works/acc/cont/base_fails1/' + ('f' * 101))
|
||||||
|
|
||||||
def test_extract_tar_fail_compress_type(self):
|
def test_extract_tar_fail_compress_type(self):
|
||||||
tar = self.build_tar()
|
self.build_tar()
|
||||||
req = Request.blank('/tar_works/acc/cont/')
|
req = Request.blank('/tar_works/acc/cont/')
|
||||||
req.environ['wsgi.input'] = open(os.path.join(self.testdir,
|
req.environ['wsgi.input'] = open(os.path.join(self.testdir,
|
||||||
'tar_fails.tar'))
|
'tar_fails.tar'))
|
||||||
@ -306,7 +306,7 @@ class TestUntar(unittest.TestCase):
|
|||||||
self.assertEquals(self.app.calls, 0)
|
self.assertEquals(self.app.calls, 0)
|
||||||
|
|
||||||
def test_extract_tar_fail_max_file_name_length(self):
|
def test_extract_tar_fail_max_file_name_length(self):
|
||||||
tar = self.build_tar()
|
self.build_tar()
|
||||||
with patch.object(self.bulk, 'max_failed_extractions', 1):
|
with patch.object(self.bulk, 'max_failed_extractions', 1):
|
||||||
self.app.calls = 0
|
self.app.calls = 0
|
||||||
req = Request.blank('/tar_works/acc/cont/',
|
req = Request.blank('/tar_works/acc/cont/',
|
||||||
@ -345,7 +345,7 @@ class TestUntar(unittest.TestCase):
|
|||||||
{'sub_dir2': ['sub2_file1', 'sub2_file2']},
|
{'sub_dir2': ['sub2_file1', 'sub2_file2']},
|
||||||
'f' * 101,
|
'f' * 101,
|
||||||
{'sub_dir3': [{'sub4_dir1': 'sub4_file1'}]}]
|
{'sub_dir3': [{'sub4_dir1': 'sub4_file1'}]}]
|
||||||
tar = self.build_tar(dir_tree)
|
self.build_tar(dir_tree)
|
||||||
with patch.object(self.bulk, 'max_containers', 1):
|
with patch.object(self.bulk, 'max_containers', 1):
|
||||||
self.app.calls = 0
|
self.app.calls = 0
|
||||||
body = open(os.path.join(self.testdir, 'tar_fails.tar')).read()
|
body = open(os.path.join(self.testdir, 'tar_fails.tar')).read()
|
||||||
@ -361,7 +361,7 @@ class TestUntar(unittest.TestCase):
|
|||||||
{'sub_dir2': ['sub2_file1', 'sub2_file2']},
|
{'sub_dir2': ['sub2_file1', 'sub2_file2']},
|
||||||
'f\xde',
|
'f\xde',
|
||||||
{'./sub_dir3': [{'sub4_dir1': 'sub4_file1'}]}]}]
|
{'./sub_dir3': [{'sub4_dir1': 'sub4_file1'}]}]}]
|
||||||
tar = self.build_tar(dir_tree)
|
self.build_tar(dir_tree)
|
||||||
req = Request.blank('/create_cont_fail/acc/cont/',
|
req = Request.blank('/create_cont_fail/acc/cont/',
|
||||||
headers={'Accept': 'application/json'})
|
headers={'Accept': 'application/json'})
|
||||||
req.environ['wsgi.input'] = open(os.path.join(self.testdir,
|
req.environ['wsgi.input'] = open(os.path.join(self.testdir,
|
||||||
@ -373,7 +373,7 @@ class TestUntar(unittest.TestCase):
|
|||||||
self.assertEquals(len(resp_data['Errors']), 5)
|
self.assertEquals(len(resp_data['Errors']), 5)
|
||||||
|
|
||||||
def test_extract_tar_fail_create_cont_value_err(self):
|
def test_extract_tar_fail_create_cont_value_err(self):
|
||||||
tar = self.build_tar()
|
self.build_tar()
|
||||||
req = Request.blank('/create_cont_fail/acc/cont/',
|
req = Request.blank('/create_cont_fail/acc/cont/',
|
||||||
headers={'Accept': 'application/json'})
|
headers={'Accept': 'application/json'})
|
||||||
req.environ['wsgi.input'] = open(os.path.join(self.testdir,
|
req.environ['wsgi.input'] = open(os.path.join(self.testdir,
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from swift.common.swob import Request, Response
|
from swift.common.swob import Request
|
||||||
from swift.common.middleware import catch_errors
|
from swift.common.middleware import catch_errors
|
||||||
from swift.common.utils import get_logger
|
from swift.common.utils import get_logger
|
||||||
|
|
||||||
|
@ -280,7 +280,7 @@ class TestCappedFileLikeObject(unittest.TestCase):
|
|||||||
self.assertEquals(fp.readline(), 'def')
|
self.assertEquals(fp.readline(), 'def')
|
||||||
except EOFError, err:
|
except EOFError, err:
|
||||||
exc = err
|
exc = err
|
||||||
self.assertEquals(str(err), 'max_file_size exceeded')
|
self.assertEquals(str(exc), 'max_file_size exceeded')
|
||||||
|
|
||||||
def test_read_sized(self):
|
def test_read_sized(self):
|
||||||
fp = formpost._CappedFileLikeObject(StringIO('abcdefg'), 10)
|
fp = formpost._CappedFileLikeObject(StringIO('abcdefg'), 10)
|
||||||
|
@ -83,7 +83,7 @@ class SwiftAuth(unittest.TestCase):
|
|||||||
role = self.test_auth.reseller_admin_role
|
role = self.test_auth.reseller_admin_role
|
||||||
headers = self._get_identity_headers(role=role)
|
headers = self._get_identity_headers(role=role)
|
||||||
req = self._make_request('/v1/AUTH_acct/c', headers)
|
req = self._make_request('/v1/AUTH_acct/c', headers)
|
||||||
resp = req.get_response(self._get_successful_middleware())
|
req.get_response(self._get_successful_middleware())
|
||||||
self.assertTrue(req.environ.get('reseller_request'))
|
self.assertTrue(req.environ.get('reseller_request'))
|
||||||
|
|
||||||
def test_confirmed_identity_is_not_authorized(self):
|
def test_confirmed_identity_is_not_authorized(self):
|
||||||
|
@ -74,7 +74,6 @@ class TestListEndpoints(unittest.TestCase):
|
|||||||
'ip': '10.1.2.2', 'port': 6000,
|
'ip': '10.1.2.2', 'port': 6000,
|
||||||
'device': 'sdd1'}]
|
'device': 'sdd1'}]
|
||||||
intended_part_shift = 30
|
intended_part_shift = 30
|
||||||
intended_reload_time = 15
|
|
||||||
ring.RingData(intended_replica2part2dev_id_a,
|
ring.RingData(intended_replica2part2dev_id_a,
|
||||||
intended_devs, intended_part_shift).save(accountgz)
|
intended_devs, intended_part_shift).save(accountgz)
|
||||||
ring.RingData(intended_replica2part2dev_id_c,
|
ring.RingData(intended_replica2part2dev_id_c,
|
||||||
|
@ -74,7 +74,7 @@ class TestCacheMiddleware(unittest.TestCase):
|
|||||||
memcache.ConfigParser = ExcConfigParser
|
memcache.ConfigParser = ExcConfigParser
|
||||||
exc = None
|
exc = None
|
||||||
try:
|
try:
|
||||||
app = memcache.MemcacheMiddleware(FakeApp(), {})
|
memcache.MemcacheMiddleware(FakeApp(), {})
|
||||||
except Exception, err:
|
except Exception, err:
|
||||||
exc = err
|
exc = err
|
||||||
finally:
|
finally:
|
||||||
@ -87,7 +87,7 @@ class TestCacheMiddleware(unittest.TestCase):
|
|||||||
memcache.ConfigParser = ExcConfigParser
|
memcache.ConfigParser = ExcConfigParser
|
||||||
exc = None
|
exc = None
|
||||||
try:
|
try:
|
||||||
app = memcache.MemcacheMiddleware(
|
memcache.MemcacheMiddleware(
|
||||||
FakeApp(), {'memcache_servers': '1.2.3.4:5',
|
FakeApp(), {'memcache_servers': '1.2.3.4:5',
|
||||||
'memcache_serialization_support': '2'})
|
'memcache_serialization_support': '2'})
|
||||||
except Exception, err:
|
except Exception, err:
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import time
|
import time
|
||||||
from urllib import quote, unquote
|
from urllib import unquote
|
||||||
import cStringIO as StringIO
|
import cStringIO as StringIO
|
||||||
from logging.handlers import SysLogHandler
|
from logging.handlers import SysLogHandler
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ class FakeAppReadline(object):
|
|||||||
def __call__(self, env, start_response):
|
def __call__(self, env, start_response):
|
||||||
start_response('200 OK', [('Content-Type', 'text/plain'),
|
start_response('200 OK', [('Content-Type', 'text/plain'),
|
||||||
('Content-Length', '8')])
|
('Content-Length', '8')])
|
||||||
line = env['wsgi.input'].readline()
|
env['wsgi.input'].readline()
|
||||||
return ["FAKE APP"]
|
return ["FAKE APP"]
|
||||||
|
|
||||||
|
|
||||||
@ -130,7 +130,8 @@ class TestProxyLogging(unittest.TestCase):
|
|||||||
for url in ['/', '/foo', '/foo/bar', '/v1']:
|
for url in ['/', '/foo', '/foo/bar', '/v1']:
|
||||||
req = Request.blank(url, environ={'REQUEST_METHOD': 'GET'})
|
req = Request.blank(url, environ={'REQUEST_METHOD': 'GET'})
|
||||||
resp = app(req.environ, start_response)
|
resp = app(req.environ, start_response)
|
||||||
resp_body = ''.join(resp)
|
# get body
|
||||||
|
''.join(resp)
|
||||||
self.assertEqual([], app.access_logger.log_dict['timing'])
|
self.assertEqual([], app.access_logger.log_dict['timing'])
|
||||||
self.assertEqual([], app.access_logger.log_dict['update_stats'])
|
self.assertEqual([], app.access_logger.log_dict['update_stats'])
|
||||||
|
|
||||||
@ -295,7 +296,7 @@ class TestProxyLogging(unittest.TestCase):
|
|||||||
'REQUEST_METHOD': 'GET'})
|
'REQUEST_METHOD': 'GET'})
|
||||||
resp = app(req.environ, start_response)
|
resp = app(req.environ, start_response)
|
||||||
resp_body = ''.join(resp)
|
resp_body = ''.join(resp)
|
||||||
log_parts = self._log_parts(app, should_be_empty=True)
|
self._log_parts(app, should_be_empty=True)
|
||||||
self.assertEquals(resp_body, 'FAKE APP')
|
self.assertEquals(resp_body, 'FAKE APP')
|
||||||
|
|
||||||
def test_multi_segment_resp(self):
|
def test_multi_segment_resp(self):
|
||||||
@ -321,7 +322,8 @@ class TestProxyLogging(unittest.TestCase):
|
|||||||
app.access_logger = FakeLogger()
|
app.access_logger = FakeLogger()
|
||||||
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'})
|
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'})
|
||||||
resp = app(req.environ, start_response)
|
resp = app(req.environ, start_response)
|
||||||
exhaust_generator = [x for x in resp]
|
# exhaust generator
|
||||||
|
[x for x in resp]
|
||||||
log_parts = self._log_parts(app)
|
log_parts = self._log_parts(app)
|
||||||
headers = unquote(log_parts[14]).split('\n')
|
headers = unquote(log_parts[14]).split('\n')
|
||||||
self.assert_('Host: localhost:80' in headers)
|
self.assert_('Host: localhost:80' in headers)
|
||||||
@ -333,7 +335,8 @@ class TestProxyLogging(unittest.TestCase):
|
|||||||
req = Request.blank('/v1/a/c/o/foo', environ={'REQUEST_METHOD': 'PUT',
|
req = Request.blank('/v1/a/c/o/foo', environ={'REQUEST_METHOD': 'PUT',
|
||||||
'wsgi.input': StringIO.StringIO('some stuff')})
|
'wsgi.input': StringIO.StringIO('some stuff')})
|
||||||
resp = app(req.environ, start_response)
|
resp = app(req.environ, start_response)
|
||||||
exhaust_generator = [x for x in resp]
|
# exhaust generator
|
||||||
|
[x for x in resp]
|
||||||
log_parts = self._log_parts(app)
|
log_parts = self._log_parts(app)
|
||||||
self.assertEquals(log_parts[11], str(len('FAKE APP')))
|
self.assertEquals(log_parts[11], str(len('FAKE APP')))
|
||||||
self.assertEquals(log_parts[10], str(len('some stuff')))
|
self.assertEquals(log_parts[10], str(len('some stuff')))
|
||||||
@ -349,7 +352,8 @@ class TestProxyLogging(unittest.TestCase):
|
|||||||
'wsgi.input': StringIO.StringIO(
|
'wsgi.input': StringIO.StringIO(
|
||||||
'some stuff\nsome other stuff\n')})
|
'some stuff\nsome other stuff\n')})
|
||||||
resp = app(req.environ, start_response)
|
resp = app(req.environ, start_response)
|
||||||
exhaust_generator = [x for x in resp]
|
# exhaust generator
|
||||||
|
[x for x in resp]
|
||||||
log_parts = self._log_parts(app)
|
log_parts = self._log_parts(app)
|
||||||
self.assertEquals(log_parts[11], str(len('FAKE APP')))
|
self.assertEquals(log_parts[11], str(len('FAKE APP')))
|
||||||
self.assertEquals(log_parts[10], str(len('some stuff\n')))
|
self.assertEquals(log_parts[10], str(len('some stuff\n')))
|
||||||
@ -363,7 +367,8 @@ class TestProxyLogging(unittest.TestCase):
|
|||||||
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET',
|
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET',
|
||||||
'QUERY_STRING': 'x=3'})
|
'QUERY_STRING': 'x=3'})
|
||||||
resp = app(req.environ, start_response)
|
resp = app(req.environ, start_response)
|
||||||
exhaust_generator = [x for x in resp]
|
# exhaust generator
|
||||||
|
[x for x in resp]
|
||||||
log_parts = self._log_parts(app)
|
log_parts = self._log_parts(app)
|
||||||
self.assertEquals(unquote(log_parts[4]), '/?x=3')
|
self.assertEquals(unquote(log_parts[4]), '/?x=3')
|
||||||
|
|
||||||
@ -373,7 +378,8 @@ class TestProxyLogging(unittest.TestCase):
|
|||||||
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET',
|
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET',
|
||||||
'REMOTE_ADDR': '1.2.3.4'})
|
'REMOTE_ADDR': '1.2.3.4'})
|
||||||
resp = app(req.environ, start_response)
|
resp = app(req.environ, start_response)
|
||||||
exhaust_generator = [x for x in resp]
|
# exhaust generator
|
||||||
|
[x for x in resp]
|
||||||
log_parts = self._log_parts(app)
|
log_parts = self._log_parts(app)
|
||||||
self.assertEquals(log_parts[0], '1.2.3.4') # client ip
|
self.assertEquals(log_parts[0], '1.2.3.4') # client ip
|
||||||
self.assertEquals(log_parts[1], '1.2.3.4') # remote addr
|
self.assertEquals(log_parts[1], '1.2.3.4') # remote addr
|
||||||
@ -386,7 +392,8 @@ class TestProxyLogging(unittest.TestCase):
|
|||||||
'REMOTE_ADDR': '1.2.3.4',
|
'REMOTE_ADDR': '1.2.3.4',
|
||||||
'HTTP_X_FORWARDED_FOR': '4.5.6.7,8.9.10.11'})
|
'HTTP_X_FORWARDED_FOR': '4.5.6.7,8.9.10.11'})
|
||||||
resp = app(req.environ, start_response)
|
resp = app(req.environ, start_response)
|
||||||
exhaust_generator = [x for x in resp]
|
# exhaust generator
|
||||||
|
[x for x in resp]
|
||||||
log_parts = self._log_parts(app)
|
log_parts = self._log_parts(app)
|
||||||
self.assertEquals(log_parts[0], '4.5.6.7') # client ip
|
self.assertEquals(log_parts[0], '4.5.6.7') # client ip
|
||||||
self.assertEquals(log_parts[1], '1.2.3.4') # remote addr
|
self.assertEquals(log_parts[1], '1.2.3.4') # remote addr
|
||||||
@ -398,7 +405,8 @@ class TestProxyLogging(unittest.TestCase):
|
|||||||
'REMOTE_ADDR': '1.2.3.4',
|
'REMOTE_ADDR': '1.2.3.4',
|
||||||
'HTTP_X_CLUSTER_CLIENT_IP': '4.5.6.7'})
|
'HTTP_X_CLUSTER_CLIENT_IP': '4.5.6.7'})
|
||||||
resp = app(req.environ, start_response)
|
resp = app(req.environ, start_response)
|
||||||
exhaust_generator = [x for x in resp]
|
# exhaust generator
|
||||||
|
[x for x in resp]
|
||||||
log_parts = self._log_parts(app)
|
log_parts = self._log_parts(app)
|
||||||
self.assertEquals(log_parts[0], '4.5.6.7') # client ip
|
self.assertEquals(log_parts[0], '4.5.6.7') # client ip
|
||||||
self.assertEquals(log_parts[1], '1.2.3.4') # remote addr
|
self.assertEquals(log_parts[1], '1.2.3.4') # remote addr
|
||||||
@ -421,7 +429,8 @@ class TestProxyLogging(unittest.TestCase):
|
|||||||
app.access_logger = FakeLogger()
|
app.access_logger = FakeLogger()
|
||||||
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'})
|
req = Request.blank('/', environ={'REQUEST_METHOD': 'GET'})
|
||||||
resp = app(req.environ, start_response)
|
resp = app(req.environ, start_response)
|
||||||
read_first_chunk = next(resp)
|
# read first chunk
|
||||||
|
next(resp)
|
||||||
resp.close() # raise a GeneratorExit in middleware app_iter loop
|
resp.close() # raise a GeneratorExit in middleware app_iter loop
|
||||||
log_parts = self._log_parts(app)
|
log_parts = self._log_parts(app)
|
||||||
self.assertEquals(log_parts[6], '499')
|
self.assertEquals(log_parts[6], '499')
|
||||||
@ -434,7 +443,8 @@ class TestProxyLogging(unittest.TestCase):
|
|||||||
'wsgi.input': FileLikeExceptor()})
|
'wsgi.input': FileLikeExceptor()})
|
||||||
try:
|
try:
|
||||||
resp = app(req.environ, start_response)
|
resp = app(req.environ, start_response)
|
||||||
body = ''.join(resp)
|
# read body
|
||||||
|
''.join(resp)
|
||||||
except IOError:
|
except IOError:
|
||||||
pass
|
pass
|
||||||
log_parts = self._log_parts(app)
|
log_parts = self._log_parts(app)
|
||||||
@ -449,7 +459,8 @@ class TestProxyLogging(unittest.TestCase):
|
|||||||
'wsgi.input': FileLikeExceptor()})
|
'wsgi.input': FileLikeExceptor()})
|
||||||
try:
|
try:
|
||||||
resp = app(req.environ, start_response)
|
resp = app(req.environ, start_response)
|
||||||
body = ''.join(resp)
|
# read body
|
||||||
|
''.join(resp)
|
||||||
except IOError:
|
except IOError:
|
||||||
pass
|
pass
|
||||||
log_parts = self._log_parts(app)
|
log_parts = self._log_parts(app)
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from swift.common.swob import Request, Response, HTTPUnauthorized
|
from swift.common.swob import Request, HTTPUnauthorized
|
||||||
from swift.common.middleware import container_quotas
|
from swift.common.middleware import container_quotas
|
||||||
|
|
||||||
class FakeCache(object):
|
class FakeCache(object):
|
||||||
|
@ -158,7 +158,7 @@ class TestRateLimit(unittest.TestCase):
|
|||||||
global time_ticker
|
global time_ticker
|
||||||
begin = time.time()
|
begin = time.time()
|
||||||
for x in range(0, num):
|
for x in range(0, num):
|
||||||
result = callable_func()
|
callable_func()
|
||||||
end = time.time()
|
end = time.time()
|
||||||
total_time = float(num) / rate - 1.0 / rate # 1st request isn't limited
|
total_time = float(num) / rate - 1.0 / rate # 1st request isn't limited
|
||||||
# Allow for one second of variation in the total time.
|
# Allow for one second of variation in the total time.
|
||||||
|
@ -620,14 +620,8 @@ class TestReconSuccess(TestCase):
|
|||||||
'UDP: inuse 16 mem 4', 'UDPLITE: inuse 0',
|
'UDP: inuse 16 mem 4', 'UDPLITE: inuse 0',
|
||||||
'RAW: inuse 0', 'FRAG: inuse 0 memory 0',
|
'RAW: inuse 0', 'FRAG: inuse 0 memory 0',
|
||||||
'']
|
'']
|
||||||
sockstat6_content = ['TCP6: inuse 1',
|
|
||||||
'UDP6: inuse 3',
|
|
||||||
'UDPLITE6: inuse 0',
|
|
||||||
'RAW6: inuse 0',
|
|
||||||
'FRAG6: inuse 0 memory 0',
|
|
||||||
'']
|
|
||||||
oart = OpenAndReadTester(sockstat_content)
|
oart = OpenAndReadTester(sockstat_content)
|
||||||
rv = self.app.get_socket_info(openr=oart.open)
|
self.app.get_socket_info(openr=oart.open)
|
||||||
self.assertEquals(oart.open_calls, [(('/proc/net/sockstat', 'r'), {}),
|
self.assertEquals(oart.open_calls, [(('/proc/net/sockstat', 'r'), {}),
|
||||||
(('/proc/net/sockstat6', 'r'), {})])
|
(('/proc/net/sockstat6', 'r'), {})])
|
||||||
|
|
||||||
@ -672,7 +666,7 @@ class TestReconMiddleware(unittest.TestCase):
|
|||||||
|
|
||||||
def test_get_device_info(self):
|
def test_get_device_info(self):
|
||||||
get_device_resp = ['{"/srv/1/node": ["sdb1"]}']
|
get_device_resp = ['{"/srv/1/node": ["sdb1"]}']
|
||||||
req = Request.blank('/recon/devices',
|
req = Request.blank('/recon/devices',
|
||||||
environ={'REQUEST_METHOD': 'GET'})
|
environ={'REQUEST_METHOD': 'GET'})
|
||||||
resp = self.app(req.environ, start_response)
|
resp = self.app(req.environ, start_response)
|
||||||
self.assertEquals(resp, get_device_resp)
|
self.assertEquals(resp, get_device_resp)
|
||||||
@ -811,7 +805,7 @@ class TestReconMiddleware(unittest.TestCase):
|
|||||||
environ={'REQUEST_METHOD': 'GET'})
|
environ={'REQUEST_METHOD': 'GET'})
|
||||||
resp = self.app(req.environ, start_response)
|
resp = self.app(req.environ, start_response)
|
||||||
self.assertEquals(resp, get_unmounted_resp)
|
self.assertEquals(resp, get_unmounted_resp)
|
||||||
|
|
||||||
def test_recon_no_get_unmounted(self):
|
def test_recon_no_get_unmounted(self):
|
||||||
get_unmounted_resp = '[]'
|
get_unmounted_resp = '[]'
|
||||||
self.app.get_unmounted = self.frecon.fake_no_unmounted
|
self.app.get_unmounted = self.frecon.fake_no_unmounted
|
||||||
|
@ -17,9 +17,7 @@ import unittest
|
|||||||
from mock import patch
|
from mock import patch
|
||||||
from swift.common.middleware import slo
|
from swift.common.middleware import slo
|
||||||
from swift.common.utils import json
|
from swift.common.utils import json
|
||||||
from swift.common.constraints import MAX_META_VALUE_LENGTH
|
from swift.common.swob import Request, Response, HTTPException
|
||||||
from swift.common.swob import Request, Response, HTTPException, \
|
|
||||||
HTTPRequestEntityTooLarge
|
|
||||||
|
|
||||||
|
|
||||||
class FakeApp(object):
|
class FakeApp(object):
|
||||||
|
@ -22,7 +22,6 @@ from contextlib import contextmanager
|
|||||||
|
|
||||||
from swift.common.swob import Request, Response
|
from swift.common.swob import Request, Response
|
||||||
from swift.common.middleware import staticweb
|
from swift.common.middleware import staticweb
|
||||||
from test.unit import FakeLogger
|
|
||||||
|
|
||||||
|
|
||||||
class FakeMemcache(object):
|
class FakeMemcache(object):
|
||||||
@ -460,11 +459,6 @@ class TestStaticWeb(unittest.TestCase):
|
|||||||
self.assertEquals(resp.status_int, 200)
|
self.assertEquals(resp.status_int, 200)
|
||||||
self.assert_('Test main index.html file.' in resp.body)
|
self.assert_('Test main index.html file.' in resp.body)
|
||||||
|
|
||||||
def test_container3subdir(self):
|
|
||||||
resp = Request.blank(
|
|
||||||
'/v1/a/c3/subdir').get_response(self.test_staticweb)
|
|
||||||
self.assertEquals(resp.status_int, 301)
|
|
||||||
|
|
||||||
def test_container3subsubdir(self):
|
def test_container3subsubdir(self):
|
||||||
resp = Request.blank(
|
resp = Request.blank(
|
||||||
'/v1/a/c3/subdir3/subsubdir').get_response(self.test_staticweb)
|
'/v1/a/c3/subdir3/subsubdir').get_response(self.test_staticweb)
|
||||||
|
@ -334,7 +334,7 @@ class TestAuth(unittest.TestCase):
|
|||||||
cache_key = 'AUTH_/token/AUTH_t'
|
cache_key = 'AUTH_/token/AUTH_t'
|
||||||
cache_entry = (time()+3600, '.reseller_admin')
|
cache_entry = (time()+3600, '.reseller_admin')
|
||||||
req.environ['swift.cache'].set(cache_key, cache_entry)
|
req.environ['swift.cache'].set(cache_key, cache_entry)
|
||||||
resp = req.get_response(self.test_auth)
|
req.get_response(self.test_auth)
|
||||||
self.assertTrue(req.environ.get('reseller_request', False))
|
self.assertTrue(req.environ.get('reseller_request', False))
|
||||||
|
|
||||||
def test_account_put_permissions(self):
|
def test_account_put_permissions(self):
|
||||||
|
@ -201,7 +201,7 @@ class TestTempURL(unittest.TestCase):
|
|||||||
path = '/v1/a/c/o'
|
path = '/v1/a/c/o'
|
||||||
key = 'abc'
|
key = 'abc'
|
||||||
hmac_body = '%s\n%s\n%s' % (method, expires, path)
|
hmac_body = '%s\n%s\n%s' % (method, expires, path)
|
||||||
sig = hmac.new(key, hmac_body, sha1).hexdigest()
|
hmac.new(key, hmac_body, sha1).hexdigest()
|
||||||
req = self._make_request(path,
|
req = self._make_request(path,
|
||||||
environ={'QUERY_STRING': 'temp_url_expires=%s' % expires})
|
environ={'QUERY_STRING': 'temp_url_expires=%s' % expires})
|
||||||
req.environ['swift.cache'].set('temp-url-key/a', key)
|
req.environ['swift.cache'].set('temp-url-key/a', key)
|
||||||
|
@ -23,7 +23,6 @@ from mock import Mock, call as mock_call
|
|||||||
|
|
||||||
from swift.common import exceptions
|
from swift.common import exceptions
|
||||||
from swift.common import ring
|
from swift.common import ring
|
||||||
from swift.common.ring import RingBuilder, RingData
|
|
||||||
|
|
||||||
|
|
||||||
class TestRingBuilder(unittest.TestCase):
|
class TestRingBuilder(unittest.TestCase):
|
||||||
@ -669,7 +668,7 @@ class TestRingBuilder(unittest.TestCase):
|
|||||||
fake_pickle = Mock(return_value=rb)
|
fake_pickle = Mock(return_value=rb)
|
||||||
fake_open = Mock(return_value=None)
|
fake_open = Mock(return_value=None)
|
||||||
pickle.load = fake_pickle
|
pickle.load = fake_pickle
|
||||||
builder = RingBuilder.load('fake.builder', open=fake_open)
|
builder = ring.RingBuilder.load('fake.builder', open=fake_open)
|
||||||
self.assertEquals(fake_pickle.call_count, 1)
|
self.assertEquals(fake_pickle.call_count, 1)
|
||||||
fake_open.assert_has_calls([mock_call('fake.builder', 'rb')])
|
fake_open.assert_has_calls([mock_call('fake.builder', 'rb')])
|
||||||
self.assertEquals(builder, rb)
|
self.assertEquals(builder, rb)
|
||||||
@ -679,7 +678,7 @@ class TestRingBuilder(unittest.TestCase):
|
|||||||
#test old style builder
|
#test old style builder
|
||||||
fake_pickle.return_value = rb.to_dict()
|
fake_pickle.return_value = rb.to_dict()
|
||||||
pickle.load = fake_pickle
|
pickle.load = fake_pickle
|
||||||
builder = RingBuilder.load('fake.builder', open=fake_open)
|
builder = ring.RingBuilder.load('fake.builder', open=fake_open)
|
||||||
fake_open.assert_has_calls([mock_call('fake.builder', 'rb')])
|
fake_open.assert_has_calls([mock_call('fake.builder', 'rb')])
|
||||||
self.assertEquals(builder.devs, rb.devs)
|
self.assertEquals(builder.devs, rb.devs)
|
||||||
fake_pickle.reset_mock()
|
fake_pickle.reset_mock()
|
||||||
@ -691,7 +690,7 @@ class TestRingBuilder(unittest.TestCase):
|
|||||||
del(dev['meta'])
|
del(dev['meta'])
|
||||||
fake_pickle.return_value = no_meta_builder
|
fake_pickle.return_value = no_meta_builder
|
||||||
pickle.load = fake_pickle
|
pickle.load = fake_pickle
|
||||||
builder = RingBuilder.load('fake.builder', open=fake_open)
|
builder = ring.RingBuilder.load('fake.builder', open=fake_open)
|
||||||
fake_open.assert_has_calls([mock_call('fake.builder', 'rb')])
|
fake_open.assert_has_calls([mock_call('fake.builder', 'rb')])
|
||||||
self.assertEquals(builder.devs, rb.devs)
|
self.assertEquals(builder.devs, rb.devs)
|
||||||
fake_pickle.reset_mock()
|
fake_pickle.reset_mock()
|
||||||
|
@ -330,7 +330,6 @@ class TestRing(unittest.TestCase):
|
|||||||
self.assertEquals(primary_zones, exp_zones)
|
self.assertEquals(primary_zones, exp_zones)
|
||||||
devs = list(r.get_more_nodes(part))
|
devs = list(r.get_more_nodes(part))
|
||||||
self.assertEquals([d['id'] for d in devs], exp_handoffs)
|
self.assertEquals([d['id'] for d in devs], exp_handoffs)
|
||||||
seen_shared_zone = False
|
|
||||||
|
|
||||||
# The first 6 replicas plus the 3 primary nodes should cover all 9
|
# The first 6 replicas plus the 3 primary nodes should cover all 9
|
||||||
# zones in this test
|
# zones in this test
|
||||||
|
@ -16,8 +16,7 @@
|
|||||||
import unittest
|
import unittest
|
||||||
from test.unit import MockTrue
|
from test.unit import MockTrue
|
||||||
|
|
||||||
from swift.common.swob import HTTPBadRequest, HTTPLengthRequired, \
|
from swift.common.swob import HTTPBadRequest, Request
|
||||||
HTTPRequestEntityTooLarge, Request
|
|
||||||
from swift.common.http import HTTP_REQUEST_ENTITY_TOO_LARGE, \
|
from swift.common.http import HTTP_REQUEST_ENTITY_TOO_LARGE, \
|
||||||
HTTP_BAD_REQUEST, HTTP_LENGTH_REQUIRED
|
HTTP_BAD_REQUEST, HTTP_LENGTH_REQUIRED
|
||||||
from swift.common import constraints
|
from swift.common import constraints
|
||||||
|
@ -20,7 +20,6 @@ import hashlib
|
|||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
from shutil import rmtree, copy
|
from shutil import rmtree, copy
|
||||||
from StringIO import StringIO
|
|
||||||
from time import sleep, time
|
from time import sleep, time
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
@ -695,7 +694,7 @@ class TestContainerBroker(unittest.TestCase):
|
|||||||
broker.put_object('z', normalize_timestamp(time()), 0, 'text/plain',
|
broker.put_object('z', normalize_timestamp(time()), 0, 'text/plain',
|
||||||
'd41d8cd98f00b204e9800998ecf8427e')
|
'd41d8cd98f00b204e9800998ecf8427e')
|
||||||
# Test before deletion
|
# Test before deletion
|
||||||
res = broker.reclaim(normalize_timestamp(time()), time())
|
broker.reclaim(normalize_timestamp(time()), time())
|
||||||
broker.delete_db(normalize_timestamp(time()))
|
broker.delete_db(normalize_timestamp(time()))
|
||||||
|
|
||||||
def test_delete_object(self):
|
def test_delete_object(self):
|
||||||
|
@ -22,7 +22,6 @@ from shutil import rmtree
|
|||||||
from tempfile import mkdtemp, NamedTemporaryFile
|
from tempfile import mkdtemp, NamedTemporaryFile
|
||||||
|
|
||||||
from swift.common import db_replicator
|
from swift.common import db_replicator
|
||||||
from swift.common import utils
|
|
||||||
from swift.common.utils import normalize_timestamp
|
from swift.common.utils import normalize_timestamp
|
||||||
from swift.container import server as container_server
|
from swift.container import server as container_server
|
||||||
|
|
||||||
@ -215,11 +214,9 @@ class TestDBReplicator(unittest.TestCase):
|
|||||||
def test_rsync_file(self):
|
def test_rsync_file(self):
|
||||||
replicator = TestReplicator({})
|
replicator = TestReplicator({})
|
||||||
with _mock_process(-1):
|
with _mock_process(-1):
|
||||||
fake_device = {'ip': '127.0.0.1', 'device': 'sda1'}
|
|
||||||
self.assertEquals(False,
|
self.assertEquals(False,
|
||||||
replicator._rsync_file('/some/file', 'remote:/some/file'))
|
replicator._rsync_file('/some/file', 'remote:/some/file'))
|
||||||
with _mock_process(0):
|
with _mock_process(0):
|
||||||
fake_device = {'ip': '127.0.0.1', 'device': 'sda1'}
|
|
||||||
self.assertEquals(True,
|
self.assertEquals(True,
|
||||||
replicator._rsync_file('/some/file', 'remote:/some/file'))
|
replicator._rsync_file('/some/file', 'remote:/some/file'))
|
||||||
|
|
||||||
|
@ -289,7 +289,7 @@ class TestInternalClient(unittest.TestCase):
|
|||||||
try:
|
try:
|
||||||
client.make_request('GET', '/', {}, (201,))
|
client.make_request('GET', '/', {}, (201,))
|
||||||
except Exception, err:
|
except Exception, err:
|
||||||
exc = err
|
pass
|
||||||
self.assertEquals(200, err.resp.status_int)
|
self.assertEquals(200, err.resp.status_int)
|
||||||
finally:
|
finally:
|
||||||
internal_client.sleep = old_sleep
|
internal_client.sleep = old_sleep
|
||||||
@ -324,7 +324,7 @@ class TestInternalClient(unittest.TestCase):
|
|||||||
try:
|
try:
|
||||||
client.make_request('PUT', '/', {}, (2,), fobj)
|
client.make_request('PUT', '/', {}, (2,), fobj)
|
||||||
except Exception, err:
|
except Exception, err:
|
||||||
exc = err
|
pass
|
||||||
self.assertEquals(404, err.resp.status_int)
|
self.assertEquals(404, err.resp.status_int)
|
||||||
finally:
|
finally:
|
||||||
internal_client.sleep = old_sleep
|
internal_client.sleep = old_sleep
|
||||||
|
@ -21,7 +21,6 @@ import sys
|
|||||||
import resource
|
import resource
|
||||||
import signal
|
import signal
|
||||||
import errno
|
import errno
|
||||||
from contextlib import contextmanager
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from time import sleep, time
|
from time import sleep, time
|
||||||
|
@ -580,14 +580,16 @@ class TestResponse(unittest.TestCase):
|
|||||||
'/', environ={'HTTP_HOST': 'somehost'})
|
'/', environ={'HTTP_HOST': 'somehost'})
|
||||||
resp = self._get_response()
|
resp = self._get_response()
|
||||||
resp.location = '/something'
|
resp.location = '/something'
|
||||||
body = ''.join(resp(req.environ, start_response))
|
# read response
|
||||||
|
''.join(resp(req.environ, start_response))
|
||||||
self.assertEquals(resp.location, 'http://somehost/something')
|
self.assertEquals(resp.location, 'http://somehost/something')
|
||||||
|
|
||||||
req = swift.common.swob.Request.blank(
|
req = swift.common.swob.Request.blank(
|
||||||
'/', environ={'HTTP_HOST': 'somehost:80'})
|
'/', environ={'HTTP_HOST': 'somehost:80'})
|
||||||
resp = self._get_response()
|
resp = self._get_response()
|
||||||
resp.location = '/something'
|
resp.location = '/something'
|
||||||
body = ''.join(resp(req.environ, start_response))
|
# read response
|
||||||
|
''.join(resp(req.environ, start_response))
|
||||||
self.assertEquals(resp.location, 'http://somehost/something')
|
self.assertEquals(resp.location, 'http://somehost/something')
|
||||||
|
|
||||||
req = swift.common.swob.Request.blank(
|
req = swift.common.swob.Request.blank(
|
||||||
@ -595,7 +597,8 @@ class TestResponse(unittest.TestCase):
|
|||||||
'wsgi.url_scheme': 'http'})
|
'wsgi.url_scheme': 'http'})
|
||||||
resp = self._get_response()
|
resp = self._get_response()
|
||||||
resp.location = '/something'
|
resp.location = '/something'
|
||||||
body = ''.join(resp(req.environ, start_response))
|
# read response
|
||||||
|
''.join(resp(req.environ, start_response))
|
||||||
self.assertEquals(resp.location, 'http://somehost:443/something')
|
self.assertEquals(resp.location, 'http://somehost:443/something')
|
||||||
|
|
||||||
req = swift.common.swob.Request.blank(
|
req = swift.common.swob.Request.blank(
|
||||||
@ -603,7 +606,8 @@ class TestResponse(unittest.TestCase):
|
|||||||
'wsgi.url_scheme': 'https'})
|
'wsgi.url_scheme': 'https'})
|
||||||
resp = self._get_response()
|
resp = self._get_response()
|
||||||
resp.location = '/something'
|
resp.location = '/something'
|
||||||
body = ''.join(resp(req.environ, start_response))
|
# read response
|
||||||
|
''.join(resp(req.environ, start_response))
|
||||||
self.assertEquals(resp.location, 'https://somehost/something')
|
self.assertEquals(resp.location, 'https://somehost/something')
|
||||||
|
|
||||||
def test_location_rewrite_no_host(self):
|
def test_location_rewrite_no_host(self):
|
||||||
@ -614,7 +618,8 @@ class TestResponse(unittest.TestCase):
|
|||||||
del req.environ['HTTP_HOST']
|
del req.environ['HTTP_HOST']
|
||||||
resp = self._get_response()
|
resp = self._get_response()
|
||||||
resp.location = '/something'
|
resp.location = '/something'
|
||||||
body = ''.join(resp(req.environ, start_response))
|
# read response
|
||||||
|
''.join(resp(req.environ, start_response))
|
||||||
self.assertEquals(resp.location, 'http://local/something')
|
self.assertEquals(resp.location, 'http://local/something')
|
||||||
|
|
||||||
req = swift.common.swob.Request.blank(
|
req = swift.common.swob.Request.blank(
|
||||||
@ -622,7 +627,8 @@ class TestResponse(unittest.TestCase):
|
|||||||
del req.environ['HTTP_HOST']
|
del req.environ['HTTP_HOST']
|
||||||
resp = self._get_response()
|
resp = self._get_response()
|
||||||
resp.location = '/something'
|
resp.location = '/something'
|
||||||
body = ''.join(resp(req.environ, start_response))
|
# read response
|
||||||
|
''.join(resp(req.environ, start_response))
|
||||||
self.assertEquals(resp.location, 'http://local:81/something')
|
self.assertEquals(resp.location, 'http://local:81/something')
|
||||||
|
|
||||||
def test_location_no_rewrite(self):
|
def test_location_no_rewrite(self):
|
||||||
@ -632,7 +638,8 @@ class TestResponse(unittest.TestCase):
|
|||||||
'/', environ={'HTTP_HOST': 'somehost'})
|
'/', environ={'HTTP_HOST': 'somehost'})
|
||||||
resp = self._get_response()
|
resp = self._get_response()
|
||||||
resp.location = 'http://www.google.com/'
|
resp.location = 'http://www.google.com/'
|
||||||
body = ''.join(resp(req.environ, start_response))
|
# read response
|
||||||
|
''.join(resp(req.environ, start_response))
|
||||||
self.assertEquals(resp.location, 'http://www.google.com/')
|
self.assertEquals(resp.location, 'http://www.google.com/')
|
||||||
|
|
||||||
def test_app_iter(self):
|
def test_app_iter(self):
|
||||||
@ -655,7 +662,8 @@ class TestResponse(unittest.TestCase):
|
|||||||
resp.conditional_response = True
|
resp.conditional_response = True
|
||||||
resp.content_length = 10
|
resp.content_length = 10
|
||||||
|
|
||||||
content = ''.join(resp._response_iter(resp.app_iter, ''))
|
# read response
|
||||||
|
''.join(resp._response_iter(resp.app_iter, ''))
|
||||||
|
|
||||||
self.assertEquals(resp.status, '200 OK')
|
self.assertEquals(resp.status, '200 OK')
|
||||||
self.assertEqual(10, resp.content_length)
|
self.assertEqual(10, resp.content_length)
|
||||||
@ -672,7 +680,8 @@ class TestResponse(unittest.TestCase):
|
|||||||
resp.conditional_response = True
|
resp.conditional_response = True
|
||||||
resp.content_length = 10
|
resp.content_length = 10
|
||||||
|
|
||||||
content = ''.join(resp._response_iter(resp.app_iter, ''))
|
# read response
|
||||||
|
''.join(resp._response_iter(resp.app_iter, ''))
|
||||||
|
|
||||||
self.assertEquals(resp.status, '200 OK')
|
self.assertEquals(resp.status, '200 OK')
|
||||||
self.assertEqual(10, resp.content_length)
|
self.assertEqual(10, resp.content_length)
|
||||||
|
@ -20,7 +20,6 @@ from test.unit import temptree
|
|||||||
import ctypes
|
import ctypes
|
||||||
import errno
|
import errno
|
||||||
import logging
|
import logging
|
||||||
import mimetools
|
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
@ -35,9 +34,7 @@ from shutil import rmtree
|
|||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from tempfile import TemporaryFile, NamedTemporaryFile
|
from tempfile import TemporaryFile, NamedTemporaryFile
|
||||||
from logging import handlers as logging_handlers
|
|
||||||
|
|
||||||
from eventlet import sleep
|
|
||||||
from mock import patch
|
from mock import patch
|
||||||
|
|
||||||
from swift.common.exceptions import (Timeout, MessageTimeout,
|
from swift.common.exceptions import (Timeout, MessageTimeout,
|
||||||
@ -422,7 +419,7 @@ class TestUtils(unittest.TestCase):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
utils.SysLogHandler = syslog_handler_catcher
|
utils.SysLogHandler = syslog_handler_catcher
|
||||||
logger = utils.get_logger({
|
utils.get_logger({
|
||||||
'log_facility': 'LOG_LOCAL3',
|
'log_facility': 'LOG_LOCAL3',
|
||||||
}, 'server', log_route='server')
|
}, 'server', log_route='server')
|
||||||
self.assertEquals([
|
self.assertEquals([
|
||||||
@ -431,7 +428,7 @@ class TestUtils(unittest.TestCase):
|
|||||||
syslog_handler_args)
|
syslog_handler_args)
|
||||||
|
|
||||||
syslog_handler_args = []
|
syslog_handler_args = []
|
||||||
logger = utils.get_logger({
|
utils.get_logger({
|
||||||
'log_facility': 'LOG_LOCAL3',
|
'log_facility': 'LOG_LOCAL3',
|
||||||
'log_address': '/foo/bar',
|
'log_address': '/foo/bar',
|
||||||
}, 'server', log_route='server')
|
}, 'server', log_route='server')
|
||||||
@ -445,7 +442,7 @@ class TestUtils(unittest.TestCase):
|
|||||||
|
|
||||||
# Using UDP with default port
|
# Using UDP with default port
|
||||||
syslog_handler_args = []
|
syslog_handler_args = []
|
||||||
logger = utils.get_logger({
|
utils.get_logger({
|
||||||
'log_udp_host': 'syslog.funtimes.com',
|
'log_udp_host': 'syslog.funtimes.com',
|
||||||
}, 'server', log_route='server')
|
}, 'server', log_route='server')
|
||||||
self.assertEquals([
|
self.assertEquals([
|
||||||
@ -456,7 +453,7 @@ class TestUtils(unittest.TestCase):
|
|||||||
|
|
||||||
# Using UDP with non-default port
|
# Using UDP with non-default port
|
||||||
syslog_handler_args = []
|
syslog_handler_args = []
|
||||||
logger = utils.get_logger({
|
utils.get_logger({
|
||||||
'log_udp_host': 'syslog.funtimes.com',
|
'log_udp_host': 'syslog.funtimes.com',
|
||||||
'log_udp_port': '2123',
|
'log_udp_port': '2123',
|
||||||
}, 'server', log_route='server')
|
}, 'server', log_route='server')
|
||||||
@ -627,7 +624,7 @@ class TestUtils(unittest.TestCase):
|
|||||||
self.assert_('127.0.0.1' in myips)
|
self.assert_('127.0.0.1' in myips)
|
||||||
|
|
||||||
def test_hash_path(self):
|
def test_hash_path(self):
|
||||||
_prefix = utils.HASH_PATH_PREFIX
|
_prefix = utils.HASH_PATH_PREFIX
|
||||||
utils.HASH_PATH_PREFIX = ''
|
utils.HASH_PATH_PREFIX = ''
|
||||||
# Yes, these tests are deliberately very fragile. We want to make sure
|
# Yes, these tests are deliberately very fragile. We want to make sure
|
||||||
# that if someones changes the results hash_path produces, they know it
|
# that if someones changes the results hash_path produces, they know it
|
||||||
@ -1576,7 +1573,6 @@ class TestStatsdLoggingDelegation(unittest.TestCase):
|
|||||||
self.assertEquals(called, [12345])
|
self.assertEquals(called, [12345])
|
||||||
|
|
||||||
def test_fsync_bad_fullsync(self):
|
def test_fsync_bad_fullsync(self):
|
||||||
called = []
|
|
||||||
class FCNTL:
|
class FCNTL:
|
||||||
F_FULLSYNC = 123
|
F_FULLSYNC = 123
|
||||||
def fcntl(self, fd, op):
|
def fcntl(self, fd, op):
|
||||||
|
@ -16,20 +16,14 @@
|
|||||||
""" Tests for swift.common.utils """
|
""" Tests for swift.common.utils """
|
||||||
|
|
||||||
from __future__ import with_statement
|
from __future__ import with_statement
|
||||||
import logging
|
import errno
|
||||||
import mimetools
|
import mimetools
|
||||||
import os
|
|
||||||
import socket
|
import socket
|
||||||
import sys
|
|
||||||
import unittest
|
import unittest
|
||||||
from getpass import getuser
|
|
||||||
from shutil import rmtree
|
|
||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from urllib import quote
|
from urllib import quote
|
||||||
|
|
||||||
from eventlet import sleep
|
|
||||||
|
|
||||||
from swift.common.swob import Request
|
from swift.common.swob import Request
|
||||||
from swift.common import wsgi
|
from swift.common import wsgi
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ from tempfile import mkdtemp
|
|||||||
from eventlet import spawn, Timeout, listen
|
from eventlet import spawn, Timeout, listen
|
||||||
import simplejson
|
import simplejson
|
||||||
|
|
||||||
from swift.common.swob import Request, HTTPBadRequest
|
from swift.common.swob import Request
|
||||||
import swift.container
|
import swift.container
|
||||||
from swift.container import server as container_server
|
from swift.container import server as container_server
|
||||||
from swift.common.utils import normalize_timestamp, mkdirs
|
from swift.common.utils import normalize_timestamp, mkdirs
|
||||||
@ -1176,7 +1176,6 @@ class TestContainerController(unittest.TestCase):
|
|||||||
self.assertEquals(outbuf.getvalue()[:4], '412 ')
|
self.assertEquals(outbuf.getvalue()[:4], '412 ')
|
||||||
|
|
||||||
def test_invalid_method_doesnt_exist(self):
|
def test_invalid_method_doesnt_exist(self):
|
||||||
inbuf = StringIO()
|
|
||||||
errbuf = StringIO()
|
errbuf = StringIO()
|
||||||
outbuf = StringIO()
|
outbuf = StringIO()
|
||||||
|
|
||||||
@ -1190,7 +1189,6 @@ class TestContainerController(unittest.TestCase):
|
|||||||
self.assertEquals(outbuf.getvalue()[:4], '405 ')
|
self.assertEquals(outbuf.getvalue()[:4], '405 ')
|
||||||
|
|
||||||
def test_invalid_method_is_not_public(self):
|
def test_invalid_method_is_not_public(self):
|
||||||
inbuf = StringIO()
|
|
||||||
errbuf = StringIO()
|
errbuf = StringIO()
|
||||||
outbuf = StringIO()
|
outbuf = StringIO()
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
import cPickle as pickle
|
import cPickle as pickle
|
||||||
import os
|
import os
|
||||||
import sys
|
|
||||||
import unittest
|
import unittest
|
||||||
from gzip import GzipFile
|
from gzip import GzipFile
|
||||||
from shutil import rmtree
|
from shutil import rmtree
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
from test import unit
|
from test import unit
|
||||||
import unittest
|
import unittest
|
||||||
import tempfile
|
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
from shutil import rmtree
|
from shutil import rmtree
|
||||||
@ -26,9 +25,8 @@ from swift.obj import auditor
|
|||||||
from swift.obj import server as object_server
|
from swift.obj import server as object_server
|
||||||
from swift.obj.server import DiskFile, write_metadata, DATADIR
|
from swift.obj.server import DiskFile, write_metadata, DATADIR
|
||||||
from swift.common.utils import hash_path, mkdirs, normalize_timestamp, \
|
from swift.common.utils import hash_path, mkdirs, normalize_timestamp, \
|
||||||
renamer, storage_directory
|
storage_directory
|
||||||
from swift.obj.replicator import invalidate_hash
|
from swift.obj.replicator import invalidate_hash
|
||||||
from swift.common.exceptions import AuditException
|
|
||||||
|
|
||||||
|
|
||||||
class TestAuditor(unittest.TestCase):
|
class TestAuditor(unittest.TestCase):
|
||||||
@ -303,8 +301,6 @@ class TestAuditor(unittest.TestCase):
|
|||||||
def test_with_tombstone(self):
|
def test_with_tombstone(self):
|
||||||
ts_file_path = self.setup_bad_zero_byte(with_ts=True)
|
ts_file_path = self.setup_bad_zero_byte(with_ts=True)
|
||||||
self.auditor.run_once()
|
self.auditor.run_once()
|
||||||
quarantine_path = os.path.join(self.devices,
|
|
||||||
'sda', 'quarantined', 'objects')
|
|
||||||
self.assertTrue(ts_file_path.endswith('ts'))
|
self.assertTrue(ts_file_path.endswith('ts'))
|
||||||
self.assertTrue(os.path.exists(ts_file_path))
|
self.assertTrue(os.path.exists(ts_file_path))
|
||||||
|
|
||||||
|
@ -13,15 +13,12 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import json
|
|
||||||
from sys import exc_info
|
|
||||||
from time import time
|
from time import time
|
||||||
from unittest import main, TestCase
|
from unittest import main, TestCase
|
||||||
from test.unit import FakeLogger
|
from test.unit import FakeLogger
|
||||||
|
|
||||||
from swift.common import internal_client
|
from swift.common import internal_client
|
||||||
from swift.obj import expirer
|
from swift.obj import expirer
|
||||||
from swift.proxy.server import Application
|
|
||||||
|
|
||||||
|
|
||||||
def not_random():
|
def not_random():
|
||||||
@ -402,14 +399,13 @@ class TestObjectExpirer(TestCase):
|
|||||||
'interval': interval})
|
'interval': interval})
|
||||||
orig_random = expirer.random
|
orig_random = expirer.random
|
||||||
orig_sleep = expirer.sleep
|
orig_sleep = expirer.sleep
|
||||||
exc = None
|
|
||||||
try:
|
try:
|
||||||
expirer.random = not_random
|
expirer.random = not_random
|
||||||
expirer.sleep = not_sleep
|
expirer.sleep = not_sleep
|
||||||
x.run_once = raise_system_exit
|
x.run_once = raise_system_exit
|
||||||
x.run_forever()
|
x.run_forever()
|
||||||
except SystemExit, err:
|
except SystemExit, err:
|
||||||
exc = err
|
pass
|
||||||
finally:
|
finally:
|
||||||
expirer.random = orig_random
|
expirer.random = orig_random
|
||||||
expirer.sleep = orig_sleep
|
expirer.sleep = orig_sleep
|
||||||
@ -428,13 +424,12 @@ class TestObjectExpirer(TestCase):
|
|||||||
x = expirer.ObjectExpirer({})
|
x = expirer.ObjectExpirer({})
|
||||||
x.logger = FakeLogger()
|
x.logger = FakeLogger()
|
||||||
orig_sleep = expirer.sleep
|
orig_sleep = expirer.sleep
|
||||||
exc = None
|
|
||||||
try:
|
try:
|
||||||
expirer.sleep = not_sleep
|
expirer.sleep = not_sleep
|
||||||
x.run_once = raise_exceptions
|
x.run_once = raise_exceptions
|
||||||
x.run_forever()
|
x.run_forever()
|
||||||
except SystemExit, err:
|
except SystemExit, err:
|
||||||
exc = err
|
pass
|
||||||
finally:
|
finally:
|
||||||
expirer.sleep = orig_sleep
|
expirer.sleep = orig_sleep
|
||||||
self.assertEquals(str(err), 'exiting exception 2')
|
self.assertEquals(str(err), 'exiting exception 2')
|
||||||
|
@ -20,8 +20,6 @@ import os
|
|||||||
from gzip import GzipFile
|
from gzip import GzipFile
|
||||||
from shutil import rmtree
|
from shutil import rmtree
|
||||||
import cPickle as pickle
|
import cPickle as pickle
|
||||||
import logging
|
|
||||||
import fcntl
|
|
||||||
import time
|
import time
|
||||||
import tempfile
|
import tempfile
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
@ -407,7 +405,7 @@ class TestObjectReplicator(unittest.TestCase):
|
|||||||
try:
|
try:
|
||||||
rmtree(self.objects, ignore_errors=1)
|
rmtree(self.objects, ignore_errors=1)
|
||||||
object_replicator.mkdirs = blowup_mkdirs
|
object_replicator.mkdirs = blowup_mkdirs
|
||||||
jobs = self.replicator.collect_jobs()
|
self.replicator.collect_jobs()
|
||||||
self.assertTrue('exception' in self.replicator.logger.log_dict)
|
self.assertTrue('exception' in self.replicator.logger.log_dict)
|
||||||
self.assertEquals(
|
self.assertEquals(
|
||||||
len(self.replicator.logger.log_dict['exception']), 1)
|
len(self.replicator.logger.log_dict['exception']), 1)
|
||||||
@ -423,7 +421,6 @@ class TestObjectReplicator(unittest.TestCase):
|
|||||||
def test_collect_jobs(self):
|
def test_collect_jobs(self):
|
||||||
jobs = self.replicator.collect_jobs()
|
jobs = self.replicator.collect_jobs()
|
||||||
jobs_to_delete = [j for j in jobs if j['delete']]
|
jobs_to_delete = [j for j in jobs if j['delete']]
|
||||||
jobs_to_keep = [j for j in jobs if not j['delete']]
|
|
||||||
jobs_by_part = {}
|
jobs_by_part = {}
|
||||||
for job in jobs:
|
for job in jobs:
|
||||||
jobs_by_part[job['partition']] = job
|
jobs_by_part[job['partition']] = job
|
||||||
@ -458,7 +455,6 @@ class TestObjectReplicator(unittest.TestCase):
|
|||||||
self.assertTrue(os.path.isfile(part_1_path)) # sanity check
|
self.assertTrue(os.path.isfile(part_1_path)) # sanity check
|
||||||
jobs = self.replicator.collect_jobs()
|
jobs = self.replicator.collect_jobs()
|
||||||
jobs_to_delete = [j for j in jobs if j['delete']]
|
jobs_to_delete = [j for j in jobs if j['delete']]
|
||||||
jobs_to_keep = [j for j in jobs if not j['delete']]
|
|
||||||
jobs_by_part = {}
|
jobs_by_part = {}
|
||||||
for job in jobs:
|
for job in jobs:
|
||||||
jobs_by_part[job['partition']] = job
|
jobs_by_part[job['partition']] = job
|
||||||
@ -484,8 +480,6 @@ class TestObjectReplicator(unittest.TestCase):
|
|||||||
def test_delete_partition(self):
|
def test_delete_partition(self):
|
||||||
df = DiskFile(self.devices, 'sda', '0', 'a', 'c', 'o', FakeLogger())
|
df = DiskFile(self.devices, 'sda', '0', 'a', 'c', 'o', FakeLogger())
|
||||||
mkdirs(df.datadir)
|
mkdirs(df.datadir)
|
||||||
ohash = hash_path('a', 'c', 'o')
|
|
||||||
data_dir = ohash[-3:]
|
|
||||||
part_path = os.path.join(self.objects, '1')
|
part_path = os.path.join(self.objects, '1')
|
||||||
self.assertTrue(os.access(part_path, os.F_OK))
|
self.assertTrue(os.access(part_path, os.F_OK))
|
||||||
self.replicator.replicate()
|
self.replicator.replicate()
|
||||||
@ -494,8 +488,6 @@ class TestObjectReplicator(unittest.TestCase):
|
|||||||
def test_delete_partition_override_params(self):
|
def test_delete_partition_override_params(self):
|
||||||
df = DiskFile(self.devices, 'sda', '0', 'a', 'c', 'o', FakeLogger())
|
df = DiskFile(self.devices, 'sda', '0', 'a', 'c', 'o', FakeLogger())
|
||||||
mkdirs(df.datadir)
|
mkdirs(df.datadir)
|
||||||
ohash = hash_path('a', 'c', 'o')
|
|
||||||
data_dir = ohash[-3:]
|
|
||||||
part_path = os.path.join(self.objects, '1')
|
part_path = os.path.join(self.objects, '1')
|
||||||
self.assertTrue(os.access(part_path, os.F_OK))
|
self.assertTrue(os.access(part_path, os.F_OK))
|
||||||
self.replicator.replicate(override_devices=['sdb'])
|
self.replicator.replicate(override_devices=['sdb'])
|
||||||
|
@ -22,7 +22,7 @@ import unittest
|
|||||||
import email
|
import email
|
||||||
from shutil import rmtree
|
from shutil import rmtree
|
||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
from time import gmtime, sleep, strftime, time
|
from time import gmtime, strftime, time
|
||||||
from tempfile import mkdtemp
|
from tempfile import mkdtemp
|
||||||
from hashlib import md5
|
from hashlib import md5
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ from test.unit import FakeLogger
|
|||||||
from test.unit import _getxattr as getxattr
|
from test.unit import _getxattr as getxattr
|
||||||
from test.unit import _setxattr as setxattr
|
from test.unit import _setxattr as setxattr
|
||||||
from test.unit import connect_tcp, readuntil2crlfs
|
from test.unit import connect_tcp, readuntil2crlfs
|
||||||
from swift.obj import server as object_server, replicator
|
from swift.obj import server as object_server
|
||||||
from swift.common import utils
|
from swift.common import utils
|
||||||
from swift.common.utils import hash_path, mkdirs, normalize_timestamp, \
|
from swift.common.utils import hash_path, mkdirs, normalize_timestamp, \
|
||||||
NullLogger, storage_directory
|
NullLogger, storage_directory
|
||||||
@ -1421,7 +1421,6 @@ class TestObjectController(unittest.TestCase):
|
|||||||
self.assertEquals(outbuf.getvalue()[:4], '405 ')
|
self.assertEquals(outbuf.getvalue()[:4], '405 ')
|
||||||
|
|
||||||
def test_invalid_method_doesnt_exist(self):
|
def test_invalid_method_doesnt_exist(self):
|
||||||
inbuf = StringIO()
|
|
||||||
errbuf = StringIO()
|
errbuf = StringIO()
|
||||||
outbuf = StringIO()
|
outbuf = StringIO()
|
||||||
def start_response(*args):
|
def start_response(*args):
|
||||||
@ -1433,7 +1432,6 @@ class TestObjectController(unittest.TestCase):
|
|||||||
self.assertEquals(outbuf.getvalue()[:4], '405 ')
|
self.assertEquals(outbuf.getvalue()[:4], '405 ')
|
||||||
|
|
||||||
def test_invalid_method_is_not_public(self):
|
def test_invalid_method_is_not_public(self):
|
||||||
inbuf = StringIO()
|
|
||||||
errbuf = StringIO()
|
errbuf = StringIO()
|
||||||
outbuf = StringIO()
|
outbuf = StringIO()
|
||||||
def start_response(*args):
|
def start_response(*args):
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import cPickle as pickle
|
import cPickle as pickle
|
||||||
import json
|
|
||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
from gzip import GzipFile
|
from gzip import GzipFile
|
||||||
|
@ -30,8 +30,7 @@ from hashlib import md5
|
|||||||
from tempfile import mkdtemp
|
from tempfile import mkdtemp
|
||||||
import random
|
import random
|
||||||
|
|
||||||
import eventlet
|
from eventlet import sleep, spawn, wsgi, listen
|
||||||
from eventlet import sleep, spawn, Timeout, util, wsgi, listen
|
|
||||||
import simplejson
|
import simplejson
|
||||||
|
|
||||||
from test.unit import connect_tcp, readuntil2crlfs, FakeLogger, fake_http_connect
|
from test.unit import connect_tcp, readuntil2crlfs, FakeLogger, fake_http_connect
|
||||||
|
Loading…
Reference in New Issue
Block a user