View | Details | Raw Unified | Return to bug 35351
Collapse All | Expand All

(-)a/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/44replication_binary (-1 / +1 lines)
 Lines 72-78   do Link Here 
72
			--set fax-number='+1-555-234' --set fax-number='+1-555-432' \
72
			--set fax-number='+1-555-234' --set fax-number='+1-555-432' \
73
			--set roomNumber=1 \
73
			--set roomNumber=1 \
74
			--set departmentNumber=1 \
74
			--set departmentNumber=1 \
75
			--set street="Mayr Somerville Str. 1" \
75
			--set street="Mary Somerville Str. 1" \
76
			--set postcode="28359" \
76
			--set postcode="28359" \
77
			--set city="Bremen" \
77
			--set city="Bremen" \
78
			--set homeTelephoneNumber='+1-555-345' --set homeTelephoneNumber='+1-555-543' \
78
			--set homeTelephoneNumber='+1-555-345' --set homeTelephoneNumber='+1-555-543' \
(-)a/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/45replication_modrdn (-1 / +3 lines)
 Lines 14-19    Link Here 
14
## bugs:
14
## bugs:
15
##  - 33495
15
##  - 33495
16
## exposure: dangerous
16
## exposure: dangerous
17
## logfiles:
18
##  - /var/log/univention/listener.log
17
19
18
from univention.testing.strings import random_name
20
from univention.testing.strings import random_name
19
from univention.testing.utils import wait_for_replication, stop_listener, start_listener
21
from univention.testing.utils import wait_for_replication, stop_listener, start_listener
 Lines 85-91   for consider_listener in [False,True]: Link Here 
85
			wait_for_replication()
87
			wait_for_replication()
86
			utils.verify_ldap_object(computer_new)
88
			utils.verify_ldap_object(computer_new)
87
			utils.verify_ldap_object(computer, should_exist=False)
89
			utils.verify_ldap_object(computer, should_exist=False)
88
			
90
89
			check_listener_stop(consider_listener)
91
			check_listener_stop(consider_listener)
90
			name = computer_name+random_name(4) # make name uniq
92
			name = computer_name+random_name(4) # make name uniq
91
			print '\n***** Move twice *****'
93
			print '\n***** Move twice *****'
(-)a/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/46replication_modrdn_local_modification (-17 / +5 lines)
 Lines 13-18    Link Here 
13
## bugs:
13
## bugs:
14
##  - 33495
14
##  - 33495
15
## exposure: dangerous
15
## exposure: dangerous
16
## logfiles:
17
##  - /var/log/univention/listener.log
16
18
17
from univention.testing.strings import random_name
19
from univention.testing.strings import random_name
18
from univention.testing.utils import wait_for_replication, stop_listener, start_listener
20
from univention.testing.utils import wait_for_replication, stop_listener, start_listener
 Lines 23-28   import os Link Here 
23
import ldap
25
import ldap
24
import re
26
import re
25
import sys
27
import sys
28
from ldap_utils import get_rootpw, get_entryUUID
26
29
27
success = True
30
success = True
28
31
 Lines 47-68   addlist_subobject = [ Link Here 
47
	('univentionObjectType', ['container/cn']),
50
	('univentionObjectType', ['container/cn']),
48
]
51
]
49
52
50
def get_entryUUID(lo, dn):
53
51
	result = lo.search_s(base=dn, scope=ldap.SCOPE_BASE, attrlist=['*', '+'])
52
	print 'DN: %s\n%s' % (dn, result)
53
	return result[0][1].get('entryUUID')[0]
54
55
def get_rootpw():
56
	pwd=''
57
	f = open('/etc/ldap/rootpw.conf', 'r')
58
	rootdn_pattern=re.compile('^rootpw[ \t]+"([^"]+)"')
59
	for line in f.readlines():
60
		line=line[0:-1]
61
		if rootdn_pattern.match(line):
62
			pwd = rootdn_pattern.findall(line)[0]
63
			break
64
	f.close()
65
	return pwd
