Explorar o código

Issue 83 - lib389 - Fix tests and create_test.py

Bug description: After the commit that has changed the ReplicaRole
objects in lib389 we have issues with tests.
Also, create_test.py can be opitimized according to the new feature
of create_topology() function.

Fix description: Fix constants in numerous tests. Add copyright block
if it's missing. Refactor create_test.py to use create_topology()
function.

https://pagure.io/lib389/issue/83

Reviewed by: wibrown (Thanks!)
Simon Pichugin %!s(int64=8) %!d(string=hai) anos
pai
achega
63ea19dcbe

+ 48 - 467
dirsrvtests/create_test.py

@@ -47,35 +47,10 @@ def writeFinalizer():
     """Write the finalizer function - delete/stop each instance"""
 
     def writeInstanceOp(action):
-        """Write instance finializer action"""
-
-        if repl_deployment:
-            for idx in range(masters):
-                idx += 1
-                TEST.write('            master' + str(idx) + '.' + action +
-                           '()\n')
-            for idx in range(hubs):
-                idx += 1
-                TEST.write('            hub' + str(idx) + '.' + action +
-                           '()\n')
-            for idx in range(consumers):
-                idx += 1
-                TEST.write('            consumer' + str(idx) + '.' + action +
-                           '()\n')
-        else:
-            for idx in range(instances):
-                idx += 1
-                if idx == 1:
-                    idx = ''
-                else:
-                    idx = str(idx)
-                TEST.write('            standalone' + idx + '.' + action +
-                           '()\n')
+        TEST.write('            map(lambda inst: inst.{}(), topology.all_insts.values())\n'.format(action))
 
     TEST.write('\n    def fin():\n')
-    TEST.write('        """If we are debugging just stop the instances,\n' +
-               '        otherwise remove them\n')
-    TEST.write('        """\n\n')
+    TEST.write('        """If we are debugging just stop the instances, otherwise remove them"""\n\n')
     TEST.write('        if DEBUGGING:\n')
     writeInstanceOp('stop')
     TEST.write('        else:\n')
@@ -237,13 +212,8 @@ if len(sys.argv) > 0:
     else:
         topology_import = ''
 
-    TEST.write('import time\nimport ldap\n' +
-               'import logging\nimport pytest\n')
-    TEST.write('from lib389 import DirSrv, Entry, tools, tasks\nfrom ' +
-               'lib389.tools import DirSrvTools\nfrom lib389._constants ' +
-               'import *\nfrom lib389.properties import *\n' +
-               'from lib389.tasks import *\nfrom lib389.utils import *\n' +
-               '{}\n'.format(topology_import))
+    TEST.write('import logging\nimport pytest\n')
+    TEST.write('{}\n'.format(topology_import))
 
     TEST.write('DEBUGGING = os.getenv("DEBUGGING", default=False)\n')
     TEST.write('if DEBUGGING:\n')
@@ -255,450 +225,61 @@ if len(sys.argv) > 0:
     # Add topology function for non existing (in lib389/topologies.py) topologies only
     if not my_topology[0]:
         # Write the replication or standalone classes
-        repl_deployment = False
-
-        if masters + hubs + consumers > 0:
-            repl_deployment = True
-
-            TEST.write('class TopologyReplication(object):\n')
-            TEST.write('    def __init__(self')
-            for idx in range(masters):
-                TEST.write(', master' + str(idx + 1))
-            for idx in range(hubs):
-                TEST.write(', hub' + str(idx + 1))
-            for idx in range(consumers):
-                TEST.write(', consumer' + str(idx + 1))
-            TEST.write('):\n')
-
-            for idx in range(masters):
-                TEST.write('        master' + str(idx + 1) + '.open()\n')
-                TEST.write('        self.master' + str(idx + 1) + ' = master' +
-                           str(idx + 1) + '\n')
-            for idx in range(hubs):
-                TEST.write('        hub' + str(idx + 1) + '.open()\n')
-                TEST.write('        self.hub' + str(idx + 1) + ' = hub' +
-                           str(idx + 1) + '\n')
-            for idx in range(consumers):
-                TEST.write('        consumer' + str(idx + 1) + '.open()\n')
-                TEST.write('        self.consumer' + str(idx + 1) + ' = consumer' +
-                           str(idx + 1) + '\n')
-            TEST.write('\n\n')
-        else:
-            TEST.write('class TopologyStandalone(object):\n')
-            TEST.write('    def __init__(self')
-            for idx in range(instances):
-                idx += 1
-                if idx == 1:
-                    idx = ''
-                else:
-                    idx = str(idx)
-                TEST.write(', standalone' + idx)
-            TEST.write('):\n')
-
-            for idx in range(instances):
-                idx += 1
-                if idx == 1:
-                    idx = ''
-                else:
-                    idx = str(idx)
-                TEST.write('        standalone' + idx + '.open()\n')
-                TEST.write('        self.standalone' + idx + ' = standalone' +
-                           idx + '\n')
-            TEST.write('\n\n')
+        topologies_str = ""
+        if masters > 0:
+            topologies_str += " {} masters".format(masters)
+        if hubs > 0:
+            topologies_str += " {} hubs".format(hubs)
+        if consumers > 0:
+            topologies_str += " {} consumers".format(consumers)
+        if instances > 0:
+            topologies_str += " {} standalone instances".format(instances)
 
         # Write the 'topology function'
         TEST.write('@pytest.fixture(scope="module")\n')
         TEST.write('def topo(request):\n')
