This is an automated email from the git hooks/post-receive script.
spichugi pushed a change to branch master in repository lib389.
from 934741a Ticket 62 - dirsrv offline log new ffa0af5 Ticket 63 - lib389 python 3 fix new 5335246 Ticket 63 - part 2, agreement test new 46ef071 Ticket 65 - Add m2c2 topology
The 3 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/__init__.py | 6 +- lib389/_entry.py | 2 +- lib389/agreement.py | 22 ++-- lib389/idm/user.py | 11 +- lib389/nss_ssl.py | 4 +- lib389/replica.py | 8 +- lib389/sasl.py | 4 +- lib389/tests/agreement_test.py | 51 ++++----- lib389/tests/idm/user_and_group_test.py | 12 +- lib389/topologies.py | 197 ++++++++++++++++++++++++++++++++ lib389/utils.py | 14 ++- 11 files changed, 270 insertions(+), 61 deletions(-)
This is an automated email from the git hooks/post-receive script.
spichugi pushed a commit to branch master in repository lib389.
commit ffa0af5f5ff9fda503af773f6c4d5cffaeddc1ef Author: William Brown firstyear@redhat.com Date: Mon Jun 5 15:12:39 2017 +1000
Ticket 63 - lib389 python 3 fix
Bug Description: In def open for python 3 we introduced a bynes vs str issue in tls setopt
Fix Description: wrap the offending code in ensure str
https://pagure.io/lib389/issue/63
Author: wibrown
Review by: ??? --- lib389/__init__.py | 6 +++--- lib389/_entry.py | 2 +- lib389/idm/user.py | 2 +- lib389/nss_ssl.py | 4 +++- 4 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/lib389/__init__.py b/lib389/__init__.py index d96a937..9e2465f 100644 --- a/lib389/__init__.py +++ b/lib389/__init__.py @@ -1034,12 +1034,12 @@ class DirSrv(SimpleLDAPObject, object): if userkey is not None: # Note this sets LDAP.OPT not SELF. Because once self has opened # it can NOT change opts AT ALL. - ldap.set_option(ldap.OPT_X_TLS_KEYFILE, userkey) + ldap.set_option(ldap.OPT_X_TLS_KEYFILE, ensure_str(userkey)) log.debug("Using user private key %s" % userkey) if usercert is not None: # Note this sets LDAP.OPT not SELF. Because once self has opened # it can NOT change opts AT ALL. - ldap.set_option(ldap.OPT_X_TLS_CERTFILE, usercert) + ldap.set_option(ldap.OPT_X_TLS_CERTFILE, ensure_str(usercert)) log.debug("Using user certificate %s" % usercert)
if certdir is not None: @@ -1048,7 +1048,7 @@ class DirSrv(SimpleLDAPObject, object): """ # Note this sets LDAP.OPT not SELF. Because once self has opened # it can NOT change opts AT ALL. - ldap.set_option(ldap.OPT_X_TLS_CACERTDIR, certdir) + ldap.set_option(ldap.OPT_X_TLS_CACERTDIR, ensure_str(certdir)) log.debug("Using external ca certificate %s" % certdir)
if certdir or starttls: diff --git a/lib389/_entry.py b/lib389/_entry.py index 5b7aaec..cf04817 100644 --- a/lib389/_entry.py +++ b/lib389/_entry.py @@ -185,7 +185,7 @@ class Entry(object): return val == self.data.get(name) if isinstance(val, tuple): return list(val) == self.data.get(name) - return val in self.data.get(name) + return ensure_bytes(val) in self.data.get(name)
def hasValueCase(self, name, val): """ diff --git a/lib389/idm/user.py b/lib389/idm/user.py index 66a72cf..965d0be 100644 --- a/lib389/idm/user.py +++ b/lib389/idm/user.py @@ -53,7 +53,7 @@ class UserAccount(Account): self._protected = False
def _validate(self, rdn, properties, basedn): - if properties.has_key('ntUserDomainId') and 'ntUser' not in self._create_objectclasses: + if 'ntUserDomainId' in properties and 'ntUser' not in self._create_objectclasses: self._create_objectclasses.append('ntUser')
return super(UserAccount, self)._validate(rdn, properties, basedn) diff --git a/lib389/nss_ssl.py b/lib389/nss_ssl.py index 05ddbfc..90e78f9 100644 --- a/lib389/nss_ssl.py +++ b/lib389/nss_ssl.py @@ -19,6 +19,8 @@ import socket from subprocess import check_call, check_output from lib389.passwd import password_generate
+from lib389.utils import ensure_str, ensure_bytes + KEYBITS = 4096 CA_NAME = 'Self-Signed-CA' CERT_NAME = 'Server-Cert' @@ -139,7 +141,7 @@ class NssSsl(object): ] certdetails = check_output(cmd) with open('%s/ca.crt' % self.dirsrv.get_cert_dir(), 'w') as f: - f.write(certdetails) + f.write(ensure_str(certdetails)) if os.path.isfile('/usr/sbin/cacertdir_rehash'): check_output(['/usr/sbin/cacertdir_rehash', self.dirsrv.get_cert_dir()]) return True
This is an automated email from the git hooks/post-receive script.
spichugi pushed a commit to branch master in repository lib389.
commit 5335246a2a17287c77fa2502683e01df7e6912f7 Author: William Brown firstyear@redhat.com Date: Tue Jun 6 10:42:02 2017 +1000
Ticket 63 - part 2, agreement test
Bug Description: This resolves a number of issues in the python 3 replication agreement test.
Fix Description: Fix bytes vs str when needed, and replace some raw ldap calls with object types.
https://pagure.io/lib389/issue/63
Author: wibrown
Review by: ??? --- lib389/agreement.py | 22 +++++++------- lib389/idm/user.py | 9 ++++++ lib389/replica.py | 8 +++--- lib389/sasl.py | 4 ++- lib389/tests/agreement_test.py | 51 ++++++++++++++++----------------- lib389/tests/idm/user_and_group_test.py | 12 ++------ lib389/utils.py | 14 +++++++-- 7 files changed, 65 insertions(+), 55 deletions(-)
diff --git a/lib389/agreement.py b/lib389/agreement.py index fabc3a4..666f5b2 100644 --- a/lib389/agreement.py +++ b/lib389/agreement.py @@ -14,7 +14,7 @@ import six from lib389._constants import * from lib389.properties import * from lib389._entry import FormatDict -from lib389.utils import normalizeDN +from lib389.utils import normalizeDN, ensure_bytes, ensure_str, ensure_dict_str from lib389 import Entry, DirSrv, NoSuchEntryError, InvalidArgumentError
@@ -97,9 +97,10 @@ class Agreement(object): "Reap Active: %(nsds5ReplicaReapActive)s" "\n" ) # FormatDict manages missing fields in string formatting - result = retstr % FormatDict(ent.data) + entry_data = ensure_dict_str(ent.data) + result = retstr % FormatDict(entry_data) result += "Replication Status: %s\n" % status - return retstr % FormatDict(ent.data) + return result
def _check_interval(self, interval): ''' @@ -173,8 +174,7 @@ class Agreement(object):
# update it self.log.info("Schedule replication agreement %s" % agmtdn) - mod = [( - ldap.MOD_REPLACE, 'nsds5replicaupdateschedule', [interval])] + mod = [(ldap.MOD_REPLACE, 'nsds5replicaupdateschedule', [ensure_bytes(interval)])] self.conn.modify_s(agmtdn, mod)
def getProperties(self, agmnt_dn=None, properties=None): @@ -348,7 +348,7 @@ class Agreement(object): if prop_name == RA_SCHEDULE: self._check_interval(properties[prop])
- mod.append((mod_type, attr, properties[prop])) + mod.append((mod_type, attr, ensure_bytes(properties[prop])))
# Now time to run the effective modify self.conn.modify_s(agmnt_dn, mod) @@ -645,7 +645,7 @@ class Agreement(object): # trigger the total init # self.log.info("Starting total init %s" % entry.dn) - mod = [(ldap.MOD_ADD, 'nsds5BeginReplicaRefresh', 'start')] + mod = [(ldap.MOD_ADD, 'nsds5BeginReplicaRefresh', ensure_bytes('start'))] self.conn.modify_s(entry.dn, mod)
def pause(self, agmtdn, interval=NEVER): @@ -705,7 +705,7 @@ class Agreement(object): """Return a list of changes sent by this agreement.""" retval = 0 try: - ent = self.conn.getEntry(agmnt_dn, ldap.SCOPE_BASE, + ent = self.conn.getEntry(ensure_str(agmnt_dn), ldap.SCOPE_BASE, "(objectclass=*)", [RA_PROPNAME_TO_ATTRNAME[RA_CHANGES]]) except: @@ -714,12 +714,12 @@ class Agreement(object):
if ent.nsds5replicaChangesSentSinceStartup: val = ent.nsds5replicaChangesSentSinceStartup - items = val.split(' ') + items = val.split(ensure_bytes(' ')) if len(items) == 1: retval = int(items[0]) else: for item in items: - ary = item.split(":") + ary = item.split(ensure_bytes(":")) if ary and len(ary) > 1: - retval = retval + int(ary[1].split("/")[0]) + retval = retval + int(ary[1].split(ensure_bytes("/"))[0]) return retval diff --git a/lib389/idm/user.py b/lib389/idm/user.py index 965d0be..ee4e08d 100644 --- a/lib389/idm/user.py +++ b/lib389/idm/user.py @@ -21,6 +21,15 @@ MUST_ATTRIBUTES = [ ] RDN = 'uid'
+TEST_USER_PROPERTIES = { + 'uid': 'testuser', + 'cn' : 'testuser', + 'sn' : 'user', + 'uidNumber' : '1000', + 'gidNumber' : '2000', + 'homeDirectory' : '/home/testuser' +} +
class UserAccount(Account): def __init__(self, instance, dn=None, batch=False): diff --git a/lib389/replica.py b/lib389/replica.py index 8ba527c..4de88be 100644 --- a/lib389/replica.py +++ b/lib389/replica.py @@ -12,7 +12,7 @@ import decimal import time from lib389._constants import * from lib389.properties import * -from lib389.utils import normalizeDN, escapeDNValue +from lib389.utils import normalizeDN, escapeDNValue, ensure_bytes from lib389._replication import RUV from lib389.repltools import ReplTools from lib389 import DirSrv, Entry, NoSuchEntryError, InvalidArgumentError @@ -557,14 +557,14 @@ class ReplicaLegacy(object): if not refresh: # done - check status if not status: print("No status yet") - elif status.find("replica busy") > -1: + elif status.find(ensure_bytes("replica busy")) > -1: print("Update failed - replica busy - status", status) done = True hasError = 2 - elif status.find("Total update succeeded") > -1: + elif status.find(ensure_bytes("Total update succeeded")) > -1: print("Update succeeded: status ", status) done = True - elif inprogress.lower() == 'true': + elif inprogress.lower() == ensure_bytes('true'): print("Update in progress yet not in progress: status ", status) else: diff --git a/lib389/sasl.py b/lib389/sasl.py index e64e3c3..0015f60 100644 --- a/lib389/sasl.py +++ b/lib389/sasl.py @@ -12,7 +12,9 @@ Lib389 python ldap sasl operations. These should be upstreamed if possible. """
-from ldap.sasl import sasl, CB_AUTHNAME, CB_PASS +from ldap.sasl import sasl, CB_AUTHNAME, CB_PASS, CB_USER + +from lib389.utils import ensure_bytes
class LdapSSOTokenSASL(sasl): """ diff --git a/lib389/tests/agreement_test.py b/lib389/tests/agreement_test.py index 4be609d..456cbfa 100644 --- a/lib389/tests/agreement_test.py +++ b/lib389/tests/agreement_test.py @@ -16,6 +16,9 @@ from lib389.agreement import Agreement from lib389._constants import * from lib389.properties import * from lib389 import DirSrv, Entry +from lib389.utils import ensure_bytes, ensure_str +from lib389.idm.user import UserAccounts, TEST_USER_PROPERTIES +from lib389.idm.domain import Domain
# Used for One master / One consumer topology HOST_MASTER = LOCALHOST @@ -107,18 +110,18 @@ def test_create(topology): topology.master.agreement.init(SUFFIX, HOST_CONSUMER, PORT_CONSUMER) topology.master.waitForReplInit(repl_agreement)
- # Add a test entry - topology.master.add_s(Entry((ENTRY_DN, {'objectclass': - "top person".split(), - 'sn': 'test_entry', - 'cn': 'test_entry'}))) + master_users = UserAccounts(topology.master, SUFFIX) + consumer_users = UserAccounts(topology.consumer, SUFFIX) + + testuser = master_users.create(properties=TEST_USER_PROPERTIES) + testuser_dn = testuser.dn
+ # Add a test entry # Check replication is working loop = 0 while loop <= 10: try: - ent = topology.consumer.getEntry(ENTRY_DN, ldap.SCOPE_BASE, - "(objectclass=*)") + consumer_users.get(dn=testuser_dn) break except ldap.NO_SUCH_OBJECT: time.sleep(1) @@ -148,9 +151,9 @@ def test_list(topology): ents = topology.master.agreement.list(suffix=SUFFIX) assert len(ents) == 1 assert ents[0].getValue(RA_PROPNAME_TO_ATTRNAME[RA_CONSUMER_HOST]) == \ - topology.consumer.host + ensure_bytes(topology.consumer.host) assert ents[0].getValue(RA_PROPNAME_TO_ATTRNAME[RA_CONSUMER_PORT]) == \ - str(topology.consumer.port) + ensure_bytes(str(topology.consumer.port))
# Create a second RA to check .list returns 2 RA properties = {RA_NAME: r'meTo_%s:%d' % (topology.consumer.host, @@ -172,9 +175,9 @@ def test_list(topology): consumer_port=topology.consumer.port) assert len(ents) == 1 assert ents[0].getValue(RA_PROPNAME_TO_ATTRNAME[RA_CONSUMER_HOST]) == \ - topology.consumer.host + ensure_bytes(topology.consumer.host) assert ents[0].getValue(RA_PROPNAME_TO_ATTRNAME[RA_CONSUMER_PORT]) == \ - str(topology.consumer.port) + ensure_bytes(str(topology.consumer.port))
def test_delete(topology): @@ -216,7 +219,7 @@ def test_status(topology): topology.master.log.info("\n\n###########\n## STATUS\n##########") ents = topology.master.agreement.list(suffix=SUFFIX) for ent in ents: - ra_status = topology.master.agreement.status(ent.dn) + ra_status = topology.master.agreement.status(ensure_str(ent.dn)) assert ra_status topology.master.log.info("Status of %s: %s" % (ent.dn, ra_status))
@@ -236,7 +239,7 @@ def test_schedule(topology): consumer_port=topology.consumer.port) assert len(ents) == 1 assert ents[0].getValue(RA_PROPNAME_TO_ATTRNAME[RA_SCHEDULE]) == \ - Agreement.ALWAYS + ensure_bytes(Agreement.ALWAYS)
topology.master.agreement.schedule(ents[0].dn, Agreement.NEVER) ents = topology.master.agreement.list(suffix=SUFFIX, @@ -244,7 +247,7 @@ def test_schedule(topology): consumer_port=topology.consumer.port) assert len(ents) == 1 assert ents[0].getValue(RA_PROPNAME_TO_ATTRNAME[RA_SCHEDULE]) == \ - Agreement.NEVER + ensure_bytes(Agreement.NEVER)
CUSTOM_SCHEDULE = "0000-1234 6420" topology.master.agreement.schedule(ents[0].dn, CUSTOM_SCHEDULE) @@ -253,7 +256,7 @@ def test_schedule(topology): consumer_port=topology.consumer.port) assert len(ents) == 1 assert ents[0].getValue(RA_PROPNAME_TO_ATTRNAME[RA_SCHEDULE]) == \ - CUSTOM_SCHEDULE + ensure_bytes(CUSTOM_SCHEDULE)
CUSTOM_SCHEDULES = ("2500-1234 6420", # Invalid HOUR schedule "0000-2534 6420", # ^^ @@ -308,8 +311,8 @@ def test_setProperties(topology): properties = topology.master.agreement.getProperties( agmnt_dn=ents[0].dn, properties=[RA_SCHEDULE, RA_DESCRIPTION]) assert len(properties) == 2 - assert properties[RA_SCHEDULE][0] == test_schedule - assert properties[RA_DESCRIPTION][0] == test_desc + assert properties[RA_SCHEDULE][0] == ensure_bytes(test_schedule) + assert properties[RA_DESCRIPTION][0] == ensure_bytes(test_desc)
# Set RA Schedule back to "always" topology.master.agreement.schedule(ents[0].dn, Agreement.ALWAYS) @@ -331,20 +334,16 @@ def test_changes(topology):
# Do an update TEST_STRING = 'test_string' - mod = [(ldap.MOD_REPLACE, 'description', [TEST_STRING])] - topology.master.modify_s(ENTRY_DN, mod) + master_domain = Domain(topology.master, SUFFIX) + consumer_domain = Domain(topology.consumer, SUFFIX)
- ent = topology.consumer.getEntry(ENTRY_DN, ldap.SCOPE_BASE, - "(objectclass=*)") + master_domain.set('description', TEST_STRING)
# The update has been replicated loop = 0 while loop <= 10: - ent = topology.consumer.getEntry(ENTRY_DN, ldap.SCOPE_BASE, - "(objectclass=*)") - if ent and ent.hasValue('description'): - if ent.getValue('description') == TEST_STRING: - break + if consumer_domain.present('description', TEST_STRING): + break time.sleep(1) loop += 1 assert loop <= 10 diff --git a/lib389/tests/idm/user_and_group_test.py b/lib389/tests/idm/user_and_group_test.py index f072dfd..09ff74e 100644 --- a/lib389/tests/idm/user_and_group_test.py +++ b/lib389/tests/idm/user_and_group_test.py @@ -11,7 +11,7 @@ from lib389.properties import * from lib389.tasks import * from lib389.utils import *
-from lib389.idm.user import UserAccounts +from lib389.idm.user import UserAccounts, TEST_USER_PROPERTIES from lib389.idm.group import Groups
from lib389.topologies import topology_st as topology @@ -46,15 +46,7 @@ def test_users_and_groups(topology):
# Create a user
- user_properties = { - 'uid': 'testuser', - 'cn' : 'testuser', - 'sn' : 'user', - 'uidNumber' : '1000', - 'gidNumber' : '2000', - 'homeDirectory' : '/home/testuser' - } - users.create(properties=user_properties) + users.create(properties=TEST_USER_PROPERTIES)
assert(len(users.list()) == 1)
diff --git a/lib389/utils.py b/lib389/utils.py index a42cdaa..2108475 100644 --- a/lib389/utils.py +++ b/lib389/utils.py @@ -782,16 +782,24 @@ def ensure_bytes(val): return val.encode() return val
- def ensure_str(val): if val != None and type(val) != str: return val.decode('utf-8') return val
- def ensure_list_bytes(val): - # if MAJOR >= 3: return [ensure_bytes(v) for v in val]
def ensure_list_str(val): return [ensure_str(v) for v in val] + +def ensure_dict_str(val): + if MAJOR <= 2: + return val + retdict = {} + for k in val: + if isinstance(val[k], list): + retdict[k] = ensure_list_str(val[k]) + else: + retdict[k] = ensure_str(val[k]) + return retdict
This is an automated email from the git hooks/post-receive script.
spichugi pushed a commit to branch master in repository lib389.
commit 46ef071706f88390fa8a7929e693ee096cf2e02b Author: Sankar Ramalingam sramling@redhat.com Date: Tue Jun 6 17:13:42 2017 +0530
Ticket 65 - Add m2c2 topology
Bug Description: Replication topology for two master and two consumers is not available.
Fix Description: Add m2c2 replication topology.
https://pagure.io/lib389/issue/65
Author: Sankar Ramalingam
Reviewed by: spichugi
Signed-off-by: Simon Pichugin spichugi@redhat.com --- lib389/topologies.py | 197 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 197 insertions(+)
diff --git a/lib389/topologies.py b/lib389/topologies.py index 9b2258a..19d121d 100644 --- a/lib389/topologies.py +++ b/lib389/topologies.py @@ -984,3 +984,200 @@ def topology_m4(request): "master4": master4, "master4_agmts": {"m4_m1": m4_m1_agmt, "m4_m2": m4_m2_agmt, "m4_m3": m4_m3_agmt}}) + + +@pytest.fixture(scope="module") +def topology_m2c2(request): + """Create Replication Deployment with two masters and two consumers""" + + # 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_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) + + # Creating consumer 1... + if DEBUGGING: + consumer1 = DirSrv(verbose=True) + else: + consumer1 = DirSrv(verbose=False) + args_instance[SER_HOST] = HOST_CONSUMER_1 + args_instance[SER_PORT] = PORT_CONSUMER_1 + args_instance[SER_SERVERID_PROP] = SERVERID_CONSUMER_1 + args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX + args_consumer = args_instance.copy() + consumer1.allocate(args_consumer) + instance_consumer1 = consumer1.exists() + if instance_consumer1: + consumer1.delete() + consumer1.create() + consumer1.open() + consumer1.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_CONSUMER, replicaId=CONSUMER_REPLICAID) + + # Creating consumer 2... + if DEBUGGING: + consumer2 = DirSrv(verbose=True) + else: + consumer2 = DirSrv(verbose=False) + args_instance[SER_HOST] = HOST_CONSUMER_2 + args_instance[SER_PORT] = PORT_CONSUMER_2 + args_instance[SER_SERVERID_PROP] = SERVERID_CONSUMER_2 + args_instance[SER_CREATION_SUFFIX] = DEFAULT_SUFFIX + args_consumer = args_instance.copy() + consumer2.allocate(args_consumer) + instance_consumer2 = consumer2.exists() + if instance_consumer2: + consumer2.delete() + consumer2.create() + consumer2.open() + consumer2.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_CONSUMER, replicaId=CONSUMER_REPLICAID) + + def fin(): + if DEBUGGING: + master1.stop() + master2.stop() + consumer1.stop() + consumer2.stop() + else: + master1.delete() + master2.delete() + consumer1.delete() + consumer2.delete() + + request.addfinalizer(fin) + + # 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) + + # Creating agreement from master 1 to consumer 1 + properties = {RA_NAME: 'meTo_' + consumer1.host + ':' + str(consumer1.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_c1_agmt = master1.agreement.create(suffix=SUFFIX, host=consumer1.host, port=consumer1.port, + properties=properties) + if not m1_c1_agmt: + log.fatal("Fail to create a hub -> consumer replica agreement") + sys.exit(1) + log.debug("%s created" % m1_c1_agmt) + + # Creating agreement from master 1 to consumer 2 + properties = {RA_NAME: 'meTo_' + consumer2.host + ':' + str(consumer2.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_c2_agmt = master1.agreement.create(suffix=SUFFIX, host=consumer2.host, port=consumer2.port, + properties=properties) + if not m1_c2_agmt: + log.fatal("Fail to create a hub -> consumer replica agreement") + sys.exit(1) + log.debug("%s created" % m1_c2_agmt) + + # Creating agreement from master 2 to consumer 1 + properties = {RA_NAME: 'meTo_' + consumer1.host + ':' + str(consumer1.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_c1_agmt = master2.agreement.create(suffix=SUFFIX, host=consumer1.host, port=consumer1.port, + properties=properties) + if not m2_c1_agmt: + log.fatal("Fail to create a hub -> consumer replica agreement") + sys.exit(1) + log.debug("%s created" % m2_c1_agmt) + + # Creating agreement from master 2 to consumer 2 + properties = {RA_NAME: 'meTo_' + consumer2.host + ':' + str(consumer2.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_c2_agmt = master2.agreement.create(suffix=SUFFIX, host=consumer2.host, port=consumer2.port, + properties=properties) + if not m2_c2_agmt: + log.fatal("Fail to create a hub -> consumer replica agreement") + sys.exit(1) + log.debug("%s created" % m2_c2_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) + master1.agreement.init(SUFFIX, HOST_CONSUMER_1, PORT_CONSUMER_1) + master1.waitForReplInit(m1_c1_agmt) + master1.agreement.init(SUFFIX, HOST_CONSUMER_2, PORT_CONSUMER_2) + master1.waitForReplInit(m1_c2_agmt) + + # Check replication is working... + if master1.testReplication(DEFAULT_SUFFIX, consumer1): + log.info('Replication is working.') + else: + log.fatal('Replication is not working.') + assert False + + # Clear out the tmp dir + master1.clearTmpDir(__file__) + + return TopologyMain(masters={"master1": master1, "master1_agmts": {"m1_m2": m1_m2_agmt, + "m1_c1": m1_c1_agmt, + "m1_c2": m1_c2_agmt}, + "master2": master2, "master2_agmts": {"m2_m1": m2_m1_agmt, + "m2_c1": m2_c1_agmt, + "m2_c2": m2_c2_agmt}}, + consumers={"consumer1": consumer1, "consumer2": consumer2})
389-commits@lists.fedoraproject.org