This is an automated email from the git hooks/post-receive script.
mreynolds pushed a commit to branch 389-ds-base-1.4.0
in repository 389-ds-base.
The following commit(s) were added to refs/heads/389-ds-base-1.4.0 by this push:
new 73d18c8 Ticket 50303 - Add task creation date to task data
73d18c8 is described below
commit 73d18c8e8979679d8aaf7021e78133a75fd40eea
Author: Mark Reynolds <mreynolds(a)redhat.com>
AuthorDate: Wed Mar 27 11:03:07 2019 -0400
Ticket 50303 - Add task creation date to task data
Description: Add a new attribute to the slapi task entry containing
the start date. This provides a nice convenience without
having to change LDAP clients.
https://pagure.io/389-ds-base/issue/50303
Reviewed by: firstyear & spichugi(Thanks!)
(cherry picked from commit 78003de289556ca6cdbe81fd200f80f4e8f69cbb)
---
dirsrvtests/tests/suites/basic/basic_test.py | 44 ++++++++++++++++------------
ldap/schema/02common.ldif | 10 ++++++-
ldap/servers/slapd/slap.h | 6 ++--
ldap/servers/slapd/task.c | 7 ++++-
4 files changed, 43 insertions(+), 24 deletions(-)
diff --git a/dirsrvtests/tests/suites/basic/basic_test.py
b/dirsrvtests/tests/suites/basic/basic_test.py
index 50b5dc0..271f905 100644
--- a/dirsrvtests/tests/suites/basic/basic_test.py
+++ b/dirsrvtests/tests/suites/basic/basic_test.py
@@ -244,28 +244,32 @@ def test_basic_import_export(topology_st, import_example_ldif):
log.info('Running test_basic_import_export...')
- tmp_dir = '/tmp'
-
#
# Test online/offline LDIF imports
#
topology_st.standalone.start()
# Generate a test ldif (50k entries)
+ log.info("Generating LDIF...")
ldif_dir = topology_st.standalone.get_ldif_dir()
import_ldif = ldif_dir + '/basic_import.ldif'
dbgen(topology_st.standalone, 50000, import_ldif, DEFAULT_SUFFIX)
# Online
- try:
- topology_st.standalone.tasks.importLDIF(suffix=DEFAULT_SUFFIX,
- input_file=import_ldif,
- args={TASK_WAIT: True})
- except ValueError:
- log.fatal('test_basic_import_export: Online import failed')
- assert False
+ log.info("Importing LDIF online...")
+ r = ImportTask(topology_st.standalone)
+ r.import_suffix_from_ldif(ldiffile=import_ldif, suffix=DEFAULT_SUFFIX)
+
+ # Good as place as any to quick test the task has some expected attributes
+ assert r.present('nstaskcreated')
+ assert r.present('nstasklog')
+ assert r.present('nstaskcurrentitem')
+ assert r.present('nstasktotalitems')
+
+ r.wait()
# Offline
+ log.info("Importing LDIF offline...")
topology_st.standalone.stop()
if not topology_st.standalone.ldif2db(DEFAULT_BENAME, None, None, None,
import_ldif):
log.fatal('test_basic_import_export: Offline import failed')
@@ -277,16 +281,15 @@ def test_basic_import_export(topology_st, import_example_ldif):
#
# Online export
+ log.info("Exporting LDIF online...")
export_ldif = ldif_dir + '/export.ldif'
- exportTask = Tasks(topology_st.standalone)
- try:
- args = {TASK_WAIT: True}
- exportTask.exportLDIF(DEFAULT_SUFFIX, None, export_ldif, args)
- except ValueError:
- log.fatal('test_basic_import_export: Online export failed')
- assert False
+
+ r = ExportTask(topology_st.standalone)
+ r.export_suffix_to_ldif(ldiffile=export_ldif, suffix=DEFAULT_SUFFIX)
+ r.wait()
# Offline export
+ log.info("Exporting LDIF offline...")
topology_st.standalone.stop()
if not topology_st.standalone.db2ldif(DEFAULT_BENAME, (DEFAULT_SUFFIX,),
None, None, None, export_ldif):
@@ -298,6 +301,7 @@ def test_basic_import_export(topology_st, import_example_ldif):
#
# Cleanup - Import the Example LDIF for the other tests in this suite
#
+ log.info("Restore datrabase, import initial LDIF...")
ldif = '%s/dirsrv/data/Example.ldif' % topology_st.standalone.get_data_dir()
import_ldif = topology_st.standalone.get_ldif_dir() + "/Example.ldif"
shutil.copyfile(ldif, import_ldif)
@@ -366,6 +370,7 @@ 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.
@@ -902,7 +907,7 @@ def create_users(topology_st):
log.info('Adding 5 test users')
for name in user_names:
- user = users.create(properties={
+ users.create(properties={
'uid': name,
'sn': name,
'cn': name,
@@ -1020,6 +1025,7 @@ def test_connection_buffer_size(topology_st):
with pytest.raises(ldap.OPERATIONS_ERROR):
topology_st.standalone.config.replace('nsslapd-connection-buffer',
value)
+
@pytest.mark.bz1637439
def test_critical_msg_on_empty_range_idl(topology_st):
"""Doing a range index lookup should not report a critical message
even if IDL is empty
@@ -1092,6 +1098,7 @@ def test_critical_msg_on_empty_range_idl(topology_st):
# Step 5
assert not topology_st.standalone.searchErrorsLog('CRIT - list_candidates - NULL
idl was recieved from filter_candidates_ext.')
+
def audit_pattern_found(server, log_pattern):
file_obj = open(server.ds_paths.audit_log, "r")
@@ -1107,6 +1114,7 @@ def audit_pattern_found(server, log_pattern):
return found
+
@pytest.mark.ds50026
def test_ticketldbm_audit(topology_st):
"""When updating LDBM config attributes, those attributes/values are
not listed
@@ -1198,5 +1206,3 @@ if __name__ == '__main__':
# -s for DEBUG mode
CURRENT_FILE = os.path.realpath(__file__)
pytest.main("-s %s" % CURRENT_FILE)
-
-
diff --git a/ldap/schema/02common.ldif b/ldap/schema/02common.ldif
index 62e77a7..23d38f7 100644
--- a/ldap/schema/02common.ldif
+++ b/ldap/schema/02common.ldif
@@ -137,6 +137,13 @@ attributeTypes: ( 2.16.840.1.113730.3.1.3023 NAME
'nsViewFilter' DESC 'Netscape
attributeTypes: ( 2.16.840.1.113730.3.1.2063 NAME 'nsEncryptionAlgorithm' DESC
'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15
SINGLE-VALUE X-ORIGIN 'Netscape Directory Server' )
attributeTypes: ( 2.16.840.1.113730.3.1.2094 NAME 'nsslapd-parent-suffix' DESC
'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.12 X-ORIGIN
'Netscape' )
attributeTypes: ( 2.16.840.1.113730.3.1.2401 NAME 'ConflictCSN' DESC
'Netscape defined attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 USAGE
directoryOperation X-ORIGIN 'Netscape Directory Server' )
+attributeTypes: ( 2.16.840.1.113730.3.1.2085 NAME 'isReplicated' DESC
'Changelog attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 X-ORIGIN
'Netscape Directory Server' )
+attributeTypes: ( 2.16.840.1.113730.3.1.2354 NAME 'nsTaskLog' DESC 'Slapi
Task log' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN '389
Directory Server' )
+attributeTypes: ( 2.16.840.1.113730.3.1.2355 NAME 'nsTaskStatus' DESC 'Slapi
Task status' SYNTAX 1.3.6.1.4.1.1466.115.121.1.15 SINGLE-VALUE X-ORIGIN '389
Directory Server' )
+attributeTypes: ( 2.16.840.1.113730.3.1.2356 NAME 'nsTaskExitCode' DESC
'Slapi Task exit code' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN
'389 Directory Server' )
+attributeTypes: ( 2.16.840.1.113730.3.1.2357 NAME 'nsTaskCurrentItem' DESC
'Slapi Task item' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE X-ORIGIN
'389 Directory Server' )
+attributeTypes: ( 2.16.840.1.113730.3.1.2358 NAME 'nsTaskTotalItems' DESC
'Slapi Task total items' SYNTAX 1.3.6.1.4.1.1466.115.121.1.27 SINGLE-VALUE
X-ORIGIN '389 Directory Server' )
+attributeTypes: ( 2.16.840.1.113730.3.1.2359 NAME 'nsTaskCreated' DESC 'Slapi
Task creation date' SYNTAX 1.3.6.1.4.1.1466.115.121.1.24 SINGLE-VALUE X-ORIGIN
'389 Directory Server' )
#
# objectclasses:
#
@@ -169,4 +176,5 @@ objectClasses: ( 2.16.840.1.113730.3.2.503 NAME
'nsDSWindowsReplicationAgreement
objectClasses: ( 2.16.840.1.113730.3.2.128 NAME 'costemplate' DESC 'Netscape
defined objectclass' SUP top MAY ( cn $ cospriority ) X-ORIGIN 'Netscape Directory
Server' )
objectClasses: ( 2.16.840.1.113730.3.2.304 NAME 'nsView' DESC 'Netscape
defined objectclass' SUP top AUXILIARY MAY ( nsViewFilter $ description ) X-ORIGIN
'Netscape Directory Server' )
objectClasses: ( 2.16.840.1.113730.3.2.316 NAME 'nsAttributeEncryption' DESC
'Netscape defined objectclass' SUP top MUST ( cn $ nsEncryptionAlgorithm )
X-ORIGIN 'Netscape Directory Server' )
-attributeTypes: ( 2.16.840.1.113730.3.1.2085 NAME 'isReplicated' DESC
'Changelog attribute type' SYNTAX 1.3.6.1.4.1.1466.115.121.1.7 X-ORIGIN
'Netscape Directory Server' )
+objectClasses: ( 2.16.840.1.113730.3.2.335 NAME 'nsSlapiTask' DESC
'Slapi_Task objectclass' SUP top MUST ( cn ) MAY ( ttl $ nsTaskLog $ nsTaskStatus
$ nsTaskExitCode $ nsTaskCurrentItem $ nsTaskTotalItems $ nsTaskCreated ) X-ORIGIN
'389 Directory Server' )
+
diff --git a/ldap/servers/slapd/slap.h b/ldap/servers/slapd/slap.h
index 6b80b3e..c7becf5 100644
--- a/ldap/servers/slapd/slap.h
+++ b/ldap/servers/slapd/slap.h
@@ -1723,13 +1723,13 @@ struct slapi_task
int task_flags; /* (see above) */
char *task_status; /* transient status info */
char *task_log; /* appended warnings, etc */
+ char task_date[SLAPI_TIMESTAMP_BUFSIZE]; /* Date/time when task was created */
void *task_private; /* allow opaque data to be stashed in the task */
TaskCallbackFn cancel; /* task has been cancelled by user */
TaskCallbackFn destructor; /* task entry is being destroyed */
int task_refcount;
- void *origin_plugin; /* If this is a plugin create task, store the plugin object
*/
- PRLock *task_log_lock; /* To protect task_log to be realloced if
- it's in use */
+ void *origin_plugin; /* If this is a plugin create task, store the plugin
object */
+ PRLock *task_log_lock; /* To protect task_log to be realloced if it's in use
*/
} slapi_task;
/* End of interface to support online tasks **********************************/
diff --git a/ldap/servers/slapd/task.c b/ldap/servers/slapd/task.c
index b42e872..6e223fe 100644
--- a/ldap/servers/slapd/task.c
+++ b/ldap/servers/slapd/task.c
@@ -45,6 +45,7 @@ static int shutting_down = 0;
#define TASK_EXITCODE_NAME "nsTaskExitCode"
#define TASK_PROGRESS_NAME "nsTaskCurrentItem"
#define TASK_WORK_NAME "nsTaskTotalItems"
+#define TASK_DATE_NAME "nsTaskCreated"
#define DEFAULT_TTL "3600" /* seconds */
#define TASK_SYSCONFIG_FILE_ATTR "sysconfigfile" /* sysconfig reload task file
attr */
@@ -347,6 +348,7 @@ slapi_task_status_changed(Slapi_Task *task)
sprintf(s3, "%d", task->task_work);
NEXTMOD(TASK_PROGRESS_NAME, s2);
NEXTMOD(TASK_WORK_NAME, s3);
+ NEXTMOD(TASK_DATE_NAME, task->task_date);
/* only add the exit code when the job is done */
if ((task->task_state == SLAPI_TASK_FINISHED) ||
(task->task_state == SLAPI_TASK_CANCELLED)) {
@@ -604,6 +606,9 @@ new_task(const char *rawdn, void *plugin)
return NULL;
}
+ /* Set the task creation time */
+ slapi_timestamp_utc_hr(task->task_date, SLAPI_TIMESTAMP_BUFSIZE);
+
/* Now take our lock to setup everything correctly. */
PR_Lock(task->task_log_lock);
@@ -687,7 +692,7 @@ destroy_task(time_t when, void *arg)
slapi_delete_internal_pb(pb);
slapi_pblock_destroy(pb);
- slapi_ch_free((void **)&task->task_dn);
+ slapi_ch_free_string(&task->task_dn);
slapi_ch_free((void **)&task);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.