-
-        if repl_deployment:
-            TEST.write('    """Create Replication Deployment"""\n')
-            for idx in range(masters):
-                idx = str(idx + 1)
-                TEST.write('\n    # Creating master ' + idx + '...\n')
-                TEST.write('    if DEBUGGING:\n')
-                TEST.write('        master' + idx + ' = DirSrv(verbose=True)\n')
-                TEST.write('    else:\n')
-                TEST.write('        master' + idx + ' = DirSrv(verbose=False)\n')
-                TEST.write('    args_instance[SER_HOST] = HOST_MASTER_' + idx +
-                           '\n')
-                TEST.write('    args_instance[SER_PORT] = PORT_MASTER_' + idx +
-                           '\n')
-                TEST.write('    args_instance[SER_SERVERID_PROP] = ' +
-                           'SERVERID_MASTER_' + idx + '\n')
-                TEST.write('    args_instance[SER_CREATION_SUFFIX] = ' +
-                           'DEFAULT_SUFFIX\n')
-                TEST.write('    args_master = args_instance.copy()\n')
-                TEST.write('    master' + idx + '.allocate(args_master)\n')
-                TEST.write('    instance_master' + idx + ' = master' + idx +
-                           '.exists()\n')
-                TEST.write('    if instance_master' + idx + ':\n')
-                TEST.write('        master' + idx + '.delete()\n')
-                TEST.write('    master' + idx + '.create()\n')
-                TEST.write('    master' + idx + '.open()\n')
-                TEST.write('    master' + idx + '.replica.enableReplication' +
-                           '(suffix=SUFFIX, role=REPLICAROLE_MASTER, ' +
-                           'replicaId=REPLICAID_MASTER_' + idx + ')\n')
-
-            for idx in range(hubs):
-                idx = str(idx + 1)
-                TEST.write('\n    # Creating hub ' + idx + '...\n')
-                TEST.write('    if DEBUGGING:\n')
-                TEST.write('        hub' + idx + ' = DirSrv(verbose=True)\n')
-                TEST.write('    else:\n')
-                TEST.write('        hub' + idx + ' = DirSrv(verbose=False)\n')
-                TEST.write('    args_instance[SER_HOST] = HOST_HUB_' + idx + '\n')
-                TEST.write('    args_instance[SER_PORT] = PORT_HUB_' + idx + '\n')
-                TEST.write('    args_instance[SER_SERVERID_PROP] = SERVERID_HUB_' +
-                           idx + '\n')
-                TEST.write('    args_instance[SER_CREATION_SUFFIX] = ' +
-                           'DEFAULT_SUFFIX\n')
-                TEST.write('    args_hub = args_instance.copy()\n')
-                TEST.write('    hub' + idx + '.allocate(args_hub)\n')
-                TEST.write('    instance_hub' + idx + ' = hub' + idx +
-                           '.exists()\n')
-                TEST.write('    if instance_hub' + idx + ':\n')
-                TEST.write('        hub' + idx + '.delete()\n')
-                TEST.write('    hub' + idx + '.create()\n')
-                TEST.write('    hub' + idx + '.open()\n')
-                TEST.write('    hub' + idx + '.replica.enableReplication' +
-                           '(suffix=SUFFIX, role=REPLICAROLE_HUB, ' +
-                           'replicaId=REPLICAID_HUB_' + idx + ')\n')
-
-            for idx in range(consumers):
-                idx = str(idx + 1)
-                TEST.write('\n    # Creating consumer ' + idx + '...\n')
-                TEST.write('    if DEBUGGING:\n')
-                TEST.write('        consumer' + idx + ' = DirSrv(verbose=True)\n')
-                TEST.write('    else:\n')
-                TEST.write('        consumer' + idx + ' = DirSrv(verbose=False)\n')
-                TEST.write('    args_instance[SER_HOST] = HOST_CONSUMER_' + idx +
-                           '\n')
-                TEST.write('    args_instance[SER_PORT] = PORT_CONSUMER_' + idx +
-                           '\n')
-                TEST.write('    args_instance[SER_SERVERID_PROP] = ' +
-                           'SERVERID_CONSUMER_' + idx + '\n')
-                TEST.write('    args_instance[SER_CREATION_SUFFIX] = ' +
-                           'DEFAULT_SUFFIX\n')
-                TEST.write('    args_consumer = args_instance.copy()\n')
-                TEST.write('    consumer' + idx + '.allocate(args_consumer)\n')
-                TEST.write('    instance_consumer' + idx + ' = consumer' + idx +
-                           '.exists()\n')
-                TEST.write('    if instance_consumer' + idx + ':\n')
-                TEST.write('        consumer' + idx + '.delete()\n')
-                TEST.write('    consumer' + idx + '.create()\n')
-                TEST.write('    consumer' + idx + '.open()\n')
-                TEST.write('    consumer' + idx + '.replica.enableReplication' +
-                           '(suffix=SUFFIX, role=REPLICAROLE_CONSUMER, ' +
-                           'replicaId=CONSUMER_REPLICAID)\n')
-
-            writeFinalizer()
-
-            # Create the master agreements
-            TEST.write('    # Create all the agreements\n')
-            agmt_count = 0
-
-            for idx in range(masters):
-                master_idx = idx + 1
-
-                # Create agreements with the other masters (master -> master)
-                for idx in range(masters):
-                    idx += 1
-
-                    # Skip ourselves
-                    if master_idx == idx:
-                        continue
-
-                    TEST.write('\n    # Creating agreement from master ' +
-                               str(master_idx) + ' to master ' + str(idx) + '\n')
-                    TEST.write("    properties = {RA_NAME: " +
-                               "'meTo_' + master" + str(idx) +
-                               ".host + ':' + str(master" + str(idx) +
-                               ".port),\n")
-                    TEST.write("                  RA_BINDDN: " +
-                               "defaultProperties[REPLICATION_BIND_DN],\n")
-                    TEST.write("                  RA_BINDPW: " +
-                               "defaultProperties[REPLICATION_BIND_PW],\n")
-                    TEST.write("                  RA_METHOD: " +
-                               "defaultProperties[REPLICATION_BIND_METHOD],\n")
-                    TEST.write("                  RA_TRANSPORT_PROT: " +
-                               "defaultProperties[REPLICATION_TRANSPORT]}\n")
-                    TEST.write('    m' + str(master_idx) + '_m' + str(idx) +
-                               '_agmt = master' + str(master_idx) +
-                               '.agreement.create(suffix=SUFFIX, host=master' +
-                               str(idx) + '.host, port=master' + str(idx) +
-                               '.port, properties=properties)\n')
-                    TEST.write('    if not m' + str(master_idx) + '_m' + str(idx) +
-                               '_agmt:\n')
-                    TEST.write('        log.fatal("Fail to create a master -> ' +
-                               'master replica agreement")\n')
-                    TEST.write('        sys.exit(1)\n')
-                    TEST.write('    log.debug("%s created" % m' + str(master_idx) +
-                               '_m' + str(idx) + '_agmt)\n')
-                    agmt_count += 1
-
-                # Create agmts from each master to each hub (master -> hub)
-                for idx in range(hubs):
-                    idx += 1
-                    TEST.write('\n    # Creating agreement from master ' +
-                               str(master_idx) + ' to hub ' + str(idx) + '\n')
-                    TEST.write("    properties = {RA_NAME: " +
-                               "'meTo_' + hub" + str(idx) +
-                               ".host + ':' + str(hub" + str(idx) +
-                               ".port),\n")
-                    TEST.write("                  RA_BINDDN: " +
-                               "defaultProperties[REPLICATION_BIND_DN],\n")
-                    TEST.write("                  RA_BINDPW: " +
-                               "defaultProperties[REPLICATION_BIND_PW],\n")
-                    TEST.write("                  RA_METHOD: " +
-                               "defaultProperties[REPLICATION_BIND_METHOD],\n")
-                    TEST.write("                  RA_TRANSPORT_PROT: " +
-                               "defaultProperties[REPLICATION_TRANSPORT]}\n")
-                    TEST.write('    m' + str(master_idx) + '_h' + str(idx) +
-                               '_agmt = master' + str(master_idx) +
-                               '.agreement.create(suffix=SUFFIX, host=hub' +
-                               str(idx) + '.host, port=hub' + str(idx) +
-                               '.port, properties=properties)\n')
-                    TEST.write('    if not m' + str(master_idx) + '_h' + str(idx) +
-                               '_agmt:\n')
-                    TEST.write('        log.fatal("Fail to create a master -> ' +
-                               'hub replica agreement")\n')
-                    TEST.write('        sys.exit(1)\n')
-                    TEST.write('    log.debug("%s created" % m' + str(master_idx) +
-                               '_h' + str(idx) + '_agmt)\n')
-                    agmt_count += 1
-
-            # Create the hub agreements
-            for idx in range(hubs):
-                hub_idx = idx + 1
-
-                # Add agreements from each hub to each consumer (hub -> consumer)
-                for idx in range(consumers):
-                    idx += 1
-                    TEST.write('\n    # Creating agreement from hub ' + str(hub_idx)
-                               + ' to consumer ' + str(idx) + '\n')
-                    TEST.write("    properties = {RA_NAME: " +
-                               "'meTo_' + consumer" + str(idx) +
-                               ".host + ':' + str(consumer" + str(idx) +
-                               ".port),\n")
-                    TEST.write("                  RA_BINDDN: " +
-                               "defaultProperties[REPLICATION_BIND_DN],\n")
-                    TEST.write("                  RA_BINDPW: " +
-                               "defaultProperties[REPLICATION_BIND_PW],\n")
-                    TEST.write("                  RA_METHOD: " +
-                               "defaultProperties[REPLICATION_BIND_METHOD],\n")
-                    TEST.write("                  RA_TRANSPORT_PROT: " +
-                               "defaultProperties[REPLICATION_TRANSPORT]}\n")
-                    TEST.write('    h' + str(hub_idx) + '_c' + str(idx) +
-                               '_agmt = hub' + str(hub_idx) +
-                               '.agreement.create(suffix=SUFFIX, host=consumer' +
-                               str(idx) + '.host, port=consumer' + str(idx) +
-                               '.port, properties=properties)\n')
-                    TEST.write('    if not h' + str(hub_idx) + '_c' + str(idx) +
-                               '_agmt:\n')
-                    TEST.write('        log.fatal("Fail to create a hub -> ' +
-                               'consumer replica agreement")\n')
-                    TEST.write('        sys.exit(1)\n')
-                    TEST.write('    log.debug("%s created" % h' + str(hub_idx) +
-                               '_c' + str(idx) + '_agmt)\n')
-                    agmt_count += 1
-
-            # No Hubs, see if there are any consumers to create agreements to
-            if hubs == 0:
-
-                # Create agreements with the consumers (master -> consumer)
-                for idx in range(masters):
-                    master_idx = idx + 1
-
-                    for idx in range(consumers):
-                        idx += 1
-                        TEST.write('\n    # Creating agreement from master ' +
-                                   str(master_idx) + ' to consumer ' + str(idx) +
-                                   '\n')
-                        TEST.write("    properties = {RA_NAME: " +
-                                   "'meTo_' + consumer" + str(idx) +
-                                   ".host + ':' + str(consumer" + str(idx) +
-                                   ".port),\n")
-                        TEST.write("                  RA_BINDDN: " +
-                                   "defaultProperties[REPLICATION_BIND_DN],\n")
-                        TEST.write("                  RA_BINDPW: " +
-                                   "defaultProperties[REPLICATION_BIND_PW],\n")
-                        TEST.write("                  RA_METHOD: " +
-                                   "defaultProperties[REPLICATION_BIND_METHOD],\n")
-                        TEST.write("                  RA_TRANSPORT_PROT: " +
-                                   "defaultProperties[REPLICATION_TRANSPORT]}\n")
-                        TEST.write('    m' + str(master_idx) + '_c' + str(idx) +
-                                   '_agmt = master' + str(master_idx) +
-                                   '.agreement.create(suffix=SUFFIX, ' +
-                                   'host=consumer' + str(idx) +
-                                   '.host, port=consumer' + str(idx) +
-                                   '.port, properties=properties)\n')
-                        TEST.write('    if not m' + str(master_idx) + '_c' +
-                                   str(idx) + '_agmt:\n')
-                        TEST.write('        log.fatal("Fail to create a hub -> ' +
-                                   'consumer replica agreement")\n')
-                        TEST.write('        sys.exit(1)\n')
-                        TEST.write('    log.debug("%s created" % m' +
-                                   str(master_idx) + '_c' + str(idx) +
-                                   '_agmt)\n')
-                        agmt_count += 1
-
-            # Add sleep that allows all the agreements to get situated
-            TEST.write('\n    # Allow the replicas to get situated with the new ' +
-                       'agreements...\n')
-            TEST.write('    time.sleep(5)\n')
-
-            # Write the replication initializations
-            TEST.write('\n    # Initialize all the agreements\n')
-
-            # Masters
-            for idx in range(masters):
-                idx += 1
-                if idx == 1:
-                    continue
-                TEST.write('    master1.agreement.init(SUFFIX, HOST_MASTER_' +
-                           str(idx) + ', PORT_MASTER_' + str(idx) + ')\n')
-                TEST.write('    master1.waitForReplInit(m1_m' + str(idx) +
-                           '_agmt)\n')
-
-            # Hubs
-            consumers_inited = False
-            for idx in range(hubs):
-                idx += 1
-                TEST.write('    master1.agreement.init(SUFFIX, HOST_HUB_' +
-                           str(idx) + ', PORT_HUB_' + str(idx) + ')\n')
-                TEST.write('    master1.waitForReplInit(m1_h' + str(idx) +
-                           '_agmt)\n')
-                for idx in range(consumers):
-                    if consumers_inited:
-                        continue
-                    idx += 1
-                    TEST.write('    hub1.agreement.init(SUFFIX, HOST_CONSUMER_' +
-                               str(idx) + ', PORT_CONSUMER_' + str(idx) + ')\n')
-                    TEST.write('    hub1.waitForReplInit(h1_c' + str(idx) +
-                               '_agmt)\n')
-                consumers_inited = True
-
-            # Consumers (master -> consumer)
-            if hubs == 0:
-                for idx in range(consumers):
-                    idx += 1
-                    TEST.write('    master1.agreement.init(SUFFIX, ' +
-                               'HOST_CONSUMER_' + str(idx) + ', PORT_CONSUMER_' +
-                               str(idx) + ')\n')
-                    TEST.write('    master1.waitForReplInit(m1_c' + str(idx) +
-                               '_agmt)\n')
-
-            TEST.write('\n')
-
-            # Write replicaton check
-            if agmt_count > 0:
-                # Find the lowest replica type (consumer -> master)
-                if consumers > 0:
-                    replica = 'consumer1'
-                elif hubs > 0:
-                    replica = 'hub1'
-                else:
-                    replica = 'master2'
-                TEST.write('    # Check replication is working...\n')
-                TEST.write('    if master1.testReplication(DEFAULT_SUFFIX, ' +
-                           replica + '):\n')
-                TEST.write("        log.info('Replication is working.')\n")
-                TEST.write('    else:\n')
-                TEST.write("        log.fatal('Replication is not working.')\n")
-                TEST.write('        assert False\n')
-                TEST.write('\n')
-
-            # Write the finals steps for replication
-            TEST.write('    # Clear out the tmp dir\n')
-            TEST.write('    master1.clearTmpDir(__file__)\n\n')
-            TEST.write('    return TopologyReplication(master1')
-
-            for idx in range(masters):
-                idx += 1
-                if idx == 1:
-                    continue
-                TEST.write(', master' + str(idx))
-            for idx in range(hubs):
-                TEST.write(', hub' + str(idx + 1))
-            for idx in range(consumers):
-                TEST.write(', consumer' + str(idx + 1))
-            TEST.write(')\n\n\n')
-
-        # Standalone servers
-        else:
-            TEST.write('    """Create DS Deployment"""\n')
-            for idx in range(instances):
-                idx += 1
-                if idx == 1:
-                    idx = ''
-                else:
-                    idx = str(idx)
-                TEST.write('\n    # Creating standalone instance ' + idx + '...\n')
-                TEST.write('    if DEBUGGING:\n')
-                TEST.write('        standalone' + idx +
-                           ' = DirSrv(verbose=True)\n')
-                TEST.write('    else:\n')
-                TEST.write('        standalone' + idx +
-                           ' = DirSrv(verbose=False)\n')
-                TEST.write('    args_instance[SER_HOST] = HOST_STANDALONE' +
-                           idx + '\n')
-                TEST.write('    args_instance[SER_PORT] = PORT_STANDALONE' +
-                           idx + '\n')
-                TEST.write('    args_instance[SER_SERVERID_PROP] = ' +
-                           'SERVERID_STANDALONE' + idx + '\n')
-                TEST.write('    args_instance[SER_CREATION_SUFFIX] = ' +
-                           'DEFAULT_SUFFIX\n')
-                TEST.write('    args_standalone' + idx + ' = args_instance.copy' +
-                           '()\n')
-                TEST.write('    standalone' + idx + '.allocate(args_standalone' +
-                           idx + ')\n')
-
-                # Get the status of the instance and restart it if it exists
-                TEST.write('    instance_standalone' + idx + ' = standalone' +
-                           idx + '.exists()\n')
-
-                # Remove the instance
-                TEST.write('    if instance_standalone' + idx + ':\n')
-                TEST.write('        standalone' + idx + '.delete()\n')
-
-                # Create and open the instance
-                TEST.write('    standalone' + idx + '.create()\n')
-                TEST.write('    standalone' + idx + '.open()\n')
-
-            writeFinalizer()
-
-            TEST.write('    return TopologyStandalone(standalone')
-            for idx in range(instances):
-                idx += 1
-                if idx == 1:
-                    continue
-                TEST.write(', standalone' + str(idx))
-            TEST.write(')\n\n\n')
+        TEST.write('    """Create a topology with{}"""\n\n'.format(topologies_str))
+        TEST.write('    topology = create_topology({\n')
+        if masters > 0:
+            TEST.write('        ReplicaRole.MASTER: {},\n'.format(masters))
+        if hubs > 0:
+            TEST.write('        ReplicaRole.HUB: {},\n'.format(hubs))
+        if consumers > 0:
+            TEST.write('        ReplicaRole.CONSUMER: {},\n'.format(consumers))
+        if instances > 0:
+            TEST.write('        ReplicaRole.STANDALONE: {},\n'.format(instances))
+        TEST.write('        })\n')
+
+        TEST.write('    # You can write replica test here. Just uncomment the block and choose instances\n')
+        TEST.write('    # replicas = Replicas(topology.ms["master1"])\n')
+        TEST.write('    # replicas.test(DEFAULT_SUFFIX, topology.cs["consumer1"])\n')
+
+        writeFinalizer()
 
     tc_id = '0'
     while not check_id_uniqueness(tc_id): tc_id = uuid.uuid4()
 
     # Write the test function
     if ticket:
