This is an automated email from the git hooks/post-receive script.
firstyear pushed a change to branch master in repository lib389.
from a9a942a Ticket 67 - get attr by type new b5a8279 Ticket 59 - lib389 support for index management.
The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference.
Summary of changes: lib389/__init__.py | 2 +- lib389/backend.py | 7 +++++ lib389/index.py | 26 ++++++++++++++--- lib389/tests/index_test.py | 69 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+), 5 deletions(-) create mode 100644 lib389/tests/index_test.py
This is an automated email from the git hooks/post-receive script.
firstyear pushed a commit to branch master in repository lib389.
commit b5a82795f8f5df3a58bd4c9b87f42dfddf7fefce Author: William Brown firstyear@redhat.com Date: Fri Jun 23 14:51:31 2017 +1000
Ticket 59 - lib389 support for index management.
Bug Description: To allow tests and dsconf to manage indexes we need the supporting objectClasses in place.
Fix Description: This adds the Indexes and Index types, as well as a linking method from a backend to get it's related Indexes.
https://pagure.io/lib389/issue/59
Author: wibrown
Review by: ilias95, spichugi (Thanks!) --- lib389/__init__.py | 2 +- lib389/backend.py | 7 +++++ lib389/index.py | 26 ++++++++++++++--- lib389/tests/index_test.py | 69 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+), 5 deletions(-)
diff --git a/lib389/__init__.py b/lib389/__init__.py index ae3e6f7..43ead6b 100644 --- a/lib389/__init__.py +++ b/lib389/__init__.py @@ -308,7 +308,7 @@ class DirSrv(SimpleLDAPObject, object): from lib389.schema import Schema from lib389.plugins import Plugins from lib389.tasks import Tasks - from lib389.index import Index + from lib389.index import IndexLegacy as Index from lib389.monitor import Monitor, MonitorLDBM from lib389.rootdse import RootDSE
diff --git a/lib389/backend.py b/lib389/backend.py index 3e208bf..75443b2 100644 --- a/lib389/backend.py +++ b/lib389/backend.py @@ -20,6 +20,7 @@ from lib389.exceptions import NoSuchEntryError, InvalidArgumentError
# We need to be a factor to the backend monitor from lib389.monitor import MonitorBackend +from lib389.index import Indexes
# This is for sample entry creation. from lib389.configurations import get_sample_entries @@ -508,6 +509,12 @@ class Backend(DSLdapObject): monitor = MonitorBackend(instance=self._instance, dn= "cn=monitor,%s" % self._dn, batch=self._batch) return monitor
+ def get_indexes(self): + indexes = Indexes(self._instance, basedn="cn=index,%s" % self._dn) + return indexes + + # Future: add reindex task for this be. + # This only does ldbm backends. Chaining backends are a special case # of this, so they can be subclassed off. class Backends(DSLdapObjects): diff --git a/lib389/index.py b/lib389/index.py index 8d4a181..cf66368 100644 --- a/lib389/index.py +++ b/lib389/index.py @@ -14,15 +14,33 @@ from lib389.properties import * from lib389 import Entry from lib389.utils import ensure_str, ensure_bytes
+from lib389._mapped_object import DSLdapObjects, DSLdapObject + MAJOR, MINOR, _, _, _ = sys.version_info
if MAJOR >= 3 or (MAJOR == 2 and MINOR >= 7): from ldap.controls.readentry import PostReadControl
- - - -class Index(object): +DEFAULT_INDEX_DN = "cn=default indexes,%s" % DN_CONFIG_LDBM + +class Index(DSLdapObject): + def __init__(self, instance, dn=None, batch=False): + super(Index, self).__init__(instance, dn, batch) + self._rdn_attribute = 'cn' + self._must_attributes = ['cn', 'nsSystemIndex', 'nsIndexType'] + self._create_objectclasses = ['top', 'nsIndex'] + self._protected = False + self._lint_functions = [] + +class Indexes(DSLdapObjects): + def __init__(self, instance, basedn=DEFAULT_INDEX_DN, batch=False): + super(Indexes, self).__init__(instance=instance, batch=batch) + self._objectclasses = ['nsIndex'] + self._filterattrs = ['cn'] + self._childobject = Index + self._basedn = basedn + +class IndexLegacy(object):
def __init__(self, conn): """@param conn - a DirSrv instance""" diff --git a/lib389/tests/index_test.py b/lib389/tests/index_test.py new file mode 100644 index 0000000..58dbf3d --- /dev/null +++ b/lib389/tests/index_test.py @@ -0,0 +1,69 @@ +# --- BEGIN COPYRIGHT BLOCK --- +# Copyright (C) 2017 Red Hat, Inc. +# All rights reserved. +# +# License: GPL (version 3 or any later version). +# See LICENSE for details. +# --- END COPYRIGHT BLOCK --- +# + +import pytest +import ldap + +from lib389.topologies import topology_st + +from lib389.backend import Backends +from lib389.index import Indexes + +def test_default_index_list(topology_st): + indexes = Indexes(topology_st.standalone) + # create and delete a default index. + + index = indexes.create(properties={ + 'cn': 'modifytimestamp', + 'nsSystemIndex': 'false', + 'nsIndexType': 'eq' + }) + default_index_list = indexes.list() + found = False + for i in default_index_list: + if i.dn.startswith('cn=modifytimestamp'): + found = True + assert found + index.delete() + + default_index_list = indexes.list() + found = False + for i in default_index_list: + if i.dn.startswith('cn=modifytimestamp'): + found = True + assert not found + +def test_backend_index(topology_st): + backends = Backends(topology_st.standalone) + ur_backend = backends.get('userRoot') + ur_indexes = ur_backend.get_indexes() + + index = ur_indexes.create(properties={ + 'cn': 'modifytimestamp', + 'nsSystemIndex': 'false', + 'nsIndexType': 'eq' + }) + + index_list = ur_indexes.list() + found = False + for i in index_list: + if i.dn.startswith('cn=modifytimestamp'): + found = True + assert found + index.delete() + + index_list = ur_indexes.list() + found = False + for i in index_list: + if i.dn.startswith('cn=modifytimestamp'): + found = True + assert not found + + +
389-commits@lists.fedoraproject.org