Exemplo n.º 1
0
def test_reaper_affect_other_vo_via_run(vo, second_vo, scope_factory, caches_mock, file_config_mock):
    """ MULTI VO (DAEMON): Test that reaper runs on the specified VO(s) and does not reap others"""
    [cache_region] = caches_mock
    new_vo = second_vo
    scope_name, [scope_tst, scope_new] = scope_factory(vos=[vo, new_vo])
    rse_name = rse_name_generator()

    nb_files = 30
    file_size = 200  # 2G
    names = ['lfn' + generate_uuid() for _ in range(nb_files)]
    _, rse_id_tst, _ = __add_test_rse_and_replicas(vo=vo, scope=scope_tst, rse_name=rse_name, names=names, file_size=file_size)
    _, rse_id_new, _ = __add_test_rse_and_replicas(vo=new_vo, scope=scope_new, rse_name=rse_name, names=names, file_size=file_size)

    rse_api.set_rse_usage(rse=rse_name, source='storage', used=nb_files * file_size, free=1, issuer='root', vo=vo)
    rse_api.set_rse_limits(rse=rse_name, name='MinFreeSpace', value=5 * 200, issuer='root', vo=vo)
    rse_api.set_rse_limits(rse=rse_name, name='MaxBeingDeletedFiles', value=10, issuer='root', vo=vo)

    rse_api.set_rse_usage(rse=rse_name, source='storage', used=nb_files * file_size, free=1, issuer='root', vo=new_vo)
    rse_api.set_rse_limits(rse=rse_name, name='MinFreeSpace', value=5 * 200, issuer='root', vo=new_vo)
    rse_api.set_rse_limits(rse=rse_name, name='MaxBeingDeletedFiles', value=10, issuer='root', vo=new_vo)

    # Check we start of with the expected number of replicas
    assert len(list(replica_api.list_replicas([{'scope': scope_name, 'name': n} for n in names], rse_expression=rse_name, vo=vo))) == nb_files
    assert len(list(replica_api.list_replicas([{'scope': scope_name, 'name': n} for n in names], rse_expression=rse_name, vo=new_vo))) == nb_files

    # Check we don't affect a second VO that isn't specified
    cache_region.invalidate()
    run_reaper(once=True, rses=[rse_name], vos=['new'])
    assert len(list(replica_api.list_replicas([{'scope': scope_name, 'name': n} for n in names], rse_expression=rse_name, vo=vo))) == nb_files
    assert len(list(replica_api.list_replicas([{'scope': scope_name, 'name': n} for n in names], rse_expression=rse_name, vo=new_vo))) == 25
Exemplo n.º 2
0
def test_reaper_multi_vo_via_run(vo):
    """ MULTI VO (DAEMON): Test that reaper runs on the specified VO(s) """
    new_vo = __setup_new_vo()
    scope_name, [scope_tst, scope_new] = __setup_scopes_for_vos(vo, new_vo)
    rse_name = rse_name_generator()

    nb_files = 30
    file_size = 200  # 2G
    names = ['lfn' + generate_uuid() for _ in range(nb_files)]
    _, rse_id_tst, _ = __add_test_rse_and_replicas(vo=vo,
                                                   scope=scope_tst,
                                                   rse_name=rse_name,
                                                   names=names,
                                                   file_size=file_size)
    _, rse_id_new, _ = __add_test_rse_and_replicas(vo=new_vo,
                                                   scope=scope_new,
                                                   rse_name=rse_name,
                                                   names=names,
                                                   file_size=file_size)

    rse_api.set_rse_usage(rse=rse_name,
                          source='storage',
                          used=nb_files * file_size,
                          free=1,
                          issuer='root',
                          vo=vo)
    rse_api.set_rse_limits(rse=rse_name,
                           name='MinFreeSpace',
                           value=5 * 200,
                           issuer='root',
                           vo=vo)
    rse_api.set_rse_limits(rse=rse_name,
                           name='MaxBeingDeletedFiles',
                           value=10,
                           issuer='root',
                           vo=vo)

    rse_api.set_rse_usage(rse=rse_name,
                          source='storage',
                          used=nb_files * file_size,
                          free=1,
                          issuer='root',
                          vo=new_vo)
    rse_api.set_rse_limits(rse=rse_name,
                           name='MinFreeSpace',
                           value=5 * 200,
                           issuer='root',
                           vo=new_vo)
    rse_api.set_rse_limits(rse=rse_name,
                           name='MaxBeingDeletedFiles',
                           value=10,
                           issuer='root',
                           vo=new_vo)

    # Check we start of with the expected number of replicas
    assert len(
        list(
            replica_api.list_replicas([{
                'scope': scope_name,
                'name': n
            } for n in names],
                                      rse_expression=rse_name,
                                      vo=vo))) == nb_files
    assert len(
        list(
            replica_api.list_replicas([{
                'scope': scope_name,
                'name': n
            } for n in names],
                                      rse_expression=rse_name,
                                      vo=new_vo))) == nb_files

    # Check we reap all VOs by default
    REGION.invalidate()
    run_reaper(once=True, rses=[rse_name])
    assert len(
        list(
            replica_api.list_replicas([{
                'scope': scope_name,
                'name': n
            } for n in names],
                                      rse_expression=rse_name,
                                      vo=vo))) == 25
    assert len(
        list(
            replica_api.list_replicas([{
                'scope': scope_name,
                'name': n
            } for n in names],
                                      rse_expression=rse_name,
                                      vo=new_vo))) == 25