-        TEST.write('def test_ticket{}(topo):\n'.format(ticket))
-        TEST.write('    """Write your testcase here...\n\n')
-        TEST.write('    Also, if you need any testcase initialization,\n')
-        TEST.write('    please, write additional fixture for that' +
-                   '(include finalizer).\n')
-        TEST.write('    """\n\n')
+        TEST.write('\ndef test_ticket{}(topo):\n'.format(ticket))
     else:
-        TEST.write('def test_something(topo):\n')
-        TEST.write('    """Write one-line test case purpose (name) here\n\n')
-        TEST.write('    :ID: {}\n'.format(tc_id))
-        TEST.write('    :feature: Fill in feature name here\n')
-        TEST.write('    :setup: Fill in set up configuration here\n')
-        TEST.write('    :steps: 1. Fill in test case steps here\n')
-        TEST.write('            2. And indent them like this (RST format requirement)\n')
-        TEST.write('    :expectedresults: Fill in the result that is expected\n')
-        TEST.write('    """\n\n')
-        TEST.write('    # If you need any test suite initialization,\n')
-        TEST.write('    # please, write additional fixture for that (including finalizer).\n'
-                   '    # Topology for suites are predefined in lib389/topologies.py.\n\n')
+        TEST.write('\ndef test_something(topo):\n')
+    TEST.write('    """Write one-line test case purpose (name) here\n\n')
+    TEST.write('    :id: {}\n'.format(tc_id))
+    TEST.write('    :feature: Fill in feature name here\n')
+    TEST.write('    :setup: Fill in set up configuration here\n')
+    TEST.write('    :steps:\n')
+    TEST.write('        1. Fill in test case steps here\n')
+    TEST.write('        2. And indent them like this (RST format requirement)\n')
+    TEST.write('    :expectedresults:\n')
+    TEST.write('        1. Fill in the result that is expected\n')
+    TEST.write('        2. For each test step\n')
+    TEST.write('    """\n\n')
+    TEST.write('    # If you need any test suite initialization,\n')
+    TEST.write('    # please, write additional fixture for that (including finalizer).\n'
+               '    # Topology for suites are predefined in lib389/topologies.py.\n\n')
+    TEST.write('    # If you need host, port or any other data about instance,\n')
+    TEST.write('    # Please, use the instance object attributes for that (for example, topo.ms["master1"].serverid)\n\n')
 
     TEST.write('    if DEBUGGING:\n')
     TEST.write('        # Add debugging steps(if any)...\n')

