Branch '389-ds-base-1.3.4' - ldap/admin
by Noriko Hosoi
ldap/admin/src/scripts/DSCreate.pm.in | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
New commits:
commit 48308f34269ed37712f21b59665f5df5e42b9fd9
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Tue Dec 8 12:30:15 2015 -0800
Ticket #48305 - perl module conditional test is not conditional when checking SELinux policies
Description: commit 9fefc13c02c9ae037fad053152193794706aaa31 introduced
a regression:
Bug 1287547 - 389-ds-base-1.3.4.5-1.fc23.x86_64 leaves empty /NUL around
after ipa-server-install
To check the existence of a character special file "/dev/null", "-c" is
supposed to be used instead of "-f".
Reviewed by mreynolds(a)redhat.com (Thank you, Mark!!)
https://fedorahosted.org/389/ticket/48305
(cherry picked from commit c4233ec14a82d1d4c0c71915be40913259d417fa)
diff --git a/ldap/admin/src/scripts/DSCreate.pm.in b/ldap/admin/src/scripts/DSCreate.pm.in
index 50498fe..7082fd9 100644
--- a/ldap/admin/src/scripts/DSCreate.pm.in
+++ b/ldap/admin/src/scripts/DSCreate.pm.in
@@ -261,7 +261,7 @@ sub createInstanceScripts {
my $skip = shift;
my $perlexec = "@perlexec@" || "/usr/bin/env perl";
my $myperl = "!$perlexec";
- my $mydevnull = (-f "/dev/null" ? " /dev/null " : " NUL ");
+ my $mydevnull = (-c "/dev/null" ? " /dev/null " : " NUL ");
# determine initconfig_dir
my $initconfig_dir = $inf->{slapd}->{initconfig_dir} || get_initconfigdir($inf->{General}->{prefix});
@@ -957,7 +957,7 @@ sub setDefaults {
sub updateSelinuxPolicy {
my $inf = shift;
- my $mydevnull = (-f "/dev/null" ? " /dev/null " : " NUL ");
+ my $mydevnull = (-c "/dev/null" ? " /dev/null " : " NUL ");
# if selinux is not available, do nothing
if ((getLogin() eq 'root') and "@with_selinux@" and
@@ -1407,7 +1407,7 @@ sub removeDSInstance {
}
# remove the selinux label from the ports if needed
- my $mydevnull = (-f "/dev/null" ? " /dev/null " : " NUL ");
+ my $mydevnull = (-c "/dev/null" ? " /dev/null " : " NUL ");
if ((getLogin() eq 'root') and "@with_selinux@" and
-f "@sbindir@/sestatus" and !system ("@sbindir@/sestatus | egrep -i \"selinux status:\\s*enabled\" > $mydevnull 2>&1")) {
foreach my $port (@{$entry->{"nsslapd-port"}})
8 years, 4 months
ldap/admin
by Noriko Hosoi
ldap/admin/src/scripts/DSCreate.pm.in | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
New commits:
commit c4233ec14a82d1d4c0c71915be40913259d417fa
Author: Noriko Hosoi <nhosoi(a)redhat.com>
Date: Tue Dec 8 12:30:15 2015 -0800
Ticket #48305 - perl module conditional test is not conditional when checking SELinux policies
Description: commit 9fefc13c02c9ae037fad053152193794706aaa31 introduced
a regression:
Bug 1287547 - 389-ds-base-1.3.4.5-1.fc23.x86_64 leaves empty /NUL around
after ipa-server-install
To check the existence of a character special file "/dev/null", "-c" is
supposed to be used instead of "-f".
Reviewed by mreynolds(a)redhat.com (Thank you, Mark!!)
https://fedorahosted.org/389/ticket/48305
diff --git a/ldap/admin/src/scripts/DSCreate.pm.in b/ldap/admin/src/scripts/DSCreate.pm.in
index d449b02..e62ae2c 100644
--- a/ldap/admin/src/scripts/DSCreate.pm.in
+++ b/ldap/admin/src/scripts/DSCreate.pm.in
@@ -283,7 +283,7 @@ sub createInstanceScripts {
my $skip = shift;
my $perlexec = "@perlexec@" || "/usr/bin/env perl";
my $myperl = "!$perlexec";
- my $mydevnull = (-f "/dev/null" ? " /dev/null " : " NUL ");
+ my $mydevnull = (-c "/dev/null" ? " /dev/null " : " NUL ");
# If we have InstScriptsEnabled, we likely have setup.inf or the argument.
# However, during an upgrade, we need to know if we should upgrade the template files or not.
@@ -997,7 +997,7 @@ sub setDefaults {
sub updateSelinuxPolicy {
my $inf = shift;
- my $mydevnull = (-f "/dev/null" ? " /dev/null " : " NUL ");
+ my $mydevnull = (-c "/dev/null" ? " /dev/null " : " NUL ");
# if selinux is not available, do nothing
if ((getLogin() eq 'root') and "@with_selinux@" and
@@ -1451,7 +1451,7 @@ sub removeDSInstance {
}
# remove the selinux label from the ports if needed
- my $mydevnull = (-f "/dev/null" ? " /dev/null " : " NUL ");
+ my $mydevnull = (-c "/dev/null" ? " /dev/null " : " NUL ");
if ((getLogin() eq 'root') and "@with_selinux@" and
-f "@sbindir@/sestatus" and !system ("@sbindir@/sestatus | egrep -i \"selinux status:\\s*enabled\" > $mydevnull 2>&1")) {
foreach my $port (@{$entry->{"nsslapd-port"}})
8 years, 4 months
ldap/servers
by William Brown
ldap/servers/slapd/back-ldbm/dblayer.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
New commits:
commit 00513dbb4b97b6b91510ec3b57ae0e8c6b952195
Author: William Brown <firstyear(a)redhat.com>
Date: Tue Dec 8 13:52:29 2015 +1000
Ticket 48372 - ASAN invalid write in dblayer.c
Bug Description: During server start up we attempt to write 513 bytes to a
buffer that is only 512 bytes long.
Fix Description: Increase the size of the buffer that sscanf writes into.
https://fedorahosted.org/389/ticket/48372
Author: wibrown
Review by: rmeggins (Thanks!)
diff --git a/ldap/servers/slapd/back-ldbm/dblayer.c b/ldap/servers/slapd/back-ldbm/dblayer.c
index 33506f4..9168c8c 100644
--- a/ldap/servers/slapd/back-ldbm/dblayer.c
+++ b/ldap/servers/slapd/back-ldbm/dblayer.c
@@ -5191,8 +5191,8 @@ static int read_metadata(struct ldbminfo *li)
PRFileInfo64 prfinfo;
int return_value = 0;
PRInt32 byte_count = 0;
- char attribute[512];
- char value[128], delimiter;
+ char attribute[513];
+ char value[129], delimiter;
int number = 0;
dblayer_private *priv = (dblayer_private *)li->li_dblayer_private;
8 years, 4 months
dirsrvtests/cmd dirsrvtests/data dirsrvtests/__init__.py dirsrvtests/suites dirsrvtests/tickets dirsrvtests/tmp .gitignore
by William Brown
.gitignore | 2 ++
1 file changed, 2 insertions(+)
New commits:
commit 2eeaf899be53abcfc51a84132e77f4268d5ee99d
Author: William Brown <firstyear(a)redhat.com>
Date: Thu Dec 3 08:17:00 2015 +1000
Ticket 48333 - Simplify accessiblitiy of tests for ds
Bug Description: Previously, it was hard to run the full test suite without
scripting or other external means. We want to be able to run
py.test dirsrvtests
To test the full scope of the application. We can also use this to trigger
specific tests:
py.test dirsrvtests -k test_ticket48109_1
Fix Description: To achieve this, we create __init__.py in all the needed
folders, to make the python path accessible by py.test to discover all the
tests. Additionally, we add __pycache__ and *.pyc to gitignore
https://fedorahosted.org/389/ticket/48333
Author: wibrown
Review by: mreynolds (Thanks!)
diff --git a/.gitignore b/.gitignore
index 9ab10e4..f6583c2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,6 +10,8 @@ autom4te.cache
*.la
*.lo
*.o
+*.pyc
+__pycache__
.libs
.deps
rpmbuild
diff --git a/dirsrvtests/__init__.py b/dirsrvtests/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/cmd/__init__.py b/dirsrvtests/cmd/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/cmd/dsadm/__init__.py b/dirsrvtests/cmd/dsadm/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/data/__init__.py b/dirsrvtests/data/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/data/basic/__init__.py b/dirsrvtests/data/basic/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/data/ticket47953/__init__.py b/dirsrvtests/data/ticket47953/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/data/ticket47988/__init__.py b/dirsrvtests/data/ticket47988/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/data/ticket48212/__init__.py b/dirsrvtests/data/ticket48212/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/__init__.py b/dirsrvtests/suites/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/acct_usability_plugin/__init__.py b/dirsrvtests/suites/acct_usability_plugin/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/acctpolicy_plugin/__init__.py b/dirsrvtests/suites/acctpolicy_plugin/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/acl/__init__.py b/dirsrvtests/suites/acl/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/attr_encryption/__init__.py b/dirsrvtests/suites/attr_encryption/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/attr_uniqueness_plugin/__init__.py b/dirsrvtests/suites/attr_uniqueness_plugin/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/automember_plugin/__init__.py b/dirsrvtests/suites/automember_plugin/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/basic/__init__.py b/dirsrvtests/suites/basic/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/betxns/__init__.py b/dirsrvtests/suites/betxns/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/chaining_plugin/__init__.py b/dirsrvtests/suites/chaining_plugin/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/clu/__init__.py b/dirsrvtests/suites/clu/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/collation_plugin/__init__.py b/dirsrvtests/suites/collation_plugin/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/config/__init__.py b/dirsrvtests/suites/config/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/cos_plugin/__init__.py b/dirsrvtests/suites/cos_plugin/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/deref_plugin/__init__.py b/dirsrvtests/suites/deref_plugin/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/disk_monitoring/__init__.py b/dirsrvtests/suites/disk_monitoring/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/distrib_plugin/__init__.py b/dirsrvtests/suites/distrib_plugin/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/dna_plugin/__init__.py b/dirsrvtests/suites/dna_plugin/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/ds_logs/__init__.py b/dirsrvtests/suites/ds_logs/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/dynamic-plugins/__init__.py b/dirsrvtests/suites/dynamic-plugins/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/filter/__init__.py b/dirsrvtests/suites/filter/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/get_effective_rights/__init__.py b/dirsrvtests/suites/get_effective_rights/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/ldapi/__init__.py b/dirsrvtests/suites/ldapi/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/linkedattrs_plugin/__init__.py b/dirsrvtests/suites/linkedattrs_plugin/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/mapping_tree/__init__.py b/dirsrvtests/suites/mapping_tree/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/memberof_plugin/__init__.py b/dirsrvtests/suites/memberof_plugin/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/memory_leaks/__init__.py b/dirsrvtests/suites/memory_leaks/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/mep_plugin/__init__.py b/dirsrvtests/suites/mep_plugin/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/monitor/__init__.py b/dirsrvtests/suites/monitor/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/paged_results/__init__.py b/dirsrvtests/suites/paged_results/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/pam_passthru_plugin/__init__.py b/dirsrvtests/suites/pam_passthru_plugin/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/passthru_plugin/__init__.py b/dirsrvtests/suites/passthru_plugin/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/password/__init__.py b/dirsrvtests/suites/password/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/posix_winsync_plugin/__init__.py b/dirsrvtests/suites/posix_winsync_plugin/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/psearch/__init__.py b/dirsrvtests/suites/psearch/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/referint_plugin/__init__.py b/dirsrvtests/suites/referint_plugin/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/replication/__init__.py b/dirsrvtests/suites/replication/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/replsync_plugin/__init__.py b/dirsrvtests/suites/replsync_plugin/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/resource_limits/__init__.py b/dirsrvtests/suites/resource_limits/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/retrocl_plugin/__init__.py b/dirsrvtests/suites/retrocl_plugin/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/reverpwd_plugin/__init__.py b/dirsrvtests/suites/reverpwd_plugin/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/roles_plugin/__init__.py b/dirsrvtests/suites/roles_plugin/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/rootdn_plugin/__init__.py b/dirsrvtests/suites/rootdn_plugin/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/sasl/__init__.py b/dirsrvtests/suites/sasl/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/schema/__init__.py b/dirsrvtests/suites/schema/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/schema_reload_plugin/__init__.py b/dirsrvtests/suites/schema_reload_plugin/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/snmp/__init__.py b/dirsrvtests/suites/snmp/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/ssl/__init__.py b/dirsrvtests/suites/ssl/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/syntax_plugin/__init__.py b/dirsrvtests/suites/syntax_plugin/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/usn_plugin/__init__.py b/dirsrvtests/suites/usn_plugin/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/views_plugin/__init__.py b/dirsrvtests/suites/views_plugin/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/vlv/__init__.py b/dirsrvtests/suites/vlv/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/suites/whoami_plugin/__init__.py b/dirsrvtests/suites/whoami_plugin/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/tickets/__init__.py b/dirsrvtests/tickets/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/dirsrvtests/tmp/__init__.py b/dirsrvtests/tmp/__init__.py
new file mode 100644
index 0000000..e69de29
8 years, 4 months
ldap/servers
by William Brown
ldap/servers/slapd/plugin.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 324cf9f38f57108eda0965dfe9415f39ecf63a26
Author: William Brown <firstyear(a)redhat.com>
Date: Fri Dec 4 14:47:46 2015 +1000
Ticket 48280 - enable logging of internal ops in the audit log
Bug Description: many plugins add and modify entries, but these changes are not
visible in the audit log. It can be very useful to have these changes available.
Fix Description: This feature actually already existed:
nsslapd-logAccess
nsslapd-logAudit
On a plugin, will turn on the respective logs.
This change brings the audit log in line with access to respect the value of
nsslapd-plugin-logging
Such that when plugin-logging is enabled globally in cn=config, plugins will
log based on the values in:
nsslapd-accesslog-logging-enabled
nsslapd-auditlog-logging-enabled
nsslapd-auditfaillog-logging-enabled
https://fedorahosted.org/389/ticket/48280
Author: wibrown
Review by: ???
diff --git a/ldap/servers/slapd/plugin.c b/ldap/servers/slapd/plugin.c
index 0e99095..4ab644b 100644
--- a/ldap/servers/slapd/plugin.c
+++ b/ldap/servers/slapd/plugin.c
@@ -3808,7 +3808,7 @@ int plugin_build_operation_action_bitmap (int input_actions, const struct slapdp
if (plugin->plg_conf.plgc_log_access || config_get_plugin_logging())
result_actions |= OP_FLAG_ACTION_LOG_ACCESS;
- if (plugin->plg_conf.plgc_log_audit)
+ if (plugin->plg_conf.plgc_log_audit || config_get_plugin_logging())
result_actions |= OP_FLAG_ACTION_LOG_AUDIT;
/*
8 years, 4 months
Branch '389-ds-base-1.2.11' - dirsrvtests/tickets ldap/servers
by Mark Reynolds
dirsrvtests/tickets/ticket48370_test.py | 236 ++++++++++++++++++++++++++++++++
ldap/servers/slapd/back-ldbm/index.c | 29 +--
2 files changed, 247 insertions(+), 18 deletions(-)
New commits:
commit c7cf0001002da1bcabe0371d9511a014d8e2b16f
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Mon Dec 7 16:45:06 2015 -0500
Ticket 48370 - The 'eq' index does not get updated properly
when deleting and re-adding attributes in
the same modify operation
Bug Description: If you delete several values of the same attribute, and
add at least one of them back in the same operation, the
equality index does not get updated.
Fix Description: Modify the logic of the index code to update the index if
at least one of the values in the entry changes.
Also did pep8 cleanup of create_test.py
https://fedorahosted.org/389/ticket/48370
Reviewed by: wibrown(Thanks!)
(cherry picked from commit 63b80b5c31ebda51445c662903a28e2a79ebe60a)
(cherry picked from commit 5cd8f73205007ecbd44ae2fbfb5bcdf7e39c3d6e)
(cherry picked from commit 8e49d6db6973078396b869ab4ed59c565d7010a9)
diff --git a/dirsrvtests/tickets/ticket48370_test.py b/dirsrvtests/tickets/ticket48370_test.py
new file mode 100644
index 0000000..f5b1f47
--- /dev/null
+++ b/dirsrvtests/tickets/ticket48370_test.py
@@ -0,0 +1,236 @@
+import os
+import ldap
+import logging
+import pytest
+from lib389 import DirSrv, Entry
+from lib389._constants import *
+from lib389.properties import *
+from lib389.tasks import *
+from lib389.utils import *
+
+logging.getLogger(__name__).setLevel(logging.DEBUG)
+log = logging.getLogger(__name__)
+
+installation1_prefix = None
+
+
+class TopologyStandalone(object):
+ def __init__(self, standalone):
+ standalone.open()
+ self.standalone = standalone
+
+
+(a)pytest.fixture(scope="module")
+def topology(request):
+ global installation1_prefix
+ if installation1_prefix:
+ args_instance[SER_DEPLOYED_DIR] = installation1_prefix
+
+ # Creating standalone instance ...
+ standalone = DirSrv(verbose=False)
+ args_instance[SER_HOST] = HOST_STANDALONE
+ args_instance[SER_PORT] = PORT_STANDALONE
+ args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_standalone = args_instance.copy()
+ standalone.allocate(args_standalone)
+ instance_standalone = standalone.exists()
+ if instance_standalone:
+ standalone.delete()
+ standalone.create()
+ standalone.open()
+
+ # Delete each instance in the end
+ def fin():
+ standalone.delete()
+ request.addfinalizer(fin)
+
+ # Clear out the tmp dir
+ standalone.clearTmpDir(__file__)
+
+ return TopologyStandalone(standalone)
+
+
+def test_ticket48370(topology):
+ """
+ Deleting attirbute values and readding a value does not properly update
+ the pres index. The values are not actually deleted from the index
+ """
+
+ DN = 'uid=user0099,' + DEFAULT_SUFFIX
+
+ #
+ # Add an entry
+ #
+ topology.standalone.add_s(Entry((DN, {
+ 'objectclass': ['top', 'person',
+ 'organizationalPerson',
+ 'inetorgperson',
+ 'posixAccount'],
+ 'givenname': 'test',
+ 'sn': 'user',
+ 'loginshell': '/bin/bash',
+ 'uidNumber': '10099',
+ 'gidNumber': '10099',
+ 'gecos': 'Test User',
+ 'mail': ['user0099(a)dev.null',
+ 'alias(a)dev.null',
+ 'user0099(a)redhat.com'],
+ 'cn': 'Test User',
+ 'homeDirectory': '/home/user0099',
+ 'uid': 'admin2',
+ 'userpassword': 'password'})))
+
+ #
+ # Perform modify (delete & add mail attributes)
+ #
+ try:
+ topology.standalone.modify_s(DN, [(ldap.MOD_DELETE,
+ 'mail',
+ 'user0099(a)dev.null'),
+ (ldap.MOD_DELETE,
+ 'mail',
+ 'alias(a)dev.null'),
+ (ldap.MOD_ADD,
+ 'mail', 'user0099(a)dev.null')])
+ except ldap.LDAPError as e:
+ log.fatal('Failedto modify user: ' + str(e))
+ assert False
+
+ #
+ # Search using deleted attribute value- no entries should be returned
+ #
+ try:
+ entry = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ 'mail=alias(a)dev.null')
+ if entry:
+ log.fatal('Entry incorrectly returned')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to search for user: ' + str(e))
+ assert False
+
+ #
+ # Search using existing attribute value - the entry should be returned
+ #
+ try:
+ entry = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ 'mail=user0099(a)dev.null')
+ if entry is None:
+ log.fatal('Entry not found, but it should have been')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to search for user: ' + str(e))
+ assert False
+
+ #
+ # Delete the last values
+ #
+ try:
+ topology.standalone.modify_s(DN, [(ldap.MOD_DELETE,
+ 'mail',
+ 'user0099(a)dev.null'),
+ (ldap.MOD_DELETE,
+ 'mail',
+ 'user0099(a)redhat.com')
+ ])
+ except ldap.LDAPError as e:
+ log.fatal('Failed to modify user: ' + str(e))
+ assert False
+
+ #
+ # Search using deleted attribute value - no entries should be returned
+ #
+ try:
+ entry = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ 'mail=user0099(a)redhat.com')
+ if entry:
+ log.fatal('Entry incorrectly returned')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to search for user: ' + str(e))
+ assert False
+
+ #
+ # Make sure presence index is correctly updated - no entries should be
+ # returned
+ #
+ try:
+ entry = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ 'mail=*')
+ if entry:
+ log.fatal('Entry incorrectly returned')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to search for user: ' + str(e))
+ assert False
+
+ #
+ # Now add the attributes back, and lets run a different set of tests with
+ # a different number of attributes
+ #
+ try:
+ topology.standalone.modify_s(DN, [(ldap.MOD_ADD,
+ 'mail',
+ ['user0099(a)dev.null',
+ 'alias(a)dev.null'])])
+ except ldap.LDAPError as e:
+ log.fatal('Failedto modify user: ' + str(e))
+ assert False
+
+ #
+ # Remove and readd some attibutes
+ #
+ try:
+ topology.standalone.modify_s(DN, [(ldap.MOD_DELETE,
+ 'mail',
+ 'alias(a)dev.null'),
+ (ldap.MOD_DELETE,
+ 'mail',
+ 'user0099(a)dev.null'),
+ (ldap.MOD_ADD,
+ 'mail', 'user0099(a)dev.null')])
+ except ldap.LDAPError as e:
+ log.fatal('Failedto modify user: ' + str(e))
+ assert False
+
+ #
+ # Search using deleted attribute value - no entries should be returned
+ #
+ try:
+ entry = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ 'mail=alias(a)dev.null')
+ if entry:
+ log.fatal('Entry incorrectly returned')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to search for user: ' + str(e))
+ assert False
+
+ #
+ # Search using existing attribute value - the entry should be returned
+ #
+ try:
+ entry = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ 'mail=user0099(a)dev.null')
+ if entry is None:
+ log.fatal('Entry not found, but it should have been')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to search for user: ' + str(e))
+ assert False
+
+ log.info('Test PASSED')
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s %s" % CURRENT_FILE)
diff --git a/ldap/servers/slapd/back-ldbm/index.c b/ldap/servers/slapd/back-ldbm/index.c
index 90d1d23..0b41ce4 100644
--- a/ldap/servers/slapd/back-ldbm/index.c
+++ b/ldap/servers/slapd/back-ldbm/index.c
@@ -740,31 +740,24 @@ index_add_mods(
flags = BE_INDEX_DEL|BE_INDEX_PRESENCE|BE_INDEX_EQUALITY;
} else {
flags = BE_INDEX_DEL;
-
- /* If the same value doesn't exist in a subtype, set
- * BE_INDEX_EQUALITY flag so the equality index is
- * removed.
- */
curr_attr = NULL;
slapi_entry_attr_find(olde->ep_entry,
- mods[i]->mod_type, &curr_attr);
+ mods[i]->mod_type,
+ &curr_attr);
if (curr_attr) {
- int found = 0;
for (j = 0; mods_valueArray[j] != NULL; j++ ) {
- if ( slapi_valueset_find(curr_attr, all_vals, mods_valueArray[j])) {
- /* The same value found in evals.
- * We don't touch the equality index. */
- found = 1;
+ if ( !slapi_valueset_find(curr_attr, all_vals, mods_valueArray[j]) ) {
+ /*
+ * If the mod del value is not found in all_vals
+ * we need to update the equality index as the
+ * final value(s) have changed
+ */
+ if (!(flags & BE_INDEX_EQUALITY)) {
+ flags |= BE_INDEX_EQUALITY;
+ }
break;
}
}
- /*
- * to-be-deleted curr_attr does not exist in the
- * new value set evals. So, we can remove it.
- */
- if (!found && !(flags & BE_INDEX_EQUALITY)) {
- flags |= BE_INDEX_EQUALITY;
- }
}
}
8 years, 4 months
Branch '389-ds-base-1.3.1' - dirsrvtests/tickets ldap/servers
by Mark Reynolds
dirsrvtests/tickets/ticket48370_test.py | 236 ++++++++++++++++++++++++++++++++
ldap/servers/slapd/back-ldbm/index.c | 29 +--
2 files changed, 247 insertions(+), 18 deletions(-)
New commits:
commit c24ecabcfcb9016c4049fa8b0524108c704b640d
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Mon Dec 7 16:45:06 2015 -0500
Ticket 48370 - The 'eq' index does not get updated properly
when deleting and re-adding attributes in
the same modify operation
Bug Description: If you delete several values of the same attribute, and
add at least one of them back in the same operation, the
equality index does not get updated.
Fix Description: Modify the logic of the index code to update the index if
at least one of the values in the entry changes.
Also did pep8 cleanup of create_test.py
https://fedorahosted.org/389/ticket/48370
Reviewed by: wibrown(Thanks!)
(cherry picked from commit 63b80b5c31ebda51445c662903a28e2a79ebe60a)
(cherry picked from commit 5cd8f73205007ecbd44ae2fbfb5bcdf7e39c3d6e)
(cherry picked from commit 8e49d6db6973078396b869ab4ed59c565d7010a9)
diff --git a/dirsrvtests/tickets/ticket48370_test.py b/dirsrvtests/tickets/ticket48370_test.py
new file mode 100644
index 0000000..f5b1f47
--- /dev/null
+++ b/dirsrvtests/tickets/ticket48370_test.py
@@ -0,0 +1,236 @@
+import os
+import ldap
+import logging
+import pytest
+from lib389 import DirSrv, Entry
+from lib389._constants import *
+from lib389.properties import *
+from lib389.tasks import *
+from lib389.utils import *
+
+logging.getLogger(__name__).setLevel(logging.DEBUG)
+log = logging.getLogger(__name__)
+
+installation1_prefix = None
+
+
+class TopologyStandalone(object):
+ def __init__(self, standalone):
+ standalone.open()
+ self.standalone = standalone
+
+
+(a)pytest.fixture(scope="module")
+def topology(request):
+ global installation1_prefix
+ if installation1_prefix:
+ args_instance[SER_DEPLOYED_DIR] = installation1_prefix
+
+ # Creating standalone instance ...
+ standalone = DirSrv(verbose=False)
+ args_instance[SER_HOST] = HOST_STANDALONE
+ args_instance[SER_PORT] = PORT_STANDALONE
+ args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_standalone = args_instance.copy()
+ standalone.allocate(args_standalone)
+ instance_standalone = standalone.exists()
+ if instance_standalone:
+ standalone.delete()
+ standalone.create()
+ standalone.open()
+
+ # Delete each instance in the end
+ def fin():
+ standalone.delete()
+ request.addfinalizer(fin)
+
+ # Clear out the tmp dir
+ standalone.clearTmpDir(__file__)
+
+ return TopologyStandalone(standalone)
+
+
+def test_ticket48370(topology):
+ """
+ Deleting attirbute values and readding a value does not properly update
+ the pres index. The values are not actually deleted from the index
+ """
+
+ DN = 'uid=user0099,' + DEFAULT_SUFFIX
+
+ #
+ # Add an entry
+ #
+ topology.standalone.add_s(Entry((DN, {
+ 'objectclass': ['top', 'person',
+ 'organizationalPerson',
+ 'inetorgperson',
+ 'posixAccount'],
+ 'givenname': 'test',
+ 'sn': 'user',
+ 'loginshell': '/bin/bash',
+ 'uidNumber': '10099',
+ 'gidNumber': '10099',
+ 'gecos': 'Test User',
+ 'mail': ['user0099(a)dev.null',
+ 'alias(a)dev.null',
+ 'user0099(a)redhat.com'],
+ 'cn': 'Test User',
+ 'homeDirectory': '/home/user0099',
+ 'uid': 'admin2',
+ 'userpassword': 'password'})))
+
+ #
+ # Perform modify (delete & add mail attributes)
+ #
+ try:
+ topology.standalone.modify_s(DN, [(ldap.MOD_DELETE,
+ 'mail',
+ 'user0099(a)dev.null'),
+ (ldap.MOD_DELETE,
+ 'mail',
+ 'alias(a)dev.null'),
+ (ldap.MOD_ADD,
+ 'mail', 'user0099(a)dev.null')])
+ except ldap.LDAPError as e:
+ log.fatal('Failedto modify user: ' + str(e))
+ assert False
+
+ #
+ # Search using deleted attribute value- no entries should be returned
+ #
+ try:
+ entry = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ 'mail=alias(a)dev.null')
+ if entry:
+ log.fatal('Entry incorrectly returned')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to search for user: ' + str(e))
+ assert False
+
+ #
+ # Search using existing attribute value - the entry should be returned
+ #
+ try:
+ entry = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ 'mail=user0099(a)dev.null')
+ if entry is None:
+ log.fatal('Entry not found, but it should have been')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to search for user: ' + str(e))
+ assert False
+
+ #
+ # Delete the last values
+ #
+ try:
+ topology.standalone.modify_s(DN, [(ldap.MOD_DELETE,
+ 'mail',
+ 'user0099(a)dev.null'),
+ (ldap.MOD_DELETE,
+ 'mail',
+ 'user0099(a)redhat.com')
+ ])
+ except ldap.LDAPError as e:
+ log.fatal('Failed to modify user: ' + str(e))
+ assert False
+
+ #
+ # Search using deleted attribute value - no entries should be returned
+ #
+ try:
+ entry = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ 'mail=user0099(a)redhat.com')
+ if entry:
+ log.fatal('Entry incorrectly returned')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to search for user: ' + str(e))
+ assert False
+
+ #
+ # Make sure presence index is correctly updated - no entries should be
+ # returned
+ #
+ try:
+ entry = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ 'mail=*')
+ if entry:
+ log.fatal('Entry incorrectly returned')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to search for user: ' + str(e))
+ assert False
+
+ #
+ # Now add the attributes back, and lets run a different set of tests with
+ # a different number of attributes
+ #
+ try:
+ topology.standalone.modify_s(DN, [(ldap.MOD_ADD,
+ 'mail',
+ ['user0099(a)dev.null',
+ 'alias(a)dev.null'])])
+ except ldap.LDAPError as e:
+ log.fatal('Failedto modify user: ' + str(e))
+ assert False
+
+ #
+ # Remove and readd some attibutes
+ #
+ try:
+ topology.standalone.modify_s(DN, [(ldap.MOD_DELETE,
+ 'mail',
+ 'alias(a)dev.null'),
+ (ldap.MOD_DELETE,
+ 'mail',
+ 'user0099(a)dev.null'),
+ (ldap.MOD_ADD,
+ 'mail', 'user0099(a)dev.null')])
+ except ldap.LDAPError as e:
+ log.fatal('Failedto modify user: ' + str(e))
+ assert False
+
+ #
+ # Search using deleted attribute value - no entries should be returned
+ #
+ try:
+ entry = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ 'mail=alias(a)dev.null')
+ if entry:
+ log.fatal('Entry incorrectly returned')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to search for user: ' + str(e))
+ assert False
+
+ #
+ # Search using existing attribute value - the entry should be returned
+ #
+ try:
+ entry = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ 'mail=user0099(a)dev.null')
+ if entry is None:
+ log.fatal('Entry not found, but it should have been')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to search for user: ' + str(e))
+ assert False
+
+ log.info('Test PASSED')
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s %s" % CURRENT_FILE)
diff --git a/ldap/servers/slapd/back-ldbm/index.c b/ldap/servers/slapd/back-ldbm/index.c
index eac265b..b820805 100644
--- a/ldap/servers/slapd/back-ldbm/index.c
+++ b/ldap/servers/slapd/back-ldbm/index.c
@@ -741,31 +741,24 @@ index_add_mods(
flags = BE_INDEX_DEL|BE_INDEX_PRESENCE|BE_INDEX_EQUALITY;
} else {
flags = BE_INDEX_DEL;
-
- /* If the same value doesn't exist in a subtype, set
- * BE_INDEX_EQUALITY flag so the equality index is
- * removed.
- */
curr_attr = NULL;
slapi_entry_attr_find(olde->ep_entry,
- mods[i]->mod_type, &curr_attr);
+ mods[i]->mod_type,
+ &curr_attr);
if (curr_attr) {
- int found = 0;
for (j = 0; mods_valueArray[j] != NULL; j++ ) {
- if ( slapi_valueset_find(curr_attr, all_vals, mods_valueArray[j])) {
- /* The same value found in evals.
- * We don't touch the equality index. */
- found = 1;
+ if ( !slapi_valueset_find(curr_attr, all_vals, mods_valueArray[j]) ) {
+ /*
+ * If the mod del value is not found in all_vals
+ * we need to update the equality index as the
+ * final value(s) have changed
+ */
+ if (!(flags & BE_INDEX_EQUALITY)) {
+ flags |= BE_INDEX_EQUALITY;
+ }
break;
}
}
- /*
- * to-be-deleted curr_attr does not exist in the
- * new value set evals. So, we can remove it.
- */
- if (!found && !(flags & BE_INDEX_EQUALITY)) {
- flags |= BE_INDEX_EQUALITY;
- }
}
}
8 years, 4 months
Branch '389-ds-base-1.3.2' - dirsrvtests/tickets ldap/servers
by Mark Reynolds
dirsrvtests/tickets/ticket48370_test.py | 236 ++++++++++++++++++++++++++++++++
ldap/servers/slapd/back-ldbm/index.c | 29 +--
2 files changed, 247 insertions(+), 18 deletions(-)
New commits:
commit 8e49d6db6973078396b869ab4ed59c565d7010a9
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Mon Dec 7 16:45:06 2015 -0500
Ticket 48370 - The 'eq' index does not get updated properly
when deleting and re-adding attributes in
the same modify operation
Bug Description: If you delete several values of the same attribute, and
add at least one of them back in the same operation, the
equality index does not get updated.
Fix Description: Modify the logic of the index code to update the index if
at least one of the values in the entry changes.
Also did pep8 cleanup of create_test.py
https://fedorahosted.org/389/ticket/48370
Reviewed by: wibrown(Thanks!)
(cherry picked from commit 63b80b5c31ebda51445c662903a28e2a79ebe60a)
(cherry picked from commit 5cd8f73205007ecbd44ae2fbfb5bcdf7e39c3d6e)
diff --git a/dirsrvtests/tickets/ticket48370_test.py b/dirsrvtests/tickets/ticket48370_test.py
new file mode 100644
index 0000000..f5b1f47
--- /dev/null
+++ b/dirsrvtests/tickets/ticket48370_test.py
@@ -0,0 +1,236 @@
+import os
+import ldap
+import logging
+import pytest
+from lib389 import DirSrv, Entry
+from lib389._constants import *
+from lib389.properties import *
+from lib389.tasks import *
+from lib389.utils import *
+
+logging.getLogger(__name__).setLevel(logging.DEBUG)
+log = logging.getLogger(__name__)
+
+installation1_prefix = None
+
+
+class TopologyStandalone(object):
+ def __init__(self, standalone):
+ standalone.open()
+ self.standalone = standalone
+
+
+(a)pytest.fixture(scope="module")
+def topology(request):
+ global installation1_prefix
+ if installation1_prefix:
+ args_instance[SER_DEPLOYED_DIR] = installation1_prefix
+
+ # Creating standalone instance ...
+ standalone = DirSrv(verbose=False)
+ args_instance[SER_HOST] = HOST_STANDALONE
+ args_instance[SER_PORT] = PORT_STANDALONE
+ args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_standalone = args_instance.copy()
+ standalone.allocate(args_standalone)
+ instance_standalone = standalone.exists()
+ if instance_standalone:
+ standalone.delete()
+ standalone.create()
+ standalone.open()
+
+ # Delete each instance in the end
+ def fin():
+ standalone.delete()
+ request.addfinalizer(fin)
+
+ # Clear out the tmp dir
+ standalone.clearTmpDir(__file__)
+
+ return TopologyStandalone(standalone)
+
+
+def test_ticket48370(topology):
+ """
+ Deleting attirbute values and readding a value does not properly update
+ the pres index. The values are not actually deleted from the index
+ """
+
+ DN = 'uid=user0099,' + DEFAULT_SUFFIX
+
+ #
+ # Add an entry
+ #
+ topology.standalone.add_s(Entry((DN, {
+ 'objectclass': ['top', 'person',
+ 'organizationalPerson',
+ 'inetorgperson',
+ 'posixAccount'],
+ 'givenname': 'test',
+ 'sn': 'user',
+ 'loginshell': '/bin/bash',
+ 'uidNumber': '10099',
+ 'gidNumber': '10099',
+ 'gecos': 'Test User',
+ 'mail': ['user0099(a)dev.null',
+ 'alias(a)dev.null',
+ 'user0099(a)redhat.com'],
+ 'cn': 'Test User',
+ 'homeDirectory': '/home/user0099',
+ 'uid': 'admin2',
+ 'userpassword': 'password'})))
+
+ #
+ # Perform modify (delete & add mail attributes)
+ #
+ try:
+ topology.standalone.modify_s(DN, [(ldap.MOD_DELETE,
+ 'mail',
+ 'user0099(a)dev.null'),
+ (ldap.MOD_DELETE,
+ 'mail',
+ 'alias(a)dev.null'),
+ (ldap.MOD_ADD,
+ 'mail', 'user0099(a)dev.null')])
+ except ldap.LDAPError as e:
+ log.fatal('Failedto modify user: ' + str(e))
+ assert False
+
+ #
+ # Search using deleted attribute value- no entries should be returned
+ #
+ try:
+ entry = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ 'mail=alias(a)dev.null')
+ if entry:
+ log.fatal('Entry incorrectly returned')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to search for user: ' + str(e))
+ assert False
+
+ #
+ # Search using existing attribute value - the entry should be returned
+ #
+ try:
+ entry = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ 'mail=user0099(a)dev.null')
+ if entry is None:
+ log.fatal('Entry not found, but it should have been')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to search for user: ' + str(e))
+ assert False
+
+ #
+ # Delete the last values
+ #
+ try:
+ topology.standalone.modify_s(DN, [(ldap.MOD_DELETE,
+ 'mail',
+ 'user0099(a)dev.null'),
+ (ldap.MOD_DELETE,
+ 'mail',
+ 'user0099(a)redhat.com')
+ ])
+ except ldap.LDAPError as e:
+ log.fatal('Failed to modify user: ' + str(e))
+ assert False
+
+ #
+ # Search using deleted attribute value - no entries should be returned
+ #
+ try:
+ entry = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ 'mail=user0099(a)redhat.com')
+ if entry:
+ log.fatal('Entry incorrectly returned')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to search for user: ' + str(e))
+ assert False
+
+ #
+ # Make sure presence index is correctly updated - no entries should be
+ # returned
+ #
+ try:
+ entry = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ 'mail=*')
+ if entry:
+ log.fatal('Entry incorrectly returned')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to search for user: ' + str(e))
+ assert False
+
+ #
+ # Now add the attributes back, and lets run a different set of tests with
+ # a different number of attributes
+ #
+ try:
+ topology.standalone.modify_s(DN, [(ldap.MOD_ADD,
+ 'mail',
+ ['user0099(a)dev.null',
+ 'alias(a)dev.null'])])
+ except ldap.LDAPError as e:
+ log.fatal('Failedto modify user: ' + str(e))
+ assert False
+
+ #
+ # Remove and readd some attibutes
+ #
+ try:
+ topology.standalone.modify_s(DN, [(ldap.MOD_DELETE,
+ 'mail',
+ 'alias(a)dev.null'),
+ (ldap.MOD_DELETE,
+ 'mail',
+ 'user0099(a)dev.null'),
+ (ldap.MOD_ADD,
+ 'mail', 'user0099(a)dev.null')])
+ except ldap.LDAPError as e:
+ log.fatal('Failedto modify user: ' + str(e))
+ assert False
+
+ #
+ # Search using deleted attribute value - no entries should be returned
+ #
+ try:
+ entry = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ 'mail=alias(a)dev.null')
+ if entry:
+ log.fatal('Entry incorrectly returned')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to search for user: ' + str(e))
+ assert False
+
+ #
+ # Search using existing attribute value - the entry should be returned
+ #
+ try:
+ entry = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ 'mail=user0099(a)dev.null')
+ if entry is None:
+ log.fatal('Entry not found, but it should have been')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to search for user: ' + str(e))
+ assert False
+
+ log.info('Test PASSED')
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s %s" % CURRENT_FILE)
diff --git a/ldap/servers/slapd/back-ldbm/index.c b/ldap/servers/slapd/back-ldbm/index.c
index ffeedef..ff59875 100644
--- a/ldap/servers/slapd/back-ldbm/index.c
+++ b/ldap/servers/slapd/back-ldbm/index.c
@@ -747,31 +747,24 @@ index_add_mods(
flags = BE_INDEX_DEL|BE_INDEX_PRESENCE|BE_INDEX_EQUALITY;
} else {
flags = BE_INDEX_DEL;
-
- /* If the same value doesn't exist in a subtype, set
- * BE_INDEX_EQUALITY flag so the equality index is
- * removed.
- */
curr_attr = NULL;
slapi_entry_attr_find(olde->ep_entry,
- mods[i]->mod_type, &curr_attr);
+ mods[i]->mod_type,
+ &curr_attr);
if (curr_attr) {
- int found = 0;
for (j = 0; mods_valueArray[j] != NULL; j++ ) {
- if ( slapi_valueset_find(curr_attr, all_vals, mods_valueArray[j])) {
- /* The same value found in evals.
- * We don't touch the equality index. */
- found = 1;
+ if ( !slapi_valueset_find(curr_attr, all_vals, mods_valueArray[j]) ) {
+ /*
+ * If the mod del value is not found in all_vals
+ * we need to update the equality index as the
+ * final value(s) have changed
+ */
+ if (!(flags & BE_INDEX_EQUALITY)) {
+ flags |= BE_INDEX_EQUALITY;
+ }
break;
}
}
- /*
- * to-be-deleted curr_attr does not exist in the
- * new value set evals. So, we can remove it.
- */
- if (!found && !(flags & BE_INDEX_EQUALITY)) {
- flags |= BE_INDEX_EQUALITY;
- }
}
}
8 years, 4 months
Branch '389-ds-base-1.3.3' - dirsrvtests/create_test.py dirsrvtests/tickets ldap/servers
by Mark Reynolds
dirsrvtests/create_test.py | 345 ++++++++++++++++++++------------
dirsrvtests/tickets/ticket48370_test.py | 236 +++++++++++++++++++++
ldap/servers/slapd/back-ldbm/index.c | 29 +-
3 files changed, 469 insertions(+), 141 deletions(-)
New commits:
commit 5cd8f73205007ecbd44ae2fbfb5bcdf7e39c3d6e
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Mon Dec 7 16:45:06 2015 -0500
Ticket 48370 - The 'eq' index does not get updated properly
when deleting and re-adding attributes in
the same modify operation
Bug Description: If you delete several values of the same attribute, and
add at least one of them back in the same operation, the
equality index does not get updated.
Fix Description: Modify the logic of the index code to update the index if
at least one of the values in the entry changes.
Also did pep8 cleanup of create_test.py
https://fedorahosted.org/389/ticket/48370
Reviewed by: wibrown(Thanks!)
(cherry picked from commit 63b80b5c31ebda51445c662903a28e2a79ebe60a)
diff --git a/dirsrvtests/create_test.py b/dirsrvtests/create_test.py
index ad9e5aa..4a8dca3 100755
--- a/dirsrvtests/create_test.py
+++ b/dirsrvtests/create_test.py
@@ -21,14 +21,16 @@ non-interesting parts of a test script:
def displayUsage():
- print ('\nUsage:\ncreate_ticket.py -t|--ticket <ticket number> -s|--suite <suite name> ' +
- '[ i|--instances <number of standalone instances> [ -m|--masters <number of masters> ' +
- '-h|--hubs <number of hubs> -c|--consumers <number of consumers> ] ' +
- '-o|--outputfile ]\n')
- print ('If only "-t" is provided then a single standalone instance is created. ' +
- 'Or you can create a test suite script using "-s|--suite" instead of using "-t|--ticket".' +
- 'The "-i" option can add mulitple standalone instances(maximum 10). ' +
- 'However, you can not mix "-i" with the replication options(-m, -h , -c). ' +
+ print ('\nUsage:\ncreate_ticket.py -t|--ticket <ticket number> ' +
+ '-s|--suite <suite name> ' +
+ '[ i|--instances <number of standalone instances> ' +
+ '[ -m|--masters <number of masters> -h|--hubs <number of hubs> ' +
+ '-c|--consumers <number of consumers> ] -o|--outputfile ]\n')
+ print ('If only "-t" is provided then a single standalone instance is ' +
+ 'created. Or you can create a test suite script using ' +
+ '"-s|--suite" instead of using "-t|--ticket". The "-i" option ' +
+ 'can add mulitple standalone instances(maximum 10). However, you' +
+ ' can not mix "-i" with the replication options(-m, -h , -c). ' +
'There is a maximum of 10 masters, 10 hubs, and 10 consumers.')
exit(1)
@@ -86,34 +88,47 @@ if len(sys.argv) > 0:
displayUsage()
if args.ticket and args.suite:
- print 'You must choose either "-t|--ticket" or "-s|--suite", but not both.'
+ print('You must choose either "-t|--ticket" or "-s|--suite", ' +
+ 'but not both.')
displayUsage()
if int(args.masters) == 0:
if int(args.hubs) > 0 or int(args.consumers) > 0:
- print 'You must use "-m|--masters" if you want to have hubs and/or consumers'
+ print('You must use "-m|--masters" if you want to have hubs ' +
+ 'and/or consumers')
displayUsage()
- if not args.masters.isdigit() or int(args.masters) > 10 or int(args.masters) < 0:
- print 'Invalid value for "--masters", it must be a number and it can not be greater than 10'
+ if not args.masters.isdigit() or \
+ int(args.masters) > 10 or \
+ int(args.masters) < 0:
+ print('Invalid value for "--masters", it must be a number and it can' +
+ ' not be greater than 10')
displayUsage()
if not args.hubs.isdigit() or int(args.hubs) > 10 or int(args.hubs) < 0:
- print 'Invalid value for "--hubs", it must be a number and it can not be greater than 10'
+ print('Invalid value for "--hubs", it must be a number and it can ' +
+ 'not be greater than 10')
displayUsage()
- if not args.consumers.isdigit() or int(args.consumers) > 10 or int(args.consumers) < 0:
- print 'Invalid value for "--consumers", it must be a number and it can not be greater than 10'
+ if not args.consumers.isdigit() or \
+ int(args.consumers) > 10 or \
+ int(args.consumers) < 0:
+ print('Invalid value for "--consumers", it must be a number and it ' +
+ 'can not be greater than 10')
displayUsage()
if args.inst:
- if not args.inst.isdigit() or int(args.inst) > 10 or int(args.inst) < 1:
- print ('Invalid value for "--instances", it must be a number greater than 0 ' +
- 'and not greater than 10')
+ if not args.inst.isdigit() or \
+ int(args.inst) > 10 or \
+ int(args.inst) < 1:
+ print('Invalid value for "--instances", it must be a number ' +
+ 'greater than 0 and not greater than 10')
displayUsage()
if int(args.inst) > 0:
- if int(args.masters) > 0 or int(args.hubs) > 0 or int(args.consumers) > 0:
- print 'You can not mix "--instances" with replication.'
+ if int(args.masters) > 0 or \
+ int(args.hubs) > 0 or \
+ int(args.consumers) > 0:
+ print('You can not mix "--instances" with replication.')
displayUsage()
# Extract usable values
@@ -147,9 +162,11 @@ if len(sys.argv) > 0:
#
# Write the imports
#
- TEST.write('import os\nimport sys\nimport time\nimport ldap\nimport logging\nimport pytest\n')
- TEST.write('from lib389 import DirSrv, Entry, tools, tasks\nfrom lib389.tools import DirSrvTools\n' +
- 'from lib389._constants import *\nfrom lib389.properties import *\n' +
+ TEST.write('import os\nimport sys\nimport time\nimport ldap\n' +
+ 'import logging\nimport pytest\n')
+ TEST.write('from lib389 import DirSrv, Entry, tools, tasks\nfrom ' +
+ 'lib389.tools import DirSrvTools\nfrom lib389._constants ' +
+ 'import *\nfrom lib389.properties import *\n' +
'from lib389.tasks import *\nfrom lib389.utils import *\n\n')
#
@@ -181,13 +198,16 @@ if len(sys.argv) > 0:
for idx in range(masters):
TEST.write(' master' + str(idx + 1) + '.open()\n')
- TEST.write(' self.master' + str(idx + 1) + ' = master' + str(idx + 1) + '\n')
+ TEST.write(' self.master' + str(idx + 1) + ' = master' +
+ str(idx + 1) + '\n')
for idx in range(hubs):
TEST.write(' hub' + str(idx + 1) + '.open()\n')
- TEST.write(' self.hub' + str(idx + 1) + ' = hub' + str(idx + 1) + '\n')
+ TEST.write(' self.hub' + str(idx + 1) + ' = hub' +
+ str(idx + 1) + '\n')
for idx in range(consumers):
TEST.write(' consumer' + str(idx + 1) + '.open()\n')
- TEST.write(' self.consumer' + str(idx + 1) + ' = consumer' + str(idx + 1) + '\n')
+ TEST.write(' self.consumer' + str(idx + 1) + ' = consumer' +
+ str(idx + 1) + '\n')
TEST.write('\n\n')
else:
#
@@ -211,7 +231,8 @@ if len(sys.argv) > 0:
else:
idx = str(idx)
TEST.write(' standalone' + idx + '.open()\n')
- TEST.write(' self.standalone' + idx + ' = standalone' + idx + '\n')
+ TEST.write(' self.standalone' + idx + ' = standalone' +
+ idx + '\n')
TEST.write('\n\n')
#
@@ -221,7 +242,8 @@ if len(sys.argv) > 0:
TEST.write('def topology(request):\n')
TEST.write(' global installation1_prefix\n')
TEST.write(' if installation1_prefix:\n')
- TEST.write(' args_instance[SER_DEPLOYED_DIR] = installation1_prefix\n\n')
+ TEST.write(' args_instance[SER_DEPLOYED_DIR] = ' +
+ 'installation1_prefix\n\n')
if repl_deployment:
#
@@ -231,20 +253,25 @@ if len(sys.argv) > 0:
idx = str(idx + 1)
TEST.write(' # Creating master ' + idx + '...\n')
TEST.write(' master' + idx + ' = DirSrv(verbose=False)\n')
- TEST.write(' args_instance[SER_HOST] = HOST_MASTER_' + idx + '\n')
- TEST.write(' args_instance[SER_PORT] = PORT_MASTER_' + idx + '\n')
- TEST.write(' args_instance[SER_SERVERID_PROP] = SERVERID_MASTER_' + idx + '\n')
- TEST.write(' args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX\n')
+ TEST.write(' args_instance[SER_HOST] = HOST_MASTER_' + idx +
+ '\n')
+ TEST.write(' args_instance[SER_PORT] = PORT_MASTER_' + idx +
+ '\n')
+ TEST.write(' args_instance[SER_SERVERID_PROP] = ' +
+ 'SERVERID_MASTER_' + idx + '\n')
+ TEST.write(' args_instance[SER_CREATION_SUFFIX] = ' +
+ 'DEFAULT_SUFFIX\n')
TEST.write(' args_master = args_instance.copy()\n')
TEST.write(' master' + idx + '.allocate(args_master)\n')
- TEST.write(' instance_master' + idx + ' = master' + idx + '.exists()\n')
+ TEST.write(' instance_master' + idx + ' = master' + idx +
+ '.exists()\n')
TEST.write(' if instance_master' + idx + ':\n')
TEST.write(' master' + idx + '.delete()\n')
TEST.write(' master' + idx + '.create()\n')
TEST.write(' master' + idx + '.open()\n')
- TEST.write(' master' + idx + '.replica.enableReplication(suffix=SUFFIX, ' +
- 'role=REPLICAROLE_MASTER, ' +
- 'replicaId=REPLICAID_MASTER_' + idx + ')\n\n')
+ TEST.write(' master' + idx + '.replica.enableReplication' +
+ '(suffix=SUFFIX, role=REPLICAROLE_MASTER, ' +
+ 'replicaId=REPLICAID_MASTER_' + idx + ')\n\n')
for idx in range(hubs):
idx = str(idx + 1)
@@ -252,37 +279,45 @@ if len(sys.argv) > 0:
TEST.write(' hub' + idx + ' = DirSrv(verbose=False)\n')
TEST.write(' args_instance[SER_HOST] = HOST_HUB_' + idx + '\n')
TEST.write(' args_instance[SER_PORT] = PORT_HUB_' + idx + '\n')
- TEST.write(' args_instance[SER_SERVERID_PROP] = SERVERID_HUB_' + idx + '\n')
- TEST.write(' args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX\n')
+ TEST.write(' args_instance[SER_SERVERID_PROP] = SERVERID_HUB_' +
+ idx + '\n')
+ TEST.write(' args_instance[SER_CREATION_SUFFIX] = ' +
+ 'DEFAULT_SUFFIX\n')
TEST.write(' args_hub = args_instance.copy()\n')
TEST.write(' hub' + idx + '.allocate(args_hub)\n')
- TEST.write(' instance_hub' + idx + ' = hub' + idx + '.exists()\n')
+ TEST.write(' instance_hub' + idx + ' = hub' + idx +
+ '.exists()\n')
TEST.write(' if instance_hub' + idx + ':\n')
TEST.write(' hub' + idx + '.delete()\n')
TEST.write(' hub' + idx + '.create()\n')
TEST.write(' hub' + idx + '.open()\n')
- TEST.write(' hub' + idx + '.replica.enableReplication(suffix=SUFFIX, ' +
- 'role=REPLICAROLE_HUB, ' +
- 'replicaId=REPLICAID_HUB_' + idx + ')\n\n')
+ TEST.write(' hub' + idx + '.replica.enableReplication' +
+ '(suffix=SUFFIX, role=REPLICAROLE_HUB, ' +
+ 'replicaId=REPLICAID_HUB_' + idx + ')\n\n')
for idx in range(consumers):
idx = str(idx + 1)
TEST.write(' # Creating consumer ' + idx + '...\n')
TEST.write(' consumer' + idx + ' = DirSrv(verbose=False)\n')
- TEST.write(' args_instance[SER_HOST] = HOST_CONSUMER_' + idx + '\n')
- TEST.write(' args_instance[SER_PORT] = PORT_CONSUMER_' + idx + '\n')
- TEST.write(' args_instance[SER_SERVERID_PROP] = SERVERID_CONSUMER_' + idx + '\n')
- TEST.write(' args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX\n')
+ TEST.write(' args_instance[SER_HOST] = HOST_CONSUMER_' + idx +
+ '\n')
+ TEST.write(' args_instance[SER_PORT] = PORT_CONSUMER_' + idx +
+ '\n')
+ TEST.write(' args_instance[SER_SERVERID_PROP] = ' +
+ 'SERVERID_CONSUMER_' + idx + '\n')
+ TEST.write(' args_instance[SER_CREATION_SUFFIX] = ' +
+ 'DEFAULT_SUFFIX\n')
TEST.write(' args_consumer = args_instance.copy()\n')
TEST.write(' consumer' + idx + '.allocate(args_consumer)\n')
- TEST.write(' instance_consumer' + idx + ' = consumer' + idx + '.exists()\n')
+ TEST.write(' instance_consumer' + idx + ' = consumer' + idx +
+ '.exists()\n')
TEST.write(' if instance_consumer' + idx + ':\n')
TEST.write(' consumer' + idx + '.delete()\n')
TEST.write(' consumer' + idx + '.create()\n')
TEST.write(' consumer' + idx + '.open()\n')
- TEST.write(' consumer' + idx + '.replica.enableReplication(suffix=SUFFIX, ' +
- 'role=REPLICAROLE_CONSUMER, ' +
- 'replicaId=CONSUMER_REPLICAID)\n\n')
+ TEST.write(' consumer' + idx + '.replica.enableReplication' +
+ '(suffix=SUFFIX, role=REPLICAROLE_CONSUMER, ' +
+ 'replicaId=CONSUMER_REPLICAID)\n\n')
#
# Create the master agreements
@@ -301,39 +336,61 @@ if len(sys.argv) > 0:
if master_idx == idx:
# skip ourselves
continue
- TEST.write(' # Creating agreement from master ' + str(master_idx) + ' to master ' + str(idx) + '\n')
- TEST.write(" properties = {RA_NAME: r'meTo_$host:$port',\n")
- TEST.write(" RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],\n")
- TEST.write(" RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],\n")
- TEST.write(" RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],\n")
- TEST.write(" RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}\n")
- TEST.write(' m' + str(master_idx) + '_m' + str(idx) + '_agmt = master' + str(master_idx) +
+ TEST.write(' # Creating agreement from master ' +
+ str(master_idx) + ' to master ' + str(idx) + '\n')
+ TEST.write(" properties = {RA_NAME: " +
+ "r'meTo_$host:$port',\n")
+ TEST.write(" RA_BINDDN: " +
+ "defaultProperties[REPLICATION_BIND_DN],\n")
+ TEST.write(" RA_BINDPW: " +
+ "defaultProperties[REPLICATION_BIND_PW],\n")
+ TEST.write(" RA_METHOD: " +
+ "defaultProperties[REPLICATION_BIND_METHOD],\n")
+ TEST.write(" RA_TRANSPORT_PROT: " +
+ "defaultProperties[REPLICATION_TRANSPORT]}\n")
+ TEST.write(' m' + str(master_idx) + '_m' + str(idx) +
+ '_agmt = master' + str(master_idx) +
'.agreement.create(suffix=SUFFIX, host=master' +
- str(idx) + '.host, port=master' + str(idx) + '.port, properties=properties)\n')
- TEST.write(' if not m' + str(master_idx) + '_m' + str(idx) + '_agmt:\n')
- TEST.write(' log.fatal("Fail to create a master -> master replica agreement")\n')
+ str(idx) + '.host, port=master' + str(idx) +
+ '.port, properties=properties)\n')
+ TEST.write(' if not m' + str(master_idx) + '_m' + str(idx) +
+ '_agmt:\n')
+ TEST.write(' log.fatal("Fail to create a master -> ' +
+ 'master replica agreement")\n')
TEST.write(' sys.exit(1)\n')
- TEST.write(' log.debug("%s created" % m' + str(master_idx) + '_m' + str(idx) + '_agmt)\n\n')
+ TEST.write(' log.debug("%s created" % m' + str(master_idx) +
+ '_m' + str(idx) + '_agmt)\n\n')
agmt_count += 1
for idx in range(hubs):
idx += 1
#
- # Create agreements from each master to each hub (master -> hub)
+ # Create agmts from each master to each hub (master -> hub)
#
- TEST.write(' # Creating agreement from master ' + str(master_idx) + ' to hub ' + str(idx) + '\n')
- TEST.write(" properties = {RA_NAME: r'meTo_$host:$port',\n")
- TEST.write(" RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],\n")
- TEST.write(" RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],\n")
- TEST.write(" RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],\n")
- TEST.write(" RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}\n")
- TEST.write(' m' + str(master_idx) + '_h' + str(idx) + '_agmt = master' + str(master_idx) +
- '.agreement.create(suffix=SUFFIX, host=hub' +
- str(idx) + '.host, port=hub' + str(idx) + '.port, properties=properties)\n')
- TEST.write(' if not m' + str(master_idx) + '_h' + str(idx) + '_agmt:\n')
- TEST.write(' log.fatal("Fail to create a master -> hub replica agreement")\n')
+ TEST.write(' # Creating agreement from master ' +
+ str(master_idx) + ' to hub ' + str(idx) + '\n')
+ TEST.write(" properties = {RA_NAME: " +
+ "r'meTo_$host:$port',\n")
+ TEST.write(" RA_BINDDN: " +
+ "defaultProperties[REPLICATION_BIND_DN],\n")
+ TEST.write(" RA_BINDPW: " +
+ "defaultProperties[REPLICATION_BIND_PW],\n")
+ TEST.write(" RA_METHOD: " +
+ "defaultProperties[REPLICATION_BIND_METHOD],\n")
+ TEST.write(" RA_TRANSPORT_PROT: " +
+ "defaultProperties[REPLICATION_TRANSPORT]}\n")
+ TEST.write(' m' + str(master_idx) + '_h' + str(idx) +
+ '_agmt = master' + str(master_idx) +
+ '.agreement.create(suffix=SUFFIX, host=hub' +
+ str(idx) + '.host, port=hub' + str(idx) +
+ '.port, properties=properties)\n')
+ TEST.write(' if not m' + str(master_idx) + '_h' + str(idx) +
+ '_agmt:\n')
+ TEST.write(' log.fatal("Fail to create a master -> ' +
+ 'hub replica agreement")\n')
TEST.write(' sys.exit(1)\n')
- TEST.write(' log.debug("%s created" % m' + str(master_idx) + '_h' + str(idx) + '_agmt)\n\n')
+ TEST.write(' log.debug("%s created" % m' + str(master_idx) +
+ '_h' + str(idx) + '_agmt)\n\n')
agmt_count += 1
#
@@ -349,24 +406,35 @@ if len(sys.argv) > 0:
#
# Create agreements from each hub to each consumer
#
- TEST.write(' # Creating agreement from hub ' + str(hub_idx) + ' to consumer ' + str(idx) + '\n')
- TEST.write(" properties = {RA_NAME: r'meTo_$host:$port',\n")
- TEST.write(" RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],\n")
- TEST.write(" RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],\n")
- TEST.write(" RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],\n")
- TEST.write(" RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}\n")
- TEST.write(' h' + str(hub_idx) + '_c' + str(idx) + '_agmt = hub' +
- str(hub_idx) + '.agreement.create(suffix=SUFFIX, host=consumer' +
- str(idx) + '.host, port=consumer' + str(idx) + '.port, properties=properties)\n')
- TEST.write(' if not h' + str(hub_idx) + '_c' + str(idx) + '_agmt:\n')
- TEST.write(' log.fatal("Fail to create a hub -> consumer replica agreement")\n')
+ TEST.write(' # Creating agreement from hub ' + str(hub_idx)
+ + ' to consumer ' + str(idx) + '\n')
+ TEST.write(" properties = {RA_NAME: " +
+ "r'meTo_$host:$port',\n")
+ TEST.write(" RA_BINDDN: " +
+ "defaultProperties[REPLICATION_BIND_DN],\n")
+ TEST.write(" RA_BINDPW: " +
+ "defaultProperties[REPLICATION_BIND_PW],\n")
+ TEST.write(" RA_METHOD: " +
+ "defaultProperties[REPLICATION_BIND_METHOD],\n")
+ TEST.write(" RA_TRANSPORT_PROT: " +
+ "defaultProperties[REPLICATION_TRANSPORT]}\n")
+ TEST.write(' h' + str(hub_idx) + '_c' + str(idx) +
+ '_agmt = hub' + str(hub_idx) +
+ '.agreement.create(suffix=SUFFIX, host=consumer' +
+ str(idx) + '.host, port=consumer' + str(idx) +
+ '.port, properties=properties)\n')
+ TEST.write(' if not h' + str(hub_idx) + '_c' + str(idx) +
+ '_agmt:\n')
+ TEST.write(' log.fatal("Fail to create a hub -> ' +
+ 'consumer replica agreement")\n')
TEST.write(' sys.exit(1)\n')
- TEST.write(' log.debug("%s created" % h' + str(hub_idx) + '_c' + str(idx) + '_agmt)\n\n')
+ TEST.write(' log.debug("%s created" % h' + str(hub_idx) +
+ '_c' + str(idx) + '_agmt)\n\n')
agmt_count += 1
if hubs == 0:
#
- # No Hubs, see if there are any consumers to create agreements to...
+ # No Hubs, see if there are any consumers to create agreements to
#
for idx in range(masters):
master_idx = idx + 1
@@ -378,27 +446,40 @@ if len(sys.argv) > 0:
#
# Create agreements from each master to each consumer
#
- TEST.write(' # Creating agreement from master ' + str(master_idx) +
- ' to consumer ' + str(idx) + '\n')
- TEST.write(" properties = {RA_NAME: r'meTo_$host:$port',\n")
- TEST.write(" RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],\n")
- TEST.write(" RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],\n")
- TEST.write(" RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],\n")
- TEST.write(" RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}\n")
- TEST.write(' m' + str(master_idx) + '_c' + str(idx) + '_agmt = master' + str(master_idx) +
- '.agreement.create(suffix=SUFFIX, host=consumer' +
- str(idx) + '.host, port=consumer' + str(idx) +
- '.port, properties=properties)\n')
- TEST.write(' if not m' + str(master_idx) + '_c' + str(idx) + '_agmt:\n')
- TEST.write(' log.fatal("Fail to create a hub -> consumer replica agreement")\n')
+ TEST.write(' # Creating agreement from master ' +
+ str(master_idx) + ' to consumer ' + str(idx) +
+ '\n')
+ TEST.write(" properties = {RA_NAME: " +
+ "r'meTo_$host:$port',\n")
+ TEST.write(" RA_BINDDN: " +
+ "defaultProperties[REPLICATION_BIND_DN],\n")
+ TEST.write(" RA_BINDPW: " +
+ "defaultProperties[REPLICATION_BIND_PW],\n")
+ TEST.write(" RA_METHOD: " +
+ "defaultProperties[REPLICATION_BIND_METHOD],\n")
+ TEST.write(" RA_TRANSPORT_PROT: " +
+ "defaultProperties[REPLICATION_TRANSPORT]}\n")
+ TEST.write(' m' + str(master_idx) + '_c' + str(idx) +
+ '_agmt = master' + str(master_idx) +
+ '.agreement.create(suffix=SUFFIX, ' +
+ 'host=consumer' + str(idx) +
+ '.host, port=consumer' + str(idx) +
+ '.port, properties=properties)\n')
+ TEST.write(' if not m' + str(master_idx) + '_c' +
+ str(idx) + '_agmt:\n')
+ TEST.write(' log.fatal("Fail to create a hub -> ' +
+ 'consumer replica agreement")\n')
TEST.write(' sys.exit(1)\n')
- TEST.write(' log.debug("%s created" % m' + str(master_idx) + '_c' + str(idx) + '_agmt)\n\n')
+ TEST.write(' log.debug("%s created" % m' +
+ str(master_idx) + '_c' + str(idx) +
+ '_agmt)\n\n')
agmt_count += 1
#
# Add sleep that allows all the agreemnts to get situated
#
- TEST.write(' # Allow the replicas to get situated with the new agreements...\n')
+ TEST.write(' # Allow the replicas to get situated with the new ' +
+ 'agreements...\n')
TEST.write(' time.sleep(5)\n\n')
#
@@ -415,7 +496,8 @@ if len(sys.argv) > 0:
continue
TEST.write(' master1.agreement.init(SUFFIX, HOST_MASTER_' +
str(idx) + ', PORT_MASTER_' + str(idx) + ')\n')
- TEST.write(' master1.waitForReplInit(m1_m' + str(idx) + '_agmt)\n')
+ TEST.write(' master1.waitForReplInit(m1_m' + str(idx) +
+ '_agmt)\n')
# Hubs
consumers_inited = False
@@ -423,23 +505,27 @@ if len(sys.argv) > 0:
idx += 1
TEST.write(' master1.agreement.init(SUFFIX, HOST_HUB_' +
str(idx) + ', PORT_HUB_' + str(idx) + ')\n')
- TEST.write(' master1.waitForReplInit(m1_h' + str(idx) + '_agmt)\n')
+ TEST.write(' master1.waitForReplInit(m1_h' + str(idx) +
+ '_agmt)\n')
for idx in range(consumers):
if consumers_inited:
continue
idx += 1
TEST.write(' hub1.agreement.init(SUFFIX, HOST_CONSUMER_' +
str(idx) + ', PORT_CONSUMER_' + str(idx) + ')\n')
- TEST.write(' hub1.waitForReplInit(h1_c' + str(idx) + '_agmt)\n')
+ TEST.write(' hub1.waitForReplInit(h1_c' + str(idx) +
+ '_agmt)\n')
consumers_inited = True
# Consumers (master -> consumer)
if hubs == 0:
for idx in range(consumers):
idx += 1
- TEST.write(' master1.agreement.init(SUFFIX, HOST_CONSUMER_' +
- str(idx) + ', PORT_CONSUMER_' + str(idx) + ')\n')
- TEST.write(' master1.waitForReplInit(m1_c' + str(idx) + '_agmt)\n')
+ TEST.write(' master1.agreement.init(SUFFIX, ' +
+ 'HOST_CONSUMER_' + str(idx) + ', PORT_CONSUMER_' +
+ str(idx) + ')\n')
+ TEST.write(' master1.waitForReplInit(m1_c' + str(idx) +
+ '_agmt)\n')
TEST.write('\n')
@@ -447,7 +533,7 @@ if len(sys.argv) > 0:
# Write replicaton check
#
if agmt_count > 0:
- # Find the lowest replica type in the deployment(consumer -> master)
+ # Find the lowest replica type (consumer -> master)
if consumers > 0:
replica = 'consumer1'
elif hubs > 0:
@@ -455,7 +541,8 @@ if len(sys.argv) > 0:
else:
replica = 'master2'
TEST.write(' # Check replication is working...\n')
- TEST.write(' if master1.testReplication(DEFAULT_SUFFIX, ' + replica + '):\n')
+ TEST.write(' if master1.testReplication(DEFAULT_SUFFIX, ' +
+ replica + '):\n')
TEST.write(" log.info('Replication is working.')\n")
TEST.write(' else:\n')
TEST.write(" log.fatal('Replication is not working.')\n")
@@ -494,15 +581,22 @@ if len(sys.argv) > 0:
idx = str(idx)
TEST.write(' # Creating standalone instance ' + idx + '...\n')
TEST.write(' standalone' + idx + ' = DirSrv(verbose=False)\n')
- TEST.write(' args_instance[SER_HOST] = HOST_STANDALONE' + idx + '\n')
- TEST.write(' args_instance[SER_PORT] = PORT_STANDALONE' + idx + '\n')
- TEST.write(' args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE' + idx + '\n')
- TEST.write(' args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX\n')
- TEST.write(' args_standalone' + idx + ' = args_instance.copy()\n')
- TEST.write(' standalone' + idx + '.allocate(args_standalone' + idx + ')\n')
+ TEST.write(' args_instance[SER_HOST] = HOST_STANDALONE' +
+ idx + '\n')
+ TEST.write(' args_instance[SER_PORT] = PORT_STANDALONE' +
+ idx + '\n')
+ TEST.write(' args_instance[SER_SERVERID_PROP] = ' +
+ 'SERVERID_STANDALONE' + idx + '\n')
+ TEST.write(' args_instance[SER_CREATION_SUFFIX] = ' +
+ 'DEFAULT_SUFFIX\n')
+ TEST.write(' args_standalone' + idx + ' = args_instance.copy' +
+ '()\n')
+ TEST.write(' standalone' + idx + '.allocate(args_standalone' +
+ idx + ')\n')
# Get the status of the instance and restart it if it exists
- TEST.write(' instance_standalone' + idx + ' = standalone' + idx + '.exists()\n')
+ TEST.write(' instance_standalone' + idx + ' = standalone' +
+ idx + '.exists()\n')
# Remove the instance
TEST.write(' if instance_standalone' + idx + ':\n')
@@ -535,14 +629,18 @@ if len(sys.argv) > 0:
TEST.write('def test_ticket' + ticket + '(topology):\n')
if repl_deployment:
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\n')
+ TEST.write(' To access each DirSrv instance use: ' +
+ 'topology.master1, topology.master2,\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')
+ TEST.write(' please, write additional fixture for that' +
+ '(include ' + 'finalizer).\n')
else:
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(' please, write additional fixture for that' +
+ '(include finalizer).\n')
TEST.write(' """\n\n')
TEST.write(" log.info('Test complete')\n")
TEST.write('\n\n')
@@ -551,7 +649,8 @@ if len(sys.argv) > 0:
TEST.write('def test_' + suite + '_#####(topology):\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(' please, write additional fixture for that(include ' +
+ 'finalizer).\n')
TEST.write(' """\n\n return\n\n\n')
#
@@ -561,7 +660,7 @@ if len(sys.argv) > 0:
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)')
+ TEST.write(' pytest.main("-s %s" % CURRENT_FILE)\n')
#
# Done, close things up
diff --git a/dirsrvtests/tickets/ticket48370_test.py b/dirsrvtests/tickets/ticket48370_test.py
new file mode 100644
index 0000000..f5b1f47
--- /dev/null
+++ b/dirsrvtests/tickets/ticket48370_test.py
@@ -0,0 +1,236 @@
+import os
+import ldap
+import logging
+import pytest
+from lib389 import DirSrv, Entry
+from lib389._constants import *
+from lib389.properties import *
+from lib389.tasks import *
+from lib389.utils import *
+
+logging.getLogger(__name__).setLevel(logging.DEBUG)
+log = logging.getLogger(__name__)
+
+installation1_prefix = None
+
+
+class TopologyStandalone(object):
+ def __init__(self, standalone):
+ standalone.open()
+ self.standalone = standalone
+
+
+(a)pytest.fixture(scope="module")
+def topology(request):
+ global installation1_prefix
+ if installation1_prefix:
+ args_instance[SER_DEPLOYED_DIR] = installation1_prefix
+
+ # Creating standalone instance ...
+ standalone = DirSrv(verbose=False)
+ args_instance[SER_HOST] = HOST_STANDALONE
+ args_instance[SER_PORT] = PORT_STANDALONE
+ args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_standalone = args_instance.copy()
+ standalone.allocate(args_standalone)
+ instance_standalone = standalone.exists()
+ if instance_standalone:
+ standalone.delete()
+ standalone.create()
+ standalone.open()
+
+ # Delete each instance in the end
+ def fin():
+ standalone.delete()
+ request.addfinalizer(fin)
+
+ # Clear out the tmp dir
+ standalone.clearTmpDir(__file__)
+
+ return TopologyStandalone(standalone)
+
+
+def test_ticket48370(topology):
+ """
+ Deleting attirbute values and readding a value does not properly update
+ the pres index. The values are not actually deleted from the index
+ """
+
+ DN = 'uid=user0099,' + DEFAULT_SUFFIX
+
+ #
+ # Add an entry
+ #
+ topology.standalone.add_s(Entry((DN, {
+ 'objectclass': ['top', 'person',
+ 'organizationalPerson',
+ 'inetorgperson',
+ 'posixAccount'],
+ 'givenname': 'test',
+ 'sn': 'user',
+ 'loginshell': '/bin/bash',
+ 'uidNumber': '10099',
+ 'gidNumber': '10099',
+ 'gecos': 'Test User',
+ 'mail': ['user0099(a)dev.null',
+ 'alias(a)dev.null',
+ 'user0099(a)redhat.com'],
+ 'cn': 'Test User',
+ 'homeDirectory': '/home/user0099',
+ 'uid': 'admin2',
+ 'userpassword': 'password'})))
+
+ #
+ # Perform modify (delete & add mail attributes)
+ #
+ try:
+ topology.standalone.modify_s(DN, [(ldap.MOD_DELETE,
+ 'mail',
+ 'user0099(a)dev.null'),
+ (ldap.MOD_DELETE,
+ 'mail',
+ 'alias(a)dev.null'),
+ (ldap.MOD_ADD,
+ 'mail', 'user0099(a)dev.null')])
+ except ldap.LDAPError as e:
+ log.fatal('Failedto modify user: ' + str(e))
+ assert False
+
+ #
+ # Search using deleted attribute value- no entries should be returned
+ #
+ try:
+ entry = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ 'mail=alias(a)dev.null')
+ if entry:
+ log.fatal('Entry incorrectly returned')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to search for user: ' + str(e))
+ assert False
+
+ #
+ # Search using existing attribute value - the entry should be returned
+ #
+ try:
+ entry = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ 'mail=user0099(a)dev.null')
+ if entry is None:
+ log.fatal('Entry not found, but it should have been')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to search for user: ' + str(e))
+ assert False
+
+ #
+ # Delete the last values
+ #
+ try:
+ topology.standalone.modify_s(DN, [(ldap.MOD_DELETE,
+ 'mail',
+ 'user0099(a)dev.null'),
+ (ldap.MOD_DELETE,
+ 'mail',
+ 'user0099(a)redhat.com')
+ ])
+ except ldap.LDAPError as e:
+ log.fatal('Failed to modify user: ' + str(e))
+ assert False
+
+ #
+ # Search using deleted attribute value - no entries should be returned
+ #
+ try:
+ entry = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ 'mail=user0099(a)redhat.com')
+ if entry:
+ log.fatal('Entry incorrectly returned')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to search for user: ' + str(e))
+ assert False
+
+ #
+ # Make sure presence index is correctly updated - no entries should be
+ # returned
+ #
+ try:
+ entry = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ 'mail=*')
+ if entry:
+ log.fatal('Entry incorrectly returned')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to search for user: ' + str(e))
+ assert False
+
+ #
+ # Now add the attributes back, and lets run a different set of tests with
+ # a different number of attributes
+ #
+ try:
+ topology.standalone.modify_s(DN, [(ldap.MOD_ADD,
+ 'mail',
+ ['user0099(a)dev.null',
+ 'alias(a)dev.null'])])
+ except ldap.LDAPError as e:
+ log.fatal('Failedto modify user: ' + str(e))
+ assert False
+
+ #
+ # Remove and readd some attibutes
+ #
+ try:
+ topology.standalone.modify_s(DN, [(ldap.MOD_DELETE,
+ 'mail',
+ 'alias(a)dev.null'),
+ (ldap.MOD_DELETE,
+ 'mail',
+ 'user0099(a)dev.null'),
+ (ldap.MOD_ADD,
+ 'mail', 'user0099(a)dev.null')])
+ except ldap.LDAPError as e:
+ log.fatal('Failedto modify user: ' + str(e))
+ assert False
+
+ #
+ # Search using deleted attribute value - no entries should be returned
+ #
+ try:
+ entry = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ 'mail=alias(a)dev.null')
+ if entry:
+ log.fatal('Entry incorrectly returned')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to search for user: ' + str(e))
+ assert False
+
+ #
+ # Search using existing attribute value - the entry should be returned
+ #
+ try:
+ entry = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ 'mail=user0099(a)dev.null')
+ if entry is None:
+ log.fatal('Entry not found, but it should have been')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to search for user: ' + str(e))
+ assert False
+
+ log.info('Test PASSED')
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s %s" % CURRENT_FILE)
diff --git a/ldap/servers/slapd/back-ldbm/index.c b/ldap/servers/slapd/back-ldbm/index.c
index 0d9ac33..695f2d6 100644
--- a/ldap/servers/slapd/back-ldbm/index.c
+++ b/ldap/servers/slapd/back-ldbm/index.c
@@ -760,31 +760,24 @@ index_add_mods(
flags = BE_INDEX_DEL|BE_INDEX_PRESENCE|BE_INDEX_EQUALITY;
} else {
flags = BE_INDEX_DEL;
-
- /* If the same value doesn't exist in a subtype, set
- * BE_INDEX_EQUALITY flag so the equality index is
- * removed.
- */
curr_attr = NULL;
slapi_entry_attr_find(olde->ep_entry,
- mods[i]->mod_type, &curr_attr);
+ mods[i]->mod_type,
+ &curr_attr);
if (curr_attr) {
- int found = 0;
for (j = 0; mods_valueArray[j] != NULL; j++ ) {
- if ( slapi_valueset_find(curr_attr, all_vals, mods_valueArray[j])) {
- /* The same value found in evals.
- * We don't touch the equality index. */
- found = 1;
+ if ( !slapi_valueset_find(curr_attr, all_vals, mods_valueArray[j]) ) {
+ /*
+ * If the mod del value is not found in all_vals
+ * we need to update the equality index as the
+ * final value(s) have changed
+ */
+ if (!(flags & BE_INDEX_EQUALITY)) {
+ flags |= BE_INDEX_EQUALITY;
+ }
break;
}
}
- /*
- * to-be-deleted curr_attr does not exist in the
- * new value set evals. So, we can remove it.
- */
- if (!found && !(flags & BE_INDEX_EQUALITY)) {
- flags |= BE_INDEX_EQUALITY;
- }
}
}
8 years, 4 months
Branch '389-ds-base-1.3.4' - dirsrvtests/create_test.py dirsrvtests/tickets ldap/servers
by Mark Reynolds
dirsrvtests/create_test.py | 343 ++++++++++++++++++++------------
dirsrvtests/tickets/ticket48370_test.py | 236 ++++++++++++++++++++++
ldap/servers/slapd/back-ldbm/index.c | 29 +-
3 files changed, 468 insertions(+), 140 deletions(-)
New commits:
commit 4a53592ec89d288f182c509dc7fcc104d8cbc4a8
Author: Mark Reynolds <mreynolds(a)redhat.com>
Date: Mon Dec 7 16:45:06 2015 -0500
Ticket 48370 - The 'eq' index does not get updated properly
when deleting and re-adding attributes in
the same modify operation
Bug Description: If you delete several values of the same attribute, and
add at least one of them back in the same operation, the
equality index does not get updated.
Fix Description: Modify the logic of the index code to update the index if
at least one of the values in the entry changes.
Also did pep8 cleanup of create_test.py
https://fedorahosted.org/389/ticket/48370
Reviewed by: wibrown(Thanks!)
(cherry picked from commit 63b80b5c31ebda51445c662903a28e2a79ebe60a)
diff --git a/dirsrvtests/create_test.py b/dirsrvtests/create_test.py
index 0979f6e..e3b89aa 100755
--- a/dirsrvtests/create_test.py
+++ b/dirsrvtests/create_test.py
@@ -21,14 +21,16 @@ non-interesting parts of a test script:
def displayUsage():
- print ('\nUsage:\ncreate_ticket.py -t|--ticket <ticket number> -s|--suite <suite name> ' +
- '[ i|--instances <number of standalone instances> [ -m|--masters <number of masters> ' +
- '-h|--hubs <number of hubs> -c|--consumers <number of consumers> ] ' +
- '-o|--outputfile ]\n')
- print ('If only "-t" is provided then a single standalone instance is created. ' +
- 'Or you can create a test suite script using "-s|--suite" instead of using "-t|--ticket".' +
- 'The "-i" option can add mulitple standalone instances(maximum 10). ' +
- 'However, you can not mix "-i" with the replication options(-m, -h , -c). ' +
+ print ('\nUsage:\ncreate_ticket.py -t|--ticket <ticket number> ' +
+ '-s|--suite <suite name> ' +
+ '[ i|--instances <number of standalone instances> ' +
+ '[ -m|--masters <number of masters> -h|--hubs <number of hubs> ' +
+ '-c|--consumers <number of consumers> ] -o|--outputfile ]\n')
+ print ('If only "-t" is provided then a single standalone instance is ' +
+ 'created. Or you can create a test suite script using ' +
+ '"-s|--suite" instead of using "-t|--ticket". The "-i" option ' +
+ 'can add mulitple standalone instances(maximum 10). However, you' +
+ ' can not mix "-i" with the replication options(-m, -h , -c). ' +
'There is a maximum of 10 masters, 10 hubs, and 10 consumers.')
exit(1)
@@ -86,33 +88,46 @@ if len(sys.argv) > 0:
displayUsage()
if args.ticket and args.suite:
- print('You must choose either "-t|--ticket" or "-s|--suite", but not both.')
+ print('You must choose either "-t|--ticket" or "-s|--suite", ' +
+ 'but not both.')
displayUsage()
if int(args.masters) == 0:
if int(args.hubs) > 0 or int(args.consumers) > 0:
- print('You must use "-m|--masters" if you want to have hubs and/or consumers')
+ print('You must use "-m|--masters" if you want to have hubs ' +
+ 'and/or consumers')
displayUsage()
- if not args.masters.isdigit() or int(args.masters) > 10 or int(args.masters) < 0:
- print('Invalid value for "--masters", it must be a number and it can not be greater than 10')
+ if not args.masters.isdigit() or \
+ int(args.masters) > 10 or \
+ int(args.masters) < 0:
+ print('Invalid value for "--masters", it must be a number and it can' +
+ ' not be greater than 10')
displayUsage()
if not args.hubs.isdigit() or int(args.hubs) > 10 or int(args.hubs) < 0:
- print('Invalid value for "--hubs", it must be a number and it can not be greater than 10')
+ print('Invalid value for "--hubs", it must be a number and it can ' +
+ 'not be greater than 10')
displayUsage()
- if not args.consumers.isdigit() or int(args.consumers) > 10 or int(args.consumers) < 0:
- print('Invalid value for "--consumers", it must be a number and it can not be greater than 10')
+ if not args.consumers.isdigit() or \
+ int(args.consumers) > 10 or \
+ int(args.consumers) < 0:
+ print('Invalid value for "--consumers", it must be a number and it ' +
+ 'can not be greater than 10')
displayUsage()
if args.inst:
- if not args.inst.isdigit() or int(args.inst) > 10 or int(args.inst) < 1:
- print('Invalid value for "--instances", it must be a number greater than 0 ' +
- 'and not greater than 10')
+ if not args.inst.isdigit() or \
+ int(args.inst) > 10 or \
+ int(args.inst) < 1:
+ print('Invalid value for "--instances", it must be a number ' +
+ 'greater than 0 and not greater than 10')
displayUsage()
if int(args.inst) > 0:
- if int(args.masters) > 0 or int(args.hubs) > 0 or int(args.consumers) > 0:
+ if int(args.masters) > 0 or \
+ int(args.hubs) > 0 or \
+ int(args.consumers) > 0:
print('You can not mix "--instances" with replication.')
displayUsage()
@@ -147,9 +162,11 @@ if len(sys.argv) > 0:
#
# Write the imports
#
- TEST.write('import os\nimport sys\nimport time\nimport ldap\nimport logging\nimport pytest\n')
- TEST.write('from lib389 import DirSrv, Entry, tools, tasks\nfrom lib389.tools import DirSrvTools\n' +
- 'from lib389._constants import *\nfrom lib389.properties import *\n' +
+ TEST.write('import os\nimport sys\nimport time\nimport ldap\n' +
+ 'import logging\nimport pytest\n')
+ TEST.write('from lib389 import DirSrv, Entry, tools, tasks\nfrom ' +
+ 'lib389.tools import DirSrvTools\nfrom lib389._constants ' +
+ 'import *\nfrom lib389.properties import *\n' +
'from lib389.tasks import *\nfrom lib389.utils import *\n\n')
#
@@ -181,13 +198,16 @@ if len(sys.argv) > 0:
for idx in range(masters):
TEST.write(' master' + str(idx + 1) + '.open()\n')
- TEST.write(' self.master' + str(idx + 1) + ' = master' + str(idx + 1) + '\n')
+ TEST.write(' self.master' + str(idx + 1) + ' = master' +
+ str(idx + 1) + '\n')
for idx in range(hubs):
TEST.write(' hub' + str(idx + 1) + '.open()\n')
- TEST.write(' self.hub' + str(idx + 1) + ' = hub' + str(idx + 1) + '\n')
+ TEST.write(' self.hub' + str(idx + 1) + ' = hub' +
+ str(idx + 1) + '\n')
for idx in range(consumers):
TEST.write(' consumer' + str(idx + 1) + '.open()\n')
- TEST.write(' self.consumer' + str(idx + 1) + ' = consumer' + str(idx + 1) + '\n')
+ TEST.write(' self.consumer' + str(idx + 1) + ' = consumer' +
+ str(idx + 1) + '\n')
TEST.write('\n\n')
else:
#
@@ -211,7 +231,8 @@ if len(sys.argv) > 0:
else:
idx = str(idx)
TEST.write(' standalone' + idx + '.open()\n')
- TEST.write(' self.standalone' + idx + ' = standalone' + idx + '\n')
+ TEST.write(' self.standalone' + idx + ' = standalone' +
+ idx + '\n')
TEST.write('\n\n')
#
@@ -221,7 +242,8 @@ if len(sys.argv) > 0:
TEST.write('def topology(request):\n')
TEST.write(' global installation1_prefix\n')
TEST.write(' if installation1_prefix:\n')
- TEST.write(' args_instance[SER_DEPLOYED_DIR] = installation1_prefix\n\n')
+ TEST.write(' args_instance[SER_DEPLOYED_DIR] = ' +
+ 'installation1_prefix\n\n')
if repl_deployment:
#
@@ -231,20 +253,25 @@ if len(sys.argv) > 0:
idx = str(idx + 1)
TEST.write(' # Creating master ' + idx + '...\n')
TEST.write(' master' + idx + ' = DirSrv(verbose=False)\n')
- TEST.write(' args_instance[SER_HOST] = HOST_MASTER_' + idx + '\n')
- TEST.write(' args_instance[SER_PORT] = PORT_MASTER_' + idx + '\n')
- TEST.write(' args_instance[SER_SERVERID_PROP] = SERVERID_MASTER_' + idx + '\n')
- TEST.write(' args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX\n')
+ TEST.write(' args_instance[SER_HOST] = HOST_MASTER_' + idx +
+ '\n')
+ TEST.write(' args_instance[SER_PORT] = PORT_MASTER_' + idx +
+ '\n')
+ TEST.write(' args_instance[SER_SERVERID_PROP] = ' +
+ 'SERVERID_MASTER_' + idx + '\n')
+ TEST.write(' args_instance[SER_CREATION_SUFFIX] = ' +
+ 'DEFAULT_SUFFIX\n')
TEST.write(' args_master = args_instance.copy()\n')
TEST.write(' master' + idx + '.allocate(args_master)\n')
- TEST.write(' instance_master' + idx + ' = master' + idx + '.exists()\n')
+ TEST.write(' instance_master' + idx + ' = master' + idx +
+ '.exists()\n')
TEST.write(' if instance_master' + idx + ':\n')
TEST.write(' master' + idx + '.delete()\n')
TEST.write(' master' + idx + '.create()\n')
TEST.write(' master' + idx + '.open()\n')
- TEST.write(' master' + idx + '.replica.enableReplication(suffix=SUFFIX, ' +
- 'role=REPLICAROLE_MASTER, ' +
- 'replicaId=REPLICAID_MASTER_' + idx + ')\n\n')
+ TEST.write(' master' + idx + '.replica.enableReplication' +
+ '(suffix=SUFFIX, role=REPLICAROLE_MASTER, ' +
+ 'replicaId=REPLICAID_MASTER_' + idx + ')\n\n')
for idx in range(hubs):
idx = str(idx + 1)
@@ -252,37 +279,45 @@ if len(sys.argv) > 0:
TEST.write(' hub' + idx + ' = DirSrv(verbose=False)\n')
TEST.write(' args_instance[SER_HOST] = HOST_HUB_' + idx + '\n')
TEST.write(' args_instance[SER_PORT] = PORT_HUB_' + idx + '\n')
- TEST.write(' args_instance[SER_SERVERID_PROP] = SERVERID_HUB_' + idx + '\n')
- TEST.write(' args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX\n')
+ TEST.write(' args_instance[SER_SERVERID_PROP] = SERVERID_HUB_' +
+ idx + '\n')
+ TEST.write(' args_instance[SER_CREATION_SUFFIX] = ' +
+ 'DEFAULT_SUFFIX\n')
TEST.write(' args_hub = args_instance.copy()\n')
TEST.write(' hub' + idx + '.allocate(args_hub)\n')
- TEST.write(' instance_hub' + idx + ' = hub' + idx + '.exists()\n')
+ TEST.write(' instance_hub' + idx + ' = hub' + idx +
+ '.exists()\n')
TEST.write(' if instance_hub' + idx + ':\n')
TEST.write(' hub' + idx + '.delete()\n')
TEST.write(' hub' + idx + '.create()\n')
TEST.write(' hub' + idx + '.open()\n')
- TEST.write(' hub' + idx + '.replica.enableReplication(suffix=SUFFIX, ' +
- 'role=REPLICAROLE_HUB, ' +
- 'replicaId=REPLICAID_HUB_' + idx + ')\n\n')
+ TEST.write(' hub' + idx + '.replica.enableReplication' +
+ '(suffix=SUFFIX, role=REPLICAROLE_HUB, ' +
+ 'replicaId=REPLICAID_HUB_' + idx + ')\n\n')
for idx in range(consumers):
idx = str(idx + 1)
TEST.write(' # Creating consumer ' + idx + '...\n')
TEST.write(' consumer' + idx + ' = DirSrv(verbose=False)\n')
- TEST.write(' args_instance[SER_HOST] = HOST_CONSUMER_' + idx + '\n')
- TEST.write(' args_instance[SER_PORT] = PORT_CONSUMER_' + idx + '\n')
- TEST.write(' args_instance[SER_SERVERID_PROP] = SERVERID_CONSUMER_' + idx + '\n')
- TEST.write(' args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX\n')
+ TEST.write(' args_instance[SER_HOST] = HOST_CONSUMER_' + idx +
+ '\n')
+ TEST.write(' args_instance[SER_PORT] = PORT_CONSUMER_' + idx +
+ '\n')
+ TEST.write(' args_instance[SER_SERVERID_PROP] = ' +
+ 'SERVERID_CONSUMER_' + idx + '\n')
+ TEST.write(' args_instance[SER_CREATION_SUFFIX] = ' +
+ 'DEFAULT_SUFFIX\n')
TEST.write(' args_consumer = args_instance.copy()\n')
TEST.write(' consumer' + idx + '.allocate(args_consumer)\n')
- TEST.write(' instance_consumer' + idx + ' = consumer' + idx + '.exists()\n')
+ TEST.write(' instance_consumer' + idx + ' = consumer' + idx +
+ '.exists()\n')
TEST.write(' if instance_consumer' + idx + ':\n')
TEST.write(' consumer' + idx + '.delete()\n')
TEST.write(' consumer' + idx + '.create()\n')
TEST.write(' consumer' + idx + '.open()\n')
- TEST.write(' consumer' + idx + '.replica.enableReplication(suffix=SUFFIX, ' +
- 'role=REPLICAROLE_CONSUMER, ' +
- 'replicaId=CONSUMER_REPLICAID)\n\n')
+ TEST.write(' consumer' + idx + '.replica.enableReplication' +
+ '(suffix=SUFFIX, role=REPLICAROLE_CONSUMER, ' +
+ 'replicaId=CONSUMER_REPLICAID)\n\n')
#
# Create the master agreements
@@ -301,39 +336,61 @@ if len(sys.argv) > 0:
if master_idx == idx:
# skip ourselves
continue
- TEST.write(' # Creating agreement from master ' + str(master_idx) + ' to master ' + str(idx) + '\n')
- TEST.write(" properties = {RA_NAME: r'meTo_$host:$port',\n")
- TEST.write(" RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],\n")
- TEST.write(" RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],\n")
- TEST.write(" RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],\n")
- TEST.write(" RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}\n")
- TEST.write(' m' + str(master_idx) + '_m' + str(idx) + '_agmt = master' + str(master_idx) +
+ TEST.write(' # Creating agreement from master ' +
+ str(master_idx) + ' to master ' + str(idx) + '\n')
+ TEST.write(" properties = {RA_NAME: " +
+ "r'meTo_$host:$port',\n")
+ TEST.write(" RA_BINDDN: " +
+ "defaultProperties[REPLICATION_BIND_DN],\n")
+ TEST.write(" RA_BINDPW: " +
+ "defaultProperties[REPLICATION_BIND_PW],\n")
+ TEST.write(" RA_METHOD: " +
+ "defaultProperties[REPLICATION_BIND_METHOD],\n")
+ TEST.write(" RA_TRANSPORT_PROT: " +
+ "defaultProperties[REPLICATION_TRANSPORT]}\n")
+ TEST.write(' m' + str(master_idx) + '_m' + str(idx) +
+ '_agmt = master' + str(master_idx) +
'.agreement.create(suffix=SUFFIX, host=master' +
- str(idx) + '.host, port=master' + str(idx) + '.port, properties=properties)\n')
- TEST.write(' if not m' + str(master_idx) + '_m' + str(idx) + '_agmt:\n')
- TEST.write(' log.fatal("Fail to create a master -> master replica agreement")\n')
+ str(idx) + '.host, port=master' + str(idx) +
+ '.port, properties=properties)\n')
+ TEST.write(' if not m' + str(master_idx) + '_m' + str(idx) +
+ '_agmt:\n')
+ TEST.write(' log.fatal("Fail to create a master -> ' +
+ 'master replica agreement")\n')
TEST.write(' sys.exit(1)\n')
- TEST.write(' log.debug("%s created" % m' + str(master_idx) + '_m' + str(idx) + '_agmt)\n\n')
+ TEST.write(' log.debug("%s created" % m' + str(master_idx) +
+ '_m' + str(idx) + '_agmt)\n\n')
agmt_count += 1
for idx in range(hubs):
idx += 1
#
- # Create agreements from each master to each hub (master -> hub)
+ # Create agmts from each master to each hub (master -> hub)
#
- TEST.write(' # Creating agreement from master ' + str(master_idx) + ' to hub ' + str(idx) + '\n')
- TEST.write(" properties = {RA_NAME: r'meTo_$host:$port',\n")
- TEST.write(" RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],\n")
- TEST.write(" RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],\n")
- TEST.write(" RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],\n")
- TEST.write(" RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}\n")
- TEST.write(' m' + str(master_idx) + '_h' + str(idx) + '_agmt = master' + str(master_idx) +
- '.agreement.create(suffix=SUFFIX, host=hub' +
- str(idx) + '.host, port=hub' + str(idx) + '.port, properties=properties)\n')
- TEST.write(' if not m' + str(master_idx) + '_h' + str(idx) + '_agmt:\n')
- TEST.write(' log.fatal("Fail to create a master -> hub replica agreement")\n')
+ TEST.write(' # Creating agreement from master ' +
+ str(master_idx) + ' to hub ' + str(idx) + '\n')
+ TEST.write(" properties = {RA_NAME: " +
+ "r'meTo_$host:$port',\n")
+ TEST.write(" RA_BINDDN: " +
+ "defaultProperties[REPLICATION_BIND_DN],\n")
+ TEST.write(" RA_BINDPW: " +
+ "defaultProperties[REPLICATION_BIND_PW],\n")
+ TEST.write(" RA_METHOD: " +
+ "defaultProperties[REPLICATION_BIND_METHOD],\n")
+ TEST.write(" RA_TRANSPORT_PROT: " +
+ "defaultProperties[REPLICATION_TRANSPORT]}\n")
+ TEST.write(' m' + str(master_idx) + '_h' + str(idx) +
+ '_agmt = master' + str(master_idx) +
+ '.agreement.create(suffix=SUFFIX, host=hub' +
+ str(idx) + '.host, port=hub' + str(idx) +
+ '.port, properties=properties)\n')
+ TEST.write(' if not m' + str(master_idx) + '_h' + str(idx) +
+ '_agmt:\n')
+ TEST.write(' log.fatal("Fail to create a master -> ' +
+ 'hub replica agreement")\n')
TEST.write(' sys.exit(1)\n')
- TEST.write(' log.debug("%s created" % m' + str(master_idx) + '_h' + str(idx) + '_agmt)\n\n')
+ TEST.write(' log.debug("%s created" % m' + str(master_idx) +
+ '_h' + str(idx) + '_agmt)\n\n')
agmt_count += 1
#
@@ -349,24 +406,35 @@ if len(sys.argv) > 0:
#
# Create agreements from each hub to each consumer
#
- TEST.write(' # Creating agreement from hub ' + str(hub_idx) + ' to consumer ' + str(idx) + '\n')
- TEST.write(" properties = {RA_NAME: r'meTo_$host:$port',\n")
- TEST.write(" RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],\n")
- TEST.write(" RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],\n")
- TEST.write(" RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],\n")
- TEST.write(" RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}\n")
- TEST.write(' h' + str(hub_idx) + '_c' + str(idx) + '_agmt = hub' +
- str(hub_idx) + '.agreement.create(suffix=SUFFIX, host=consumer' +
- str(idx) + '.host, port=consumer' + str(idx) + '.port, properties=properties)\n')
- TEST.write(' if not h' + str(hub_idx) + '_c' + str(idx) + '_agmt:\n')
- TEST.write(' log.fatal("Fail to create a hub -> consumer replica agreement")\n')
+ TEST.write(' # Creating agreement from hub ' + str(hub_idx)
+ + ' to consumer ' + str(idx) + '\n')
+ TEST.write(" properties = {RA_NAME: " +
+ "r'meTo_$host:$port',\n")
+ TEST.write(" RA_BINDDN: " +
+ "defaultProperties[REPLICATION_BIND_DN],\n")
+ TEST.write(" RA_BINDPW: " +
+ "defaultProperties[REPLICATION_BIND_PW],\n")
+ TEST.write(" RA_METHOD: " +
+ "defaultProperties[REPLICATION_BIND_METHOD],\n")
+ TEST.write(" RA_TRANSPORT_PROT: " +
+ "defaultProperties[REPLICATION_TRANSPORT]}\n")
+ TEST.write(' h' + str(hub_idx) + '_c' + str(idx) +
+ '_agmt = hub' + str(hub_idx) +
+ '.agreement.create(suffix=SUFFIX, host=consumer' +
+ str(idx) + '.host, port=consumer' + str(idx) +
+ '.port, properties=properties)\n')
+ TEST.write(' if not h' + str(hub_idx) + '_c' + str(idx) +
+ '_agmt:\n')
+ TEST.write(' log.fatal("Fail to create a hub -> ' +
+ 'consumer replica agreement")\n')
TEST.write(' sys.exit(1)\n')
- TEST.write(' log.debug("%s created" % h' + str(hub_idx) + '_c' + str(idx) + '_agmt)\n\n')
+ TEST.write(' log.debug("%s created" % h' + str(hub_idx) +
+ '_c' + str(idx) + '_agmt)\n\n')
agmt_count += 1
if hubs == 0:
#
- # No Hubs, see if there are any consumers to create agreements to...
+ # No Hubs, see if there are any consumers to create agreements to
#
for idx in range(masters):
master_idx = idx + 1
@@ -378,27 +446,40 @@ if len(sys.argv) > 0:
#
# Create agreements from each master to each consumer
#
- TEST.write(' # Creating agreement from master ' + str(master_idx) +
- ' to consumer ' + str(idx) + '\n')
- TEST.write(" properties = {RA_NAME: r'meTo_$host:$port',\n")
- TEST.write(" RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],\n")
- TEST.write(" RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],\n")
- TEST.write(" RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],\n")
- TEST.write(" RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}\n")
- TEST.write(' m' + str(master_idx) + '_c' + str(idx) + '_agmt = master' + str(master_idx) +
- '.agreement.create(suffix=SUFFIX, host=consumer' +
- str(idx) + '.host, port=consumer' + str(idx) +
- '.port, properties=properties)\n')
- TEST.write(' if not m' + str(master_idx) + '_c' + str(idx) + '_agmt:\n')
- TEST.write(' log.fatal("Fail to create a hub -> consumer replica agreement")\n')
+ TEST.write(' # Creating agreement from master ' +
+ str(master_idx) + ' to consumer ' + str(idx) +
+ '\n')
+ TEST.write(" properties = {RA_NAME: " +
+ "r'meTo_$host:$port',\n")
+ TEST.write(" RA_BINDDN: " +
+ "defaultProperties[REPLICATION_BIND_DN],\n")
+ TEST.write(" RA_BINDPW: " +
+ "defaultProperties[REPLICATION_BIND_PW],\n")
+ TEST.write(" RA_METHOD: " +
+ "defaultProperties[REPLICATION_BIND_METHOD],\n")
+ TEST.write(" RA_TRANSPORT_PROT: " +
+ "defaultProperties[REPLICATION_TRANSPORT]}\n")
+ TEST.write(' m' + str(master_idx) + '_c' + str(idx) +
+ '_agmt = master' + str(master_idx) +
+ '.agreement.create(suffix=SUFFIX, ' +
+ 'host=consumer' + str(idx) +
+ '.host, port=consumer' + str(idx) +
+ '.port, properties=properties)\n')
+ TEST.write(' if not m' + str(master_idx) + '_c' +
+ str(idx) + '_agmt:\n')
+ TEST.write(' log.fatal("Fail to create a hub -> ' +
+ 'consumer replica agreement")\n')
TEST.write(' sys.exit(1)\n')
- TEST.write(' log.debug("%s created" % m' + str(master_idx) + '_c' + str(idx) + '_agmt)\n\n')
+ TEST.write(' log.debug("%s created" % m' +
+ str(master_idx) + '_c' + str(idx) +
+ '_agmt)\n\n')
agmt_count += 1
#
# Add sleep that allows all the agreemnts to get situated
#
- TEST.write(' # Allow the replicas to get situated with the new agreements...\n')
+ TEST.write(' # Allow the replicas to get situated with the new ' +
+ 'agreements...\n')
TEST.write(' time.sleep(5)\n\n')
#
@@ -415,7 +496,8 @@ if len(sys.argv) > 0:
continue
TEST.write(' master1.agreement.init(SUFFIX, HOST_MASTER_' +
str(idx) + ', PORT_MASTER_' + str(idx) + ')\n')
- TEST.write(' master1.waitForReplInit(m1_m' + str(idx) + '_agmt)\n')
+ TEST.write(' master1.waitForReplInit(m1_m' + str(idx) +
+ '_agmt)\n')
# Hubs
consumers_inited = False
@@ -423,23 +505,27 @@ if len(sys.argv) > 0:
idx += 1
TEST.write(' master1.agreement.init(SUFFIX, HOST_HUB_' +
str(idx) + ', PORT_HUB_' + str(idx) + ')\n')
- TEST.write(' master1.waitForReplInit(m1_h' + str(idx) + '_agmt)\n')
+ TEST.write(' master1.waitForReplInit(m1_h' + str(idx) +
+ '_agmt)\n')
for idx in range(consumers):
if consumers_inited:
continue
idx += 1
TEST.write(' hub1.agreement.init(SUFFIX, HOST_CONSUMER_' +
str(idx) + ', PORT_CONSUMER_' + str(idx) + ')\n')
- TEST.write(' hub1.waitForReplInit(h1_c' + str(idx) + '_agmt)\n')
+ TEST.write(' hub1.waitForReplInit(h1_c' + str(idx) +
+ '_agmt)\n')
consumers_inited = True
# Consumers (master -> consumer)
if hubs == 0:
for idx in range(consumers):
idx += 1
- TEST.write(' master1.agreement.init(SUFFIX, HOST_CONSUMER_' +
- str(idx) + ', PORT_CONSUMER_' + str(idx) + ')\n')
- TEST.write(' master1.waitForReplInit(m1_c' + str(idx) + '_agmt)\n')
+ TEST.write(' master1.agreement.init(SUFFIX, ' +
+ 'HOST_CONSUMER_' + str(idx) + ', PORT_CONSUMER_' +
+ str(idx) + ')\n')
+ TEST.write(' master1.waitForReplInit(m1_c' + str(idx) +
+ '_agmt)\n')
TEST.write('\n')
@@ -447,7 +533,7 @@ if len(sys.argv) > 0:
# Write replicaton check
#
if agmt_count > 0:
- # Find the lowest replica type in the deployment(consumer -> master)
+ # Find the lowest replica type (consumer -> master)
if consumers > 0:
replica = 'consumer1'
elif hubs > 0:
@@ -455,7 +541,8 @@ if len(sys.argv) > 0:
else:
replica = 'master2'
TEST.write(' # Check replication is working...\n')
- TEST.write(' if master1.testReplication(DEFAULT_SUFFIX, ' + replica + '):\n')
+ TEST.write(' if master1.testReplication(DEFAULT_SUFFIX, ' +
+ replica + '):\n')
TEST.write(" log.info('Replication is working.')\n")
TEST.write(' else:\n')
TEST.write(" log.fatal('Replication is not working.')\n")
@@ -494,15 +581,22 @@ if len(sys.argv) > 0:
idx = str(idx)
TEST.write(' # Creating standalone instance ' + idx + '...\n')
TEST.write(' standalone' + idx + ' = DirSrv(verbose=False)\n')
- TEST.write(' args_instance[SER_HOST] = HOST_STANDALONE' + idx + '\n')
- TEST.write(' args_instance[SER_PORT] = PORT_STANDALONE' + idx + '\n')
- TEST.write(' args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE' + idx + '\n')
- TEST.write(' args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX\n')
- TEST.write(' args_standalone' + idx + ' = args_instance.copy()\n')
- TEST.write(' standalone' + idx + '.allocate(args_standalone' + idx + ')\n')
+ TEST.write(' args_instance[SER_HOST] = HOST_STANDALONE' +
+ idx + '\n')
+ TEST.write(' args_instance[SER_PORT] = PORT_STANDALONE' +
+ idx + '\n')
+ TEST.write(' args_instance[SER_SERVERID_PROP] = ' +
+ 'SERVERID_STANDALONE' + idx + '\n')
+ TEST.write(' args_instance[SER_CREATION_SUFFIX] = ' +
+ 'DEFAULT_SUFFIX\n')
+ TEST.write(' args_standalone' + idx + ' = args_instance.copy' +
+ '()\n')
+ TEST.write(' standalone' + idx + '.allocate(args_standalone' +
+ idx + ')\n')
# Get the status of the instance and restart it if it exists
- TEST.write(' instance_standalone' + idx + ' = standalone' + idx + '.exists()\n')
+ TEST.write(' instance_standalone' + idx + ' = standalone' +
+ idx + '.exists()\n')
# Remove the instance
TEST.write(' if instance_standalone' + idx + ':\n')
@@ -535,14 +629,18 @@ if len(sys.argv) > 0:
TEST.write('def test_ticket' + ticket + '(topology):\n')
if repl_deployment:
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\n')
+ TEST.write(' To access each DirSrv instance use: ' +
+ 'topology.master1, topology.master2,\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')
+ TEST.write(' please, write additional fixture for that' +
+ '(include ' + 'finalizer).\n')
else:
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(' please, write additional fixture for that' +
+ '(include finalizer).\n')
TEST.write(' """\n\n')
TEST.write(" log.info('Test complete')\n")
TEST.write('\n\n')
@@ -551,7 +649,8 @@ if len(sys.argv) > 0:
TEST.write('def test_' + suite + '_#####(topology):\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(' please, write additional fixture for that(include ' +
+ 'finalizer).\n')
TEST.write(' """\n\n return\n\n\n')
#
@@ -561,7 +660,7 @@ if len(sys.argv) > 0:
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)')
+ TEST.write(' pytest.main("-s %s" % CURRENT_FILE)\n')
#
# Done, close things up
diff --git a/dirsrvtests/tickets/ticket48370_test.py b/dirsrvtests/tickets/ticket48370_test.py
new file mode 100644
index 0000000..f5b1f47
--- /dev/null
+++ b/dirsrvtests/tickets/ticket48370_test.py
@@ -0,0 +1,236 @@
+import os
+import ldap
+import logging
+import pytest
+from lib389 import DirSrv, Entry
+from lib389._constants import *
+from lib389.properties import *
+from lib389.tasks import *
+from lib389.utils import *
+
+logging.getLogger(__name__).setLevel(logging.DEBUG)
+log = logging.getLogger(__name__)
+
+installation1_prefix = None
+
+
+class TopologyStandalone(object):
+ def __init__(self, standalone):
+ standalone.open()
+ self.standalone = standalone
+
+
+(a)pytest.fixture(scope="module")
+def topology(request):
+ global installation1_prefix
+ if installation1_prefix:
+ args_instance[SER_DEPLOYED_DIR] = installation1_prefix
+
+ # Creating standalone instance ...
+ standalone = DirSrv(verbose=False)
+ args_instance[SER_HOST] = HOST_STANDALONE
+ args_instance[SER_PORT] = PORT_STANDALONE
+ args_instance[SER_SERVERID_PROP] = SERVERID_STANDALONE
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_standalone = args_instance.copy()
+ standalone.allocate(args_standalone)
+ instance_standalone = standalone.exists()
+ if instance_standalone:
+ standalone.delete()
+ standalone.create()
+ standalone.open()
+
+ # Delete each instance in the end
+ def fin():
+ standalone.delete()
+ request.addfinalizer(fin)
+
+ # Clear out the tmp dir
+ standalone.clearTmpDir(__file__)
+
+ return TopologyStandalone(standalone)
+
+
+def test_ticket48370(topology):
+ """
+ Deleting attirbute values and readding a value does not properly update
+ the pres index. The values are not actually deleted from the index
+ """
+
+ DN = 'uid=user0099,' + DEFAULT_SUFFIX
+
+ #
+ # Add an entry
+ #
+ topology.standalone.add_s(Entry((DN, {
+ 'objectclass': ['top', 'person',
+ 'organizationalPerson',
+ 'inetorgperson',
+ 'posixAccount'],
+ 'givenname': 'test',
+ 'sn': 'user',
+ 'loginshell': '/bin/bash',
+ 'uidNumber': '10099',
+ 'gidNumber': '10099',
+ 'gecos': 'Test User',
+ 'mail': ['user0099(a)dev.null',
+ 'alias(a)dev.null',
+ 'user0099(a)redhat.com'],
+ 'cn': 'Test User',
+ 'homeDirectory': '/home/user0099',
+ 'uid': 'admin2',
+ 'userpassword': 'password'})))
+
+ #
+ # Perform modify (delete & add mail attributes)
+ #
+ try:
+ topology.standalone.modify_s(DN, [(ldap.MOD_DELETE,
+ 'mail',
+ 'user0099(a)dev.null'),
+ (ldap.MOD_DELETE,
+ 'mail',
+ 'alias(a)dev.null'),
+ (ldap.MOD_ADD,
+ 'mail', 'user0099(a)dev.null')])
+ except ldap.LDAPError as e:
+ log.fatal('Failedto modify user: ' + str(e))
+ assert False
+
+ #
+ # Search using deleted attribute value- no entries should be returned
+ #
+ try:
+ entry = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ 'mail=alias(a)dev.null')
+ if entry:
+ log.fatal('Entry incorrectly returned')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to search for user: ' + str(e))
+ assert False
+
+ #
+ # Search using existing attribute value - the entry should be returned
+ #
+ try:
+ entry = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ 'mail=user0099(a)dev.null')
+ if entry is None:
+ log.fatal('Entry not found, but it should have been')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to search for user: ' + str(e))
+ assert False
+
+ #
+ # Delete the last values
+ #
+ try:
+ topology.standalone.modify_s(DN, [(ldap.MOD_DELETE,
+ 'mail',
+ 'user0099(a)dev.null'),
+ (ldap.MOD_DELETE,
+ 'mail',
+ 'user0099(a)redhat.com')
+ ])
+ except ldap.LDAPError as e:
+ log.fatal('Failed to modify user: ' + str(e))
+ assert False
+
+ #
+ # Search using deleted attribute value - no entries should be returned
+ #
+ try:
+ entry = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ 'mail=user0099(a)redhat.com')
+ if entry:
+ log.fatal('Entry incorrectly returned')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to search for user: ' + str(e))
+ assert False
+
+ #
+ # Make sure presence index is correctly updated - no entries should be
+ # returned
+ #
+ try:
+ entry = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ 'mail=*')
+ if entry:
+ log.fatal('Entry incorrectly returned')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to search for user: ' + str(e))
+ assert False
+
+ #
+ # Now add the attributes back, and lets run a different set of tests with
+ # a different number of attributes
+ #
+ try:
+ topology.standalone.modify_s(DN, [(ldap.MOD_ADD,
+ 'mail',
+ ['user0099(a)dev.null',
+ 'alias(a)dev.null'])])
+ except ldap.LDAPError as e:
+ log.fatal('Failedto modify user: ' + str(e))
+ assert False
+
+ #
+ # Remove and readd some attibutes
+ #
+ try:
+ topology.standalone.modify_s(DN, [(ldap.MOD_DELETE,
+ 'mail',
+ 'alias(a)dev.null'),
+ (ldap.MOD_DELETE,
+ 'mail',
+ 'user0099(a)dev.null'),
+ (ldap.MOD_ADD,
+ 'mail', 'user0099(a)dev.null')])
+ except ldap.LDAPError as e:
+ log.fatal('Failedto modify user: ' + str(e))
+ assert False
+
+ #
+ # Search using deleted attribute value - no entries should be returned
+ #
+ try:
+ entry = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ 'mail=alias(a)dev.null')
+ if entry:
+ log.fatal('Entry incorrectly returned')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to search for user: ' + str(e))
+ assert False
+
+ #
+ # Search using existing attribute value - the entry should be returned
+ #
+ try:
+ entry = topology.standalone.search_s(DEFAULT_SUFFIX,
+ ldap.SCOPE_SUBTREE,
+ 'mail=user0099(a)dev.null')
+ if entry is None:
+ log.fatal('Entry not found, but it should have been')
+ assert False
+ except ldap.LDAPError as e:
+ log.fatal('Failed to search for user: ' + str(e))
+ assert False
+
+ log.info('Test PASSED')
+
+
+if __name__ == '__main__':
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s %s" % CURRENT_FILE)
diff --git a/ldap/servers/slapd/back-ldbm/index.c b/ldap/servers/slapd/back-ldbm/index.c
index 2adf2f8..00e78a7 100644
--- a/ldap/servers/slapd/back-ldbm/index.c
+++ b/ldap/servers/slapd/back-ldbm/index.c
@@ -727,31 +727,24 @@ index_add_mods(
flags = BE_INDEX_DEL|BE_INDEX_PRESENCE|BE_INDEX_EQUALITY;
} else {
flags = BE_INDEX_DEL;
-
- /* If the same value doesn't exist in a subtype, set
- * BE_INDEX_EQUALITY flag so the equality index is
- * removed.
- */
curr_attr = NULL;
slapi_entry_attr_find(olde->ep_entry,
- mods[i]->mod_type, &curr_attr);
+ mods[i]->mod_type,
+ &curr_attr);
if (curr_attr) {
- int found = 0;
for (j = 0; mods_valueArray[j] != NULL; j++ ) {
- if ( slapi_valueset_find(curr_attr, all_vals, mods_valueArray[j])) {
- /* The same value found in evals.
- * We don't touch the equality index. */
- found = 1;
+ if ( !slapi_valueset_find(curr_attr, all_vals, mods_valueArray[j]) ) {
+ /*
+ * If the mod del value is not found in all_vals
+ * we need to update the equality index as the
+ * final value(s) have changed
+ */
+ if (!(flags & BE_INDEX_EQUALITY)) {
+ flags |= BE_INDEX_EQUALITY;
+ }
break;
}
}
- /*
- * to-be-deleted curr_attr does not exist in the
- * new value set evals. So, we can remove it.
- */
- if (!found && !(flags & BE_INDEX_EQUALITY)) {
- flags |= BE_INDEX_EQUALITY;
- }
}
}
8 years, 4 months