示例#1
0
class TestDIDClients(unittest.TestCase):
    def setUp(self):
        self.did_client = DIDClient()
        self.lifetime_client = LifetimeClient()

    def test_create_and_check_lifetime_exception(self):
        """ LIFETIME (CLIENT): Test the creation of a Lifetime Model exception """
        tmp_scope = 'mock'
        tmp_dsn1 = 'dsn_%s' % generate_uuid()
        self.did_client.add_did(scope=tmp_scope,
                                name=tmp_dsn1,
                                type=DIDType.DATASET)
        dids = [
            {
                'scope': tmp_scope,
                'name': tmp_dsn1,
                'did_type': DIDType.DATASET
            },
        ]
        exceptions = self.lifetime_client.list_exceptions()
        exception_id = self.lifetime_client.add_exception(
            dids,
            account='root',
            pattern='wekhewfk',
            comments='This is a comment',
            expires_at=datetime.now())
        exceptions = [
            exception['id']
            for exception in self.lifetime_client.list_exceptions()
        ]
        assert exception_id in exceptions
示例#2
0
 def setUp(self):
     self.did_client = DIDClient()
     self.lifetime_client = LifetimeClient()
示例#3
0
 def __init__(self):
     self.did_client = DIDClient()
     self.lifetime_client = LifetimeClient()
示例#4
0
    for dbs_file in dbs_files:
        if dbs_file['file'][0]['name'] == filename:
            size = dbs_file['file'][0]['size']
            adler32 = dbs_file['file'][0]['adler32']
            n_events = dbs_file['file'][0]['nevents']
            break

    return size, adler32, n_events


if __name__ == '__main__':

    aClient = AccountClient(account='ewv', auth_type='x509_proxy')
    dClient = DIDClient(account='ewv', auth_type='x509_proxy')
    rClient = ReplicaClient(account='ewv', auth_type='x509_proxy')
    lClient = LifetimeClient(account='ewv', auth_type='x509_proxy')
    ruleClient = RuleClient(account='ewv', auth_type='x509_proxy')

    print("Connected to rucio as %s" % aClient.whoami()['account'])

    # Make Rucio container and dataset to correspond to CMS dataset

    try:
        print("Adding dataset %s" % RUCIO_CONTAINER)
        status = dClient.add_container(scope='cms', name=RUCIO_CONTAINER, lifetime=DAYS_TO_LIVE*24*3600)
        print(' Status for add_container', status)
    except DataIdentifierAlreadyExists:
        print('Container already exists')

    # try:
    #     status = dClient.add_dataset(scope='cms', name=RUCIO_DS, lifetime=DAYS_TO_LIVE*24*3600)