+ 2 - 2
dirsrvtests/tests/stress/reliabilty/reliab_7_5_test.py

@@ -62,7 +62,7 @@ def topology(request):
         master1.delete()
     master1.create()
     master1.open()
-    master1.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER,
+    master1.replica.enableReplication(suffix=SUFFIX, role=ReplicaRole.MASTER,
                                       replicaId=REPLICAID_MASTER_1)
 
     # Creating master 2...
@@ -78,7 +78,7 @@ def topology(request):
         master2.delete()
     master2.create()
     master2.open()
-    master2.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER,
+    master2.replica.enableReplication(suffix=SUFFIX, role=ReplicaRole.MASTER,
                                       replicaId=REPLICAID_MASTER_2)
 
     #

+ 10 - 10
dirsrvtests/tests/stress/replication/mmr_01_4m-2h-4c_test.py

@@ -89,7 +89,7 @@ def topology(request):
         master1.delete()
     master1.create()
     master1.open()
-    master1.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER,
+    master1.replica.enableReplication(suffix=SUFFIX, role=ReplicaRole.MASTER,
                                       replicaId=REPLICAID_MASTER_1)
 
     # Creating master 2...
@@ -108,7 +108,7 @@ def topology(request):
         master2.delete()
     master2.create()
     master2.open()
