dirsrvtests/tests/tickets/ticket48326_test.py | 230 --------------
2 files changed, 283 insertions(+), 350 deletions(-)
New commits:
commit db116a434eb7b7bab94769a42144b339e7310aa1
Author: Simon Pichugin <spichugi@redhat.com>
Date: Fri Jul 3 15:52:23 2015 +0200
Ticket 48326 - Move CI test to config test suite and refactor
Description: Refactor config test suite to make addition of new test
case possible. Move test case from tickets/ticket48326.py to
suites/config/config_test.py and refator it afterwards.
Use a big value for an attribute instead of an ldif file.
https://fedorahosted.org/389/ticket/48326
Reviewed by: nhosoi (Thanks!)
diff --git a/dirsrvtests/tests/suites/config/config_test.py b/dirsrvtests/tests/suites/config/config_test.py
index d3631e3..4670bb1 100644
--- a/dirsrvtests/tests/suites/config/config_test.py
+++ b/dirsrvtests/tests/suites/config/config_test.py
@@ -1,5 +1,5 @@
# --- BEGIN COPYRIGHT BLOCK ---
-# Copyright (C) 2015 Red Hat, Inc.
+# Copyright (C) 2016 Red Hat, Inc.
# All rights reserved.
#
# License: GPL (version 3 or any later version).
@@ -18,181 +18,344 @@ from lib389._constants import *
from lib389.properties import *
from lib389.tasks import *
-logging.getLogger(__name__).setLevel(logging.DEBUG)
-log = logging.getLogger(__name__)
+DEBUGGING = False
+USER_DN = 'uid=test_user,%s' % DEFAULT_SUFFIX
+
+if DEBUGGING:
+ logging.getLogger(__name__).setLevel(logging.DEBUG)
+else:
+ logging.getLogger(__name__).setLevel(logging.INFO)
-installation1_prefix = None
+log = logging.getLogger(__name__)
-class TopologyStandalone(object):
- def __init__(self, standalone):
- standalone.open()
- self.standalone = standalone
+class TopologyReplication(object):
+ """The Replication Topology Class"""
+ def __init__(self, master1, master2):
+ """Init"""
+ master1.open()
+ self.master1 = master1
+ master2.open()
+ self.master2 = master2
@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
+ """Create Replication Deployment"""
+
+ # Creating master 1...
+ if DEBUGGING:
+ master1 = DirSrv(verbose=True)
+ else:
+ master1 = DirSrv(verbose=False)
+ args_instance[SER_HOST] = HOST_MASTER_1
+ args_instance[SER_PORT] = PORT_MASTER_1
+ args_instance[SER_SERVERID_PROP] = SERVERID_MASTER_1
+ args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
+ args_master = args_instance.copy()
+ master1.allocate(args_master)
+ instance_master1 = master1.exists()
+ if instance_master1:
+ master1.delete()
+ master1.create()
+ master1.open()
+ master1.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER, replicaId=REPLICAID_MASTER_1)
+
+ # Creating master 2...
+ if DEBUGGING:
+ master2 = DirSrv(verbose=True)
+ else:
+ master2 = DirSrv(verbose=False)
+ args_instance[SER_HOST] = HOST_MASTER_2
+ args_instance[SER_PORT] = PORT_MASTER_2
+ args_instance[SER_SERVERID_PROP] = SERVERID_MASTER_2
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()
+ args_master = args_instance.copy()
+ master2.allocate(args_master)
+ instance_master2 = master2.exists()
+ if instance_master2:
+ master2.delete()
+ master2.create()
+ master2.open()
+ master2.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER, replicaId=REPLICAID_MASTER_2)
+
+ #
+ # Create all the agreements
+ #
+ # Creating agreement from master 1 to master 2
+ properties = {RA_NAME: 'meTo_' + master2.host + ':' + str(master2.port),
+ RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
+ RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
+ RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
+ RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
+ m1_m2_agmt = master1.agreement.create(suffix=SUFFIX, host=master2.host, port=master2.port, properties=properties)
+ if not m1_m2_agmt:
+ log.fatal("Fail to create a master -> master replica agreement")
+ sys.exit(1)
+ log.debug("%s created" % m1_m2_agmt)
+
+ # Creating agreement from master 2 to master 1
+ properties = {RA_NAME: 'meTo_' + master1.host + ':' + str(master1.port),
+ RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
+ RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
+ RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
+ RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
+ m2_m1_agmt = master2.agreement.create(suffix=SUFFIX, host=master1.host, port=master1.port, properties=properties)
+ if not m2_m1_agmt:
+ log.fatal("Fail to create a master -> master replica agreement")
+ sys.exit(1)
+ log.debug("%s created" % m2_m1_agmt)
+
+ # Allow the replicas to get situated with the new agreements...
+ time.sleep(5)
+
+ #
+ # Initialize all the agreements
+ #
+ master1.agreement.init(SUFFIX, HOST_MASTER_2, PORT_MASTER_2)
+ master1.waitForReplInit(m1_m2_agmt)
+
+ # Check replication is working...
+ if master1.testReplication(DEFAULT_SUFFIX, master2):
+ log.info('Replication is working.')
+ else:
+ log.fatal('Replication is not working.')
+ raise
+
+ def fin():
+ """If we are debugging just stop the instances, otherwise remove
+ them
+ """
+ if DEBUGGING:
+ master1.stop()
+ master2.stop()
+ else:
+ master1.delete()
+ master2.delete()
+
+ request.addfinalizer(fin)
# Clear out the tmp dir
- standalone.clearTmpDir(__file__)
+ master1.clearTmpDir(__file__)
+
+ return TopologyReplication(master1, master2)
+
+
+@pytest.fixture(scope="module")
+def big_file():
+ TEMP_BIG_FILE = ''
+ # 1024*1024=1048576
+ # B for 1 MiB
+ # Big for 3 MiB
+ for x in range(1048576):
+ TEMP_BIG_FILE += '+'
+
+ return TEMP_BIG_FILE
+
+
+@pytest.fixture
+def test_user(topology):
+ """Add and remove test user"""
+
+ try:
+ topology.master1.add_s(Entry((USER_DN, {
+ 'uid': 'test_user',
+ 'givenName': 'test_user',
+ 'objectclass': ['top', 'person',
+ 'organizationalPerson',
+ 'inetorgperson'],
+ 'cn': 'test_user',
+ 'sn': 'test_user'})))
+ time.sleep(1)
+ except ldap.LDAPError as e:
+ log.fatal('Failed to add user (%s): error (%s)' % (USER_DN,
+ e.message['desc']))
+ raise
+
+ def fin():
+ try:
+ topology.master1.delete_s(USER_DN)
+ time.sleep(1)
+ except ldap.LDAPError as e:
+ log.fatal('Failed to delete user (%s): error (%s)' % (
+ USER_DN,
+ e.message['desc']))
+ raise
+
+
+def test_maxbersize_repl(topology, test_user, big_file):
+ """maxbersize is ignored in the replicated operations.
+
+ :Feature: Config
+
+ :Setup: MMR with two masters, test user,
+ 1 MiB big value for attribute
+
+ :Steps: 1. Set 20KiB small maxbersize on master2
+ 2. Add big value to master2
+ 3. Add big value to master1
+
+ :Assert: Adding the big value to master2 is failed,
+ adding the big value to master1 is succeed,
+ the big value is successfully replicated to master2
+ """
+ log.info("Set nsslapd-maxbersize: 20K to master2")
+ try:
+ topology.master2.modify_s("cn=config", [(ldap.MOD_REPLACE,
+ 'nsslapd-maxbersize', '20480')])
+ except ldap.LDAPError as e:
+ log.error('Failed to set nsslapd-maxbersize == 20480: error ' +
+ e.message['desc'])
+ raise
+
+ topology.master2.restart(20)
- return TopologyStandalone(standalone)
+ log.info('Try to add attribute with a big value to master2 - expect to FAIL')
+ with pytest.raises(ldap.SERVER_DOWN):
+ topology.master2.modify_s(USER_DN, [(ldap.MOD_REPLACE,
+ 'jpegphoto', big_file)])
+ topology.master2.restart(20)
+ topology.master1.restart(20)
-def test_config_init(topology):
- '''
- Initialization function
- '''
- return
+ log.info('Try to add attribute with a big value to master1 - expect to PASS')
+ try:
+ topology.master1.modify_s(USER_DN, [(ldap.MOD_REPLACE,
+ 'jpegphoto', big_file)])
+ except ldap.SERVER_DOWN as e:
+ log.fatal('Failed to add a big attribute, error: ' + e.message['desc'])
+ raise
+
+ time.sleep(1)
+
+ log.info('Check if a big value was successfully added to master1')
+ try:
+ entries = topology.master1.search_s(USER_DN, ldap.SCOPE_BASE,
+ '(cn=*)',
+ ['jpegphoto'])
+ assert entries[0].data['jpegphoto']
+ except ldap.LDAPError as e:
+ log.fatal('Search failed, error: ' + e.message['desc'])
+ raise
+
+ log.info('Check if a big value was successfully replicated to master2')
+ try:
+ entries = topology.master2.search_s(USER_DN, ldap.SCOPE_BASE,
+ '(cn=*)',
+ ['jpegphoto'])
+ assert entries[0].data['jpegphoto']
+ except ldap.LDAPError as e:
+ log.fatal('Search failed, error: ' + e.message['desc'])
+ raise
+
+ log.info("Set nsslapd-maxbersize: 2097152 (default) to master2")
+ try:
+ topology.master2.modify_s("cn=config", [(ldap.MOD_REPLACE,
+ 'nsslapd-maxbersize', '2097152')])
+ except ldap.LDAPError as e:
+ log.error('Failed to set nsslapd-maxbersize == 2097152 error ' +
+ e.message['desc'])
+ raise
def test_config_listen_backport_size(topology):
- '''
- We need to check that we can search on nsslapd-listen-backlog-size,
+ """We need to check that we can search on nsslapd-listen-backlog-size,
and change its value: to a psoitive number and a negative number.
Verify invalid value is rejected.
- '''
-
- log.info('Running test_config_listen_backport_size...')
+ """
try:
- entry = topology.standalone.search_s(DN_CONFIG, ldap.SCOPE_BASE, 'objectclass=top',
- ['nsslapd-listen-backlog-size'])
- default_val = entry[0].getValue('nsslapd-listen-backlog-size')
- if not default_val:
- log.fatal('test_config_listen_backport_size: Failed to get nsslapd-listen-backlog-size from config')
- assert False
+ entry = topology.master1.search_s(DN_CONFIG, ldap.SCOPE_BASE, 'objectclass=top',
+ ['nsslapd-listen-backlog-size'])
+ default_val = entry[0].data['nsslapd-listen-backlog-size'][0]
+ assert default_val, 'Failed to get nsslapd-listen-backlog-size from config'
except ldap.LDAPError as e:
- log.fatal('test_config_listen_backport_size: Failed to search config, error: ' + e.message('desc'))
- assert False
+ log.fatal('Failed to search config, error: ' + e.message('desc'))
+ raise
try:
- topology.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-listen-backlog-size', '256')])
+ topology.master1.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE,
+ 'nsslapd-listen-backlog-size',
+ '256')])
except ldap.LDAPError as e:
- log.fatal('test_config_listen_backport_size: Failed to modify config, error: ' + e.message('desc'))
- assert False
+ log.fatal('Failed to modify config, error: ' + e.message('desc'))
+ raise
try:
- topology.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-listen-backlog-size', '-1')])
+ topology.master1.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE,
+ 'nsslapd-listen-backlog-size',
+ '-1')])
except ldap.LDAPError as e:
- log.fatal('test_config_listen_backport_size: Failed to modify config(negative value), error: ' +
+ log.fatal('Failed to modify config(negative value), error: ' +
e.message('desc'))
- assert False
+ raise
- try:
- topology.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-listen-backlog-size', 'ZZ')])
- log.fatal('test_config_listen_backport_size: Invalid value was successfully added')
- assert False
- except ldap.LDAPError as e:
- pass
+ with pytest.raises(ldap.LDAPError):
+ topology.master1.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE,
+ 'nsslapd-listen-backlog-size',
+ 'ZZ')])
+ log.fatal('Invalid value was successfully added')
- #
# Cleanup - undo what we've done
- #
try:
- topology.standalone.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE, 'nsslapd-listen-backlog-size', default_val)])
+ topology.master1.modify_s(DN_CONFIG, [(ldap.MOD_REPLACE,
+ 'nsslapd-listen-backlog-size',
+ default_val)])
except ldap.LDAPError as e:
- log.fatal('test_config_listen_backport_size: Failed to reset config, error: ' + e.message('desc'))
- assert False
-
- log.info('test_config_listen_backport_size: PASSED')
+ log.fatal('Failed to reset config, error: ' + e.message('desc'))
+ raise
def test_config_deadlock_policy(topology):
- '''
- We need to check that nsslapd-db-deadlock-policy exists, that we can
+ """We need to check that nsslapd-db-deadlock-policy exists, that we can
change the value, and invalid values are rejected
- '''
-
- log.info('Running test_config_deadlock_policy...')
+ """
LDBM_DN = 'cn=config,cn=ldbm database,cn=plugins,cn=config'
default_val = '9'
try:
- entry = topology.standalone.search_s(LDBM_DN, ldap.SCOPE_BASE, 'objectclass=top',
- ['nsslapd-db-deadlock-policy'])
- val = entry[0].getValue('nsslapd-db-deadlock-policy')
- if not val:
- log.fatal('test_config_deadlock_policy: Failed to get nsslapd-db-deadlock-policy from config')
- assert False
- if val != default_val:
- log.fatal('test_config_deadlock_policy: The wrong derfualt value was present: (%s) but expected (%s)' %
- (val, default_val))
- assert False
+ entry = topology.master1.search_s(LDBM_DN, ldap.SCOPE_BASE, 'objectclass=top',
+ ['nsslapd-db-deadlock-policy'])
+ val = entry[0].data['nsslapd-db-deadlock-policy'][0]
+ assert val, 'Failed to get nsslapd-db-deadlock-policy from config'
+ assert val == default_val, 'The wrong derfualt value was present'
except ldap.LDAPError as e:
- log.fatal('test_config_deadlock_policy: Failed to search config, error: ' + e.message('desc'))
- assert False
+ log.fatal('Failed to search config, error: ' + e.message('desc'))
+ raise
# Try a range of valid values
for val in ('0', '5', '9'):
try:
- topology.standalone.modify_s(LDBM_DN, [(ldap.MOD_REPLACE, 'nsslapd-db-deadlock-policy', val)])
+ topology.master1.modify_s(LDBM_DN, [(ldap.MOD_REPLACE,
+ 'nsslapd-db-deadlock-policy',
+ val)])
except ldap.LDAPError as e:
- log.fatal('test_config_deadlock_policy: Failed to modify config: nsslapd-db-deadlock-policy to (%s), error: %s' %
+ log.fatal('Failed to modify config: nsslapd-db-deadlock-policy to (%s), error: %s' %
(val, e.message('desc')))
- assert False
+ raise
# Try a range of invalid values
for val in ('-1', '10'):
- try:
- topology.standalone.modify_s(LDBM_DN, [(ldap.MOD_REPLACE, 'nsslapd-db-deadlock-policy', val)])
- log.fatal('test_config_deadlock_policy: Able to add invalid value to nsslapd-db-deadlock-policy(%s)' % (val))
- assert False
- except ldap.LDAPError as e:
- pass
- #
+ with pytest.raises(ldap.LDAPError):
+ topology.master1.modify_s(LDBM_DN, [(ldap.MOD_REPLACE,
+ 'nsslapd-db-deadlock-policy',
+ val)])
+ log.fatal('Able to add invalid value to nsslapd-db-deadlock-policy(%s)' % (val))
+
# Cleanup - undo what we've done
- #
try:
- topology.standalone.modify_s(LDBM_DN, [(ldap.MOD_REPLACE, 'nsslapd-db-deadlock-policy', default_val)])
+ topology.master1.modify_s(LDBM_DN, [(ldap.MOD_REPLACE,
+ 'nsslapd-db-deadlock-policy',
+ default_val)])
except ldap.LDAPError as e:
- log.fatal('test_config_deadlock_policy: Failed to reset nsslapd-db-deadlock-policy to the default value(%s), error: %s' %
+ log.fatal('Failed to reset nsslapd-db-deadlock-policy to the default value(%s), error: %s' %
(default_val, e.message('desc')))
-
- log.info('test_config_deadlock_policy: PASSED')
-
-
-def test_config_final(topology):
- topology.standalone.delete()
- log.info('Testcase PASSED')
-
-
-def run_isolated():
- '''
- This test suite is designed to test all things cn=config Like, the core cn=config settings,
- or the ldbm database settings, etc. This suite shoud not test individual plugins - there
- should be individual suites for each plugin.
- '''
- global installation1_prefix
- installation1_prefix = None
-
- topo = topology(True)
- test_config_init(topo)
-
- test_config_listen_backport_size(topo)
- test_config_deadlock_policy(topo)
-
- test_config_final(topo)
+ raise
if __name__ == '__main__':
- run_isolated()
-
+ # Run isolated
+ # -s for DEBUG mode
+ CURRENT_FILE = os.path.realpath(__file__)
+ pytest.main("-s %s" % CURRENT_FILE)
diff --git a/dirsrvtests/tests/tickets/ticket48326_test.py b/dirsrvtests/tests/tickets/ticket48326_test.py
deleted file mode 100644
index 1434f2d..0000000
--- a/dirsrvtests/tests/tickets/ticket48326_test.py
+++ /dev/null
@@ -1,230 +0,0 @@
-# --- BEGIN COPYRIGHT BLOCK ---
-# Copyright (C) 2015 Red Hat, Inc.
-# All rights reserved.
-#
-# License: GPL (version 3 or any later version).
-# See LICENSE for details.
-# --- END COPYRIGHT BLOCK ---
-#
-import os
-import sys
-import time
-import shlex
-import subprocess
-import ldap
-import logging
-import pytest
-from lib389 import DirSrv, Entry, tools, tasks
-from lib389.tools import DirSrvTools
-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
-
-MYDN = 'uid=tuser1M,dc=example,dc=com'
-MYLDIF = 'ticket48326.ldif'
-
-class TopologyReplication(object):
- def __init__(self, master1, master2):
- master1.open()
- self.master1 = master1
- master2.open()
- self.master2 = master2
-
-
-@pytest.fixture(scope="module")
-def topology(request):
- global installation1_prefix
- if installation1_prefix:
- args_instance[SER_DEPLOYED_DIR] = installation1_prefix
-
- # Creating master 1...
- master1 = DirSrv(verbose=False)
- if installation1_prefix:
- args_instance[SER_DEPLOYED_DIR] = installation1_prefix
- args_instance[SER_HOST] = HOST_MASTER_1
- args_instance[SER_PORT] = PORT_MASTER_1
- args_instance[SER_SERVERID_PROP] = SERVERID_MASTER_1
- args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
- args_master = args_instance.copy()
- master1.allocate(args_master)
- instance_master1 = master1.exists()
- if instance_master1:
- master1.delete()
- master1.create()
- master1.open()
- master1.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER, replicaId=REPLICAID_MASTER_1)
-
- # Creating master 2...
- master2 = DirSrv(verbose=False)
- if installation1_prefix:
- args_instance[SER_DEPLOYED_DIR] = installation1_prefix
- args_instance[SER_HOST] = HOST_MASTER_2
- args_instance[SER_PORT] = PORT_MASTER_2
- args_instance[SER_SERVERID_PROP] = SERVERID_MASTER_2
- args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX
- args_master = args_instance.copy()
- master2.allocate(args_master)
- instance_master2 = master2.exists()
- if instance_master2:
- master2.delete()
- master2.create()
- master2.open()
- master2.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER, replicaId=REPLICAID_MASTER_2)
-
- #
- # Create all the agreements
- #
- # Creating agreement from master 1 to master 2
- properties = {RA_NAME: r'meTo_$host:$port',
- RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
- RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
- RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
- RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
- m1_m2_agmt = master1.agreement.create(suffix=SUFFIX, host=master2.host, port=master2.port, properties=properties)
- if not m1_m2_agmt:
- log.fatal("Fail to create a master -> master replica agreement")
- sys.exit(1)
- log.debug("%s created" % m1_m2_agmt)
-
- # Creating agreement from master 2 to master 1
- properties = {RA_NAME: r'meTo_$host:$port',
- RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
- RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],
- RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD],
- RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]}
- m2_m1_agmt = master2.agreement.create(suffix=SUFFIX, host=master1.host, port=master1.port, properties=properties)
- if not m2_m1_agmt:
- log.fatal("Fail to create a master -> master replica agreement")
- sys.exit(1)
- log.debug("%s created" % m2_m1_agmt)
-
- # Allow the replicas to get situated with the new agreements...
- time.sleep(5)
-
- #
- # Initialize all the agreements
- #
- master1.agreement.init(SUFFIX, HOST_MASTER_2, PORT_MASTER_2)
- master1.waitForReplInit(m1_m2_agmt)
-
- # Check replication is working...
- if master1.testReplication(DEFAULT_SUFFIX, master2):
- log.info('Replication is working.')
- else:
- log.fatal('Replication is not working.')
- assert False
-
- # Delete each instance in the end
- def fin():
- master1.delete()
- master2.delete()
- request.addfinalizer(fin)
-
- # Clear out the tmp dir
- master1.clearTmpDir(__file__)
-
- return TopologyReplication(master1, master2)
-
-
-@pytest.fixture(scope="module")
-
-
-def add_entry(topology, server, serverPort, expectToFail):
- """
- Adding 1Mentry to the given server
- Check the add result based upon the expectToFail info.
- """
- if expectToFail:
- log.info("Adding 1M entry to %s expecting to fail." % server)
- else:
- log.info("Adding 1M entry to %s expecting to succeed." % server)
-
- data_dir_path = topology.master1.getDir(__file__, DATA_DIR)
- ldif_file = data_dir_path + MYLDIF
-
- #strcmdline = '/usr/bin/ldapmodify -x -h localhost -p' + str(serverPort) + '-D' + DN_DM + '-w' + PW_DM + '-af' + ldif_file
- #cmdline = shlex.split(strcmdline)
- cmdline = ['/usr/bin/ldapmodify', '-x', '-h', 'localhost', '-p', str(serverPort),
- '-D', DN_DM, '-w', PW_DM, '-af', ldif_file]
- log.info("Running cmdline (%s): %s" % (server, cmdline))
-
- try:
- proc = subprocess.Popen(cmdline, stderr=subprocess.PIPE)
- except Exception as e:
- log.info("%s caught in exception: %s" % (cmdline, e))
- assert False
-
- Found = False
- Expected = "ldap_result: Can't contact LDAP server"
- while True:
- l = proc.stderr.readline()
- if l == "":
- break
- if Expected in l:
- Found = True
- break
-
- if expectToFail:
- if Found:
- log.info("Adding 1M entry to %s failed as expected: %s" % (server, l))
- else:
- log.fatal("Expected error message %s was not returned: %s" % Expected)
- assert False
- else:
- if Found:
- log.fatal("%s failed although expecting to succeed: %s" % (cmdline, l))
- assert False
- else:
- log.info("Adding 1M entry to %s succeeded as expected" % server)
-
-
-def test_ticket48326(topology):
- """
- maxbersize is ignored in the replicated operations.
- [settings]
- master1 has default size maxbersize (2MB).
- master2 has much saller size maxbersize (20KB).
- [test case]
- Adding an entry which size is larger than 20KB to master2 fails.
- But adding an entry which size is larger than 20KB and less than 2MB to master1 succeeds
- and the entry is successfully replicated to master2.
- """
- log.info("Ticket 48326 - it could be nice to have nsslapd-maxbersize default to bigger than 2Mb")
- log.info("Set nsslapd-maxbersize: 20K to master2")
- try:
- topology.master2.modify_s("cn=config", [(ldap.MOD_REPLACE, 'nsslapd-maxbersize', '20480')])
- except ldap.LDAPError as e:
- log.error('Failed to set nsslapd-maxbersize == 20480: error ' + e.message['desc'])
- assert False
-
- add_entry(topology, "master2", PORT_MASTER_2, True)
-
- add_entry(topology, "master1", PORT_MASTER_1, False)
-
- time.sleep(1)
-
- log.info('Searching for %s on master2...', MYDN)
- try:
- entries = topology.master2.search_s(MYDN, ldap.SCOPE_BASE, '(objectclass=*)')
- if not entries:
- log.fatal('Entry %s failed to repliate to master2.' % MYDN)
- assert False
- else:
- log.info('SUCCESS: Entry %s is successfully replicated to master2.' % MYDN)
- except ldap.LDAPError as e:
- log.fatal('Search failed: ' + e.message['desc'])
- assert False
-
-
-if __name__ == '__main__':
- # Run isolated
- # -s for DEBUG mode
-
- CURRENT_FILE = os.path.realpath(__file__)
- pytest.main("-s %s" % CURRENT_FILE)
--
389-commits mailing list
389-commits@lists.fedoraproject.org
https://lists.fedoraproject.org/admin/lists/389-commits@lists.fedoraproject.org
No comments:
Post a Comment