diff --git a/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/44replication_binary b/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/44replication_binary index 6cf967a..71d6b5b 100755 --- a/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/44replication_binary +++ b/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/44replication_binary @@ -72,7 +72,7 @@ do --set fax-number='+1-555-234' --set fax-number='+1-555-432' \ --set roomNumber=1 \ --set departmentNumber=1 \ - --set street="Mayr Somerville Str. 1" \ + --set street="Mary Somerville Str. 1" \ --set postcode="28359" \ --set city="Bremen" \ --set homeTelephoneNumber='+1-555-345' --set homeTelephoneNumber='+1-555-543' \ diff --git a/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/45replication_modrdn b/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/45replication_modrdn index 656d82c..3407643 100755 --- a/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/45replication_modrdn +++ b/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/45replication_modrdn @@ -14,6 +14,8 @@ ## bugs: ## - 33495 ## exposure: dangerous +## logfiles: +## - /var/log/univention/listener.log from univention.testing.strings import random_name from univention.testing.utils import wait_for_replication, stop_listener, start_listener @@ -85,7 +87,7 @@ for consider_listener in [False,True]: wait_for_replication() utils.verify_ldap_object(computer_new) utils.verify_ldap_object(computer, should_exist=False) - + check_listener_stop(consider_listener) name = computer_name+random_name(4) # make name uniq print '\n***** Move twice *****' diff --git a/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/46replication_modrdn_local_modification b/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/46replication_modrdn_local_modification index 75a3d40..1694625 100755 --- a/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/46replication_modrdn_local_modification +++ b/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/46replication_modrdn_local_modification @@ -13,6 +13,8 @@ ## bugs: ## - 33495 ## exposure: dangerous +## logfiles: +## - /var/log/univention/listener.log from univention.testing.strings import random_name from univention.testing.utils import wait_for_replication, stop_listener, start_listener @@ -23,6 +25,7 @@ import os import ldap import re import sys +from ldap_utils import get_rootpw, get_entryUUID success = True @@ -47,22 +50,7 @@ addlist_subobject = [ ('univentionObjectType', ['container/cn']), ] -def get_entryUUID(lo, dn): - result = lo.search_s(base=dn, scope=ldap.SCOPE_BASE, attrlist=['*', '+']) - print 'DN: %s\n%s' % (dn, result) - return result[0][1].get('entryUUID')[0] - -def get_rootpw(): - pwd='' - f = open('/etc/ldap/rootpw.conf', 'r') - rootdn_pattern=re.compile('^rootpw[ \t]+"([^"]+)"') - for line in f.readlines(): - line=line[0:-1] - if rootdn_pattern.match(line): - pwd = rootdn_pattern.findall(line)[0] - break - f.close() - return pwd + # create computer udm = udm_test.UCSTestUDM() @@ -115,7 +103,7 @@ if not found_backup_container: if not found_backup_subcontainer: print 'ERROR: Backup of subcontainer with UUID %s was not found' % subcontainer_UUID success = False - + udm.cleanup() wait_for_replication() diff --git a/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/47replication_modrdn_local_different_entryuuid b/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/47replication_modrdn_local_different_entryuuid index a8d7d05..a54274d 100755 --- a/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/47replication_modrdn_local_different_entryuuid +++ b/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/47replication_modrdn_local_different_entryuuid @@ -13,6 +13,8 @@ ## bugs: ## - 33495 ## exposure: dangerous +## logfiles: +## - /var/log/univention/listener.log from univention.testing.strings import random_name from univention.testing.utils import wait_for_replication, stop_listener, start_listener @@ -24,6 +26,7 @@ import os import ldap import re import sys +from ldap_utils import get_rootpw, get_entryUUID success = True @@ -38,22 +41,6 @@ modlist = [ (ldap.MOD_REPLACE, 'entryUUID', '76944348-ea2e-1032-95ad-000000000000') ] -def get_entryUUID(lo, dn): - result = lo.search_s(base=dn, scope=ldap.SCOPE_BASE, attrlist=['*', '+']) - print 'DN: %s\n%s' % (dn, result) - return result[0][1].get('entryUUID')[0] - -def get_rootpw(): - pwd='' - f = open('/etc/ldap/rootpw.conf', 'r') - rootdn_pattern=re.compile('^rootpw[ \t]+"([^"]+)"') - for line in f.readlines(): - line=line[0:-1] - if rootdn_pattern.match(line): - pwd = rootdn_pattern.findall(line)[0] - break - f.close() - return pwd rootpw = get_rootpw() lo_local = ldap.open('127.0.0.1', 7389) diff --git a/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/48replication_listener_cache_up_to_date_check b/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/48replication_listener_cache_up_to_date_check index be22f95..65f691e 100755 --- a/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/48replication_listener_cache_up_to_date_check +++ b/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/48replication_listener_cache_up_to_date_check @@ -12,6 +12,8 @@ ## - univention-directory-manager-tools ## - ldap-utils ## exposure: dangerous +## logfiles: +## - /var/log/univention/listener.log . "$TESTLIBPATH/base.sh" || exit 137 . "$TESTLIBPATH/container.sh" || exit 137 @@ -21,17 +23,17 @@ get_description () { - containername="$1" + local containername="$1" univention-ldapsearch -b "cn=$containername,cn=groups,$ldap_base" -LLL description | sed -ne 's|^description: ||p' } set_description () { - containername="$1" - description="$2" + local containername="$1" + local description="$2" - update_pwd="$(cat /etc/ldap/rootpw.conf | sed -e 's|^rootpw "||;s|"$||')" + local update_pwd="$(sed -e 's|^rootpw "||;s|"$||' >"$password_file" - univention-ssh "$password_file" root@$(ucr get ldap/master) /usr/sbin/univention-replicate-one --dn "cn=$containername,cn=groups,$ldap_base" + ucr get tests/domainadmin/pwd >"$password_file" + univention-ssh "$password_file" "root@${ldap_master}" /usr/sbin/univention-replicate-one --dn "cn=$containername,cn=groups,$ldap_base" + rm "$password_file" wait_for_replication } check_description () { - containername="$1" - expected_value="$2" + local containername="$1" + local expected_value="$2" - description="$(get_description "$containername")" + local description="$(get_description "$containername")" if [ "$description" != "$expected_value" ]; then echo "Local description is wrong. Value: $description; Expected value: $expected_value" fail_test 110 @@ -83,6 +86,4 @@ check_description "$containername" "test1" container_remove "cn=$containername,cn=groups,$ldap_base" wait_for_replication -rm "$password_file" - exit $RETVAL diff --git a/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/49replication_modrdn_with_previous_modification b/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/49replication_modrdn_with_previous_modification index 0cbc6a7..2a00302 100755 --- a/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/49replication_modrdn_with_previous_modification +++ b/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/49replication_modrdn_with_previous_modification @@ -25,6 +25,7 @@ import os import ldap import re import sys +from ldap_utils import get_entryUUID success = True @@ -32,11 +33,6 @@ ucr = ConfigRegistry() ucr.load() -def get_entryUUID(lo, dn): - result = lo.search(base=dn, scope=ldap.SCOPE_BASE, attr=['*', '+']) - print 'DN: %s\n%s' % (dn, result) - return result[0][1].get('entryUUID')[0] - def create_listener_module_for_computer(computer_name): filename = '/usr/lib/univention-directory-listener/system/%s-test.py' % (computer_name) fd = open(filename, 'w') diff --git a/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/ldap_utils.py b/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/ldap_utils.py new file mode 100644 index 0000000..cd53c57 --- /dev/null +++ b/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/ldap_utils.py @@ -0,0 +1,54 @@ +#!/usr/bin/python2.6 +# -*- coding: utf-8 -*- +# +# Copyright 2014 Univention GmbH +# +# http://www.univention.de/ +# +# All rights reserved. +# +# The source code of this program is made available +# under the terms of the GNU Affero General Public License version 3 +# (GNU AGPL V3) as published by the Free Software Foundation. +# +# Binary versions of this program provided by Univention to you as +# well as other copyrighted, protected or trademarked materials like +# Logos, graphics, fonts, specific documentations and configurations, +# cryptographic keys etc. are subject to a license agreement between +# you and Univention and not subject to the GNU AGPL V3. +# +# In the case you use this program under the terms of the GNU AGPL V3, +# the program is provided in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public +# License with the Debian GNU/Linux or Univention distribution in file +# /usr/share/common-licenses/AGPL-3; if not, see +# . + +import re +import ldap + +ROOTDN_PATTERN = re.compile('^rootpw[ \t]+"([^"]+)"') + + +def get_rootpw(): + """ + Retrieve password for cn=update,$ldap_base. + """ + with open('/etc/ldap/rootpw.conf', 'r') as f: + for line in f: + match = ROOTDN_PATTERN.match(line.rstrip()) + if match: + return match.group(1) + + +def get_entryUUID(lo, dn): + """ + Retrieve entryDN of LDAP object as specific distinguished name. + """ + result = lo.search_s(base=dn, scope=ldap.SCOPE_BASE, attrlist=['entryUUID']) + print 'DN: %s\n%s' % (dn, result) + return result[0][1].get('entryUUID')[0] diff --git a/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/60_umc/05_get_client_ip_address b/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/60_umc/05_get_client_ip_address old mode 100644 new mode 100755 diff --git a/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/univention/testing/data.py b/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/univention/testing/data.py index a941191..bcbae9f 100644 --- a/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/univention/testing/data.py +++ b/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/univention/testing/data.py @@ -40,6 +40,7 @@ RE_ILLEGAL_XML = re.compile(u'[%s]' % u''.join((u'%s-%s' % \ (unichr(low), unichr(high)) for (low, high) in ILLEGAL_XML_UNICHR if low < sys.maxunicode))) + class TestEnvironment(object): """Test environment for running test cases. @@ -156,7 +157,7 @@ class _TestReader(object): # pylint: disable-msg=R0903 while line: self.digest.update(line) line = self.stream.readline(size) - + class Verdict(object): """ @@ -493,6 +494,7 @@ class TestCase(object): self.description = None self.bugs = set() self.otrs = set() + self.logfiles = set() def load(self, filename): """ @@ -525,6 +527,7 @@ class TestCase(object): self.description = header.get('desc', '').strip() self.bugs = set(header.get('bugs', [])) self.otrs = set(header.get('otrs', [])) + self.logfiles = set(header.get('logfiles', [])) self.versions = CheckVersion(header.get('versions', {})) self.tags = CheckTags(header.get('tags', [])) self.roles = CheckRoles(header.get('roles', []), @@ -626,6 +629,13 @@ class TestCase(object): dirname = os.path.dirname(self.filename) cmd = [self.exe.filename, base] + self.args + logfiles = {} + for filename in self.logfiles: + try: + logfiles[filename] = open(filename, 'rb') + except EnvironmentError: + TestCase.logger.warn('Missing logfile %s' % (filename,)) + time_start = time() # Protect wrapper from Ctrl-C as long as test case is running @@ -638,6 +648,8 @@ class TestCase(object): def prepare_child(): """Setup child process.""" signal.signal(signal.SIGINT, signal.SIG_IGN) + for logfile in logfiles.values(): + logfile.close() try: TestCase.logger.debug('Running %r using %s in %s' % \ @@ -681,6 +693,19 @@ class TestCase(object): time_end = time() + for filename in self.logfiles: + if filename in logfiles: + continue + try: + logfiles[filename] = open(filename, 'rb') + except EnvironmentError: + continue + for filename, logfile in logfiles.iteritems(): + base = os.path.basename(filename) + content = logfile.read() + TestCase._attach(result, base, content) + logfile.close() + result.duration = int(time_end * 1000.0 - time_start * 1000.0) TestCase.logger.info('Test %r using %s in %s returned %s in %s ms' % \ (cmd, self.exe, dirname, result.result, result.duration)) diff --git a/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/univention/testing/format/junit.py b/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/univention/testing/format/junit.py index 0861e79..4d0e703 100644 --- a/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/univention/testing/format/junit.py +++ b/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/univention/testing/format/junit.py @@ -149,8 +149,23 @@ class Junit(TestFormatInterface): xml.endDocument() finally: f_report.close() + self.save_artifacts(result) super(Junit, self).end_test(result) + def save_artifacts(self, result): + for (name, (mime, content)) in result.artifacts.iteritems(): + if name in ('stdout', 'stderr', 'check'): + continue + filename = os.path.join(self.outdir, result.case.uid, name) + dirname = os.path.dirname(filename) + try: + os.makedirs(dirname) + except OSError, ex: + if ex.errno != errno.EEXIST: + raise + with open(filename, 'wb') as artifact_file: + artifact_file.write(content) + def format(self, result): """ >>> from univention.testing.data import TestCase, TestEnvironment, \