-    master2.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER,
+    master2.replica.enableReplication(suffix=SUFFIX, role=ReplicaRole.MASTER,
                                       replicaId=REPLICAID_MASTER_2)
 
     # Creating master 3...
@@ -127,7 +127,7 @@ def topology(request):
         master3.delete()
     master3.create()
     master3.open()
-    master3.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER,
+    master3.replica.enableReplication(suffix=SUFFIX, role=ReplicaRole.MASTER,
                                       replicaId=REPLICAID_MASTER_3)
 
     # Creating master 4...
@@ -146,7 +146,7 @@ def topology(request):
         master4.delete()
     master4.create()
     master4.open()
-    master4.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER,
+    master4.replica.enableReplication(suffix=SUFFIX, role=ReplicaRole.MASTER,
                                       replicaId=REPLICAID_MASTER_4)
 
     # Creating hub 1...
@@ -165,7 +165,7 @@ def topology(request):
         hub1.delete()
     hub1.create()
     hub1.open()
-    hub1.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_HUB,
+    hub1.replica.enableReplication(suffix=SUFFIX, role=ReplicaRole.HUB,
                                    replicaId=REPLICAID_HUB_1)
 
     # Creating hub 2...
@@ -184,7 +184,7 @@ def topology(request):
         hub2.delete()
     hub2.create()
     hub2.open()
-    hub2.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_HUB,
+    hub2.replica.enableReplication(suffix=SUFFIX, role=ReplicaRole.HUB,
                                    replicaId=REPLICAID_HUB_2)
 
     # Creating consumer 1...
@@ -204,7 +204,7 @@ def topology(request):
     consumer1.create()
     consumer1.open()
     consumer1.replica.enableReplication(suffix=SUFFIX,
-                                        role=REPLICAROLE_CONSUMER,
+                                        role=ReplicaRole.CONSUMER,
                                         replicaId=CONSUMER_REPLICAID)
 
     # Creating consumer 2...
@@ -224,7 +224,7 @@ def topology(request):
     consumer2.create()
     consumer2.open()
     consumer2.replica.enableReplication(suffix=SUFFIX,
-                                        role=REPLICAROLE_CONSUMER,
+                                        role=ReplicaRole.CONSUMER,
                                         replicaId=CONSUMER_REPLICAID)
 
     # Creating consumer 3...
@@ -244,7 +244,7 @@ def topology(request):
     consumer3.create()
     consumer3.open()
     consumer3.replica.enableReplication(suffix=SUFFIX,
-                                        role=REPLICAROLE_CONSUMER,
+                                        role=ReplicaRole.CONSUMER,
                                         replicaId=CONSUMER_REPLICAID)
 
     # Creating consumer 4...
@@ -264,7 +264,7 @@ def topology(request):
     consumer4.create()
     consumer4.open()
     consumer4.replica.enableReplication(suffix=SUFFIX,
-                                        role=REPLICAROLE_CONSUMER,
+                                        role=ReplicaRole.CONSUMER,
                                         replicaId=CONSUMER_REPLICAID)
 
     #

+ 4 - 4
dirsrvtests/tests/stress/replication/mmr_01_4m_test.py

@@ -66,7 +66,7 @@ def topology(request):
         master1.delete()
     master1.create()
     master1.open()
-    master1.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER,
+    master1.replica.enableReplication(suffix=SUFFIX, role=ReplicaRole.MASTER,
                                       replicaId=REPLICAID_MASTER_1)
 
     # Creating master 2...
@@ -85,7 +85,7 @@ def topology(request):
         master2.delete()
     master2.create()
     master2.open()