66
54
67
# create computer
55
# create computer
68
udm = udm_test.UCSTestUDM()
56
udm = udm_test.UCSTestUDM()
 Lines 115-121   if not found_backup_container: Link Here 
115
if not found_backup_subcontainer:
103
if not found_backup_subcontainer:
116
	print 'ERROR: Backup of subcontainer with UUID %s was not found' % subcontainer_UUID
104
	print 'ERROR: Backup of subcontainer with UUID %s was not found' % subcontainer_UUID
117
	success = False
105
	success = False
118
		
106
119
107
120
udm.cleanup()
108
udm.cleanup()
121
wait_for_replication()
109
wait_for_replication()
(-)a/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/47replication_modrdn_local_different_entryuuid (-16 / +3 lines)
 Lines 13-18    Link Here 
13
## bugs:
13
## bugs:
14
##  - 33495
14
##  - 33495
15
## exposure: dangerous
15
## exposure: dangerous
16
## logfiles:
17
##  - /var/log/univention/listener.log
16
18
17
from univention.testing.strings import random_name
19
from univention.testing.strings import random_name
18
from univention.testing.utils import wait_for_replication, stop_listener, start_listener
20
from univention.testing.utils import wait_for_replication, stop_listener, start_listener
 Lines 24-29   import os Link Here 
24
import ldap
26
import ldap
25
import re
27
import re
26
import sys
28
import sys
29
from ldap_utils import get_rootpw, get_entryUUID
27
30
28
success = True
31
success = True
29
32
 Lines 38-59   modlist = [ Link Here 
38
	(ldap.MOD_REPLACE, 'entryUUID', '76944348-ea2e-1032-95ad-000000000000')
41
	(ldap.MOD_REPLACE, 'entryUUID', '76944348-ea2e-1032-95ad-000000000000')
39
]
42
]
40
43
41
def get_entryUUID(lo, dn):
42
	result = lo.search_s(base=dn, scope=ldap.SCOPE_BASE, attrlist=['*', '+'])
43
	print 'DN: %s\n%s' % (dn, result)
44
	return result[0][1].get('entryUUID')[0]
45
46
def get_rootpw():
47
	pwd=''
48
	f = open('/etc/ldap/rootpw.conf', 'r')
49
	rootdn_pattern=re.compile('^rootpw[ \t]+"([^"]+)"')
50
	for line in f.readlines():
51
		line=line[0:-1]
52
		if rootdn_pattern.match(line):
53
			pwd = rootdn_pattern.findall(line)[0]
54
			break
55
	f.close()
56
	return pwd
57
44
58
rootpw = get_rootpw()
45
rootpw = get_rootpw()
59
lo_local = ldap.open('127.0.0.1', 7389)
46
lo_local = ldap.open('127.0.0.1', 7389)
(-)a/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/48replication_listener_cache_up_to_date_check (-12 / +13 lines)
 Lines 12-17    Link Here 
12
##  - univention-directory-manager-tools
12
##  - univention-directory-manager-tools
13
##  - ldap-utils
13
##  - ldap-utils
14
## exposure: dangerous
14
## exposure: dangerous
15
## logfiles:
16
##  - /var/log/univention/listener.log
15
17
16
. "$TESTLIBPATH/base.sh" || exit 137
18
. "$TESTLIBPATH/base.sh" || exit 137
17
. "$TESTLIBPATH/container.sh" || exit 137
19
. "$TESTLIBPATH/container.sh" || exit 137
 Lines 21-37    Link Here 
