diff --git a/test/ucs-test/univention/testing/ucs_samba.py b/test/ucs-test/univention/testing/ucs_samba.py index ab698724ce..d9a60d85e4 100644 --- a/test/ucs-test/univention/testing/ucs_samba.py +++ b/test/ucs-test/univention/testing/ucs_samba.py @@ -160,7 +160,7 @@ def _ldap_replication_complete(): return subprocess.call('/usr/lib/nagios/plugins/check_univention_replication') == 0 -def wait_for_s4connector(timeout=360, delta_t=1, s4cooldown_t=10): +def wait_for_s4connector(timeout=360, delta_t=1, s4cooldown_t=1): ucr = config_registry.ConfigRegistry() ucr.load() diff --git a/test/ucs-test/univention/testing/udm.py b/test/ucs-test/univention/testing/udm.py index 62579a77af..75f8daebaf 100644 --- a/test/ucs-test/univention/testing/udm.py +++ b/test/ucs-test/univention/testing/udm.py @@ -198,7 +198,7 @@ class UCSTestUDM(object): :param list options: A list of UDM option group to set. :param str_or_list set: A list or one single *name=value* property. :param list append: A list of *name=value* properties to add. - :param list remove: A list of *name=value* properties to add. + :param list remove: A list of *name=value* properties to remove. :param boolean remove_referring: Remove other LDAP entries referred by this entry. :param boolean ignore_exists: Ignore error on creation if entry already exists. :param boolean ignore_not_exists: Ignore error on deletion if entry does not exists. @@ -252,14 +252,15 @@ class UCSTestUDM(object): return cmd - def create_object(self, modulename, wait_for_replication=True, check_for_drs_replication=False, **kwargs): + def create_object(self, modulename, wait_for_replication=True, wait_for_s4connector=True, check_for_drs_replication=False, **kwargs): r""" Creates a LDAP object via UDM. Values for UDM properties can be passed via keyword arguments only and have to exactly match UDM property names (case-sensitive!). :param str modulename: name of UDM module (e.g. 'users/user') :param bool wait_for_replication: delay return until Listener has settled. - :param bool check_for_drs_replication: delay return until Samab4 has settled. + :param bool wait_for_s4connector: delay return until S4-Connector has settled. + :param bool check_for_drs_replication: delay return until Samba4 has settled. :param \*\*kwargs: """ if not modulename: @@ -284,16 +285,20 @@ class UCSTestUDM(object): else: raise UCSTestUDM_CreateUDMUnknownDN({'module': modulename, 'kwargs': kwargs, 'stdout': stdout, 'stderr': stderr}) - self.wait_for(modulename, dn, wait_for_replication, wait_for_drs_replication=(wait_for_replication and check_for_drs_replication and ("options" not in kwargs or "kerberos" in kwargs["options"]))) + self.wait_for(modulename, dn, wait_for_replication, wait_for_s4connector, wait_for_drs_replication=(wait_for_replication and check_for_drs_replication and ("options" not in kwargs or "kerberos" in kwargs["options"]))) return dn - def modify_object(self, modulename, wait_for_replication=True, check_for_drs_replication=False, **kwargs): + def modify_object(self, modulename, wait_for_replication=True, wait_for_s4connector=True, check_for_drs_replication=False, **kwargs): """ Modifies a LDAP object via UDM. Values for UDM properties can be passed via keyword arguments only and have to exactly match UDM property names (case-sensitive!). Please note: the object has to be created by create_object otherwise this call will raise an exception! :param str modulename: name of UDM module (e.g. 'users/user') + :param bool wait_for_replication: delay return until Listener has settled. + :param bool wait_for_s4connector: delay return until S4-Connector has settled. + :param bool check_for_drs_replication: delay return until Samba4 has settled. + :param \*\*kwargs: """ if not modulename: raise UCSTestUDM_MissingModulename() @@ -325,10 +330,10 @@ class UCSTestUDM(object): else: raise UCSTestUDM_ModifyUDMUnknownDN({'module': modulename, 'kwargs': kwargs, 'stdout': stdout, 'stderr': stderr}) - self.wait_for(modulename, dn, wait_for_replication, check_for_drs_replication) + self.wait_for(modulename, dn, wait_for_replication, wait_for_s4connector, check_for_drs_replication) return dn - def move_object(self, modulename, wait_for_replication=True, check_for_drs_replication=False, **kwargs): + def move_object(self, modulename, wait_for_replication=True, wait_for_s4connector=True, check_for_drs_replication=False, **kwargs): if not modulename: raise UCSTestUDM_MissingModulename() dn = kwargs.get('dn') @@ -355,10 +360,10 @@ class UCSTestUDM(object): else: raise UCSTestUDM_ModifyUDMUnknownDN({'module': modulename, 'kwargs': kwargs, 'stdout': stdout, 'stderr': stderr}) - self.wait_for(modulename, dn, wait_for_replication, check_for_drs_replication) + self.wait_for(modulename, dn, wait_for_replication, wait_for_s4connector, check_for_drs_replication) return new_dn - def remove_object(self, modulename, wait_for_replication=True, **kwargs): + def remove_object(self, modulename, wait_for_replication=True, wait_for_s4connector=True, check_for_drs_replication=False, **kwargs): if not modulename: raise UCSTestUDM_MissingModulename() dn = kwargs.get('dn') @@ -378,9 +383,9 @@ class UCSTestUDM(object): if dn in self._cleanup.get(modulename, []): self._cleanup[modulename].remove(dn) - self.wait_for(modulename, dn, wait_for_replication) + self.wait_for(modulename, dn, wait_for_replication, wait_for_s4connector, wait_for_drs_replication) - def wait_for(self, modulename, dn, wait_for_replication=True, wait_for_drs_replication=False, wait_for_s4connector=False): + def wait_for(self, modulename, dn, wait_for_replication=True, wait_for_s4connector=True, wait_for_drs_replication=False): conditions = [] if wait_for_replication: conditions.append((utils.ReplicationType.LISTENER, wait_for_replication)) @@ -396,7 +401,13 @@ class UCSTestUDM(object): conditions.append((utils.ReplicationType.DRS, drs_replication)) return utils.wait_for(conditions, verbose=False) - def create_user(self, wait_for_replication=True, check_for_drs_replication=True, **kwargs): # :pylint: disable-msg=W0613 + def wait_for_ng(self, modulename, dn, wait_for_drs_replication=False): + if wait_for_drs_replication and not isinstance(wait_for_drs_replication, basestring): + attr = {'container/ou': 'ou'}.get(modulename, 'cn') + samba4_condition_filter = ldap.filter.filter_format('%s=%s', (attr, ldap.dn.str2dn(dn)[0][0][1],)) + return utils.wait_for_replication_from_master_openldap_to_local_samba(ldap_filter = samba4_condition_filter, verbose=False) + + def create_user(self, wait_for_replication=True, wait_for_s4connector=True, check_for_drs_replication=True, **kwargs): # :pylint: disable-msg=W0613 """ Creates a user via UDM CLI. Values for UDM properties can be passed via keyword arguments only and have to exactly match UDM property names (case-sensitive!). Some properties have default values: @@ -417,9 +428,9 @@ class UCSTestUDM(object): ('firstname', uts.random_name()) )) - return (self.create_object('users/user', wait_for_replication, check_for_drs_replication, **attr), attr['username']) + return (self.create_object('users/user', wait_for_replication, wait_for_s4connector, check_for_drs_replication, **attr), attr['username']) - def create_ldap_user(self, wait_for_replication=True, check_for_drs_replication=False, **kwargs): # :pylint: disable-msg=W0613 + def create_ldap_user(self, wait_for_replication=True, wait_for_s4connector=True, check_for_drs_replication=False, **kwargs): # :pylint: disable-msg=W0613 # check_for_drs_replication=False -> ldap users are not replicated to s4 attr = self._set_module_default_attr(kwargs, ( ('position', 'cn=users,%s' % self.LDAP_BASE), @@ -429,7 +440,7 @@ class UCSTestUDM(object): ('name', uts.random_name()) )) - return (self.create_object('users/ldap', wait_for_replication, check_for_drs_replication, **attr), attr['username']) + return (self.create_object('users/ldap', wait_for_replication, wait_for_s4connector, check_for_drs_replication, **attr), attr['username']) def remove_user(self, username, wait_for_replication=True): """Removes a user object from the ldap given it's username.""" @@ -438,7 +449,7 @@ class UCSTestUDM(object): } self.remove_object('users/user', wait_for_replication, **kwargs) - def create_group(self, wait_for_replication=True, check_for_drs_replication=True, **kwargs): # :pylint: disable-msg=W0613 + def create_group(self, wait_for_replication=True, wait_for_s4connector=True, check_for_drs_replication=True, **kwargs): # :pylint: disable-msg=W0613 """ Creates a group via UDM CLI. Values for UDM properties can be passed via keyword arguments only and have to exactly match UDM property names (case-sensitive!). Some properties have default values: @@ -454,7 +465,7 @@ class UCSTestUDM(object): ('name', uts.random_groupname()) )) - return (self.create_object('groups/group', wait_for_replication, check_for_drs_replication, **attr), attr['name']) + return (self.create_object('groups/group', wait_for_replication, wait_for_s4connector, check_for_drs_replication, **attr), attr['name']) def _set_module_default_attr(self, attributes, defaults): """ diff --git a/test/ucs-test/univention/testing/utils.py b/test/ucs-test/univention/testing/utils.py index 4823479f7a..997bf9f601 100644 --- a/test/ucs-test/univention/testing/utils.py +++ b/test/ucs-test/univention/testing/utils.py @@ -361,9 +361,10 @@ def wait_for_replication_from_master_openldap_to_local_samba(replication_postrun conditions = [(ReplicationType.LISTENER, True)] ucr = univention.config_registry.ConfigRegistry() ucr.load() - if ucr.get('samba4/ldap/base'): + if ucr.get('samba4/ldap/base') and os.path.exists("/var/run/univention-s4-connector"): conditions.append((ReplicationType.S4C_FROM_UCS, ldap_filter)) if ucr.get('server/role') in ('domaincontroller_backup', 'domaincontroller_slave'): + # TODO: Exclude UCS@school Slave PDCs conditions.append((ReplicationType.DRS, ldap_filter)) wait_for(conditions, verbose=True) @@ -375,8 +376,9 @@ def wait_for_replication_from_local_samba_to_local_openldap(replication_postrun= ucr = univention.config_registry.ConfigRegistry() ucr.load() if ucr.get('server/role') in ('domaincontroller_backup', 'domaincontroller_slave'): + # TODO: Exclude UCS@school Slave PDCs conditions.append((ReplicationType.DRS, ldap_filter)) - if ucr.get('samba4/ldap/base'): + if ucr.get('samba4/ldap/base') and os.path.exists("/var/run/univention-s4-connector"): conditions.append((ReplicationType.S4C_FROM_UCS, ldap_filter)) if replication_postrun: conditions.append((ReplicationType.LISTENER, 'postrun'))