-    master2.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER,
+    master2.replica.enableReplication(suffix=SUFFIX, role=ReplicaRole.MASTER,
                                       replicaId=REPLICAID_MASTER_2)
 
     # Creating master 3...
@@ -104,7 +104,7 @@ def topology(request):
         master3.delete()
     master3.create()
     master3.open()
-    master3.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER,
+    master3.replica.enableReplication(suffix=SUFFIX, role=ReplicaRole.MASTER,
                                       replicaId=REPLICAID_MASTER_3)
 
     # Creating master 4...
@@ -123,7 +123,7 @@ def topology(request):
         master4.delete()
     master4.create()
     master4.open()
-    master4.replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER,
+    master4.replica.enableReplication(suffix=SUFFIX, role=ReplicaRole.MASTER,
                                       replicaId=REPLICAID_MASTER_4)
 
     #

+ 4 - 4
dirsrvtests/tests/suites/dynamic_plugins/dynamic_plugins_test.py

@@ -23,8 +23,8 @@ import stress_tests
 from lib389.topologies import topology_st
 from lib389._constants import (DN_CONFIG, DEFAULT_SUFFIX, DN_LDBM, defaultProperties,
                                PLUGIN_MEMBER_OF, PLUGIN_LINKED_ATTRS, PLUGIN_REFER_INTEGRITY,
-                               REPLICAROLE_MASTER, REPLICAROLE_CONSUMER, REPLICATION_BIND_DN,
-                               REPLICATION_BIND_PW, REPLICATION_BIND_METHOD, REPLICATION_TRANSPORT,
+                               ReplicaRole, REPLICATION_BIND_DN, REPLICATION_BIND_PW,
+                               REPLICATION_BIND_METHOD, REPLICATION_TRANSPORT,
                                LOCALHOST, REPLICA_RUV_FILTER, args_instance,
                                RA_NAME, RA_BINDDN, RA_BINDPW, RA_METHOD, RA_TRANSPORT_PROT)
 
@@ -283,10 +283,10 @@ def test_dynamic_plugins(topology_st):
 
             try:
                 topology_st.standalone.replica.enableReplication(suffix=DEFAULT_SUFFIX,
-                                                                 role=REPLICAROLE_MASTER,
+                                                                 role=ReplicaRole.MASTER,
                                                                  replicaId=1)
                 replica_inst.replica.enableReplication(suffix=DEFAULT_SUFFIX,
-                                                       role=REPLICAROLE_CONSUMER,
+                                                       role=ReplicaRole.CONSUMER,
                                                        replicaId=65535)
                 properties = {RA_NAME: r'to_replica',
                               RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],

+ 3 - 3
dirsrvtests/tests/suites/replication/acceptance_test.py

@@ -12,7 +12,7 @@ from lib389.utils import *
 from lib389.topologies import topology_m4 as topo_m4
 
 from lib389._constants import (BACKEND_NAME, DEFAULT_SUFFIX, LOG_REPLICA, REPLICA_RUV_FILTER,
-                              REPLICAROLE_MASTER, REPLICATION_BIND_DN, REPLICATION_BIND_PW,
+                              ReplicaRole, REPLICATION_BIND_DN, REPLICATION_BIND_PW,
                               REPLICATION_BIND_METHOD, REPLICATION_TRANSPORT, defaultProperties,
                               RA_NAME, RA_BINDDN, RA_BINDPW, RA_METHOD, RA_TRANSPORT_PROT,
                               DN_DM, PASSWORD, LOG_DEFAULT)
@@ -332,8 +332,8 @@ def test_new_suffix(topo_m4, new_suffix):
     m1 = topo_m4.ms["master1"]
     m2 = topo_m4.ms["master2"]
     log.info('Enable replication for new suffix {} on two masters'.format(NEW_SUFFIX))
