| 1 |
# --- BEGIN COPYRIGHT BLOCK --- |
| 2 |
# Copyright (C) 2021 Red Hat, Inc. |
| 3 |
# All rights reserved. |
| 4 |
# |
| 5 |
# License: GPL (version 3 or any later version). |
| 6 |
# See LICENSE for details. |
| 7 |
# --- END COPYRIGHT BLOCK --- |
| 8 |
# |
| 9 |
import os |
| 10 |
import logging |
| 11 |
import pytest |
| 12 |
from lib389.utils import * |
| 13 |
from lib389._constants import * |
| 14 |
from lib389.replica import Replicas, ReplicationManager |
| 15 |
from lib389.dseldif import * |
| 16 |
from test389.topologies import topology_i2 as topo_i2 |
| 17 |
|
| 18 |
|
| 19 |
pytestmark = pytest.mark.tier1 |
| 20 |
|
| 21 |
NEW_SUFFIX_NAME = 'test_repl' |
| 22 |
NEW_SUFFIX = 'o={}'.format(NEW_SUFFIX_NAME) |
| 23 |
NEW_BACKEND = 'repl_base' |
| 24 |
CHANGELOG = 'cn=changelog,{}'.format(DN_USERROOT_LDBM) |
| 25 |
MAXAGE_ATTR = 'nsslapd-changelogmaxage' |
| 26 |
MAXAGE_STR = '30' |
| 27 |
TRIMINTERVAL_STR = '5' |
| 28 |
TRIMINTERVAL = 'nsslapd-changelogtrim-interval' |
| 29 |
|
| 30 |
DEBUGGING = os.getenv("DEBUGGING", default=False) |
| 31 |
if DEBUGGING: |
| 32 |
logging.getLogger(__name__).setLevel(logging.DEBUG) |
| 33 |
else: |
| 34 |
logging.getLogger(__name__).setLevel(logging.INFO) |
| 35 |
log = logging.getLogger(__name__) |
| 36 |
|
| 37 |
|
| 38 |
def test_special_symbol_replica_agreement(topo_i2): |
| 39 |
""" Check if agreement starts with "cn=->..." then |
| 40 |
after upgrade does it get removed. |
| 41 |
|
| 42 |
:id: 68aa0072-4dd4-4e33-b107-cb383a439125 |
| 43 |
:setup: two standalone instance |
| 44 |
:steps: |
| 45 |
1. Create and Enable Replication on standalone2 and role as consumer |
| 46 |
2. Create and Enable Replication on standalone1 and role as supplier |
| 47 |
3. Create a Replication agreement starts with "cn=->..." |
| 48 |
4. Perform an upgrade operation over the supplier |
| 49 |
5. Check if the agreement is still present or not. |
| 50 |
:expectedresults: |
| 51 |
1. It should be successful |
| 52 |
2. It should be successful |
| 53 |
3. It should be successful |
| 54 |
4. It should be successful |
| 55 |
5. It should be successful |
| 56 |
""" |
| 57 |
|
| 58 |
supplier = topo_i2.ins["standalone1"] |
| 59 |
consumer = topo_i2.ins["standalone2"] |
| 60 |
consumer.replica.enableReplication(suffix=DEFAULT_SUFFIX, role=ReplicaRole.CONSUMER, replicaId=CONSUMER_REPLICAID) |
| 61 |
repl = ReplicationManager(DEFAULT_SUFFIX) |
| 62 |
repl.create_first_supplier(supplier) |
| 63 |
|
| 64 |
properties = {RA_NAME: '-\\3meTo_{}:{}'.format(consumer.host, str(consumer.port)), |
| 65 |
RA_BINDDN: defaultProperties[REPLICATION_BIND_DN], |
| 66 |
RA_BINDPW: defaultProperties[REPLICATION_BIND_PW], |
| 67 |
RA_METHOD: defaultProperties[REPLICATION_BIND_METHOD], |
| 68 |
RA_TRANSPORT_PROT: defaultProperties[REPLICATION_TRANSPORT]} |
| 69 |
|
| 70 |
supplier.agreement.create(suffix=SUFFIX, |
| 71 |
host=consumer.host, |
| 72 |
port=consumer.port, |
| 73 |
properties=properties) |
| 74 |
|
| 75 |
supplier.agreement.init(SUFFIX, consumer.host, consumer.port) |
| 76 |
|
| 77 |
replica_server = Replicas(supplier).get(DEFAULT_SUFFIX) |
| 78 |
|
| 79 |
supplier.upgrade('online') |
| 80 |
|
| 81 |
agmt = replica_server.get_agreements().list()[0] |
| 82 |
|
| 83 |
assert agmt.get_attr_val_utf8('cn') == '-\\3meTo_{}:{}'.format(consumer.host, str(consumer.port)) |
| 84 |
|
| 85 |
|
| 86 |
if __name__ == '__main__': |
| 87 |
# Run isolated |
| 88 |
# -s for DEBUG mode |
| 89 |
CURRENT_FILE = os.path.realpath(__file__) |
| 90 |
pytest.main("-s %s" % CURRENT_FILE) |