summaryrefslogtreecommitdiffstats
path: root/test/functional
diff options
context:
space:
mode:
authorLuis Pabon <lpabon@redhat.com>2014-01-10 19:44:39 -0500
committerLuis Pabon <lpabon@redhat.com>2014-01-15 11:28:08 -0800
commit6a8e9a70e9489a8f17405adf64462899d6a4ca81 (patch)
treecb5f30493b3a3a623ec1de2504d4ce9c48ded3ec /test/functional
parent62d07833db5412f482001b275d2d646abbf21c14 (diff)
Sync with OpenStack v1.11.0 Jan 10 2014v1.11.0
Updated tox.ini, functional tests, and proxy unit tests. BUG: https://bugs.launchpad.net/bugs/1268017 Change-Id: I5ff8359b8abdb8fe5ae82492c12f57c395992735 Signed-off-by: Luis Pabon <lpabon@redhat.com> Reviewed-on: http://review.gluster.org/6682 Reviewed-by: Thiago da Silva <thiago@redhat.com> Tested-by: Thiago da Silva <thiago@redhat.com>
Diffstat (limited to 'test/functional')
-rw-r--r--test/functional/swift_test_client.py23
-rw-r--r--test/functional/tests.py79
2 files changed, 72 insertions, 30 deletions
diff --git a/test/functional/swift_test_client.py b/test/functional/swift_test_client.py
index d407a33..47e023e 100644
--- a/test/functional/swift_test_client.py
+++ b/test/functional/swift_test_client.py
@@ -65,7 +65,7 @@ class ResponseError(Exception):
def listing_empty(method):
- for i in xrange(0, 6):
+ for i in xrange(6):
if len(method()) == 0:
return True
@@ -208,7 +208,11 @@ class Connection(object):
def make_request(self, method, path=[], data='', hdrs={}, parms={},
cfg={}):
- path = self.make_path(path, cfg=cfg)
+ if not cfg.get('verbatim_path'):
+ # Set verbatim_path=True to make a request to exactly the given
+ # path, not storage path + given path. Useful for
+ # non-account/container/object requests.
+ path = self.make_path(path, cfg=cfg)
headers = self.make_headers(hdrs, cfg=cfg)
if isinstance(parms, dict) and parms:
quote = urllib.quote
@@ -719,7 +723,8 @@ class File(Base):
else:
raise RuntimeError
- def write(self, data='', hdrs={}, parms={}, callback=None, cfg={}):
+ def write(self, data='', hdrs={}, parms={}, callback=None, cfg={},
+ return_resp=False):
block_size = 2 ** 20
if isinstance(data, file):
@@ -763,6 +768,9 @@ class File(Base):
pass
self.md5 = self.compute_md5sum(data)
+ if return_resp:
+ return self.conn.response
+
return True
def write_random(self, size=None, hdrs={}, parms={}, cfg={}):
@@ -772,3 +780,12 @@ class File(Base):
self.conn.make_path(self.path))
self.md5 = self.compute_md5sum(StringIO.StringIO(data))
return data
+
+ def write_random_return_resp(self, size=None, hdrs={}, parms={}, cfg={}):
+ data = self.random_data(size)
+ resp = self.write(data, hdrs=hdrs, parms=parms, cfg=cfg,
+ return_resp=True)
+ if not resp:
+ raise ResponseError(self.conn.response)
+ self.md5 = self.compute_md5sum(StringIO.StringIO(data))
+ return resp
diff --git a/test/functional/tests.py b/test/functional/tests.py
index 808208d..e4b778b 100644
--- a/test/functional/tests.py
+++ b/test/functional/tests.py
@@ -1704,8 +1704,14 @@ class TestFileComparisonEnv:
file_item.write_random(cls.file_size)
cls.files.append(file_item)
- cls.time_old = time.asctime(time.localtime(time.time() - 86400))
- cls.time_new = time.asctime(time.localtime(time.time() + 86400))
+ cls.time_old_f1 = time.strftime("%a, %d %b %Y %H:%M:%S GMT",
+ time.gmtime(time.time() - 86400))
+ cls.time_old_f2 = time.strftime("%A, %d-%b-%y %H:%M:%S GMT",
+ time.gmtime(time.time() - 86400))
+ cls.time_old_f3 = time.strftime("%a %b %d %H:%M:%S %Y",
+ time.gmtime(time.time() - 86400))
+ cls.time_new = time.strftime("%a, %d %b %Y %H:%M:%S GMT",
+ time.gmtime(time.time() + 86400))
class TestFileComparison(Base):
@@ -1732,7 +1738,7 @@ class TestFileComparison(Base):
def testIfModifiedSince(self):
for file_item in self.env.files:
- hdrs = {'If-Modified-Since': self.env.time_old}
+ hdrs = {'If-Modified-Since': self.env.time_old_f1}
self.assert_(file_item.read(hdrs=hdrs))
hdrs = {'If-Modified-Since': self.env.time_new}
@@ -1744,7 +1750,7 @@ class TestFileComparison(Base):
hdrs = {'If-Unmodified-Since': self.env.time_new}
self.assert_(file_item.read(hdrs=hdrs))
- hdrs = {'If-Unmodified-Since': self.env.time_old}
+ hdrs = {'If-Unmodified-Since': self.env.time_old_f2}
self.assertRaises(ResponseError, file_item.read, hdrs=hdrs)
self.assert_status(412)
@@ -1760,10 +1766,32 @@ class TestFileComparison(Base):
self.assert_status(412)
hdrs = {'If-Match': file_item.md5,
- 'If-Unmodified-Since': self.env.time_old}
+ 'If-Unmodified-Since': self.env.time_old_f3}
self.assertRaises(ResponseError, file_item.read, hdrs=hdrs)
self.assert_status(412)
+ def testLastModified(self):
+ file_name = Utils.create_name()
+ content_type = Utils.create_name()
+
+ file = self.env.container.file(file_name)
+ file.content_type = content_type
+ resp = file.write_random_return_resp(self.env.file_size)
+ put_last_modified = resp.getheader('last-modified')
+
+ file = self.env.container.file(file_name)
+ info = file.info()
+ self.assert_('last_modified' in info)
+ last_modified = info['last_modified']
+ self.assertEqual(put_last_modified, info['last_modified'])
+
+ hdrs = {'If-Modified-Since': last_modified}
+ self.assertRaises(ResponseError, file.read, hdrs=hdrs)
+ self.assert_status(304)
+
+ hdrs = {'If-Unmodified-Since': last_modified}
+ self.assert_(file.read(hdrs=hdrs))
+
class TestFileComparisonUTF8(Base2, TestFileComparison):
set_up = False
@@ -1776,6 +1804,24 @@ class TestSloEnv(object):
def setUp(cls):
cls.conn = Connection(config)
cls.conn.authenticate()
+
+ if cls.slo_enabled is None:
+ status = cls.conn.make_request('GET', '/info',
+ cfg={'verbatim_path': True})
+ if not (200 <= status <= 299):
+ # Can't tell if SLO is enabled or not since we're running
+ # against an old cluster, so let's skip the tests instead of
+ # possibly having spurious failures.
+ cls.slo_enabled = False
+ else:
+ # Don't bother looking for ValueError here. If something is
+ # responding to a GET /info request with invalid JSON, then
+ # the cluster is broken and a test failure will let us know.
+ cluster_info = json.loads(cls.conn.response.read())
+ cls.slo_enabled = 'slo' in cluster_info
+ if not cls.slo_enabled:
+ return
+
cls.account = Account(cls.conn, config.get('account',
config['username']))
cls.account.delete_containers()
@@ -1785,28 +1831,6 @@ class TestSloEnv(object):
if not cls.container.create():
raise ResponseError(cls.conn.response)
- # TODO(seriously, anyone can do this): make this use the /info API once
- # it lands, both for detection of SLO and for minimum segment size
- if cls.slo_enabled is None:
- test_file = cls.container.file(".test-slo")
- try:
- # If SLO is enabled, this'll raise an error since
- # X-Static-Large-Object is a reserved header.
- #
- # If SLO is not enabled, then this will get the usual 2xx
- # response.
- test_file.write(
- "some contents",
- hdrs={'X-Static-Large-Object': 'true'})
- except ResponseError as err:
- if err.status == 400:
- cls.slo_enabled = True
- else:
- raise
- else:
- cls.slo_enabled = False
- return
-
seg_info = {}
for letter, size in (('a', 1024 * 1024),
('b', 1024 * 1024),
@@ -1865,6 +1889,7 @@ class TestSlo(Base):
set_up = False
def setUp(self):
+ raise SkipTest("SLO not enabled yet in gluster-swift")
super(TestSlo, self).setUp()
if self.env.slo_enabled is False:
raise SkipTest("SLO not enabled")