-    m1.replica.enableReplication(NEW_SUFFIX, REPLICAROLE_MASTER, 101)
-    m2.replica.enableReplication(NEW_SUFFIX, REPLICAROLE_MASTER, 102)
+    m1.replica.enableReplication(NEW_SUFFIX, ReplicaRole.MASTER, 101)
+    m2.replica.enableReplication(NEW_SUFFIX, ReplicaRole.MASTER, 102)
 
     log.info("Creating agreement from master1 to master2")
     properties = {RA_NAME: 'newMeTo_{}:{}'.format(m2.host, str(m2.port)),

+ 2 - 2
dirsrvtests/tests/suites/replication/cleanallruv_test.py

@@ -13,7 +13,7 @@ from lib389.tasks import *
 from lib389.utils import *
 from lib389.topologies import topology_m4
 
-from lib389._constants import (DEFAULT_SUFFIX, REPLICA_RUV_FILTER, REPLICAROLE_MASTER,
+from lib389._constants import (DEFAULT_SUFFIX, REPLICA_RUV_FILTER, ReplicaRole,
                               REPLICAID_MASTER_4, REPLICAID_MASTER_3, REPLICAID_MASTER_2,
                               REPLICAID_MASTER_1, REPLICATION_BIND_DN, REPLICATION_BIND_PW,
                               REPLICATION_BIND_METHOD, REPLICATION_TRANSPORT, SUFFIX,
@@ -150,7 +150,7 @@ def restore_master4(topology_m4):
     log.info('Restoring master 4...')
 
     # Enable replication on master 4
-    topology_m4.ms["master4"].replica.enableReplication(suffix=SUFFIX, role=REPLICAROLE_MASTER,
+    topology_m4.ms["master4"].replica.enableReplication(suffix=SUFFIX, role=ReplicaRole.MASTER,
                                                         replicaId=REPLICAID_MASTER_4)
 
     for num in range(1, 4):

+ 7 - 7
dirsrvtests/tests/suites/replication/single_master_test.py

@@ -12,11 +12,11 @@ from lib389.utils import *
 from lib389.topologies import topology_m1c1 as topo_r # Replication
 from lib389.topologies import topology_i2 as topo_nr # No replication
 
-from lib389._constants import (REPLICAROLE_MASTER, DEFAULT_SUFFIX, REPLICAID_MASTER_1,
-                              REPLICAROLE_CONSUMER, REPLICATION_BIND_DN, REPLICATION_BIND_PW,
-                              REPLICATION_BIND_METHOD, REPLICATION_TRANSPORT, DEFAULT_BACKUPDIR,
-                              RA_NAME, RA_BINDDN, RA_BINDPW, RA_METHOD, RA_TRANSPORT_PROT,
-                              defaultProperties)
+from lib389._constants import (ReplicaRole, DEFAULT_SUFFIX, REPLICAID_MASTER_1,
+                                REPLICATION_BIND_DN, REPLICATION_BIND_PW,
+                                REPLICATION_BIND_METHOD, REPLICATION_TRANSPORT, DEFAULT_BACKUPDIR,
+                                RA_NAME, RA_BINDDN, RA_BINDPW, RA_METHOD, RA_TRANSPORT_PROT,
+                                defaultProperties)
 
 DEBUGGING = os.getenv("DEBUGGING", default=False)
 if DEBUGGING:
@@ -65,9 +65,9 @@ def replica_without_init(topo_nr):
     master = topo_nr.ins["standalone1"]
     consumer = topo_nr.ins["standalone2"]
 
-    master.replica.enableReplication(suffix=DEFAULT_SUFFIX, role=REPLICAROLE_MASTER,
+    master.replica.enableReplication(suffix=DEFAULT_SUFFIX, role=ReplicaRole.MASTER,
                                      replicaId=REPLICAID_MASTER_1)
-    consumer.replica.enableReplication(suffix=DEFAULT_SUFFIX, role=REPLICAROLE_CONSUMER)
+    consumer.replica.enableReplication(suffix=DEFAULT_SUFFIX, role=ReplicaRole.CONSUMER)
     properties = {RA_NAME: 'meTo_{}:{}'.format(consumer.host, str(consumer.port)),
                   RA_BINDDN: defaultProperties[REPLICATION_BIND_DN],
                   RA_BINDPW: defaultProperties[REPLICATION_BIND_PW],

+ 2 - 2
dirsrvtests/tests/suites/replication/tombstone_test.py

@@ -11,7 +11,7 @@ from lib389.tasks import *
 from lib389.utils import *
 from lib389.topologies import topology_st
 
-from lib389._constants import DEFAULT_SUFFIX, REPLICAROLE_MASTER, REPLICAID_MASTER_1
+from lib389._constants import DEFAULT_SUFFIX, ReplicaRole, REPLICAID_MASTER_1
 
 def test_purge_success(topology_st):
     """Verify that tombstones are created successfully
@@ -28,7 +28,7 @@ def test_purge_success(topology_st):
 
     log.info('Setting up replication...')
     topology_st.standalone.replica.enableReplication(suffix=DEFAULT_SUFFIX,
-                                                     role=REPLICAROLE_MASTER,
+                                                     role=ReplicaRole.MASTER,
                                                      replicaId=REPLICAID_MASTER_1)
 
     log.info("Add and then delete an entry to create a tombstone...")

+ 5 - 5
dirsrvtests/tests/tickets/ticket47781_test.py

@@ -12,10 +12,10 @@ import pytest
 from lib389.tasks import *
 from lib389.topologies import topology_st
 
-from lib389._constants import (defaultProperties, DEFAULT_SUFFIX, REPLICAROLE_MASTER,
-                              REPLICAID_MASTER_1, REPLICATION_BIND_DN, REPLICATION_BIND_PW,
-                              REPLICATION_BIND_METHOD, REPLICATION_TRANSPORT, RA_NAME,
-                              RA_BINDDN, RA_BINDPW, RA_METHOD, RA_TRANSPORT_PROT)
+from lib389._constants import (defaultProperties, DEFAULT_SUFFIX, ReplicaRole,
+                               REPLICAID_MASTER_1, REPLICATION_BIND_DN, REPLICATION_BIND_PW,
+                               REPLICATION_BIND_METHOD, REPLICATION_TRANSPORT, RA_NAME,
+                               RA_BINDDN, RA_BINDPW, RA_METHOD, RA_TRANSPORT_PROT)
 
 log = logging.getLogger(__name__)
 
@@ -32,7 +32,7 @@ def test_ticket47781(topology_st):
     # Setup Replication
     #
     log.info('Setting up replication...')
-    topology_st.standalone.replica.enableReplication(suffix=DEFAULT_SUFFIX, role=REPLICAROLE_MASTER,
+    topology_st.standalone.replica.enableReplication(suffix=DEFAULT_SUFFIX, role=ReplicaRole.MASTER,
                                                      replicaId=REPLICAID_MASTER_1)
 
     properties = {RA_NAME: r'meTo_$host:$port',

+ 4 - 4
dirsrvtests/tests/tickets/ticket47819_test.py

@@ -12,9 +12,9 @@ import pytest
 from lib389.tasks import *
 from lib389.topologies import topology_st
 
-from lib389._constants import (defaultProperties, DEFAULT_SUFFIX, REPLICAROLE_MASTER,
-                              REPLICAID_MASTER_1, REPLICA_PRECISE_PURGING, REPLICA_PURGE_DELAY,
-                              REPLICA_PURGE_INTERVAL)
+from lib389._constants import (defaultProperties, DEFAULT_SUFFIX, ReplicaRole,
+                               REPLICAID_MASTER_1, REPLICA_PRECISE_PURGING, REPLICA_PURGE_DELAY,
+                               REPLICA_PURGE_INTERVAL)
 
 log = logging.getLogger(__name__)
 
@@ -39,7 +39,7 @@ pytestmark = pytest.mark.skipif(ds_is_older('1.3.4'), reason="Not implemented")
     # Setup Replication
     #
     log.info('Setting up replication...')
-    topology_st.standalone.replica.enableReplication(suffix=DEFAULT_SUFFIX, role=REPLICAROLE_MASTER,
+    topology_st.standalone.replica.enableReplication(suffix=DEFAULT_SUFFIX, role=ReplicaRole.MASTER,
                                                      replicaId=REPLICAID_MASTER_1)
 
     #

+ 6 - 6
dirsrvtests/tests/tickets/ticket47950_test.py

@@ -12,11 +12,11 @@ import pytest
 from lib389.tasks import *
 from lib389.topologies import topology_st
 
-from lib389._constants import (defaultProperties, DEFAULT_SUFFIX, REPLICAROLE_MASTER,
-                              REPLICAID_MASTER_1, REPLICATION_BIND_DN, REPLICATION_BIND_PW,
-                              REPLICATION_BIND_METHOD, REPLICATION_TRANSPORT, RA_NAME,
-                              RA_BINDDN, RA_BINDPW, RA_METHOD, RA_TRANSPORT_PROT,
-                              DN_DM, PASSWORD, REPLICA_ID, RA_CONSUMER_PORT)
+from lib389._constants import (defaultProperties, DEFAULT_SUFFIX, ReplicaRole,
+                               REPLICAID_MASTER_1, REPLICATION_BIND_DN, REPLICATION_BIND_PW,
+                               REPLICATION_BIND_METHOD, REPLICATION_TRANSPORT, RA_NAME,
+                               RA_BINDDN, RA_BINDPW, RA_METHOD, RA_TRANSPORT_PROT,
+                               DN_DM, PASSWORD, REPLICA_ID, RA_CONSUMER_PORT)
 
 log = logging.getLogger(__name__)
 
@@ -107,7 +107,7 @@ def test_ticket47950(topology_st):
         assert False
 
     try:
-        topology_st.standalone.replica.enableReplication(suffix=DEFAULT_SUFFIX, role=REPLICAROLE_MASTER,
+        topology_st.standalone.replica.enableReplication(suffix=DEFAULT_SUFFIX, role=ReplicaRole.MASTER,
                                                          replicaId=REPLICAID_MASTER_1)
         log.info('Successfully enabled replication.')
     except ValueError:

+ 2 - 2
dirsrvtests/tests/tickets/ticket47966_test.py

@@ -12,7 +12,7 @@ from lib389.utils import *
 from lib389.topologies import topology_m2
 
 from lib389._constants import (DEFAULT_SUFFIX, HOST_MASTER_2, PORT_MASTER_2,
-                              REPLICAROLE_MASTER, REPLICAID_MASTER_2, BACKEND_NAME)
+                               ReplicaRole, REPLICAID_MASTER_2, BACKEND_NAME)
 
 logging.getLogger(__name__).setLevel(logging.DEBUG)
 log = logging.getLogger(__name__)
@@ -84,7 +84,7 @@ def test_ticket47966(topology_m2):
     log.info('3-1. Recreating %s and %s on Master 2.' % (vlvSrchDn, vlvIndexDn))
     M2.add_s(vlvSrchEntry)
     M2.add_s(vlvIndexEntry)
-    M2.replica.enableReplication(suffix=DEFAULT_SUFFIX, role=REPLICAROLE_MASTER, replicaId=REPLICAID_MASTER_2)
+    M2.replica.enableReplication(suffix=DEFAULT_SUFFIX, role=ReplicaRole.MASTER, replicaId=REPLICAID_MASTER_2)
     # agreement m2_m1_agmt is not needed... :p
 
     log.info('4. Initialize Master 2 from Master 1 again.')

+ 4 - 4
dirsrvtests/tests/tickets/ticket48759_test.py

@@ -12,9 +12,9 @@ import pytest
 from lib389.tasks import *
 from lib389.topologies import topology_st
 
-from lib389._constants import (PLUGIN_MEMBER_OF, DEFAULT_SUFFIX, REPLICAROLE_MASTER, REPLICAID_MASTER_1,
-                              DN_CONFIG, PLUGIN_RETRO_CHANGELOG, REPLICA_PRECISE_PURGING, REPLICA_PURGE_DELAY,
-                              REPLICA_PURGE_INTERVAL)
+from lib389._constants import (PLUGIN_MEMBER_OF, DEFAULT_SUFFIX, ReplicaRole, REPLICAID_MASTER_1,
+                               DN_CONFIG, PLUGIN_RETRO_CHANGELOG, REPLICA_PRECISE_PURGING, REPLICA_PURGE_DELAY,
+                               REPLICA_PURGE_INTERVAL)
 
 log = logging.getLogger(__name__)
 
@@ -105,7 +105,7 @@ def test_ticket48759(topology_st):
     # Setup Replication
     #
     log.info('Setting up replication...')
-    topology_st.standalone.replica.enableReplication(suffix=DEFAULT_SUFFIX, role=REPLICAROLE_MASTER,
+    topology_st.standalone.replica.enableReplication(suffix=DEFAULT_SUFFIX, role=ReplicaRole.MASTER,
                                                      replicaId=REPLICAID_MASTER_1)
 
     #

+ 14 - 3
dirsrvtests/tests/tickets/ticket49287_test.py

@@ -1,6 +1,17 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2017 Red Hat, Inc.
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
+#
 import pytest
 from lib389.tasks import *
 from lib389.utils import *
+from lib389._constants import (SUFFIX, ReplicaRole, defaultProperties, REPLICATION_BIND_DN, PLUGIN_MEMBER_OF,
+                               REPLICATION_BIND_PW, REPLICATION_BIND_METHOD, REPLICATION_TRANSPORT)
+from lib389.properties import RA_NAME, RA_BINDDN, RA_BINDPW, RA_METHOD, RA_TRANSPORT_PROT, BACKEND_NAME
 from lib389.topologies import topology_m2
 
 DEBUGGING = os.getenv('DEBUGGING', False)
@@ -193,13 +204,13 @@ def create_backend(s1, s2, beSuffix, beName):
     s2.backend.create(beSuffix, {BACKEND_NAME: beName})
 
 def replicate_backend(s1, s2, beSuffix, rid):
-    s1.replica.enableReplication(suffix=beSuffix, role=REPLICAROLE_MASTER, replicaId=rid)
-    s2.replica.enableReplication(suffix=beSuffix, role=REPLICAROLE_MASTER, replicaId=rid+1)
+    s1.replica.enableReplication(suffix=beSuffix, role=ReplicaRole.MASTER, replicaId=rid)
+    s2.replica.enableReplication(suffix=beSuffix, role=ReplicaRole.MASTER, replicaId=rid+1)
     # agreement m2_m1_agmt is not needed... :p
 
     s1s2_agmt = create_agmt(s1, s2, beSuffix)
     s2s1_agmt = create_agmt(s2, s1, beSuffix)
-    s1.agreement.init(beSuffix, HOST_MASTER_2, PORT_MASTER_2)
+    s1.agreement.init(beSuffix, s2.host, s2.port)
     s1.waitForReplInit(s1s2_agmt)
 
 def check_group_mods(server1, server2, group, testbase):

+ 8 - 0
dirsrvtests/tests/tickets/ticket49303_test.py

@@ -1,3 +1,11 @@
+# --- BEGIN COPYRIGHT BLOCK ---
+# Copyright (C) 2017 Red Hat, Inc.
+# All rights reserved.
+#
+# License: GPL (version 3 or any later version).
+# See LICENSE for details.
+# --- END COPYRIGHT BLOCK ---
+#
 import time
 import logging
 import os