21
23
22
get_description ()
24
get_description ()
23
{
25
{
24
	containername="$1"
26
	local containername="$1"
25
27
26
	univention-ldapsearch -b "cn=$containername,cn=groups,$ldap_base" -LLL description  | sed -ne 's|^description: ||p'
28
	univention-ldapsearch -b "cn=$containername,cn=groups,$ldap_base" -LLL description  | sed -ne 's|^description: ||p'
27
}
29
}
28
30
29
set_description ()
31
set_description ()
30
{
32
{
31
	containername="$1"
33
	local containername="$1"
32
	description="$2"
34
	local description="$2"
33
35
34
	update_pwd="$(cat /etc/ldap/rootpw.conf  | sed -e 's|^rootpw "||;s|"$||')"
36
	local update_pwd="$(sed -e 's|^rootpw "||;s|"$||' </etc/ldap/rootpw.conf)"
35
	ldapmodify -x -h "$hostname.$domainname" -p "$ldap_server_port" -D "cn=update,$ldap_base" -w "$update_pwd" <<EOF
37
	ldapmodify -x -h "$hostname.$domainname" -p "$ldap_server_port" -D "cn=update,$ldap_base" -w "$update_pwd" <<EOF
36
dn: cn=$containername,cn=groups,$ldap_base
38
dn: cn=$containername,cn=groups,$ldap_base
37
changetype: modify
39
changetype: modify
 Lines 44-64   EOF Link Here 
44
46
45
call_replicate_one ()
47
call_replicate_one ()
46
{
48
{
47
	containername="$1"
49
	local containername="$1" password_file
48
50
49
	password_file="$(mktemp)"
51
	password_file="$(mktemp)"
50
	echo "$(ucr get tests/domainadmin/pwd)" >>"$password_file"
52
	ucr get tests/domainadmin/pwd >"$password_file"
51
	univention-ssh "$password_file" root@$(ucr get ldap/master) /usr/sbin/univention-replicate-one --dn "cn=$containername,cn=groups,$ldap_base"
53
	univention-ssh "$password_file" "root@${ldap_master}" /usr/sbin/univention-replicate-one --dn "cn=$containername,cn=groups,$ldap_base"
54
	rm "$password_file"
52
55
53
	wait_for_replication
56
	wait_for_replication
54
}
57
}
55
58
56
check_description ()
59
check_description ()
57
{
60
{
58
	containername="$1"
61
	local containername="$1"
59
	expected_value="$2"
62
	local expected_value="$2"
60
63
61
	description="$(get_description "$containername")"
64
	local description="$(get_description "$containername")"
62
	if [ "$description" != "$expected_value" ]; then
65
	if [ "$description" != "$expected_value" ]; then
63
		echo "Local description is wrong. Value: $description; Expected value: $expected_value"
66
		echo "Local description is wrong. Value: $description; Expected value: $expected_value"
64
		fail_test 110
67
		fail_test 110
 Lines 83-88   check_description "$containername" "test1" Link Here 
83
container_remove "cn=$containername,cn=groups,$ldap_base"
86
container_remove "cn=$containername,cn=groups,$ldap_base"
84
wait_for_replication
87
wait_for_replication
85
88
86
rm "$password_file"
87
88
exit $RETVAL
89
exit $RETVAL
(-)a/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/49replication_modrdn_with_previous_modification (-5 / +1 lines)
 Lines 25-30   import os Link Here 
25
import ldap
25
import ldap
26
import re
26
import re
27
import sys
27
import sys
28
from ldap_utils import get_entryUUID
28
29
29
success = True
30
success = True
30
31
 Lines 32-42   ucr = ConfigRegistry() Link Here 
32
ucr.load()
33
ucr.load()
33
34
34
35
35
def get_entryUUID(lo, dn):
36
	result = lo.search(base=dn, scope=ldap.SCOPE_BASE, attr=['*', '+'])
37
	print 'DN: %s\n%s' % (dn, result)
38
	return result[0][1].get('entryUUID')[0]
39
40
def create_listener_module_for_computer(computer_name):
36
def create_listener_module_for_computer(computer_name):
41
	filename = '/usr/lib/univention-directory-listener/system/%s-test.py' % (computer_name)
37
	filename = '/usr/lib/univention-directory-listener/system/%s-test.py' % (computer_name)
42
	fd = open(filename, 'w')
38
	fd = open(filename, 'w')
(-)a/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/tests/10_ldap/ldap_utils.py (+54 lines)
Line 0    Link Here 
1
#!/usr/bin/python2.6
2
# -*- coding: utf-8 -*-
3
#
4
# Copyright 2014 Univention GmbH
5
#
6
# http://www.univention.de/
7
#
8
# All rights reserved.
9
#
10
# The source code of this program is made available
11
# under the terms of the GNU Affero General Public License version 3
12
# (GNU AGPL V3) as published by the Free Software Foundation.
13
#
14
# Binary versions of this program provided by Univention to you as
15
# well as other copyrighted, protected or trademarked materials like
16
# Logos, graphics, fonts, specific documentations and configurations,
17
# cryptographic keys etc. are subject to a license agreement between
18
# you and Univention and not subject to the GNU AGPL V3.
19
#
20
# In the case you use this program under the terms of the GNU AGPL V3,
21
# the program is provided in the hope that it will be useful,
22
# but WITHOUT ANY WARRANTY; without even the implied warranty of
23
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
# GNU Affero General Public License for more details.
25
#
26
# You should have received a copy of the GNU Affero General Public
27
# License with the Debian GNU/Linux or Univention distribution in file
28
# /usr/share/common-licenses/AGPL-3; if not, see
29
# <http://www.gnu.org/licenses/>.
30
31
import re
32
import ldap
33
34
ROOTDN_PATTERN = re.compile('^rootpw[ \t]+"([^"]+)"')
35
36
37
def get_rootpw():
38
	"""
39
	Retrieve password for cn=update,$ldap_base.
40
	"""
41
	with open('/etc/ldap/rootpw.conf', 'r') as f:
42
		for line in f:
43
			match = ROOTDN_PATTERN.match(line.rstrip())
44
			if match:
45
				return match.group(1)
46
47
48
def get_entryUUID(lo, dn):
49
	"""
50
	Retrieve entryDN of LDAP object as specific distinguished name.
51
	"""
52
	result = lo.search_s(base=dn, scope=ldap.SCOPE_BASE, attrlist=['entryUUID'])
53
	print 'DN: %s\n%s' % (dn, result)
54
	return result[0][1].get('entryUUID')[0]
(-)a/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/univention/testing/data.py (-1 / +26 lines)
 Lines 40-45   RE_ILLEGAL_XML = re.compile(u'[%s]' % u''.join((u'%s-%s' % \ Link Here 
40
		(unichr(low), unichr(high)) for (low, high) in ILLEGAL_XML_UNICHR
40
		(unichr(low), unichr(high)) for (low, high) in ILLEGAL_XML_UNICHR
41
		if low < sys.maxunicode)))
41
		if low < sys.maxunicode)))
42
42
43
43
class TestEnvironment(object):
44
class TestEnvironment(object):
44
	"""Test environment for running test cases.
45
	"""Test environment for running test cases.
45
46
 Lines 156-162   class _TestReader(object): # pylint: disable-msg=R0903 Link Here 
156
				while line:
157
				while line:
157
					self.digest.update(line)
158
					self.digest.update(line)
158
					line = self.stream.readline(size)
159
					line = self.stream.readline(size)
159
					
160
160
161
161
class Verdict(object):
162
class Verdict(object):
162
	"""
163
	"""
 Lines 493-498   class TestCase(object): Link Here 
493
		self.description = None
494
		self.description = None
494
		self.bugs = set()
495
		self.bugs = set()
495
		self.otrs = set()
496
		self.otrs = set()
497
		self.logfiles = set()
496
498
497
	def load(self, filename):
499
	def load(self, filename):
498
		"""
500
		"""
 Lines 525-530   class TestCase(object): Link Here 
525
		self.description = header.get('desc', '').strip()
527
		self.description = header.get('desc', '').strip()
526
		self.bugs = set(header.get('bugs', []))
528
		self.bugs = set(header.get('bugs', []))
527
		self.otrs = set(header.get('otrs', []))
529
		self.otrs = set(header.get('otrs', []))
530
		self.logfiles = set(header.get('logfiles', []))
528
		self.versions = CheckVersion(header.get('versions', {}))
531
		self.versions = CheckVersion(header.get('versions', {}))
529
		self.tags = CheckTags(header.get('tags', []))
532
		self.tags = CheckTags(header.get('tags', []))
530
		self.roles = CheckRoles(header.get('roles', []),
533
		self.roles = CheckRoles(header.get('roles', []),
 Lines 626-631   class TestCase(object): Link Here 
626
		dirname = os.path.dirname(self.filename)
629
		dirname = os.path.dirname(self.filename)
627
		cmd = [self.exe.filename, base] + self.args
630
		cmd = [self.exe.filename, base] + self.args
628
631
632
		logfiles = {}
633
		for filename in self.logfiles:
634
			try:
635
				logfiles[filename] = open(filename, 'rb')
636
			except EnvironmentError:
637
				TestCase.logger.warn('Missing logfile %s' % (filename,))
638
629
		time_start = time()
639
		time_start = time()
630
640
631
		# Protect wrapper from Ctrl-C as long as test case is running
641
		# Protect wrapper from Ctrl-C as long as test case is running
 Lines 638-643   class TestCase(object): Link Here 
638
		def prepare_child():
648
		def prepare_child():
639
			"""Setup child process."""
649
			"""Setup child process."""
640
			signal.signal(signal.SIGINT, signal.SIG_IGN)
650
			signal.signal(signal.SIGINT, signal.SIG_IGN)
651
			for logfile in logfiles.values():
652
				logfile.close()
641
653
642
		try:
654
		try:
643
			TestCase.logger.debug('Running %r using %s in %s' % \
655
			TestCase.logger.debug('Running %r using %s in %s' % \
 Lines 681-686   class TestCase(object): Link Here 
681
693
682
		time_end = time()
694
		time_end = time()
683
695
696
		for filename in self.logfiles:
697
			if filename in logfiles:
698
				continue
699
			try:
700
				logfiles[filename] = open(filename, 'rb')
701
			except EnvironmentError:
702
				continue
703
		for filename, logfile in logfiles.iteritems():
704
			base = os.path.basename(filename)
705
			content = logfile.read()
706
			TestCase._attach(result, base, content)
707
			logfile.close()
708
684
		result.duration = int(time_end * 1000.0 - time_start * 1000.0)
709
		result.duration = int(time_end * 1000.0 - time_start * 1000.0)
685
		TestCase.logger.info('Test %r using %s in %s returned %s in %s ms' % \
710
		TestCase.logger.info('Test %r using %s in %s returned %s in %s ms' % \
686
				(cmd, self.exe, dirname, result.result, result.duration))
711
				(cmd, self.exe, dirname, result.result, result.duration))
(-)a/branches/ucs-3.2/ucs-3.2-2/test/ucs-test/univention/testing/format/junit.py (+15 lines)
 Lines 149-156   class Junit(TestFormatInterface): Link Here 
149
			xml.endDocument()
149
			xml.endDocument()
150
		finally:
150
		finally:
151
			f_report.close()
151
			f_report.close()
152
		self.save_artifacts(result)
152
		super(Junit, self).end_test(result)
153
		super(Junit, self).end_test(result)
153
154
155
	def save_artifacts(self, result):
156
		for (name, (mime, content)) in result.artifacts.iteritems():
157
			if name in ('stdout', 'stderr', 'check'):
158
				continue
159
			filename = os.path.join(self.outdir, result.case.uid, name)
160
			dirname = os.path.dirname(filename)
161
			try:
162
				os.makedirs(dirname)
163
			except OSError, ex:
164
				if ex.errno != errno.EEXIST:
165
					raise
166
			with open(filename, 'wb') as artifact_file:
167
				artifact_file.write(content)
168
154
	def format(self, result):
169
	def format(self, result):
155
		"""
170
		"""
156
		>>> from univention.testing.data import TestCase, TestEnvironment, \
171
		>>> from univention.testing.data import TestCase, TestEnvironment, \

Return to bug 35351