diff options
| author | Peter Portante <peter.portante@redhat.com> | 2013-10-24 22:04:40 -0400 | 
|---|---|---|
| committer | Luis Pabon <lpabon@redhat.com> | 2013-10-25 10:57:40 -0700 | 
| commit | 04e402599b7b01c0a98df4724618555ab53cb775 (patch) | |
| tree | 591827e1d367202105be2463c5858666ad6827a0 /test | |
| parent | b48149a4af9bc2c5de14a4f479bc7b11938bcf94 (diff) | |
Sync functional tests with Swift v1.9.1
Change-Id: Id478f651fe937883837291059da9da853fcd2de2
Signed-off-by: Peter Portante <peter.portante@redhat.com>
Reviewed-on: http://review.gluster.org/6141
Reviewed-by: Luis Pabon <lpabon@redhat.com>
Tested-by: Luis Pabon <lpabon@redhat.com>
Diffstat (limited to 'test')
| -rw-r--r-- | test/__init__.py | 2 | ||||
| -rw-r--r-- | test/functional/gluster_swift_tests.py | 98 | ||||
| -rw-r--r-- | test/functional/swift_test_client.py | 10 | ||||
| -rw-r--r-- | test/functional/tests.py | 80 | ||||
| -rw-r--r-- | test/functionalnosetests/swift_testing.py | 7 | ||||
| -rwxr-xr-x | test/functionalnosetests/test_account.py | 42 | ||||
| -rwxr-xr-x | test/functionalnosetests/test_container.py | 42 | ||||
| -rwxr-xr-x | test/functionalnosetests/test_object.py | 8 | 
8 files changed, 190 insertions, 99 deletions
diff --git a/test/__init__.py b/test/__init__.py index 50b24ed..9095348 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -4,8 +4,6 @@  import __builtin__  import sys  import os -from ConfigParser import MissingSectionHeaderError -from StringIO import StringIO  from swift.common.utils import readconf diff --git a/test/functional/gluster_swift_tests.py b/test/functional/gluster_swift_tests.py index 442c315..9361408 100644 --- a/test/functional/gluster_swift_tests.py +++ b/test/functional/gluster_swift_tests.py @@ -15,12 +15,56 @@  """ OpenStack Swift based functional tests for Gluster for Swift""" -from test.functional.tests import config, locale, Base, Utils +import random + +from nose import SkipTest + +from test.functional.tests import config, locale, Base, Base2, Utils, \ +    TestFileEnv  from test.functional.swift_test_client import Account, Connection, File, \      ResponseError +web_front_end = config.get('web_front_end', 'integral') + + +class TestFile(Base): +    env = TestFileEnv +    set_up = False -class TestGlusterContainerPathsEnv: +    def testObjectManifest(self): +        if (web_front_end == 'apache2'): +            raise SkipTest() +        data = File.random_data(10000) +        parts = random.randrange(2,10) +        charsEachPart = len(data)/parts +        for i in range(parts+1): +            if i==0 : +                file = self.env.container.file('objectmanifest') +                hdrs={} +                hdrs['Content-Length']='0' +                hdrs['X-Object-Manifest']=str(self.env.container.name)+'/objectmanifest' +                self.assert_(file.write('',hdrs=hdrs)) +                self.assert_(file.name in self.env.container.files()) +                self.assert_(file.read() == '') +            elif i==parts : +                file = self.env.container.file('objectmanifest'+'-'+str(i)) +                segment=data[ (i-1)*charsEachPart :] +                self.assertTrue(file.write(segment)) +            else : +                file = self.env.container.file('objectmanifest'+'-'+str(i)) +                segment=data[ (i-1)*charsEachPart : i*charsEachPart] +                self.assertTrue(file.write(segment)) +        #matching the manifest file content with orignal data, as etag won't match +        file = self.env.container.file('objectmanifest') +        data_read = file.read() +        self.assertEquals(data,data_read) + + +class TestFileUTF8(Base2, TestFile): +    set_up = False + + +class TestContainerPathsEnv:      @classmethod      def setUp(cls):          cls.conn = Connection(config) @@ -76,8 +120,8 @@ class TestGlusterContainerPathsEnv:          cls.sorted_objects = sorted(set(cls.dirs + cls.files)) -class TestGlusterContainerPaths(Base): -    env = TestGlusterContainerPathsEnv +class TestContainerPaths(Base): +    env = TestContainerPathsEnv      set_up = False      def testTraverseContainer(self): @@ -149,3 +193,49 @@ class TestGlusterContainerPaths(Base):          assert_listing('dir1/subdir with spaces',                         ['dir1/subdir with spaces/file B']) + +class TestObjectVersioningEnv: +    @classmethod +    def setUp(cls): +        cls.conn = Connection(config) +        cls.conn.authenticate() +        cls.account = Account(cls.conn, config.get('account', +                                                   config['username'])) +        cls.account.delete_containers() +        cls.containers = {} +        #create two containers one for object other for versions of objects +        for i in range(2): +            hdrs={} +            if i==0: +                hdrs={'X-Versions-Location':'versions'} +                cont = cls.containers['object'] = cls.account.container('object') +            else: +                cont = cls.containers['versions'] = cls.account.container('versions') +            if not cont.create(hdrs=hdrs): +                raise ResponseError(cls.conn.response) +                cls.containers.append(cont) + + +class TestObjectVersioning(Base): +    env = TestObjectVersioningEnv +    set_up = False + +    def testObjectVersioning(self): +        versions = random.randrange(2,10) +        dataArr=[] +        #create versions +        for i in range(versions): +            data = File.random_data(10000*(i+1)) +            file = self.env.containers['object'].file('object') +            self.assertTrue(file.write(data)) +            dataArr.append(data) +        cont = self.env.containers['versions'] +        info = cont.info() +        self.assertEquals(info['object_count'], versions-1) +        #match the current version of object with data in arr and delete it +        for i in range(versions): +            data = dataArr[-(i+1)] +            file = self.env.containers['object'].file('object') +            self.assertEquals(data,file.read()) +            self.assert_(file.delete()) +            self.assert_status(204) diff --git a/test/functional/swift_test_client.py b/test/functional/swift_test_client.py index 65a6824..daea902 100644 --- a/test/functional/swift_test_client.py +++ b/test/functional/swift_test_client.py @@ -170,7 +170,11 @@ class Connection(object):          self.storage_host = x[2].split(':')[0]          if ':' in x[2]:              self.storage_port = int(x[2].split(':')[1]) -        self.storage_url = '/%s/%s' % (x[3], x[4]) +        # Make sure storage_url is a string and not unicode, since +        # keystoneclient (called by swiftclient) returns them in +        # unicode and this would cause troubles when doing +        # no_safe_quote query. +        self.storage_url = str('/%s/%s' % (x[3], x[4]))          self.storage_token = storage_token @@ -462,8 +466,8 @@ class Container(Base):          raise ResponseError(self.conn.response)      def info(self, hdrs={}, parms={}, cfg={}): -        status = self.conn.make_request('HEAD', self.path, hdrs=hdrs, -                                        parms=parms, cfg=cfg) +        self.conn.make_request('HEAD', self.path, hdrs=hdrs, +                               parms=parms, cfg=cfg)          if self.conn.response.status == 204:              fields = [['bytes_used', 'x-container-bytes-used'], diff --git a/test/functional/tests.py b/test/functional/tests.py index f58e7f3..dcd8b51 100644 --- a/test/functional/tests.py +++ b/test/functional/tests.py @@ -67,7 +67,7 @@ conf_exists = constraints_conf.read('/etc/swift/swift.conf')  # Constraints are set first from the test config, then from  # /etc/swift/swift.conf if it exists. If swift.conf doesn't exist,  # then limit test coverage. This allows SAIO tests to work fine but -# requires remote funtional testing to know something about the cluster +# requires remote functional testing to know something about the cluster  # that is being tested.  config = get_config('func_test')  for k in default_constraints: @@ -514,7 +514,6 @@ class TestContainer(Base):          prefixs = ['alpha/', 'beta/', 'kappa/']          prefix_files = {} -        all_files = []          for prefix in prefixs:              prefix_files[prefix] = [] @@ -791,7 +790,7 @@ class TestContainerPathsEnv:                  stored_files.add(f)          cls.stored_files = sorted(stored_files) -         +  class TestContainerPaths(Base): @@ -1231,7 +1230,6 @@ class TestFile(Base):      def testRangedGetsWithLWSinHeader(self):          #Skip this test until webob 1.2 can tolerate LWS in Range header.          file_length = 10000 -        range_size = file_length / 10          file = self.env.container.file(Utils.create_name())          data = file.write_random(file_length) @@ -1567,33 +1565,6 @@ class TestFile(Base):              info = file.info()              self.assertEquals(etag, info['etag']) -    def testObjectManifest(self): -        if (web_front_end == 'apache2'): -            raise SkipTest() -        data = File.random_data(10000) -        parts = random.randrange(2,10) -        charsEachPart = len(data)/parts -        for i in range(parts+1): -            if i==0 : -                file = self.env.container.file('objectmanifest') -                hdrs={} -                hdrs['Content-Length']='0' -                hdrs['X-Object-Manifest']=str(self.env.container.name)+'/objectmanifest' -                self.assert_(file.write('',hdrs=hdrs)) -                self.assert_(file.name in self.env.container.files()) -                self.assert_(file.read() == '') -            elif i==parts : -                file = self.env.container.file('objectmanifest'+'-'+str(i)) -                segment=data[ (i-1)*charsEachPart :] -                self.assertTrue(file.write(segment)) -            else : -                file = self.env.container.file('objectmanifest'+'-'+str(i)) -                segment=data[ (i-1)*charsEachPart : i*charsEachPart] -                self.assertTrue(file.write(segment)) -        #matching the manifest file content with orignal data, as etag won't match -        file = self.env.container.file('objectmanifest') -        data_read = file.read() -        self.assertEquals(data,data_read)  class TestFileUTF8(Base2, TestFile):      set_up = False @@ -1682,53 +1653,6 @@ class TestFileComparison(Base):              self.assert_status(412) -class TestObjectVersioningEnv: -    @classmethod -    def setUp(cls): -        cls.conn = Connection(config) -        cls.conn.authenticate() -        cls.account = Account(cls.conn, config.get('account', -                                                   config['username'])) -        cls.account.delete_containers() -        cls.containers = {} -        #create two containers one for object other for versions of objects -        for i in range(2): -            hdrs={} -            if i==0: -                hdrs={'X-Versions-Location':'versions'} -                cont = cls.containers['object'] = cls.account.container('object') -            else: -                cont = cls.containers['versions'] = cls.account.container('versions') -            if not cont.create(hdrs=hdrs): -                raise ResponseError(cls.conn.response) -                cls.containers.append(cont) - - -class TestObjectVersioning(Base): -    env = TestObjectVersioningEnv -    set_up = False - -    def testObjectVersioning(self): -        versions = random.randrange(2,10) -        dataArr=[] -        #create versions -        for i in range(versions): -            data = File.random_data(10000*(i+1)) -            file = self.env.containers['object'].file('object') -            self.assertTrue(file.write(data)) -            dataArr.append(data) -        cont = self.env.containers['versions'] -        info = cont.info() -        self.assertEquals(info['object_count'], versions-1) -        #match the current version of object with data in arr and delete it -        for i in range(versions): -            data = dataArr[-(i+1)] -            file = self.env.containers['object'].file('object') -            self.assertEquals(data,file.read()) -            self.assert_(file.delete()) -            self.assert_status(204) - -  class TestFileComparisonUTF8(Base2, TestFileComparison):      set_up = False diff --git a/test/functionalnosetests/swift_testing.py b/test/functionalnosetests/swift_testing.py index ef4005e..c49d9cd 100644 --- a/test/functionalnosetests/swift_testing.py +++ b/test/functionalnosetests/swift_testing.py @@ -28,13 +28,10 @@  # See the License for the specific language governing permissions and  # limitations under the License. -import errno  import os  import socket  import sys  from time import sleep -from nose import SkipTest -from ConfigParser import MissingSectionHeaderError  from test import get_config @@ -168,10 +165,10 @@ def retry(func, *args, **kwargs):              if attempts > retries:                  raise              parsed[use_account] = conn[use_account] = None -        except AuthError, err: +        except AuthError:              url[use_account] = token[use_account] = None              continue -        except InternalServerError, err: +        except InternalServerError:              pass          if attempts <= retries:              sleep(backoff) diff --git a/test/functionalnosetests/test_account.py b/test/functionalnosetests/test_account.py index 16e3dea..d28ff2f 100755 --- a/test/functionalnosetests/test_account.py +++ b/test/functionalnosetests/test_account.py @@ -37,7 +37,7 @@ from nose import SkipTest  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 +from swift_testing import check_response, retry, skip, web_front_end  class TestAccount(unittest.TestCase): @@ -78,6 +78,46 @@ class TestAccount(unittest.TestCase):          self.assert_(resp.status in (200, 204), resp.status)          self.assertEquals(resp.getheader('x-account-meta-test'), 'Value') +    def test_unicode_metadata(self): +        if skip: +            raise SkipTest + +        def post(url, token, parsed, conn, name, value): +            conn.request('POST', parsed.path, '', +                         {'X-Auth-Token': token, name: value}) +            return check_response(conn) + +        def head(url, token, parsed, conn): +            conn.request('HEAD', parsed.path, '', {'X-Auth-Token': token}) +            return check_response(conn) +        uni_key = u'X-Account-Meta-uni\u0E12' +        uni_value = u'uni\u0E12' +        if (web_front_end == 'integral'): +            resp = retry(post, uni_key, '1') +            resp.read() +            self.assertTrue(resp.status in (201, 204)) +            resp = retry(head) +            resp.read() +            self.assert_(resp.status in (200, 204), resp.status) +            self.assertEquals(resp.getheader(uni_key.encode('utf-8')), '1') +        resp = retry(post, 'X-Account-Meta-uni', uni_value) +        resp.read() +        self.assertEquals(resp.status, 204) +        resp = retry(head) +        resp.read() +        self.assert_(resp.status in (200, 204), resp.status) +        self.assertEquals(resp.getheader('X-Account-Meta-uni'), +                          uni_value.encode('utf-8')) +        if (web_front_end == 'integral'): +            resp = retry(post, uni_key, uni_value) +            resp.read() +            self.assertEquals(resp.status, 204) +            resp = retry(head) +            resp.read() +            self.assert_(resp.status in (200, 204), resp.status) +            self.assertEquals(resp.getheader(uni_key.encode('utf-8')), +                              uni_value.encode('utf-8')) +      def test_multi_metadata(self):          if skip:              raise SkipTest diff --git a/test/functionalnosetests/test_container.py b/test/functionalnosetests/test_container.py index 75269c3..af78a7a 100755 --- a/test/functionalnosetests/test_container.py +++ b/test/functionalnosetests/test_container.py @@ -114,6 +114,48 @@ class TestContainer(unittest.TestCase):          self.assertEquals(resp.getheader('x-container-meta-one'), '1')          self.assertEquals(resp.getheader('x-container-meta-two'), '2') +    def test_unicode_metadata(self): +        if skip: +            raise SkipTest + +        def post(url, token, parsed, conn, name, value): +            conn.request('POST', parsed.path + '/' + self.name, '', +                         {'X-Auth-Token': token, name: value}) +            return check_response(conn) + +        def head(url, token, parsed, conn): +            conn.request('HEAD', parsed.path + '/' + self.name, '', +                         {'X-Auth-Token': token}) +            return check_response(conn) + +        uni_key = u'X-Container-Meta-uni\u0E12' +        uni_value = u'uni\u0E12' +        if (web_front_end == 'integral'): +            resp = retry(post, uni_key, '1') +            resp.read() +            self.assertEquals(resp.status, 204) +            resp = retry(head) +            resp.read() +            self.assert_(resp.status in (200, 204), resp.status) +            self.assertEquals(resp.getheader(uni_key.encode('utf-8')), '1') +        resp = retry(post, 'X-Container-Meta-uni', uni_value) +        resp.read() +        self.assertEquals(resp.status, 204) +        resp = retry(head) +        resp.read() +        self.assert_(resp.status in (200, 204), resp.status) +        self.assertEquals(resp.getheader('X-Container-Meta-uni'), +                          uni_value.encode('utf-8')) +        if (web_front_end == 'integral'): +            resp = retry(post, uni_key, uni_value) +            resp.read() +            self.assertEquals(resp.status, 204) +            resp = retry(head) +            resp.read() +            self.assert_(resp.status in (200, 204), resp.status) +            self.assertEquals(resp.getheader(uni_key.encode('utf-8')), +                          uni_value.encode('utf-8')) +      def test_PUT_metadata(self):          if skip:              raise SkipTest diff --git a/test/functionalnosetests/test_object.py b/test/functionalnosetests/test_object.py index 9c7f9c5..3972aaf 100755 --- a/test/functionalnosetests/test_object.py +++ b/test/functionalnosetests/test_object.py @@ -34,12 +34,8 @@ import unittest  from nose import SkipTest  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, \      swift_test_perm, web_front_end -from test import get_config  class TestObject(unittest.TestCase): @@ -127,7 +123,7 @@ class TestObject(unittest.TestCase):                            'X-Copy-From': source})              return check_response(conn)          resp = retry(put) -        contents = resp.read() +        resp.read()          self.assertEquals(resp.status, 201)          # contents of dest should be the same as source @@ -161,7 +157,7 @@ class TestObject(unittest.TestCase):                            'Destination': dest})              return check_response(conn)          resp = retry(copy) -        contents = resp.read() +        resp.read()          self.assertEquals(resp.status, 201)          # contents of dest should be the same as source  | 
