| 1 |
# --- BEGIN COPYRIGHT BLOCK --- |
| 2 |
# Copyright (C) 2023 Red Hat, Inc. |
| 3 |
# All rights reserved. |
| 4 |
# |
| 5 |
# License: GPL (version 3 or any later version). |
| 6 |
# See LICENSE for details. |
| 7 |
# --- END COPYRIGHT BLOCK --- |
| 8 |
# |
| 9 |
import pytest |
| 10 |
from lib389.dbgen import dbgen_groups |
| 11 |
from lib389.tasks import ImportTask |
| 12 |
from lib389.utils import * |
| 13 |
from lib389.paths import Paths |
| 14 |
from test389.topologies import topology_st as topo |
| 15 |
from lib389._constants import * |
| 16 |
|
| 17 |
pytestmark = pytest.mark.tier2 |
| 18 |
|
| 19 |
logging.getLogger(__name__).setLevel(logging.DEBUG) |
| 20 |
log = logging.getLogger(__name__) |
| 21 |
|
| 22 |
ds_paths = Paths() |
| 23 |
|
| 24 |
|
| 25 |
@pytest.mark.skipif(not ds_paths.asan_enabled, reason="Don't run if ASAN is not enabled") |
| 26 |
def test_allids_search(topo): |
| 27 |
"""Add 100 groups, and run a search with a special filter that triggers a memleak. |
| 28 |
|
| 29 |
:id: 8aeca831-e671-4203-9d50-2bfe9567bec7 |
| 30 |
:setup: Standalone instance |
| 31 |
:steps: |
| 32 |
1. Add 100 test groups |
| 33 |
2. Issue a search with a special filter |
| 34 |
3. There should be no leak |
| 35 |
:expectedresults: |
| 36 |
1. 100 test groups should be added |
| 37 |
2. Search should be successful |
| 38 |
3. Success |
| 39 |
""" |
| 40 |
|
| 41 |
inst = topo.standalone |
| 42 |
|
| 43 |
import_ldif = inst.ldifdir + '/import_100_users.ldif' |
| 44 |
props = { |
| 45 |
"name": "grp", |
| 46 |
"suffix": DEFAULT_SUFFIX, |
| 47 |
"parent": DEFAULT_SUFFIX, |
| 48 |
"number": 100, |
| 49 |
"numMembers": 0, |
| 50 |
"createMembers": False, |
| 51 |
"memberParent": DEFAULT_SUFFIX, |
| 52 |
"membershipAttr": "member", |
| 53 |
} |
| 54 |
dbgen_groups(inst, import_ldif, props) |
| 55 |
|
| 56 |
task = ImportTask(inst) |
| 57 |
task.import_suffix_from_ldif(ldiffile=import_ldif, suffix=DEFAULT_SUFFIX) |
| 58 |
task.wait() |
| 59 |
|
| 60 |
inst.search_s(DEFAULT_SUFFIX, ldap.SCOPE_SUBTREE, |
| 61 |
'(&(objectClass=groupOfNames)(!(objectClass=nsTombstone))(member=doesnt_exist))') |
| 62 |
|
| 63 |
|
| 64 |
if __name__ == '__main__': |
| 65 |
# Run isolated |
| 66 |
# -s for DEBUG mode |
| 67 |
CURRENT_FILE = os.path.realpath(__file__) |
| 68 |
pytest.main("-s %s" % CURRENT_FILE) |
| 69 |
|
| 70 |
|