diff options
author | Qiu Yu <qiuyu@ebaysf.com> | 2014-02-08 23:32:34 +0800 |
---|---|---|
committer | Qiu Yu <qiuyu@ebaysf.com> | 2014-02-09 01:16:33 +0800 |
commit | 033f3776c4bc6d0db14b1b9da7c24e207e9628ab (patch) | |
tree | a961d948cee4f14c2d5c5b322bd352c12ad42226 /nova/tests/test_objectstore.py | |
parent | 5e08f52525004d09fcded9fac0e6de1f95186f10 (diff) | |
download | nova-033f3776c4bc6d0db14b1b9da7c24e207e9628ab.tar.gz |
Add HEAD api response for test s3 server BucketHandler
Current nova test s3 server lacks HEAD for BucketHandler. And it becomes
an issue for Boto after version 2.25.0 [1], which changes underlying
implementation of get_bucket method from GET to HEAD request.
This change fixes this gap by adding HEAD response to test s3 server.
And also added cases for testing bucket existence per Boto document
suggestion[2], which applies for both Boto prior to or after version
2.25.0
[1] http://docs.pythonboto.org/en/latest/releasenotes/v2.25.0.html
[2] http://docs.pythonboto.org/en/latest/s3_tut.html#accessing-a-bucket
Change-Id: If992efa40f7f36d337d1b9b1f52859aa0ae51874
Closes-bug: #1277790
Diffstat (limited to 'nova/tests/test_objectstore.py')
-rw-r--r-- | nova/tests/test_objectstore.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/nova/tests/test_objectstore.py b/nova/tests/test_objectstore.py index e66bd9fad9..3f10cab282 100644 --- a/nova/tests/test_objectstore.py +++ b/nova/tests/test_objectstore.py @@ -127,10 +127,27 @@ class S3APITestCase(test.NoDBTestCase): self._ensure_no_buckets(bucket.get_all_keys()) def test_unknown_bucket(self): + # NOTE(unicell): Since Boto v2.25.0, the underlying implementation + # of get_bucket method changed from GET to HEAD. + # + # Prior to v2.25.0, default validate=True fetched a list of keys in the + # bucket and raises S3ResponseError. As a side effect of switching to + # HEAD request, get_bucket call now generates less error message. + # + # To keep original semantics, additional get_all_keys call is + # suggestted per Boto document. This case tests both validate=False and + # validate=True case for completeness. + # + # http://docs.pythonboto.org/en/latest/releasenotes/v2.25.0.html + # http://docs.pythonboto.org/en/latest/s3_tut.html#accessing-a-bucket bucket_name = 'falalala' self.assertRaises(boto_exception.S3ResponseError, self.conn.get_bucket, bucket_name) + bucket = self.conn.get_bucket(bucket_name, validate=False) + self.assertRaises(boto_exception.S3ResponseError, + bucket.get_all_keys, + maxkeys=0) def tearDown(self): """Tear down test server.""" |