This is an automated email from the git hooks/post-receive script.
firstyear pushed a change to branch master in repository 389-ds-base.
from 938dfb7 Issue 47536 - Add Python 3 support and move test case to suites new 8a7bee6 Ticket 49461 - Improve db2index handling for test 49290
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: dirsrvtests/tests/suites/basic/basic_test.py | 19 +++++++++ dirsrvtests/tests/tickets/ticket49290_test.py | 2 +- ldap/servers/slapd/main.c | 7 +++- src/lib389/lib389/__init__.py | 59 ++++++++++++++++++--------- 4 files changed, 66 insertions(+), 21 deletions(-)
This is an automated email from the git hooks/post-receive script.
firstyear pushed a commit to branch master in repository 389-ds-base.
commit 8a7bee66da2bbcd311afb54a6bf9ae92f426ec5b Author: William Brown firstyear@redhat.com Date: Mon Nov 20 17:40:12 2017 +0100
Ticket 49461 - Improve db2index handling for test 49290
Bug Description: db2index has limited parameters we can accept, including the types of attributes we can index. Specificatlly, we must take an index name, else we do not re-index (look at ns-slapd, we require -t or -T, and if we do, we require them to have a value.
Fix Description: Fix lib389 to match the assertions of ns-slapd with regard to db2index behaviour.
https://pagure.io/389-ds-base/issue/49461
Author: wibrown
Review by: mreynolds (Thanks!) --- dirsrvtests/tests/suites/basic/basic_test.py | 19 +++++++++ dirsrvtests/tests/tickets/ticket49290_test.py | 2 +- ldap/servers/slapd/main.c | 7 +++- src/lib389/lib389/__init__.py | 59 ++++++++++++++++++--------- 4 files changed, 66 insertions(+), 21 deletions(-)
diff --git a/dirsrvtests/tests/suites/basic/basic_test.py b/dirsrvtests/tests/suites/basic/basic_test.py index 40ffde8..3fb51ea 100644 --- a/dirsrvtests/tests/suites/basic/basic_test.py +++ b/dirsrvtests/tests/suites/basic/basic_test.py @@ -366,6 +366,25 @@ def test_basic_backup(topology_st, import_example_ldif):
log.info('test_basic_backup: PASSED')
+def test_basic_db2index(topology_st, import_example_ldif): + """Assert db2index can operate correctly. + + :id: 191fc0fd-9722-46b5-a7c3-e8760effe119 + + :setup: Standalone instance + + :steps: + 1: call db2index + + :expectedresults: + 1: Index succeeds. + + """ + topology_st.standalone.stop() + topology_st.standalone.db2index() + topology_st.standalone.db2index(suffixes=[DEFAULT_SUFFIX], attrs=['uid']) + topology_st.standalone.start() +
def test_basic_acl(topology_st, import_example_ldif): """Run some basic access control (ACL) tests diff --git a/dirsrvtests/tests/tickets/ticket49290_test.py b/dirsrvtests/tests/tickets/ticket49290_test.py index 72ba9f9..fcf6b0e 100644 --- a/dirsrvtests/tests/tickets/ticket49290_test.py +++ b/dirsrvtests/tests/tickets/ticket49290_test.py @@ -52,7 +52,7 @@ def test_49290_range_unindexed_notes(topology_st): 'nsIndexType' : 'eq', }) topology_st.standalone.stop() - topology_st.standalone.db2index(DEFAULT_BENAME) + assert topology_st.standalone.db2index(DEFAULT_BENAME, attrs=['modifytimestamp'] ) topology_st.standalone.start()
# Now run the modifyTimestamp range query again. Assert that there is no diff --git a/ldap/servers/slapd/main.c b/ldap/servers/slapd/main.c index f8b591e..d53f431 100644 --- a/ldap/servers/slapd/main.c +++ b/ldap/servers/slapd/main.c @@ -2377,6 +2377,7 @@ slapd_exemode_db2index(struct main_config *mcfg) { int return_value = 0; struct slapdplugin *plugin; + char **instances = NULL;
mapping_tree_init();
@@ -2385,7 +2386,7 @@ slapd_exemode_db2index(struct main_config *mcfg) * otherwise, we use included/excluded suffix list to specify a backend. */ if (NULL == mcfg->cmd_line_instance_name) { - char **instances, **ip; + char **ip; int counter;
if (lookup_instance_name_by_suffixes(mcfg->db2ldif_include, mcfg->db2ldif_exclude, @@ -2456,6 +2457,10 @@ slapd_exemode_db2index(struct main_config *mcfg)
slapi_pblock_destroy(pb); slapi_ch_free((void **)&(mcfg->myname)); + + charray_free(mcfg->db2ldif_include); + charray_free(instances); + return (return_value); }
diff --git a/src/lib389/lib389/__init__.py b/src/lib389/lib389/__init__.py index 8a49df4..2c8c22d 100644 --- a/src/lib389/lib389/__init__.py +++ b/src/lib389/lib389/__init__.py @@ -41,7 +41,7 @@ import ldapurl import time import operator import shutil -import datetime +from datetime import datetime import logging import decimal import glob @@ -2780,34 +2780,55 @@ class DirSrv(SimpleLDAPObject, object): @param vlvTag - The VLV index name to index @return - True if reindexing succeeded """ - DirSrvTools.lib389User(user=DEFAULT_USER) - prog = os.path.join(self.ds_paths.sbin_dir, DB2INDEX) + prog = os.path.join(self.ds_paths.sbin_dir, 'ns-slapd')
- if not bename and not suffixes: + if self.status(): + log.error("db2index: Can not operate while directory server is running") + return False + + if (not bename and not suffixes) and (attrs or vlvTag): log.error("db2index: missing required backend name or suffix") return False
- cmd = '%s -Z %s' % (prog, self.serverid) + cmd = [prog,] + if attrs or vlvTag: + cmd.append('db2index') + else: + cmd.append('upgradedb') + cmd.append('-a') + now = datetime.now().isoformat() + cmd.append(os.path.join(self.get_bak_dir(), 'reindex_%s' % now)) + + cmd.append('-D') + cmd.append(self.get_config_dir()) + + if bename: - cmd = cmd + ' -n %s' % bename - if suffixes: + cmd.append('-n') + cmd.append(bename) + + # Can only use suffiix in attr only mode. + if suffixes and (attrs or vlvTag): for suffix in suffixes: - cmd = cmd + ' -s %s' % suffix + cmd.append('-s') + cmd.append(suffix) + if attrs: for attr in attrs: - cmd = cmd + ' -t %s' % attr + cmd.append('-t') + cmd.append(attr) + if vlvTag: - cmd = cmd + ' -T %s' % vlvTag + cmd.append('-T') + cmd.append(vlvTag)
- self.stop(timeout=10) - log.info('Running script: %s' % cmd) - result = True - try: - os.system(cmd) - except: - log.error("db2index: error executing %s" % cmd) - result = False - self.start(timeout=10) + result = subprocess.check_output(cmd) + u_result = ensure_str(result) + + log.debug("db2index output: BEGIN") + for line in u_result.split("\n"): + log.debug(line) + log.debug("db2index output: END")
return result
389-commits@lists.fedoraproject.org