def createRSEs(): # Add test RSEs for i in xrange(0, 3): rse1 = str(uuid()) rse2 = str(uuid()) add_rse(rse1, issuer='root') add_rse(rse2, issuer='root') add_rse_attribute(rse1, "T1", True, issuer='root') add_rse_attribute(rse2, "T1", True, issuer='root') add_rse_attribute(rse1, "DISK", True, issuer='root') add_rse_attribute(rse2, "TAPE", True, issuer='root') for i in xrange(0, 10): rse1 = str(uuid()) add_rse(rse1, issuer='root') add_rse_attribute(rse1, "T2", True, issuer='root') add_rse_attribute(rse1, "DISK", True, issuer='root') source_rse = str(uuid()) add_rse(source_rse, issuer='root') add_rse_attribute(source_rse, "T0", True, issuer='root')
def test_api_rse(self): """ RSE (API): Test external representation of RSEs """ out = api_rse.get_rse(self.rse_name, **self.vo) assert out['rse'] == self.rse_name assert out['id'] == self.rse_id out = api_rse.list_rses(**self.new_vo) out = list(out) assert 0 != len(out) rse_ids = [rse['id'] for rse in out] assert self.rse3_id in rse_ids assert self.rse4_id in rse_ids for rse in out: assert 'rse' in rse if rse['id'] == self.rse3_id: assert rse['rse'] == self.rse3_name elif rse['id'] == self.rse4_id: assert rse['rse'] == self.rse4_name key = "KEY_" + generate_uuid() api_rse.add_rse_attribute(self.rse_name, key, 1, issuer='root', **self.vo) out = api_rse.get_rses_with_attribute(key) out = list(out) assert 0 != len(out) for rse in out: assert rse['rse'] == self.rse_name out = api_rse.get_rse_protocols(self.rse_name, issuer='root', **self.vo) assert out['rse'] == self.rse_name # add some account and RSE counters rse_mock = 'MOCK4' rse_mock_id = get_rse_id(rse_mock, **self.vo) account_counter.del_counter(rse_id=rse_mock_id, account=self.account) account_counter.add_counter(rse_id=rse_mock_id, account=self.account) account_counter.increase(rse_id=rse_mock_id, account=self.account, files=1, bytes=10) account_counter.update_account_counter(self.account, rse_mock_id) did = 'file_' + generate_uuid() add_did(self.scope_name, did, 'DATASET', 'root', account=self.account_name, rse=rse_mock, **self.vo) abacus_rse.run(once=True) out = api_rse.get_rse_usage(rse_mock, per_account=True, issuer='root', **self.vo) assert rse_mock_id in [o['rse_id'] for o in out] for usage in out: if usage['rse_id'] == rse_mock_id: assert usage['rse'] == rse_mock accounts = [u['account'] for u in usage['account_usages']] assert self.account_name in accounts if self.multi_vo: assert self.account.internal not in accounts # clean up files cleaner.run(once=True) if self.multi_vo: reaper.run(once=True, include_rses='vo=%s&(%s)' % (self.vo['vo'], rse_mock), greedy=True) else: reaper.run(once=True, include_rses=rse_mock, greedy=True) abacus_rse.run(once=True) out = api_rse.parse_rse_expression( '%s|%s' % (self.rse_name, self.rse2_name), **self.vo) assert self.rse_name in out assert self.rse2_name in out assert self.rse_id not in out assert self.rse2_id not in out