def test_update_vo_unsupported(self): """ MULTI VO (REST): Test updating VO through REST layer raises UnsupportedOperation """ mw = [] headers1 = {'X-Rucio-Account': 'super_root', 'X-Rucio-Username': '******', 'X-Rucio-Password': '******'} headers1.update(self.def_header) res1 = TestApp(auth_app.wsgifunc(*mw)).get('/userpass', headers=headers1, expect_errors=True) assert_equal(res1.status, 200) token = str(res1.header('X-Rucio-Auth-Token')) params = {'email': '*****@*****.**', 'decription': 'Try updating in single vo mode'} try: config_set('common', 'multi_vo', 'False') headers2 = {'X-Rucio-Auth-Token': str(token)} res2 = TestApp(vo_app.wsgifunc(*mw)).put('/' + self.vo['vo'], headers=headers2, expect_errors=True, params=dumps(params)) assert_equal(res2.status, 409) config_remove_option('common', 'multi_vo') headers2 = {'X-Rucio-Auth-Token': str(token)} res2 = TestApp(vo_app.wsgifunc(*mw)).put('/' + self.vo['vo'], headers=headers2, expect_errors=True, params=dumps(params)) assert_equal(res2.status, 409) finally: # Make sure we don't leave the config changed due to a test failure if self.vo: config_set('common', 'multi_vo', 'True') else: config_remove_option('common', 'multi_vo')
def test_config_default_override(self): """LFN2PFN: Test override of default LFN2PFN algorithm via config (Success)""" if not config.config_has_section('policy'): config.config_add_section('policy') try: orig_value = config.config_get('policy', 'lfn2pfn_algorithm_default') except (NoOptionError, NoSectionError): orig_value = None def static_test(scope, name, rse, rse_attrs, proto_attrs): """Static test function for config override.""" del scope del name del rse del rse_attrs del proto_attrs return "static_test_value" RSEDeterministicTranslation.register(static_test) try: config.config_set('policy', 'lfn2pfn_algorithm_default', 'static_test') RSEDeterministicTranslation._module_init_() # pylint: disable=protected-access assert_equal(self.translator.path("foo", "bar"), "static_test_value") finally: if orig_value is None: config.config_remove_option('policy', 'lfn2pfn_algorithm_default') else: config.config_set('policy', 'lfn2pfn_algorithm_default', orig_value) RSEDeterministicTranslation._module_init_() # pylint: disable=protected-access
def test_multi_vo_flag(self): """ MULTI VO (CORE): Test operations fail in single_vo mode """ try: config_set('common', 'multi_vo', 'False') with assert_raises(UnsupportedOperation): vo_api.list_vos(issuer='super_root', vo='def') config_remove_option('common', 'multi_vo') with assert_raises(UnsupportedOperation): vo_api.list_vos(issuer='super_root', vo='def') finally: # Make sure we don't leave the config changed due to a test failure if self.vo: config_set('common', 'multi_vo', 'True') else: config_remove_option('common', 'multi_vo')
def test_super_root_naming(self): """ MULTI VO (CORE): Test we can only name accounts super_root when appropriate """ with assert_raises(Duplicate): # Ensure we fail from duplication rather than the choice of name add_account('super_root', 'USER', '*****@*****.**', 'root', vo='def') with assert_raises(UnsupportedAccountName): add_account('super_root', 'USER', '*****@*****.**', 'root', **self.vo) try: config_remove_option('common', 'multi_vo') with assert_raises(UnsupportedAccountName): add_account('super_root', 'USER', '*****@*****.**', 'root', **self.vo) with assert_raises(UnsupportedAccountName): add_account('super_root', 'USER', '*****@*****.**', 'root', vo='def') finally: # Make sure we don't leave the config changed due to a test failure if self.vo: config_set('common', 'multi_vo', 'True') else: config_remove_option('common', 'multi_vo')
def test_queue_requests_state(vo, use_preparer): """ REQUEST (CORE): test queuing requests """ if use_preparer == 'preparer enabled': use_preparer = True elif use_preparer == 'preparer disabled': use_preparer = False else: return pytest.xfail(reason=f'unknown test parameter use_preparer={use_preparer}') db_session = session.get_session() dest_rse = 'MOCK' dest_rse2 = 'MOCK2' source_rse = 'MOCK4' source_rse2 = 'MOCK5' dest_rse_id = get_rse_id(dest_rse, vo=vo) dest_rse_id2 = get_rse_id(dest_rse2, vo=vo) source_rse_id = get_rse_id(source_rse, vo=vo) source_rse_id2 = get_rse_id(source_rse2, vo=vo) scope = InternalScope('mock', vo=vo) account = InternalAccount('root', vo=vo) user_activity = 'User Subscription' config_set('conveyor', 'use_preparer', str(use_preparer)) target_state = RequestState.PREPARING if use_preparer else RequestState.QUEUED name = generate_uuid() name2 = generate_uuid() name3 = generate_uuid() add_replica(source_rse_id, scope, name, 1, account, session=db_session) add_replica(source_rse_id2, scope, name2, 1, account, session=db_session) add_replica(source_rse_id, scope, name3, 1, account, session=db_session) set_rse_transfer_limits(dest_rse_id, user_activity, max_transfers=1, session=db_session) set_rse_transfer_limits(dest_rse_id2, user_activity, max_transfers=1, session=db_session) set_rse_transfer_limits(source_rse_id, user_activity, max_transfers=1, session=db_session) set_rse_transfer_limits(source_rse_id2, user_activity, max_transfers=1, session=db_session) requests = [{ 'dest_rse_id': dest_rse_id, 'src_rse_id': source_rse_id, 'request_type': RequestType.TRANSFER, 'request_id': generate_uuid(), 'name': name, 'scope': scope, 'rule_id': generate_uuid(), 'retry_count': 1, 'requested_at': datetime.now().replace(year=2015), 'attributes': { 'activity': user_activity, 'bytes': 10, 'md5': '', 'adler32': '' } }, { 'dest_rse_id': dest_rse_id, 'src_rse_id': source_rse_id2, 'request_type': RequestType.TRANSFER, 'request_id': generate_uuid(), 'name': name2, 'scope': scope, 'rule_id': generate_uuid(), 'retry_count': 1, 'requested_at': datetime.now().replace(year=2015), 'attributes': { 'activity': 'unknown', 'bytes': 10, 'md5': '', 'adler32': '' } }, { 'dest_rse_id': dest_rse_id2, 'src_rse_id': source_rse_id, 'request_type': RequestType.TRANSFER, 'request_id': generate_uuid(), 'name': name3, 'scope': scope, 'rule_id': generate_uuid(), 'retry_count': 1, 'requested_at': datetime.now().replace(year=2015), 'attributes': { 'activity': user_activity, 'bytes': 10, 'md5': '', 'adler32': '' } }] try: queue_requests(requests, session=db_session) request = get_request_by_did(scope, name, dest_rse_id, session=db_session) assert request['state'] == target_state request = get_request_by_did(scope, name2, dest_rse_id, session=db_session) assert request['state'] == target_state request = get_request_by_did(scope, name3, dest_rse_id2, session=db_session) assert request['state'] == target_state finally: config_remove_option('conveyor', 'use_preparer') db_session.query(models.Source).delete() db_session.query(models.Request).delete() db_session.query(models.RSETransferLimit).delete() db_session.query(models.Distance).delete() db_session.commit() reset_config_table()