This is an automated email from the git hooks/post-receive script.
firstyear pushed a change to branch master in repository lib389.
from 2814d11 Ticket 21 - Missing serverid in dirsrv_test due to incorrect allocation new 813f9e8 Ticket 1 - cn=config comparison
The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference.
Summary of changes: lib389/_mapped_object.py | 2 +- lib389/config.py | 16 +++++ lib389/idm/user.py | 8 ++- lib389/tests/config_compare_test.py | 56 +++++++++++++++ lib389/tests/idm/user_compare_i2_test.py | 67 +++++++++++++++++ lib389/tests/idm/user_compare_m2Repl_test.py | 83 ++++++++++++++++++++++ ...ser_compare_test.py => user_compare_st_test.py} | 0 7 files changed, 230 insertions(+), 2 deletions(-) create mode 100644 lib389/tests/config_compare_test.py create mode 100644 lib389/tests/idm/user_compare_i2_test.py create mode 100644 lib389/tests/idm/user_compare_m2Repl_test.py rename lib389/tests/idm/{user_compare_test.py => user_compare_st_test.py} (100%)
This is an automated email from the git hooks/post-receive script.
firstyear pushed a commit to branch master in repository lib389.
commit 813f9e8cfde0db62ff0063b2d4580e7aeaa22ab8 Author: Ankit Yadav ankitwrk@gmail.com Date: Thu Apr 27 10:36:25 2017 +0530
Ticket 1 - cn=config comparison
Bug Description: Once we have enough plugin and index code, we should be able to use dsconf to compare the state of two instances. This will let us check for differing plugin, index, configuration values between two servers.
Fix Description: This patch has tests for comparing user objects of two different DS instances and master to master replicated DS instances. This patch also includes tests for cn=config comparison of two different DS instances.
https://pagure.io/lib389/issue/1
Author: ankity10
Review by: wibrown (Thank you!) --- lib389/_mapped_object.py | 2 +- lib389/config.py | 16 +++++ lib389/idm/user.py | 8 ++- lib389/tests/config_compare_test.py | 56 +++++++++++++++ lib389/tests/idm/user_compare_i2_test.py | 67 +++++++++++++++++ lib389/tests/idm/user_compare_m2Repl_test.py | 83 ++++++++++++++++++++++ ...ser_compare_test.py => user_compare_st_test.py} | 0 7 files changed, 230 insertions(+), 2 deletions(-)
diff --git a/lib389/_mapped_object.py b/lib389/_mapped_object.py index 49d0448..e2eef9f 100644 --- a/lib389/_mapped_object.py +++ b/lib389/_mapped_object.py @@ -95,7 +95,7 @@ class DSLdapObject(DSLogging): self._rdn_attribute = None self._must_attributes = None # attributes, we don't want to compare - self._compare_exclude = [] + self._compare_exclude = ['entryid']
def __unicode__(self): val = self._dn diff --git a/lib389/config.py b/lib389/config.py index 53c8f48..778c203 100644 --- a/lib389/config.py +++ b/lib389/config.py @@ -35,6 +35,22 @@ class Config(DSLdapObject): self._dn = DN_CONFIG # self._instance = conn # self.log = conn.log + config_compare_exclude = [ + 'nsslapd-ldapifilepath', + 'nsslapd-accesslog', + 'nsslapd-auditfaillog', + 'nsslapd-ldifdir', + 'nsslapd-errorlog', + 'nsslapd-instancedir', + 'nsslapd-lockdir', + 'nsslapd-bakdir', + 'nsslapd-schemadir', + 'nsslapd-auditlog', + 'nsslapd-rootpw', + 'nsslapd-workingdir', + 'nsslapd-certdir' + ] + self._compare_exclude = self._compare_exclude + config_compare_exclude
def _alter_log_enabled(self, service, state): if service not in ('access', 'error', 'audit'): diff --git a/lib389/idm/user.py b/lib389/idm/user.py index aef0ce0..40d3dfd 100644 --- a/lib389/idm/user.py +++ b/lib389/idm/user.py @@ -38,7 +38,13 @@ class UserAccount(DSLdapObject): # Can we get this into core? # 'ldapPublicKey', ] - self._compare_exclude = ['nsuniqueid'] + user_compare_exclude = [ + 'nsUniqueId', + 'modifyTimestamp', + 'createTimestamp', + 'entrydn' + ] + self._compare_exclude = self._compare_exclude + user_compare_exclude self._protected = False
def _validate(self, rdn, properties, basedn): diff --git a/lib389/tests/config_compare_test.py b/lib389/tests/config_compare_test.py new file mode 100644 index 0000000..f0c45cd --- /dev/null +++ b/lib389/tests/config_compare_test.py @@ -0,0 +1,56 @@ +import os +import sys +import time +import ldap +import logging +import pytest +from lib389._constants import * +from lib389.properties import * +from lib389.tasks import * +from lib389.utils import * + +from lib389.idm.group import Groups +from lib389.idm.user import UserAccounts, UserAccount + +from lib389.topologies import topology_st, topology_i2 +from lib389.config import Config + +DEBUGGING = os.getenv('DEBUGGING', False) + +if DEBUGGING is not False: + DEBUGGING = True + +if DEBUGGING: + logging.getLogger(__name__).setLevel(logging.DEBUG) +else: + logging.getLogger(__name__).setLevel(logging.INFO) + +log = logging.getLogger(__name__) + + +def test_config_compare(topology_i2): + """ + Compare test between cn=config of two different Directory Server intance. + """ + if DEBUGGING: + # Add debugging steps(if any)... + pass + + st1_config = topology_i2.ins.get('standalone1').config + st2_config = topology_i2.ins.get('standalone2').config + # 'nsslapd-port' attribute is expected to be same in cn=config comparison, + # but they are different in our testing environment + # as we are using 2 DS instances running, both running simultaneuosly. + # Hence explicitly adding 'nsslapd-port' to compare_exclude. + st1_config._compare_exclude.append('nsslapd-port') + st2_config._compare_exclude.append('nsslapd-port') + + assert(Config.compare(st1_config, st2_config) == True) + 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/lib389/tests/idm/user_compare_i2_test.py b/lib389/tests/idm/user_compare_i2_test.py new file mode 100644 index 0000000..c0c2004 --- /dev/null +++ b/lib389/tests/idm/user_compare_i2_test.py @@ -0,0 +1,67 @@ +import os +import sys +import time +import ldap +import logging +import pytest +from lib389._constants import * +from lib389.properties import * +from lib389.tasks import * +from lib389.utils import * + +from lib389.idm.group import Groups +from lib389.idm.user import UserAccounts, UserAccount + +from lib389.topologies import topology_i2 + +DEBUGGING = os.getenv('DEBUGGING', False) + +if DEBUGGING is not False: + DEBUGGING = True + +if DEBUGGING: + logging.getLogger(__name__).setLevel(logging.DEBUG) +else: + logging.getLogger(__name__).setLevel(logging.INFO) + +log = logging.getLogger(__name__) + + +def test_user_compare_i2(topology_i2): + """ + Compare test between users of two different Directory Server intances. + + """ + if DEBUGGING: + # Add debugging steps(if any)... + pass + + st1_users = UserAccounts(topology_i2.ins.get('standalone1'), DEFAULT_SUFFIX) + st2_users = UserAccounts(topology_i2.ins.get('standalone2'), DEFAULT_SUFFIX) + + # Create user + user_properties = { + 'uid': 'testuser', + 'cn': 'testuser', + 'sn': 'user', + 'uidNumber': '1000', + 'gidNumber': '2000', + 'homeDirectory': '/home/testuser' + } + + st1_users.create(properties=user_properties) + st1_testuser = st1_users.get('testuser') + + st2_users.create(properties=user_properties) + st2_testuser = st2_users.get('testuser') + + assert(UserAccount.compare(st1_testuser, st2_testuser) == True) + + 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/lib389/tests/idm/user_compare_m2Repl_test.py b/lib389/tests/idm/user_compare_m2Repl_test.py new file mode 100644 index 0000000..8e7b799 --- /dev/null +++ b/lib389/tests/idm/user_compare_m2Repl_test.py @@ -0,0 +1,83 @@ +import os +import sys +import time +import ldap +import logging +import pytest +import time +from lib389._constants import * +from lib389.properties import * +from lib389.tasks import * +from lib389.utils import * + +from lib389.idm.user import UserAccounts, UserAccount + +from lib389.topologies import topology_m2 + +DEBUGGING = os.getenv('DEBUGGING', False) + +if DEBUGGING is not False: + DEBUGGING = True + +if DEBUGGING: + logging.getLogger(__name__).setLevel(logging.DEBUG) +else: + logging.getLogger(__name__).setLevel(logging.INFO) + +log = logging.getLogger(__name__) + + +def test_user_compare_m2Repl(topology_m2): + """ + User compare test between users of master to master replicaton topology. + """ + if DEBUGGING: + # Add debugging steps(if any)... + pass + + m1 = topology_m2.ms.get('master1') + m2 = topology_m2.ms.get('master2') + + m1_m2_agmtdn = topology_m2.ms.get("master1_agmts").get("m1_m2") + + m1_users = UserAccounts(m1, DEFAULT_SUFFIX) + m2_users = UserAccounts(m2, DEFAULT_SUFFIX) + + # Create 1st user + user1_properties = { + 'uid': 'testuser', + 'cn': 'testuser', + 'sn': 'user', + 'uidNumber': '1000', + 'gidNumber': '2000', + 'homeDirectory': '/home/testuser' + } + + m1_users.create(properties=user1_properties) + m1_testuser = m1_users.get('testuser') + + log.info("Waiting for completion of replicaation.....") + # wait for replication to complete + m1.startReplication(m1_m2_agmtdn) + + m1_ruv = m1.replica.ruv(DEFAULT_SUFFIX) + m2_ruv = m2.replica.ruv(DEFAULT_SUFFIX) + + log.debug("m1 ruv : " + str(m1_ruv)) + log.debug("m2 ruv : " + str(m2_ruv)) + log.debug("RUV diffs: " + str(m1_ruv.getdiffs(m2_ruv))) + + # ruv comparison, if replication is complete then ruv's should be same + assert(m1_ruv == m2_ruv) + log.info("Replication completed") + m2_testuser = m2_users.get('testuser') + + assert(UserAccount.compare(m1_testuser, m2_testuser) == True) + 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/lib389/tests/idm/user_compare_test.py b/lib389/tests/idm/user_compare_st_test.py similarity index 100% rename from lib389/tests/idm/user_compare_test.py rename to lib389/tests/idm/user_compare_st_test.py
389-commits@lists.fedoraproject.org