예제 #1
0
 def setup(self):
     self.os_client = ObjectStoreClient()
     self.url = 's3+https://cephgw.usatlas.bnl.gov:8443/rucio_bucket/test_public'
     self.rse = 'BNL-OSG2_ES'
     ret = objectstore.get_signed_urls([self.url], rse=self.rse, operation='write')
     if isinstance(ret[self.url], Exception):
         raise ret[self.url]
     command = 'curl --request PUT --upload-file /bin/hostname "%s"' % ret[self.url]
     status, output = commands.getstatusoutput(command)
     if status:
         raise Exception(output)
     if 'AccessDenied' in output:
         raise Exception(output)
예제 #2
0
class TestObjectStoreClients:

    def setup(self):
        self.os_client = ObjectStoreClient()
        self.url = 's3+https://cephgw.usatlas.bnl.gov:8443/rucio_bucket/test_public'
        self.rse = 'BNL-OSG2_ES'
        ret = objectstore.get_signed_urls([self.url], rse=self.rse, operation='write')
        if isinstance(ret[self.url], Exception):
            raise ret[self.url]
        command = 'curl --request PUT --upload-file /bin/hostname "%s"' % ret[self.url]
        status, output = commands.getstatusoutput(command)
        if status:
            raise Exception(output)
        if 'AccessDenied' in output:
            raise Exception(output)

    def test_connect(self):
        """ OBJECTSTORE (CLIENT): Connect """
        self.os_client.connect(self.rse, self.url)

    def test_get_signed_url_read(self):
        """ OBJECTSTORE (CLIENT): Get signed url for read """
        ret = self.os_client.get_signed_url(self.url, rse=self.rse, operation='read')
        if not isinstance(ret, string_types):
            raise Exception("Return %s is not as expected.")

        # read
        command = 'curl "%s" > /dev/null' % str(ret)
        status, output = commands.getstatusoutput(command)
        if status:
            raise Exception(output)

        # write
        command = 'curl --request PUT --upload-file /bin/hostname "%s"' % ret
        status, output = commands.getstatusoutput(command)
        if status:
            raise Exception(output)
        if 'AccessDenied' not in output:
            raise Exception(output)

    def test_get_signed_url_write(self):
        """ OBJECTSTORE (CLIENT): Get signed url for write """
        ret = self.os_client.get_signed_url(self.url, rse=self.rse, operation='write')
        if not isinstance(ret, string_types):
            raise Exception("Return %s is not as expected.")

        # write
        command = 'curl --request PUT --upload-file /bin/hostname "%s"' % ret
        status, output = commands.getstatusoutput(command)
        if status:
            raise Exception(output)
        if 'AccessDenied' in output:
            raise Exception(output)

        # read
        command = 'curl "%s" > /dev/null' % ret
        status, output = commands.getstatusoutput(command)
        if status:
            raise Exception(output)

    @raises(exception.SourceNotFound)
    def test_get_signed_url_read_not_exists(self):
        """ OBJECTSTORE (CLIENT): Get signed not exist url for read """
        url = '%s_not_exist' % (self.url)
        self.os_client.get_signed_url(url, rse=self.rse, operation='read')
        raise Exception("Respone not as expected: should catch SourceNotFound")

    def test_get_signed_urls_read(self):
        """ OBJECTSTORE (CLIENT): Get signed urls for read """
        ret = self.os_client.get_signed_urls([self.url], rse=self.rse, operation='read')
        if isinstance(ret[self.url], Exception):
            raise ret[self.url]

        # read
        command = 'curl "%s" > /dev/null' % ret[self.url]
        status, output = commands.getstatusoutput(command)
        if status:
            raise Exception(output)

        # write
        command = 'curl --request PUT --upload-file /bin/hostname "%s"' % ret[self.url]
        status, output = commands.getstatusoutput(command)
        if status:
            raise Exception(output)
        if 'AccessDenied' not in output:
            raise Exception(output)

    def test_get_signed_urls_write(self):
        """ OBJECTSTORE (CLIENT): Get signed urls for write """
        ret = self.os_client.get_signed_urls([self.url], rse=self.rse, operation='write')
        if isinstance(ret[self.url], Exception):
            raise ret[self.url]

        # write
        command = 'curl --request PUT --upload-file /bin/hostname "%s"' % ret[self.url]
        status, output = commands.getstatusoutput(command)
        if status:
            raise Exception(output)
        if 'AccessDenied' in output:
            raise Exception(output)

        # read
        command = 'curl "%s" > /dev/null' % ret[self.url]
        status, output = commands.getstatusoutput(command)
        if status:
            raise Exception(output)

    @raises(exception.SourceNotFound)
    def test_get_signed_urls_read_not_exists(self):
        """ OBJECTSTORE (CLIENT): Get signed not exist urls for read """
        url = '%s_not_exist' % (self.url)
        self.os_client.get_signed_urls([url], rse=self.rse, operation='read')
        raise Exception("Respone not as expected: should catch SourceNotFound")

    def test_get_metadata(self):
        """ OBJECTSTORE (CLIENT): Get metadata """
        url = self.url
        ret = self.os_client.get_metadata([url], rse=self.rse)
        if isinstance(ret[url], Exception):
            raise ret[url]
        if 'filesize' not in ret[url]:
            raise Exception("Respone not as expected: should return {'filesize': filesize}, but it returns: %s" % ret[url])

    @raises(exception.SourceNotFound)
    def test_get_metadata_not_exist(self):
        """ OBJECTSTORE (CLIENT): Get metadata for not exist url """
        url = '%s_not_exist' % (self.url)
        self.os_client.get_metadata([url], rse=self.rse)
        raise Exception("Respone not as expected: should catch SourceNotFound")

    def test_rename(self):
        """ OBJECTSTORE (CLIENT): Rename """
        url = self.url
        new_url = '%s_new' % url
        self.os_client.rename(url, new_url, rse=self.rse)
        try:
            self.os_client.get_metadata([url], rse=self.rse)
        except exception.SourceNotFound:
            pass

        ret = self.os_client.get_metadata([new_url], rse=self.rse)
        if isinstance(ret[new_url], Exception):
            raise ret[new_url]
        if 'filesize' not in ret[new_url]:
            raise Exception("Respone not as expected: should return {'filesize': filesize}, but it returns: %s" % ret[new_url])
예제 #3
0
 def _rename(self, url, new_url):
     client = ObjectStoreClient()
     return client.rename(url, new_url, rse=self.rse['rse'])
예제 #4
0
 def _get_metadata(self, urls):
     client = ObjectStoreClient()
     return client.get_metadata(urls, rse=self.rse['rse'])
예제 #5
0
 def _get_signed_url(self, url, operation='read'):
     client = ObjectStoreClient()
     return client.get_signed_url(url, rse=self.rse['rse'], operation=operation)
예제 #6
0
 def _connect(self):
     url = self.path2pfn('')
     client = ObjectStoreClient()
     return client.connect(self.rse['rse'], url)