ldap/servers
by Noriko Hosoi
ldap/servers/slapd/back-ldbm/ldbm_index_config.c | 11 +++-
ldap/servers/slapd/mapping_tree.c | 52 +++++++++++++----------
2 files changed, 39 insertions(+), 24 deletions(-)
New commits:
commit 01fea1f89a680358245677f72a67e9ccf196f66d
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Fri Aug 14 11:19:24 2015 -0700
Ticket #48250 - Slapd crashes reported from latest build
Bug Description: There was a conflict between an import task and
deleting the instance. While the import task was still running,
the backend instance was removed, which should have been rejected.
Fix Description: Backend tasks keeps instance refcnt positive and
disable the backend in the mapping tree. This patch adds the
check for the mapping tree in the backend deletion callback. If
the instance refcnt is positive or the mapping tree is disabled,
the deletion is backed off.
For the backend deletion, the referral info is not needed. To
reduce unnecessary allocation and free, adding the code which
checks if the given referral variable is NULL or not to mtn_get_be.
If it is NULL, no allocation for the referral entry occurs.
https://fedorahosted.org/389/ticket/48250
Reviewed by rmeggins(a)redhat.com (Thank you, Rich!!)
diff --git a/ldap/servers/slapd/back-ldbm/ldbm_index_config.c b/ldap/servers/slapd/back-ldbm/ldbm_index_config.c
index 895d846..42c8ffe 100644
--- a/ldap/servers/slapd/back-ldbm/ldbm_index_config.c
+++ b/ldap/servers/slapd/back-ldbm/ldbm_index_config.c
@@ -128,7 +128,7 @@ ldbm_instance_index_config_add_callback(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_
/*
* Config DSE callback for index deletes.
- */
+ */
int
ldbm_instance_index_config_delete_callback(Slapi_PBlock *pb, Slapi_Entry* e, Slapi_Entry* entryAfter, int *returncode, char *returntext, void *arg)
{
@@ -138,15 +138,19 @@ ldbm_instance_index_config_delete_callback(Slapi_PBlock *pb, Slapi_Entry* e, Sla
const struct berval *attrValue;
int rc = SLAPI_DSE_CALLBACK_OK;
struct attrinfo *ainfo = NULL;
+ Slapi_Backend *be = NULL;
returntext[0] = '\0';
*returncode = LDAP_SUCCESS;
- if (slapi_counter_get_value(inst->inst_ref_count) > 0) {
+ if ((slapi_counter_get_value(inst->inst_ref_count) > 0) ||
+ /* check if the backend is ON or not.
+ * If offline or being deleted, non SUCCESS is returned. */
+ (slapi_mapping_tree_select(pb, &be, NULL, returntext) != LDAP_SUCCESS)) {
*returncode = LDAP_UNAVAILABLE;
rc = SLAPI_DSE_CALLBACK_ERROR;
+ goto bail;
}
-
*returncode = LDAP_SUCCESS;
slapi_entry_attr_find(e, "cn", &attr);
@@ -165,6 +169,7 @@ ldbm_instance_index_config_delete_callback(Slapi_PBlock *pb, Slapi_Entry* e, Sla
rc = SLAPI_DSE_CALLBACK_ERROR;
}
}
+bail:
return rc;
}
diff --git a/ldap/servers/slapd/mapping_tree.c b/ldap/servers/slapd/mapping_tree.c
index ca8d6af..165eba1 100644
--- a/ldap/servers/slapd/mapping_tree.c
+++ b/ldap/servers/slapd/mapping_tree.c
@@ -2171,7 +2171,9 @@ int slapi_mapping_tree_select(Slapi_PBlock *pb, Slapi_Backend **be, Slapi_Entry
}
be[0] = NULL;
- referral[0] = NULL;
+ if (referral) {
+ referral[0] = NULL;
+ }
mtn_lock();
@@ -2658,7 +2660,9 @@ static int mtn_get_be(mapping_tree_node *target_node, Slapi_PBlock *pb,
((SLAPI_OPERATION_SEARCH == op_type)||(SLAPI_OPERATION_BIND == op_type) ||
(SLAPI_OPERATION_UNBIND == op_type) || (SLAPI_OPERATION_COMPARE == op_type))) ||
override_referral) {
- *referral = NULL;
+ if (referral) {
+ *referral = NULL;
+ }
if ((target_node == mapping_tree_root) ){
/* If we got here, then we couldn't find a matching node
* for the target. We'll use the default backend. Once
@@ -2679,22 +2683,25 @@ static int mtn_get_be(mapping_tree_node *target_node, Slapi_PBlock *pb,
/* there is only one backend no choice possible */
*index = 0;
} else {
- *index = mtn_get_be_distributed(pb, target_node,
- target_sdn, &flag_stop);
- if (*index == SLAPI_BE_NO_BACKEND)
- result = LDAP_UNWILLING_TO_PERFORM;
- }
- }
- if (*index == SLAPI_BE_REMOTE_BACKEND) {
- *be = NULL;
- *referral = (target_node->mtn_referral_entry ?
- slapi_entry_dup(target_node->mtn_referral_entry) :
- NULL);
+ *index = mtn_get_be_distributed(pb, target_node, target_sdn, &flag_stop);
+ if (*index == SLAPI_BE_NO_BACKEND) {
+ result = LDAP_UNWILLING_TO_PERFORM;
+ }
+ }
+ }
+ if (*index == SLAPI_BE_REMOTE_BACKEND) {
+ *be = NULL;
+ if (referral) {
+ *referral = (target_node->mtn_referral_entry ?
+ slapi_entry_dup(target_node->mtn_referral_entry) : NULL);
+ }
(*index)++;
}else if ((*index == SLAPI_BE_NO_BACKEND) || (*index >= target_node->mtn_be_count)) {
- /* we have already returned all backends -> return NULL */
+ /* we have already returned all backends -> return NULL */
*be = NULL;
- *referral = NULL;
+ if (referral) {
+ *referral = NULL;
+ }
} else {
/* return next backend, increment index */
*be = target_node->mtn_be[*index];
@@ -2749,7 +2756,9 @@ static int mtn_get_be(mapping_tree_node *target_node, Slapi_PBlock *pb,
* send back NULL to jump to next node
*/
*be = NULL;
- *referral = NULL;
+ if (referral) {
+ *referral = NULL;
+ }
result = LDAP_SUCCESS;
} else {
/* first time we hit this referral -> return it
@@ -2758,11 +2767,12 @@ static int mtn_get_be(mapping_tree_node *target_node, Slapi_PBlock *pb,
* returned this referral
*/
*be = NULL;
- *referral = (target_node->mtn_referral_entry ?
- slapi_entry_dup(target_node->mtn_referral_entry) :
- NULL);
+ if (referral) {
+ *referral = (target_node->mtn_referral_entry ?
+ slapi_entry_dup(target_node->mtn_referral_entry) : NULL);
+ }
(*index)++;
- if (NULL == *referral) {
+ if (NULL == target_node->mtn_referral_entry) {
if (errorbuf) {
PR_snprintf(errorbuf, BUFSIZ,
"Mapping tree node for %s is set to return a referral,"
@@ -2782,7 +2792,7 @@ static int mtn_get_be(mapping_tree_node *target_node, Slapi_PBlock *pb,
"mapping tree selected backend : %s\n",
slapi_be_get_name(*be));
slapi_be_Rlock(*be);
- } else if (*referral) {
+ } else if (referral && *referral) {
slapi_log_error(SLAPI_LOG_ARGS, NULL,
"mapping tree selected referral at node : %s\n",
slapi_sdn_get_dn(target_node->mtn_subtree));
8 years, 8 months
Branch '389-ds-base-1.3.4' - ldap/servers
by thierry bordaz
ldap/servers/plugins/sync/sync_util.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
New commits:
commit a80fe155cb302e0ef10e14cb238c88698b5995a2
Author: Thierry Bordaz <tbordaz(a)redhat.com>
Date: Fri Aug 14 12:32:31 2015 +0200
Ticket 48249: sync_repl uuid may be invalid
Bug Description:
uuid is computed from nsuniqueid of the entry.
If the computed uuid contains NULL char, slapi_ch_smprintf("%s")
will stop on the it, leaving the rest of the buffer with the value
that was on the heap at that time
Fix Description:
use malloc/memcpy instead of slapi_ch_smprintf
https://fedorahosted.org/389/ticket/48249
Reviewed by: Noriko Hosoi (thank you !!)
Platforms tested: F22
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/plugins/sync/sync_util.c b/ldap/servers/plugins/sync/sync_util.c
index 00dc182..1dcff91 100644
--- a/ldap/servers/plugins/sync/sync_util.c
+++ b/ldap/servers/plugins/sync/sync_util.c
@@ -107,7 +107,8 @@ sync_nsuniqueid2uuid(const char *nsuniqueid)
u[16] = '\0';
- uuid = slapi_ch_smprintf("%s",(char *)u);
+ uuid = slapi_ch_malloc(sizeof(u));
+ memcpy(uuid, u, sizeof(u));
return(uuid);
}
8 years, 8 months
ldap/servers
by thierry bordaz
ldap/servers/plugins/sync/sync_util.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
New commits:
commit 88e72423c74848837d01760f53b776d0c6b33064
Author: Thierry Bordaz <tbordaz(a)redhat.com>
Date: Fri Aug 14 12:32:31 2015 +0200
Ticket 48249: sync_repl uuid may be invalid
Bug Description:
uuid is computed from nsuniqueid of the entry.
If the computed uuid contains NULL char, slapi_ch_smprintf("%s")
will stop on the it, leaving the rest of the buffer with the value
that was on the heap at that time
Fix Description:
use malloc/memcpy instead of slapi_ch_smprintf
https://fedorahosted.org/389/ticket/48249
Reviewed by: Noriko Hosoi (thank you !!)
Platforms tested: F22
Flag Day: no
Doc impact: no
diff --git a/ldap/servers/plugins/sync/sync_util.c b/ldap/servers/plugins/sync/sync_util.c
index 00dc182..1dcff91 100644
--- a/ldap/servers/plugins/sync/sync_util.c
+++ b/ldap/servers/plugins/sync/sync_util.c
@@ -107,7 +107,8 @@ sync_nsuniqueid2uuid(const char *nsuniqueid)
u[16] = '\0';
- uuid = slapi_ch_smprintf("%s",(char *)u);
+ uuid = slapi_ch_malloc(sizeof(u));
+ memcpy(uuid, u, sizeof(u));
return(uuid);
}
8 years, 8 months
Branch '389-ds-base-1.3.3' - dirsrvtests/suites
by Mark Reynolds
dirsrvtests/suites/basic/basic_test.py | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
New commits:
commit dc2292408a571c488a78ded4f1c37ff5e445625c
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Thu Aug 13 16:44:19 2015 -0400
Ticket 48248 - Use LDIF building function in basic test suite
Description: Use the new LDIF building function that properly sets
ownership and permissions of new ldif file
https://fedorahosted.org/389/ticket/48248
(cherry picked from commit dfb1c315d009e7a4c6798a7ae05f139b77d506dc)
Conflicts:
dirsrvtests/suites/basic/basic_test.py
diff --git a/dirsrvtests/suites/basic/basic_test.py b/dirsrvtests/suites/basic/basic_test.py
index 18d079d..d35f7d9 100644
--- a/dirsrvtests/suites/basic/basic_test.py
+++ b/dirsrvtests/suites/basic/basic_test.py
@@ -1,3 +1,11 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2015 Red Hat, Inc.
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
+#
import os
import sys
import time
@@ -217,8 +225,8 @@ def test_basic_import_export(topology):
# Generate a test ldif (50k entries)
import_ldif = tmp_dir + '/basic_import.ldif'
try:
- os.system('dbgen.pl -n 50000 -o ' + import_ldif)
- except OSError, e:
+ topology.standalone.buildLDIF(50000, import_ldif)
+ except OSError as e:
log.fatal('test_basic_import_export: failed to create test ldif, error: %s - %s' % (e.errno, e.strerror))
assert False
8 years, 8 months
Branch '389-ds-base-1.3.4' - dirsrvtests/suites
by Mark Reynolds
dirsrvtests/suites/basic/basic_test.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
New commits:
commit 7ea4487f81aec3aef17c82d20f6067fa36c1cf7c
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Thu Aug 13 16:44:19 2015 -0400
Ticket 48248 - Use LDIF building function in basic test suite
Description: Use the new LDIF building function that properly sets
ownership and permissions of new ldif file
https://fedorahosted.org/389/ticket/48248
(cherry picked from commit dfb1c315d009e7a4c6798a7ae05f139b77d506dc)
diff --git a/dirsrvtests/suites/basic/basic_test.py b/dirsrvtests/suites/basic/basic_test.py
index deeca59..d35f7d9 100644
--- a/dirsrvtests/suites/basic/basic_test.py
+++ b/dirsrvtests/suites/basic/basic_test.py
@@ -3,7 +3,7 @@
# All rights reserved.
#
# License: GPL (version 3 or any later version).
-# See LICENSE for details.
+# See LICENSE for details.
# --- END COPYRIGHT BLOCK ---
#
import os
@@ -225,8 +225,8 @@ def test_basic_import_export(topology):
# Generate a test ldif (50k entries)
import_ldif = tmp_dir + '/basic_import.ldif'
try:
- os.system('dbgen.pl -n 50000 -o ' + import_ldif)
- except OSError, e:
+ topology.standalone.buildLDIF(50000, import_ldif)
+ except OSError as e:
log.fatal('test_basic_import_export: failed to create test ldif, error: %s - %s' % (e.errno, e.strerror))
assert False
8 years, 8 months
dirsrvtests/suites
by Mark Reynolds
dirsrvtests/suites/basic/basic_test.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
New commits:
commit dfb1c315d009e7a4c6798a7ae05f139b77d506dc
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Thu Aug 13 16:44:19 2015 -0400
Ticket 48248 - Use LDIF building function in basic test suite
Description: Use the new LDIF building function that properly sets
ownership and permissions of new ldif file
https://fedorahosted.org/389/ticket/48248
diff --git a/dirsrvtests/suites/basic/basic_test.py b/dirsrvtests/suites/basic/basic_test.py
index deeca59..d35f7d9 100644
--- a/dirsrvtests/suites/basic/basic_test.py
+++ b/dirsrvtests/suites/basic/basic_test.py
@@ -3,7 +3,7 @@
# All rights reserved.
#
# License: GPL (version 3 or any later version).
-# See LICENSE for details.
+# See LICENSE for details.
# --- END COPYRIGHT BLOCK ---
#
import os
@@ -225,8 +225,8 @@ def test_basic_import_export(topology):
# Generate a test ldif (50k entries)
import_ldif = tmp_dir + '/basic_import.ldif'
try:
- os.system('dbgen.pl -n 50000 -o ' + import_ldif)
- except OSError, e:
+ topology.standalone.buildLDIF(50000, import_ldif)
+ except OSError as e:
log.fatal('test_basic_import_export: failed to create test ldif, error: %s - %s' % (e.errno, e.strerror))
assert False
8 years, 8 months
Changes to 'refs/tags/389-console-1.1.14'
by Noriko Hosoi
Changes since the dawn of time:
Mark Reynolds (3):
Ticket 97 - 389-console should provide man page
Ticket 47604 - 389-console: remove versioned jars from %{_javadir}
Bump version to 1.1.8
Nathan Kinder (3):
Initial import of fedora-idm-console
Resolves: 183962
Resolves: 393461
Noriko Hosoi (7):
Ticket 97 - 389-console should provide man page
Bump version to 1.1.9
version 1.1.10
version 1.1.11
version 1.1.12
version 1.1.13
version 1.1.14
Rich Megginson (33):
initial commit of Fedora Console for Windows - has no UI
added UI and graphics
package is not noarch
support for JAVA with spaces in the pathname
added license
updated spec for Fedora DS 1.1 release
Resolves: bug 428352
Resolves: bug 480631
Reviewed by: nkinder (Thanks!)
Resolves: bug 476095
bump version to 1.1.3 to sync with CVS tag
added unzip.vbs ; cleaned up/simplified Makefile
update idm console version to 20090310
update for 1.1.3
fix typo in Makefile
Initial commit of renaming to 389
Forgot to add provides and obsoletes for fedora-idm-console
added .gitignore
added need_libdir flag to control where libdir is needed to find jss
fix spelling error
Add 64-bit support - Use replaceable parameters for names, guids
Remove old package during upgrade
Remove old shortcuts must ignore All Users folders
Force shortcuts to be removed - removeoldpkg must run asyncNoWait
Bump version to 1.1.4
Changed version to 1.1.4.a1
make sure bitsadmin.exe path is quoted
update to version 1.1.4 rc1
update to version 1.1.4
update for nspr 4.8.4, nss 3.12.6, and idm console framework 1.1.5
Bug 592120 - console for 64bit Window2008 can not be installed
allow building without the script - bump version to 1.1.7
port to wix 3.0 from mozilla-build - use idm console 1.1.7
8 years, 8 months
build.properties win/Makefile win/VERSION.mak
by Noriko Hosoi
build.properties | 2 +-
win/Makefile | 3 +--
win/VERSION.mak | 2 +-
3 files changed, 3 insertions(+), 4 deletions(-)
New commits:
commit 4ac9671afab270415bcbf60e8b7c7397cd6be2de
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Wed Aug 12 10:06:15 2015 -0700
version 1.1.14
- Generates $(FILEPREF)-console-ipv4.bat on the fly with the java
option "-Djava.net.preferIPv4Stack=true"
mozilla sed does not take '-i'.
diff --git a/build.properties b/build.properties
index 3b83aac..3b0f34d 100644
--- a/build.properties
+++ b/build.properties
@@ -23,7 +23,7 @@ lang=en
console.root=.
console.version=11
-console.dotversion=1.1.13
+console.dotversion=1.1.14
console.dotgenversion=1.1
theme.core=389-console
diff --git a/win/Makefile b/win/Makefile
index 53694b2..69e0d7a 100644
--- a/win/Makefile
+++ b/win/Makefile
@@ -198,8 +198,7 @@ LAYOUT : $(PKGDIR) $(NSPRLIBDIR)\nspr4.dll $(NSSLIBDIR)\nss3.dll $(JSSDIR)\jss4.
# directory should already contain the bat file, icon, and bitmaps
@(echo @echo off&echo set FILEPREF=$(FILEPREF)) > header
copy /Y header+template.bat $(PKGDIR)\$(FILEPREF)-console.bat
- copy /Y header+template.bat $(PKGDIR)\$(FILEPREF)-console-ipv4.bat
- $(SED) -i -e "s/com.netscape.management.client.console.Console/-Djava.net.preferIPv4Stack=true &/" $(PKGDIR)\$(FILEPREF)-console-ipv4.bat
+ $(SED) -e "s/com.netscape.management.client.console.Console/-Djava.net.preferIPv4Stack=true com.netscape.management.client.console.Console/" $(PKGDIR)\$(FILEPREF)-console.bat > $(PKGDIR)\$(FILEPREF)-console-ipv4.bat
del header
copy /Y $(ICONDIR)\*.ico $(PKGDIR)
copy /Y $(BITMAPDIR)\* $(PKGDIR)\Bitmaps\*
diff --git a/win/VERSION.mak b/win/VERSION.mak
index c09d2ca..4ac88bb 100644
--- a/win/VERSION.mak
+++ b/win/VERSION.mak
@@ -7,7 +7,7 @@ BRANDNOSPACE=389
# this is the vendor or manufacturer
VENDOR=389 Project
# the version
-VERSION=1.1.13
+VERSION=1.1.14
# the name of the product - this is used in the title of the
# installer, in the name of the folder, and in the name
# of the shortcuts
8 years, 8 months
Branch '389-ds-base-1.3.3' - dirsrvtests/create_test.py
by Mark Reynolds
dirsrvtests/create_test.py | 137 +++++++++++++++++++++------------------------
1 file changed, 65 insertions(+), 72 deletions(-)
New commits:
commit 20f6bc6cedc923040fa175cdbe9dc8960efd97a0
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Wed Aug 12 11:54:37 2015 -0400
Ticket 48242 - Improve dirsrvtests/create_test.py script
From: Simon Pichugin <spichugi(a)redhat.com>
Date: Fri, 7 Aug 2015 14:00:39 +0200
Description: Refactor docstrings, now they match the PEP 0257 standard
Refactor script, depends on the pytest mechanic(finalizers,
fixtures and main function)
https://fedorahosted.org/389/ticket/48242
Reviewed by: mreynolds
(cherry picked from commit 70ccd9bcaa66133d71654c11d3aac53764d32901)
Conflicts:
dirsrvtests/create_test.py
diff --git a/dirsrvtests/create_test.py b/dirsrvtests/create_test.py
index 1f2971c..ad9e5aa 100755
--- a/dirsrvtests/create_test.py
+++ b/dirsrvtests/create_test.py
@@ -1,16 +1,23 @@
#!/usr/bin/python
+#
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2015 Red Hat, Inc.
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
import sys
import optparse
-'''
- This script generates a template test script that handles the
- non-interesting parts of a test script:
- topology,
- test (to be completed by the user),
- final,
- and run-isolated functions
-'''
+"""This script generates a template test script that handles the
+non-interesting parts of a test script:
+- topology,
+- test (to be completed by the user),
+- final,
+- and run-isolated function
+"""
def displayUsage():
@@ -25,6 +32,34 @@ def displayUsage():
'There is a maximum of 10 masters, 10 hubs, and 10 consumers.')
exit(1)
+
+def writeFinalizer():
+ """Write the finalizer function - delete each instance"""
+
+ TEST.write(' # Delete each instance in the end\n')
+ TEST.write(' def fin():\n')
+ if repl_deployment:
+ for idx in range(masters):
+ idx += 1
+ TEST.write(' master' + str(idx) + '.delete()\n')
+ for idx in range(hubs):
+ idx += 1
+ TEST.write(' hub' + str(idx) + '.delete()\n')
+ for idx in range(consumers):
+ idx += 1
+ TEST.write(' consumer' + str(idx) + '.delete()\n')
+ else:
+ for idx in range(instances):
+ idx += 1
+ if idx == 1:
+ idx = ''
+ else:
+ idx = str(idx)
+ TEST.write(' standalone' + idx + '.delete()\n')
+ TEST.write(' request.addfinalizer(fin)')
+ TEST.write('\n\n')
+
+
desc = 'Script to generate an initial lib389 test script. ' + \
'This generates the topology, test, final, and run-isolated functions.'
@@ -427,6 +462,8 @@ if len(sys.argv) > 0:
TEST.write(' assert False\n')
TEST.write('\n')
+ writeFinalizer()
+
#
# Write the finals steps for replication
#
@@ -475,9 +512,12 @@ if len(sys.argv) > 0:
TEST.write(' standalone' + idx + '.create()\n')
TEST.write(' standalone' + idx + '.open()\n\n')
+ writeFinalizer()
+
TEST.write(' # Clear out the tmp dir\n')
TEST.write(' standalone.clearTmpDir(__file__)\n')
TEST.write('\n')
+
TEST.write(' return TopologyStandalone(standalone')
for idx in range(instances):
idx += 1
@@ -493,82 +533,35 @@ if len(sys.argv) > 0:
#
if ticket:
TEST.write('def test_ticket' + ticket + '(topology):\n')
- TEST.write(" '''\n")
if repl_deployment:
- TEST.write(' Write your replication testcase here.\n\n')
+ TEST.write(' """Write your replication testcase here.\n\n')
TEST.write(' To access each DirSrv instance use: topology.master1, topology.master2,\n' +
- ' ..., topology.hub1, ..., topology.consumer1, ...\n')
+ ' ..., topology.hub1, ..., topology.consumer1, ...\n\n')
+ TEST.write(' Also, if you need any testcase initialization,\n')
+ TEST.write(' please, write additional fixture for that(include finalizer).\n')
else:
- TEST.write(' Write your testcase here...\n')
- TEST.write(" '''\n\n")
+ TEST.write(' """Write your testcase here...\n\n')
+ TEST.write(' Also, if you need any testcase initialization,\n')
+ TEST.write(' please, write additional fixture for that(include finalizer).\n')
+ TEST.write(' """\n\n')
TEST.write(" log.info('Test complete')\n")
- TEST.write("\n\n")
+ TEST.write('\n\n')
else:
- # For suite we start with an init function
- TEST.write('def test_' + suite + '_init(topology):\n')
- TEST.write(" '''\n")
- TEST.write(' Write any test suite initialization here(if needed)\n')
- TEST.write(" '''\n\n return\n\n\n")
-
# Write the first initial empty test function
TEST.write('def test_' + suite + '_#####(topology):\n')
- TEST.write(" '''\n")
- TEST.write(' Write a single test here...\n')
- TEST.write(" '''\n\n return\n\n\n")
-
- #
- # Write the final function here - delete each instance
- #
- if ticket:
- TEST.write('def test_ticket' + ticket + '_final(topology):\n')
- else:
- # suite
- TEST.write('def test_' + suite + '_final(topology):\n')
- if repl_deployment:
- for idx in range(masters):
- idx += 1
- TEST.write(' topology.master' + str(idx) + '.delete()\n')
- for idx in range(hubs):
- idx += 1
- TEST.write(' topology.hub' + str(idx) + '.delete()\n')
- for idx in range(consumers):
- idx += 1
- TEST.write(' topology.consumer' + str(idx) + '.delete()\n')
- else:
- for idx in range(instances):
- idx += 1
- if idx == 1:
- idx = ''
- else:
- idx = str(idx)
- TEST.write(' topology.standalone' + idx + '.delete()\n')
-
- if ticket:
- TEST.write(" log.info('Testcase PASSED')\n")
- else:
- # suite
- TEST.write(" log.info('" + suite + " test suite PASSED')\n")
- TEST.write('\n\n')
+ TEST.write(' """Write a single test here...\n\n')
+ TEST.write(' Also, if you need any test suite initialization,\n')
+ TEST.write(' please, write additional fixture for that(include finalizer).\n')
+ TEST.write(' """\n\n return\n\n\n')
#
# Write the main function
#
- TEST.write('def run_isolated():\n')
- TEST.write(' global installation1_prefix\n')
- TEST.write(' installation1_prefix = None\n\n')
- TEST.write(' topo = topology(True)\n')
- if ticket:
- TEST.write(' test_ticket' + ticket + '(topo)\n')
- TEST.write(' test_ticket' + ticket + '_final(topo)\n')
- else:
- # suite
- TEST.write(' test_' + suite + '_init(topo)\n')
- TEST.write(' test_' + suite + '_#####(topo)\n')
- TEST.write(' test_' + suite + '_final(topo)\n')
- TEST.write('\n\n')
-
TEST.write("if __name__ == '__main__':\n")
- TEST.write(' run_isolated()\n\n')
+ TEST.write(' # Run isolated\n')
+ TEST.write(' # -s for DEBUG mode\n')
+ TEST.write(' CURRENT_FILE = os.path.realpath(__file__)\n')
+ TEST.write(' pytest.main("-s %s" % CURRENT_FILE)')
#
# Done, close things up
8 years, 8 months
Branch '389-ds-base-1.3.4' - dirsrvtests/create_test.py
by Mark Reynolds
dirsrvtests/create_test.py | 131 +++++++++++++++++++--------------------------
1 file changed, 58 insertions(+), 73 deletions(-)
New commits:
commit c16382c8fb48783c58c2ff370939a2864a8959bc
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Wed Aug 12 11:54:37 2015 -0400
Ticket 48242 - Improve dirsrvtests/create_test.py script
From: Simon Pichugin <spichugi(a)redhat.com>
Date: Fri, 7 Aug 2015 14:00:39 +0200
Description: Refactor docstrings, now they match the PEP 0257 standard
Refactor script, depends on the pytest mechanic(finalizers,
fixtures and main function)
https://fedorahosted.org/389/ticket/48242
Reviewed by: mreynolds
(cherry picked from commit 70ccd9bcaa66133d71654c11d3aac53764d32901)
diff --git a/dirsrvtests/create_test.py b/dirsrvtests/create_test.py
index 941e922..ad9e5aa 100755
--- a/dirsrvtests/create_test.py
+++ b/dirsrvtests/create_test.py
@@ -5,20 +5,19 @@
# All rights reserved.
#
# License: GPL (version 3 or any later version).
-# See LICENSE for details.
+# See LICENSE for details.
# --- END COPYRIGHT BLOCK ---
import sys
import optparse
-'''
- This script generates a template test script that handles the
- non-interesting parts of a test script:
- topology,
- test (to be completed by the user),
- final,
- and run-isolated functions
-'''
+"""This script generates a template test script that handles the
+non-interesting parts of a test script:
+- topology,
+- test (to be completed by the user),
+- final,
+- and run-isolated function
+"""
def displayUsage():
@@ -33,6 +32,34 @@ def displayUsage():
'There is a maximum of 10 masters, 10 hubs, and 10 consumers.')
exit(1)
+
+def writeFinalizer():
+ """Write the finalizer function - delete each instance"""
+
+ TEST.write(' # Delete each instance in the end\n')
+ TEST.write(' def fin():\n')
+ if repl_deployment:
+ for idx in range(masters):
+ idx += 1
+ TEST.write(' master' + str(idx) + '.delete()\n')
+ for idx in range(hubs):
+ idx += 1
+ TEST.write(' hub' + str(idx) + '.delete()\n')
+ for idx in range(consumers):
+ idx += 1
+ TEST.write(' consumer' + str(idx) + '.delete()\n')
+ else:
+ for idx in range(instances):
+ idx += 1
+ if idx == 1:
+ idx = ''
+ else:
+ idx = str(idx)
+ TEST.write(' standalone' + idx + '.delete()\n')
+ TEST.write(' request.addfinalizer(fin)')
+ TEST.write('\n\n')
+
+
desc = 'Script to generate an initial lib389 test script. ' + \
'This generates the topology, test, final, and run-isolated functions.'
@@ -435,6 +462,8 @@ if len(sys.argv) > 0:
TEST.write(' assert False\n')
TEST.write('\n')
+ writeFinalizer()
+
#
# Write the finals steps for replication
#
@@ -483,9 +512,12 @@ if len(sys.argv) > 0:
TEST.write(' standalone' + idx + '.create()\n')
TEST.write(' standalone' + idx + '.open()\n\n')
+ writeFinalizer()
+
TEST.write(' # Clear out the tmp dir\n')
TEST.write(' standalone.clearTmpDir(__file__)\n')
TEST.write('\n')
+
TEST.write(' return TopologyStandalone(standalone')
for idx in range(instances):
idx += 1
@@ -501,82 +533,35 @@ if len(sys.argv) > 0:
#
if ticket:
TEST.write('def test_ticket' + ticket + '(topology):\n')
- TEST.write(" '''\n")
if repl_deployment:
- TEST.write(' Write your replication testcase here.\n\n')
+ TEST.write(' """Write your replication testcase here.\n\n')
TEST.write(' To access each DirSrv instance use: topology.master1, topology.master2,\n' +
- ' ..., topology.hub1, ..., topology.consumer1, ...\n')
+ ' ..., topology.hub1, ..., topology.consumer1, ...\n\n')
+ TEST.write(' Also, if you need any testcase initialization,\n')
+ TEST.write(' please, write additional fixture for that(include finalizer).\n')
else:
- TEST.write(' Write your testcase here...\n')
- TEST.write(" '''\n\n")
+ TEST.write(' """Write your testcase here...\n\n')
+ TEST.write(' Also, if you need any testcase initialization,\n')
+ TEST.write(' please, write additional fixture for that(include finalizer).\n')
+ TEST.write(' """\n\n')
TEST.write(" log.info('Test complete')\n")
- TEST.write("\n\n")
+ TEST.write('\n\n')
else:
- # For suite we start with an init function
- TEST.write('def test_' + suite + '_init(topology):\n')
- TEST.write(" '''\n")
- TEST.write(' Write any test suite initialization here(if needed)\n')
- TEST.write(" '''\n\n return\n\n\n")
-
# Write the first initial empty test function
TEST.write('def test_' + suite + '_#####(topology):\n')
- TEST.write(" '''\n")
- TEST.write(' Write a single test here...\n')
- TEST.write(" '''\n\n return\n\n\n")
-
- #
- # Write the final function here - delete each instance
- #
- if ticket:
- TEST.write('def test_ticket' + ticket + '_final(topology):\n')
- else:
- # suite
- TEST.write('def test_' + suite + '_final(topology):\n')
- if repl_deployment:
- for idx in range(masters):
- idx += 1
- TEST.write(' topology.master' + str(idx) + '.delete()\n')
- for idx in range(hubs):
- idx += 1
- TEST.write(' topology.hub' + str(idx) + '.delete()\n')
- for idx in range(consumers):
- idx += 1
- TEST.write(' topology.consumer' + str(idx) + '.delete()\n')
- else:
- for idx in range(instances):
- idx += 1
- if idx == 1:
- idx = ''
- else:
- idx = str(idx)
- TEST.write(' topology.standalone' + idx + '.delete()\n')
-
- if ticket:
- TEST.write(" log.info('Testcase PASSED')\n")
- else:
- # suite
- TEST.write(" log.info('" + suite + " test suite PASSED')\n")
- TEST.write('\n\n')
+ TEST.write(' """Write a single test here...\n\n')
+ TEST.write(' Also, if you need any test suite initialization,\n')
+ TEST.write(' please, write additional fixture for that(include finalizer).\n')
+ TEST.write(' """\n\n return\n\n\n')
#
# Write the main function
#
- TEST.write('def run_isolated():\n')
- TEST.write(' global installation1_prefix\n')
- TEST.write(' installation1_prefix = None\n\n')
- TEST.write(' topo = topology(True)\n')
- if ticket:
- TEST.write(' test_ticket' + ticket + '(topo)\n')
- TEST.write(' test_ticket' + ticket + '_final(topo)\n')
- else:
- # suite
- TEST.write(' test_' + suite + '_init(topo)\n')
- TEST.write(' test_' + suite + '_#####(topo)\n')
- TEST.write(' test_' + suite + '_final(topo)\n')
- TEST.write('\n\n')
-
TEST.write("if __name__ == '__main__':\n")
- TEST.write(' run_isolated()\n\n')
+ TEST.write(' # Run isolated\n')
+ TEST.write(' # -s for DEBUG mode\n')
+ TEST.write(' CURRENT_FILE = os.path.realpath(__file__)\n')
+ TEST.write(' pytest.main("-s %s" % CURRENT_FILE)')
#
# Done, close things up
8 years, 8 months