| 1 |
# --- BEGIN COPYRIGHT BLOCK --- |
| 2 |
# Copyright (C) 2020 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 time |
| 10 |
import logging |
| 11 |
import ldap |
| 12 |
import pytest |
| 13 |
import re |
| 14 |
from itertools import permutations |
| 15 |
from lib389._constants import * |
| 16 |
from lib389.idm.nscontainer import nsContainers |
| 17 |
from lib389.idm.user import UserAccounts, UserAccount |
| 18 |
from lib389.idm.group import Groups |
| 19 |
from lib389.idm.organizationalunit import OrganizationalUnits |
| 20 |
from lib389.replica import ReplicationManager, Replicas |
| 21 |
from lib389.agreement import Agreements |
| 22 |
from lib389.plugins import MemberOfPlugin |
| 23 |
from lib389.dirsrv_log import DirsrvErrorLog |
| 24 |
|
| 25 |
pytestmark = pytest.mark.tier1 |
| 26 |
|
| 27 |
DEBUGGING = os.getenv("DEBUGGING", default=False) |
| 28 |
if DEBUGGING: |
| 29 |
logging.getLogger(__name__).setLevel(logging.DEBUG) |
| 30 |
else: |
| 31 |
logging.getLogger(__name__).setLevel(logging.INFO) |
| 32 |
log = logging.getLogger(__name__) |
| 33 |
|
| 34 |
|
| 35 |
def _create_user(users, user_num, group_num=2000, sleep=False): |
| 36 |
"""Creates user entry""" |
| 37 |
|
| 38 |
user = users.create_test_user(user_num, group_num) |
| 39 |
if sleep: |
| 40 |
time.sleep(1) |
| 41 |
return user |
| 42 |
|
| 43 |
|
| 44 |
def _rename_user(users, user_num, new_num, sleep=False): |
| 45 |
"""Rename user entry""" |
| 46 |
|
| 47 |
assert user_num != new_num, "New user number should not be the same as the old one" |
| 48 |
|
| 49 |
user = users.get('test_user_{}'.format(user_num)) |
| 50 |
user.rename('uid=test_user_{}'.format(new_num)) |
| 51 |
if sleep: |
| 52 |
time.sleep(1) |
| 53 |
|
| 54 |
|
| 55 |
def _modify_user(users, user_num, sleep=False): |
| 56 |
"""Modify user entry""" |
| 57 |
|
| 58 |
user = users.get('test_user_{}'.format(user_num)) |
| 59 |
user.replace("homeDirectory", "/home/test_user0{}".format(user_num)) |
| 60 |
if sleep: |
| 61 |
time.sleep(1) |
| 62 |
time.sleep(1) |
| 63 |
|
| 64 |
|
| 65 |
def _delete_user(users, user_num, sleep=False): |
| 66 |
"""Delete user entry""" |
| 67 |
|
| 68 |
user = users.get('test_user_{}'.format(user_num)) |
| 69 |
user.delete() |
| 70 |
if sleep: |
| 71 |
time.sleep(1) |
| 72 |
time.sleep(1) |
| 73 |
|
| 74 |
|
| 75 |
def _create_group(groups, num, member, sleep=False): |
| 76 |
"""Creates group entry""" |
| 77 |
|
| 78 |
group_props = {'cn': 'test_group_{}'.format(num), |
| 79 |
'member': member} |
| 80 |
group = groups.create(properties=group_props) |
| 81 |
if sleep: |
| 82 |
time.sleep(1) |
| 83 |
return group |
| 84 |
|
| 85 |
|
| 86 |
def _delete_group(groups, num, sleep=False): |
| 87 |
"""Delete group entry""" |
| 88 |
|
| 89 |
group = groups.get('test_group_{}'.format(num)) |
| 90 |
group.delete() |
| 91 |
if sleep: |
| 92 |
time.sleep(1) |
| 93 |
|
| 94 |
|
| 95 |
def _create_container(inst, dn, name, sleep=False): |
| 96 |
"""Creates container entry""" |
| 97 |
|
| 98 |
conts = nsContainers(inst, dn) |
| 99 |
cont = conts.create(properties={'cn': name}) |
| 100 |
if sleep: |
| 101 |
time.sleep(1) |
| 102 |
return cont |
| 103 |
|
| 104 |
|
| 105 |
def _delete_container(cont, sleep=False): |
| 106 |
"""Deletes container entry""" |
| 107 |
|
| 108 |
cont.delete() |
| 109 |
if sleep: |
| 110 |
time.sleep(1) |
| 111 |
|
| 112 |
|
| 113 |
def _test_base(topology): |
| 114 |
"""Add test container for entries, enable plugin logging, |
| 115 |
audit log, error log for replica and access log for internal |
| 116 |
""" |
| 117 |
|
| 118 |
M1 = topology.ms["supplier1"] |
| 119 |
|
| 120 |
conts = nsContainers(M1, SUFFIX) |
| 121 |
base_m2 = conts.ensure_state(properties={'cn': 'test_container'}) |
| 122 |
|
| 123 |
for inst in topology: |
| 124 |
inst.config.loglevel([ErrorLog.DEFAULT, ErrorLog.REPLICA], service='error') |
| 125 |
inst.config.loglevel([AccessLog.DEFAULT, AccessLog.INTERNAL], service='access') |
| 126 |
inst.config.set('nsslapd-plugin-logging', 'on') |
| 127 |
inst.config.enable_log('audit') |
| 128 |
inst.restart() |
| 129 |
|
| 130 |
return base_m2 |
| 131 |
|
| 132 |
|
| 133 |
def _dump_logs(topology): |
| 134 |
""" Logs instances error logs""" |
| 135 |
for inst in topology: |
| 136 |
errlog = DirsrvErrorLog(inst) |
| 137 |
log.info(f'{inst.serverid} errorlog:') |
| 138 |
for l in errlog.readlines(): |
| 139 |
log.info(l.strip()) |
| 140 |
|
| 141 |
|
| 142 |
def _delete_test_base(inst, base_m2_dn): |
| 143 |
"""Delete test container with entries and entry conflicts""" |
| 144 |
|
| 145 |
try: |
| 146 |
ents = inst.search_s(base_m2_dn, ldap.SCOPE_SUBTREE, filterstr="(|(objectclass=*)(objectclass=ldapsubentry))") |
| 147 |
for ent in sorted(ents, key=lambda e: len(e.dn), reverse=True): |
| 148 |
log.debug("Delete entry children {}".format(ent.dn)) |
| 149 |
try: |
| 150 |
inst.delete_ext_s(ent.dn) |
| 151 |
except ldap.NO_SUCH_OBJECT: # For the case with objectclass: glue entries |
| 152 |
pass |
| 153 |
except ldap.NO_SUCH_OBJECT: # Subtree is already removed. |
| 154 |
pass |
| 155 |
|
| 156 |
|
| 157 |
def _resume_agmts(inst): |
| 158 |
"""Resume all agreements in the instance""" |
| 159 |
|
| 160 |
replicas = Replicas(inst) |
| 161 |
replica = replicas.get(DEFAULT_SUFFIX) |
| 162 |
for agreement in replica.get_agreements().list(): |
| 163 |
agreement.resume() |
| 164 |
|
| 165 |
|
| 166 |
@pytest.fixture |
| 167 |
def base_m2(topology_m2, request): |
| 168 |
tb = _test_base(topology_m2) |
| 169 |
|
| 170 |
def fin(): |
| 171 |
if not DEBUGGING: |
| 172 |
_delete_test_base(topology_m2.ms["supplier1"], tb.dn) |
| 173 |
_delete_test_base(topology_m2.ms["supplier2"], tb.dn) |
| 174 |
# Replication may break while deleting the container because naming |
| 175 |
# conflict entries still exists on the other side |
| 176 |
# Note IMHO there a bug in the entryrdn handling of replicated delete operation |
| 177 |
# ( children naming conflict or glue entries older than the parent delete operation should |
| 178 |
# should be deleted when the parent is deleted ) |
| 179 |
# So let restarts the agmt once everything is deleted. |
| 180 |
topology_m2.pause_all_replicas() |
| 181 |
topology_m2.resume_all_replicas() |
| 182 |
|
| 183 |
request.addfinalizer(fin) |
| 184 |
|
| 185 |
return tb |
| 186 |
|
| 187 |
|
| 188 |
@pytest.fixture |
| 189 |
def base_m3(topology_m3, request): |
| 190 |
tb = _test_base(topology_m3) |
| 191 |
|
| 192 |
def fin(): |
| 193 |
if not DEBUGGING: |
| 194 |
_delete_test_base(topology_m3.ms["supplier1"], tb.dn) |
| 195 |
request.addfinalizer(fin) |
| 196 |
|
| 197 |
return tb |
| 198 |
|
| 199 |
|
| 200 |
class TestTwoSuppliers: |
| 201 |
def test_add_modrdn(self, topology_m2, base_m2): |
| 202 |
"""Check that conflict properly resolved for create - modrdn operations |
| 203 |
|
| 204 |
:id: 77f09b18-03d1-45da-940b-1ad2c2908ebb |
| 205 |
:setup: Two supplier replication, test container for entries, enable plugin logging, |
| 206 |
audit log, error log for replica and access log for internal |
| 207 |
:steps: |
| 208 |
1. Add five users to m1 and wait for replication to happen |
| 209 |
2. Pause replication |
| 210 |
3. Create an entry on m1 and m2 |
| 211 |
4. Create an entry on m1 and rename on m2 |
| 212 |
5. Rename an entry on m1 and create on m2 |
| 213 |
6. Rename an entry on m1 and rename on m2 |
| 214 |
7. Rename an entry on m1 and rename on m2. Use different entries |
| 215 |
but rename them to the same entry |
| 216 |
8. Resume replication |
| 217 |
9. Check that the entries on both suppliers are the same and replication is working |
| 218 |
:expectedresults: |
| 219 |
1. It should pass |
| 220 |
2. It should pass |
| 221 |
3. It should pass |
| 222 |
4. It should pass |
| 223 |
5. It should pass |
| 224 |
6. It should pass |
| 225 |
7. It should pass |
| 226 |
8. It should pass |
| 227 |
""" |
| 228 |
|
| 229 |
M1 = topology_m2.ms["supplier1"] |
| 230 |
M2 = topology_m2.ms["supplier2"] |
| 231 |
test_users_m1 = UserAccounts(M1, base_m2.dn, rdn=None) |
| 232 |
test_users_m2 = UserAccounts(M2, base_m2.dn, rdn=None) |
| 233 |
repl = ReplicationManager(SUFFIX) |
| 234 |
|
| 235 |
for user_num in range(1000, 1005): |
| 236 |
_create_user(test_users_m1, user_num) |
| 237 |
|
| 238 |
repl.test_replication(M1, M2) |
| 239 |
topology_m2.pause_all_replicas() |
| 240 |
|
| 241 |
log.info("Test create - modrdn") |
| 242 |
user_num += 1 |
| 243 |
_create_user(test_users_m1, user_num, sleep=True) |
| 244 |
_create_user(test_users_m2, user_num, sleep=True) |
| 245 |
|
| 246 |
user_num += 1 |
| 247 |
_create_user(test_users_m1, user_num, sleep=True) |
| 248 |
_rename_user(test_users_m2, 1000, user_num, sleep=True) |
| 249 |
|
| 250 |
user_num += 1 |
| 251 |
_rename_user(test_users_m1, 1001, user_num, sleep=True) |
| 252 |
_create_user(test_users_m2, user_num, sleep=True) |
| 253 |
|
| 254 |
user_num += 1 |
| 255 |
_rename_user(test_users_m1, 1002, user_num, sleep=True) |
| 256 |
_rename_user(test_users_m2, 1002, user_num, sleep=True) |
| 257 |
|
| 258 |
user_num += 1 |
| 259 |
_rename_user(test_users_m1, 1003, user_num, sleep=True) |
| 260 |
_rename_user(test_users_m2, 1004, user_num) |
| 261 |
|
| 262 |
topology_m2.resume_all_replicas() |
| 263 |
|
| 264 |
repl.test_replication_topology(topology_m2) |
| 265 |
|
| 266 |
user_dns_m1 = [user.dn for user in test_users_m1.list()] |
| 267 |
user_dns_m2 = [user.dn for user in test_users_m2.list()] |
| 268 |
assert set(user_dns_m1) == set(user_dns_m2) |
| 269 |
|
| 270 |
def test_complex_add_modify_modrdn_delete(self, topology_m2, base_m2): |
| 271 |
"""Check that conflict properly resolved for complex operations |
| 272 |
which involve add, modify, modrdn and delete |
| 273 |
|
| 274 |
:id: 77f09b18-03d1-45da-940b-1ad2c2908eb1 |
| 275 |
:customerscenario: True |
| 276 |
:setup: Two supplier replication, test container for entries, enable plugin logging, |
| 277 |
audit log, error log for replica and access log for internal |
| 278 |
:steps: |
| 279 |
1. Add ten users to m1 and wait for replication to happen |
| 280 |
2. Pause replication |
| 281 |
3. Test add-del on m1 and add on m2 |
| 282 |
4. Test add-mod on m1 and add on m2 |
| 283 |
5. Test add-modrdn on m1 and add on m2 |
| 284 |
6. Test multiple add, modrdn |
| 285 |
7. Test Add-del on both suppliers |
| 286 |
8. Test modrdn-modrdn |
| 287 |
9. Test modrdn-del |
| 288 |
10. Resume replication |
| 289 |
11. Check that the entries on both suppliers are the same and replication is working |
| 290 |
:expectedresults: |
| 291 |
1. It should pass |
| 292 |
2. It should pass |
| 293 |
3. It should pass |
| 294 |
4. It should pass |
| 295 |
5. It should pass |
| 296 |
6. It should pass |
| 297 |
7. It should pass |
| 298 |
8. It should pass |
| 299 |
9. It should pass |
| 300 |
10. It should pass |
| 301 |
11. It should pass |
| 302 |
""" |
| 303 |
|
| 304 |
M1 = topology_m2.ms["supplier1"] |
| 305 |
M2 = topology_m2.ms["supplier2"] |
| 306 |
|
| 307 |
test_users_m1 = UserAccounts(M1, base_m2.dn, rdn=None) |
| 308 |
test_users_m2 = UserAccounts(M2, base_m2.dn, rdn=None) |
| 309 |
repl = ReplicationManager(SUFFIX) |
| 310 |
|
| 311 |
for user_num in range(1100, 1110): |
| 312 |
_create_user(test_users_m1, user_num) |
| 313 |
|
| 314 |
repl.test_replication(M1, M2) |
| 315 |
topology_m2.pause_all_replicas() |
| 316 |
|
| 317 |
log.info("Test add-del on M1 and add on M2") |
| 318 |
user_num += 1 |
| 319 |
_create_user(test_users_m1, user_num) |
| 320 |
_delete_user(test_users_m1, user_num, sleep=True) |
| 321 |
_create_user(test_users_m2, user_num, sleep=True) |
| 322 |
|
| 323 |
user_num += 1 |
| 324 |
_create_user(test_users_m1, user_num, sleep=True) |
| 325 |
_create_user(test_users_m2, user_num, sleep=True) |
| 326 |
_delete_user(test_users_m1, user_num, sleep=True) |
| 327 |
|
| 328 |
user_num += 1 |
| 329 |
_create_user(test_users_m2, user_num, sleep=True) |
| 330 |
_create_user(test_users_m1, user_num) |
| 331 |
_delete_user(test_users_m1, user_num) |
| 332 |
|
| 333 |
log.info("Test add-mod on M1 and add on M2") |
| 334 |
user_num += 1 |
| 335 |
_create_user(test_users_m1, user_num) |
| 336 |
_modify_user(test_users_m1, user_num, sleep=True) |
| 337 |
_create_user(test_users_m2, user_num, sleep=True) |
| 338 |
|
| 339 |
user_num += 1 |
| 340 |
_create_user(test_users_m1, user_num, sleep=True) |
| 341 |
_create_user(test_users_m2, user_num, sleep=True) |
| 342 |
_modify_user(test_users_m1, user_num, sleep=True) |
| 343 |
|
| 344 |
user_num += 1 |
| 345 |
_create_user(test_users_m2, user_num, sleep=True) |
| 346 |
_create_user(test_users_m1, user_num) |
| 347 |
_modify_user(test_users_m1, user_num) |
| 348 |
|
| 349 |
log.info("Test add-modrdn on M1 and add on M2") |
| 350 |
user_num += 1 |
| 351 |
_create_user(test_users_m1, user_num) |
| 352 |
_rename_user(test_users_m1, user_num, user_num+20, sleep=True) |
| 353 |
_create_user(test_users_m2, user_num, sleep=True) |
| 354 |
|
| 355 |
user_num += 1 |
| 356 |
_create_user(test_users_m1, user_num, sleep=True) |
| 357 |
_create_user(test_users_m2, user_num, sleep=True) |
| 358 |
_rename_user(test_users_m1, user_num, user_num+20, sleep=True) |
| 359 |
|
| 360 |
user_num += 1 |
| 361 |
_create_user(test_users_m2, user_num, sleep=True) |
| 362 |
_create_user(test_users_m1, user_num) |
| 363 |
_rename_user(test_users_m1, user_num, user_num+20) |
| 364 |
|
| 365 |
log.info("Test multiple add, modrdn") |
| 366 |
user_num += 1 |
| 367 |
_create_user(test_users_m1, user_num, sleep=True) |
| 368 |
_create_user(test_users_m2, user_num, sleep=True) |
| 369 |
_rename_user(test_users_m1, user_num, user_num+20) |
| 370 |
_create_user(test_users_m1, user_num, sleep=True) |
| 371 |
_modify_user(test_users_m2, user_num, sleep=True) |
| 372 |
|
| 373 |
log.info("Add - del on both suppliers") |
| 374 |
user_num += 1 |
| 375 |
_create_user(test_users_m1, user_num) |
| 376 |
_delete_user(test_users_m1, user_num, sleep=True) |
| 377 |
_create_user(test_users_m2, user_num) |
| 378 |
_delete_user(test_users_m2, user_num, sleep=True) |
| 379 |
|
| 380 |
log.info("Test modrdn - modrdn") |
| 381 |
user_num += 1 |
| 382 |
_rename_user(test_users_m1, 1109, 1129, sleep=True) |
| 383 |
_rename_user(test_users_m2, 1109, 1129, sleep=True) |
| 384 |
|
| 385 |
log.info("Test modrdn - del") |
| 386 |
user_num += 1 |
| 387 |
_rename_user(test_users_m1, 1100, 1120, sleep=True) |
| 388 |
_delete_user(test_users_m2, 1100) |
| 389 |
|
| 390 |
user_num += 1 |
| 391 |
_delete_user(test_users_m2, 1101, sleep=True) |
| 392 |
_rename_user(test_users_m1, 1101, 1121) |
| 393 |
|
| 394 |
topology_m2.resume_all_replicas() |
| 395 |
|
| 396 |
repl.test_replication_topology(topology_m2) |
| 397 |
|
| 398 |
user_dns_m1 = [user.dn for user in test_users_m1.list()] |
| 399 |
user_dns_m2 = [user.dn for user in test_users_m2.list()] |
| 400 |
assert set(user_dns_m1) == set(user_dns_m2) |
| 401 |
|
| 402 |
def test_memberof_groups(self, topology_m2, base_m2): |
| 403 |
"""Check that conflict properly resolved for operations |
| 404 |
with memberOf and groups |
| 405 |
|
| 406 |
:id: 77f09b18-03d1-45da-940b-1ad2c2908eb3 |
| 407 |
:setup: Two supplier replication, test container for entries, enable plugin logging, |
| 408 |
audit log, error log for replica and access log for internal |
| 409 |
:steps: |
| 410 |
1. Enable memberOf plugin |
| 411 |
2. Add 30 users to m1 and wait for replication to happen |
| 412 |
3. Pause replication |
| 413 |
4. Create a group on m1 and m2 |
| 414 |
5. Create a group on m1 and m2, delete from m1 |
| 415 |
6. Create a group on m1, delete from m1, and create on m2, |
| 416 |
7. Create a group on m2 and m1, delete from m1 |
| 417 |
8. Create two different groups on m2 |
| 418 |
9. Resume replication |
| 419 |
10. Check that the entries on both suppliers are the same and replication is working |
| 420 |
:expectedresults: |
| 421 |
1. It should pass |
| 422 |
2. It should pass |
| 423 |
3. It should pass |
| 424 |
4. It should pass |
| 425 |
5. It should pass |
| 426 |
6. It should pass |
| 427 |
7. It should pass |
| 428 |
8. It should pass |
| 429 |
9. It should pass |
| 430 |
10. It should pass |
| 431 |
""" |
| 432 |
|
| 433 |
pytest.xfail("Issue 49591 - work in progress") |
| 434 |
|
| 435 |
M1 = topology_m2.ms["supplier1"] |
| 436 |
M2 = topology_m2.ms["supplier2"] |
| 437 |
test_users_m1 = UserAccounts(M1, base_m2.dn, rdn=None) |
| 438 |
test_groups_m1 = Groups(M1, base_m2.dn, rdn=None) |
| 439 |
test_groups_m2 = Groups(M2, base_m2.dn, rdn=None) |
| 440 |
|
| 441 |
repl = ReplicationManager(SUFFIX) |
| 442 |
|
| 443 |
for inst in topology_m2.ms.values(): |
| 444 |
memberof = MemberOfPlugin(inst) |
| 445 |
memberof.enable() |
| 446 |
agmt = Agreements(inst).list()[0] |
| 447 |
agmt.replace_many(('nsDS5ReplicatedAttributeListTotal', |
| 448 |
'(objectclass=*) $ EXCLUDE '), |
| 449 |
('nsDS5ReplicatedAttributeList', |
| 450 |
'(objectclass=*) $ EXCLUDE memberOf')) |
| 451 |
inst.restart() |
| 452 |
user_dns = [] |
| 453 |
for user_num in range(10): |
| 454 |
user_trio = [] |
| 455 |
for num in range(0, 30, 10): |
| 456 |
user = _create_user(test_users_m1, 1200 + user_num + num) |
| 457 |
user_trio.append(user.dn) |
| 458 |
user_dns.append(user_trio) |
| 459 |
|
| 460 |
repl.test_replication(M1, M2) |
| 461 |
topology_m2.pause_all_replicas() |
| 462 |
|
| 463 |
log.info("Check a simple conflict") |
| 464 |
group_num = 0 |
| 465 |
_create_group(test_groups_m1, group_num, user_dns[group_num], sleep=True) |
| 466 |
_create_group(test_groups_m2, group_num, user_dns[group_num], sleep=True) |
| 467 |
|
| 468 |
log.info("Check a add - del") |
| 469 |
group_num += 1 |
| 470 |
_create_group(test_groups_m1, group_num, user_dns[group_num], sleep=True) |
| 471 |
_create_group(test_groups_m2, group_num, user_dns[group_num], sleep=True) |
| 472 |
_delete_group(test_groups_m1, group_num) |
| 473 |
|
| 474 |
group_num += 1 |
| 475 |
_create_group(test_groups_m1, group_num, user_dns[group_num]) |
| 476 |
_delete_group(test_groups_m1, group_num, sleep=True) |
| 477 |
_create_group(test_groups_m2, group_num, user_dns[group_num]) |
| 478 |
|
| 479 |
group_num += 1 |
| 480 |
_create_group(test_groups_m2, group_num, user_dns[group_num], sleep=True) |
| 481 |
_create_group(test_groups_m1, group_num, user_dns[group_num]) |
| 482 |
_delete_group(test_groups_m1, group_num, sleep=True) |
| 483 |
|
| 484 |
group_num += 1 |
| 485 |
_create_group(test_groups_m2, group_num, user_dns[group_num]) |
| 486 |
group_num += 1 |
| 487 |
_create_group(test_groups_m2, group_num, user_dns[group_num]) |
| 488 |
|
| 489 |
topology_m2.resume_all_replicas() |
| 490 |
|
| 491 |
repl.test_replication_topology(topology_m2) |
| 492 |
|
| 493 |
group_dns_m1 = [group.dn for group in test_groups_m1.list()] |
| 494 |
group_dns_m2 = [group.dn for group in test_groups_m2.list()] |
| 495 |
assert set(group_dns_m1) == set(group_dns_m2) |
| 496 |
|
| 497 |
def test_managed_entries(self, topology_m2): |
| 498 |
"""Check that conflict properly resolved for operations |
| 499 |
with managed entries |
| 500 |
|
| 501 |
:id: 77f09b18-03d1-45da-940b-1ad2c2908eb4 |
| 502 |
:setup: Two supplier replication, test container for entries, enable plugin logging, |
| 503 |
audit log, error log for replica and access log for internal |
| 504 |
:steps: |
| 505 |
1. Create ou=managed_users and ou=managed_groups under test container |
| 506 |
2. Configure managed entries plugin and add a template to test container |
| 507 |
3. Add a user to m1 and wait for replication to happen |
| 508 |
4. Pause replication |
| 509 |
5. Create a user on m1 and m2 with a same group ID on both supplier |
| 510 |
6. Create a user on m1 and m2 with a different group ID on both supplier |
| 511 |
7. Resume replication |
| 512 |
8. Check that the entries on both suppliers are the same and replication is working |
| 513 |
:expectedresults: |
| 514 |
1. It should pass |
| 515 |
2. It should pass |
| 516 |
3. It should pass |
| 517 |
4. It should pass |
| 518 |
5. It should pass |
| 519 |
6. It should pass |
| 520 |
7. It should pass |
| 521 |
8. It should pass |
| 522 |
""" |
| 523 |
|
| 524 |
pytest.xfail("Issue 49591 - work in progress") |
| 525 |
|
| 526 |
M1 = topology_m2.ms["supplier1"] |
| 527 |
M2 = topology_m2.ms["supplier2"] |
| 528 |
repl = ReplicationManager(SUFFIX) |
| 529 |
|
| 530 |
ous = OrganizationalUnits(M1, DEFAULT_SUFFIX) |
| 531 |
ou_people = ous.create(properties={'ou': 'managed_people'}) |
| 532 |
ou_groups = ous.create(properties={'ou': 'managed_groups'}) |
| 533 |
|
| 534 |
test_users_m1 = UserAccounts(M1, DEFAULT_SUFFIX, rdn='ou={}'.format(ou_people.rdn)) |
| 535 |
test_users_m2 = UserAccounts(M2, DEFAULT_SUFFIX, rdn='ou={}'.format(ou_people.rdn)) |
| 536 |
|
| 537 |
# TODO: Refactor ManagedPlugin class functionality (also add configs and templates) |
| 538 |
conts = nsContainers(M1, SUFFIX) |
| 539 |
template = conts.create(properties={ |
| 540 |
'objectclass': 'top mepTemplateEntry extensibleObject'.split(), |
| 541 |
'cn': 'MEP Template', |
| 542 |
'mepRDNAttr': 'cn', |
| 543 |
'mepStaticAttr': ['objectclass: posixGroup', 'objectclass: extensibleObject'], |
| 544 |
'mepMappedAttr': ['cn: $uid', 'uid: $cn', 'gidNumber: $uidNumber'] |
| 545 |
}) |
| 546 |
repl.test_replication(M1, M2) |
| 547 |
|
| 548 |
for inst in topology_m2.ms.values(): |
| 549 |
conts = nsContainers(inst, "cn={},{}".format(PLUGIN_MANAGED_ENTRY, DN_PLUGIN)) |
| 550 |
conts.create(properties={'objectclass': 'top extensibleObject'.split(), |
| 551 |
'cn': 'config', |
| 552 |
'originScope': ou_people.dn, |
| 553 |
'originFilter': 'objectclass=posixAccount', |
| 554 |
'managedBase': ou_groups.dn, |
| 555 |
'managedTemplate': template.dn}) |
| 556 |
inst.restart() |
| 557 |
|
| 558 |
_create_user(test_users_m1, 1, 1) |
| 559 |
|
| 560 |
topology_m2.pause_all_replicas() |
| 561 |
|
| 562 |
_create_user(test_users_m1, 2, 2, sleep=True) |
| 563 |
_create_user(test_users_m2, 2, 2, sleep=True) |
| 564 |
|
| 565 |
_create_user(test_users_m1, 3, 3, sleep=True) |
| 566 |
_create_user(test_users_m2, 3, 33) |
| 567 |
|
| 568 |
topology_m2.resume_all_replicas() |
| 569 |
|
| 570 |
repl.test_replication_topology(topology_m2) |
| 571 |
|
| 572 |
user_dns_m1 = [user.dn for user in test_users_m1.list()] |
| 573 |
user_dns_m2 = [user.dn for user in test_users_m2.list()] |
| 574 |
assert set(user_dns_m1) == set(user_dns_m2) |
| 575 |
|
| 576 |
def test_nested_entries_with_children(self, topology_m2, base_m2): |
| 577 |
"""Check that conflict properly resolved for operations |
| 578 |
with nested entries with children |
| 579 |
|
| 580 |
:id: 77f09b18-03d1-45da-940b-1ad2c2908eb5 |
| 581 |
:setup: Two supplier replication, test container for entries, enable plugin logging, |
| 582 |
audit log, error log for replica and access log for internal |
| 583 |
:steps: |
| 584 |
1. Add 15 containers to m1 and wait for replication to happen |
| 585 |
2. Pause replication |
| 586 |
3. Create parent-child on supplier2 and supplier1 |
| 587 |
4. Create parent-child on supplier1 and supplier2 |
| 588 |
5. Create parent-child on supplier1 and supplier2 different child rdn |
| 589 |
6. Create parent-child on supplier1 and delete parent on supplier2 |
| 590 |
7. Create parent on supplier1, delete it and parent-child on supplier2, delete them |
| 591 |
8. Create parent on supplier1, delete it and parent-two children on supplier2 |
| 592 |
9. Create parent-two children on supplier1 and parent-child on supplier2, delete them |
| 593 |
10. Create three subsets inside existing container entry, applying only part of changes on m2 |
| 594 |
11. Create more combinations of the subset with parent-child on m1 and parent on m2 |
| 595 |
12. Delete container on m1, modify user1 on m1, create parent on m2 and modify user2 on m2 |
| 596 |
13. Resume replication |
| 597 |
14. Check that the entries on both suppliers are the same and replication is working |
| 598 |
:expectedresults: |
| 599 |
1. It should pass |
| 600 |
2. It should pass |
| 601 |
3. It should pass |
| 602 |
4. It should pass |
| 603 |
5. It should pass |
| 604 |
6. It should pass |
| 605 |
7. It should pass |
| 606 |
8. It should pass |
| 607 |
9. It should pass |
| 608 |
10. It should pass |
| 609 |
11. It should pass |
| 610 |
12. It should pass |
| 611 |
13. It should pass |
| 612 |
14. It should pass |
| 613 |
""" |
| 614 |
|
| 615 |
pytest.xfail("Issue 49591 - work in progress") |
| 616 |
|
| 617 |
M1 = topology_m2.ms["supplier1"] |
| 618 |
M2 = topology_m2.ms["supplier2"] |
| 619 |
repl = ReplicationManager(SUFFIX) |
| 620 |
test_users_m1 = UserAccounts(M1, base_m2.dn, rdn=None) |
| 621 |
test_users_m2 = UserAccounts(M2, base_m2.dn, rdn=None) |
| 622 |
_create_user(test_users_m1, 4000) |
| 623 |
_create_user(test_users_m1, 4001) |
| 624 |
|
| 625 |
cont_list = [] |
| 626 |
for num in range(15): |
| 627 |
cont = _create_container(M1, base_m2.dn, 'sub{}'.format(num)) |
| 628 |
cont_list.append(cont) |
| 629 |
|
| 630 |
repl.test_replication(M1, M2) |
| 631 |
|
| 632 |
topology_m2.pause_all_replicas() |
| 633 |
|
| 634 |
log.info("Create parent-child on supplier2 and supplier1") |
| 635 |
_create_container(M2, base_m2.dn, 'p0', sleep=True) |
| 636 |
cont_p = _create_container(M1, base_m2.dn, 'p0', sleep=True) |
| 637 |
_create_container(M1, cont_p.dn, 'c0', sleep=True) |
| 638 |
_create_container(M2, cont_p.dn, 'c0', sleep=True) |
| 639 |
|
| 640 |
log.info("Create parent-child on supplier1 and supplier2") |
| 641 |
cont_p = _create_container(M1, base_m2.dn, 'p1', sleep=True) |
| 642 |
_create_container(M2, base_m2.dn, 'p1', sleep=True) |
| 643 |
_create_container(M1, cont_p.dn, 'c1', sleep=True) |
| 644 |
_create_container(M2, cont_p.dn, 'c1', sleep=True) |
| 645 |
|
| 646 |
log.info("Create parent-child on supplier1 and supplier2 different child rdn") |
| 647 |
cont_p = _create_container(M1, base_m2.dn, 'p2', sleep=True) |
| 648 |
_create_container(M2, base_m2.dn, 'p2', sleep=True) |
| 649 |
_create_container(M1, cont_p.dn, 'c2', sleep=True) |
| 650 |
_create_container(M2, cont_p.dn, 'c3', sleep=True) |
| 651 |
|
| 652 |
log.info("Create parent-child on supplier1 and delete parent on supplier2") |
| 653 |
cont_num = 0 |
| 654 |
cont_p_m1 = _create_container(M1, cont_list[cont_num].dn, 'p0', sleep=True) |
| 655 |
cont_p_m2 = _create_container(M2, cont_list[cont_num].dn, 'p0', sleep=True) |
| 656 |
_create_container(M1, cont_p_m1.dn, 'c0', sleep=True) |
| 657 |
_delete_container(cont_p_m2) |
| 658 |
|
| 659 |
cont_num += 1 |
| 660 |
cont_p_m2 = _create_container(M2, cont_list[cont_num].dn, 'p0', sleep=True) |
| 661 |
cont_p_m1 = _create_container(M1, cont_list[cont_num].dn, 'p0') |
| 662 |
_create_container(M1, cont_p_m1.dn, 'c0', sleep=True) |
| 663 |
_delete_container(cont_p_m2, sleep=True) |
| 664 |
|
| 665 |
log.info("Create parent on supplier1, delete it and parent-child on supplier2, delete them") |
| 666 |
cont_num += 1 |
| 667 |
cont_p_m1 = _create_container(M1, cont_list[cont_num].dn, 'p0') |
| 668 |
_delete_container(cont_p_m1, sleep=True) |
| 669 |
|
| 670 |
cont_p_m2 = _create_container(M2, cont_list[cont_num].dn, 'p0') |
| 671 |
cont_c_m2 = _create_container(M2, cont_p_m2.dn, 'c0') |
| 672 |
_delete_container(cont_c_m2) |
| 673 |
_delete_container(cont_p_m2) |
| 674 |
|
| 675 |
cont_num += 1 |
| 676 |
cont_p_m2 = _create_container(M2, cont_list[cont_num].dn, 'p0') |
| 677 |
cont_c_m2 = _create_container(M2, cont_p_m2.dn, 'c0') |
| 678 |
_delete_container(cont_c_m2) |
| 679 |
_delete_container(cont_p_m2, sleep=True) |
| 680 |
|
| 681 |
cont_p_m1 = _create_container(M1, cont_list[cont_num].dn, 'p0') |
| 682 |
_delete_container(cont_p_m1) |
| 683 |
|
| 684 |
log.info("Create parent on supplier1, delete it and parent-two children on supplier2") |
| 685 |
cont_num += 1 |
| 686 |
cont_p_m1 = _create_container(M1, cont_list[cont_num].dn, 'p0') |
| 687 |
_delete_container(cont_p_m1, sleep=True) |
| 688 |
|
| 689 |
cont_p_m2 = _create_container(M2, cont_list[cont_num].dn, 'p0') |
| 690 |
_create_container(M2, cont_p_m2.dn, 'c0') |
| 691 |
_create_container(M2, cont_p_m2.dn, 'c1') |
| 692 |
|
| 693 |
cont_num += 1 |
| 694 |
cont_p_m2 = _create_container(M2, cont_list[cont_num].dn, 'p0') |
| 695 |
_create_container(M2, cont_p_m2.dn, 'c0') |
| 696 |
_create_container(M2, cont_p_m2.dn, 'c1', sleep=True) |
| 697 |
|
| 698 |
cont_p_m1 = _create_container(M1, cont_list[cont_num].dn, 'p0') |
| 699 |
_delete_container(cont_p_m1, sleep=True) |
| 700 |
|
| 701 |
log.info("Create parent-two children on supplier1 and parent-child on supplier2, delete them") |
| 702 |
cont_num += 1 |
| 703 |
cont_p_m2 = _create_container(M2, cont_list[cont_num].dn, 'p0') |
| 704 |
cont_c_m2 = _create_container(M2, cont_p_m2.dn, 'c0') |
| 705 |
_delete_container(cont_c_m2) |
| 706 |
_delete_container(cont_p_m2, sleep=True) |
| 707 |
|
| 708 |
cont_p_m1 = _create_container(M1, cont_list[cont_num].dn, 'p0') |
| 709 |
_create_container(M1, cont_p_m1.dn, 'c0') |
| 710 |
_create_container(M1, cont_p_m1.dn, 'c1') |
| 711 |
|
| 712 |
cont_num += 1 |
| 713 |
cont_p_m1 = _create_container(M1, cont_list[cont_num].dn, 'p0') |
| 714 |
_create_container(M1, cont_p_m1.dn, 'c0') |
| 715 |
_create_container(M1, cont_p_m1.dn, 'c1', sleep=True) |
| 716 |
|
| 717 |
cont_p_m2 = _create_container(M2, cont_list[cont_num].dn, 'p0') |
| 718 |
cont_c_m2 = _create_container(M2, cont_p_m2.dn, 'c0') |
| 719 |
_delete_container(cont_c_m2) |
| 720 |
_delete_container(cont_p_m2, sleep=True) |
| 721 |
|
| 722 |
log.info("Create three subsets inside existing container entry, applying only part of changes on m2") |
| 723 |
cont_num += 1 |
| 724 |
cont_p_m1 = _create_container(M1, cont_list[cont_num].dn, 'p0') |
| 725 |
_create_container(M1, cont_p_m1.dn, 'c0') |
| 726 |
_create_container(M1, cont_p_m1.dn, 'c1', sleep=True) |
| 727 |
_create_container(M2, cont_list[cont_num].dn, 'p0', sleep=True) |
| 728 |
|
| 729 |
cont_num += 1 |
| 730 |
cont_p_m1 = _create_container(M1, cont_list[cont_num].dn, 'p0') |
| 731 |
_create_container(M1, cont_p_m1.dn, 'c0') |
| 732 |
_create_container(M1, cont_p_m1.dn, 'c1', sleep=True) |
| 733 |
cont_p_m2 = _create_container(M2, cont_list[cont_num].dn, 'p0') |
| 734 |
_create_container(M2, cont_p_m2.dn, 'c0', sleep=True) |
| 735 |
|
| 736 |
cont_num += 1 |
| 737 |
cont_p_m1 = _create_container(M1, cont_list[cont_num].dn, 'p0') |
| 738 |
_create_container(M1, cont_p_m1.dn, 'c0') |
| 739 |
_create_container(M1, cont_p_m1.dn, 'c1', sleep=True) |
| 740 |
cont_p_m2 = _create_container(M2, cont_list[cont_num].dn, 'p0') |
| 741 |
cont_c_m2 = _create_container(M2, cont_p_m2.dn, 'c0') |
| 742 |
_delete_container(cont_c_m2, sleep=True) |
| 743 |
|
| 744 |
log.info("Create more combinations of the subset with parent-child on m1 and parent on m2") |
| 745 |
cont_num += 1 |
| 746 |
cont_p_m1 = _create_container(M1, cont_list[cont_num].dn, 'p0', sleep=True) |
| 747 |
cont_p_m2 = _create_container(M2, cont_list[cont_num].dn, 'p0', sleep=True) |
| 748 |
_delete_container(cont_p_m1, sleep=True) |
| 749 |
cont_c_m2 = _create_container(M2, cont_p_m2.dn, 'c0') |
| 750 |
_delete_container(cont_c_m2) |
| 751 |
_delete_container(cont_p_m2, sleep=True) |
| 752 |
|
| 753 |
cont_num += 1 |
| 754 |
cont_p_m1 = _create_container(M1, cont_list[cont_num].dn, 'p0', sleep=True) |
| 755 |
cont_p_m2 = _create_container(M2, cont_list[cont_num].dn, 'p0', sleep=True) |
| 756 |
_delete_container(cont_p_m1, sleep=True) |
| 757 |
_create_container(M2, cont_p_m2.dn, 'c0', sleep=True) |
| 758 |
|
| 759 |
cont_num += 1 |
| 760 |
cont_p_m1 = _create_container(M1, cont_list[cont_num].dn, 'p0', sleep=True) |
| 761 |
cont_p_m2 = _create_container(M2, cont_list[cont_num].dn, 'p0', sleep=True) |
| 762 |
cont_c_m1 = _create_container(M1, cont_p_m1.dn, 'c0', sleep=True) |
| 763 |
_create_container(M2, cont_p_m2.dn, 'c0', sleep=True) |
| 764 |
_delete_container(cont_c_m1, sleep=True) |
| 765 |
_create_container(M2, cont_p_m2.dn, 'c1', sleep=True) |
| 766 |
_delete_container(cont_p_m1, sleep=True) |
| 767 |
|
| 768 |
log.info("Delete container on m1, modify user1 on m1, create parent on m2 and modify user2 on m2") |
| 769 |
cont_num += 1 |
| 770 |
_delete_container(cont_list[cont_num]) |
| 771 |
_modify_user(test_users_m1, 4000, sleep=True) |
| 772 |
_create_container(M2, cont_list[cont_num].dn, 'p0') |
| 773 |
_modify_user(test_users_m2, 4001) |
| 774 |
|
| 775 |
topology_m2.resume_all_replicas() |
| 776 |
|
| 777 |
repl.test_replication_topology(topology_m2, timeout=60) |
| 778 |
|
| 779 |
conts_dns = {} |
| 780 |
for num in range(1, 3): |
| 781 |
inst = topology_m2.ms["supplier{}".format(num)] |
| 782 |
conts_dns[inst.serverid] = [] |
| 783 |
conts = nsContainers(inst, base_m2.dn) |
| 784 |
for cont in conts.list(): |
| 785 |
conts_p = nsContainers(inst, cont.dn) |
| 786 |
for cont_p in conts_p.list(): |
| 787 |
conts_c = nsContainers(inst, cont_p.dn) |
| 788 |
conts_dns[inst.serverid].extend([cont_c.dn for cont_c in conts_c.list()]) |
| 789 |
conts_dns[inst.serverid].extend([cont_p.dn for cont_p in conts_p.list()]) |
| 790 |
conts_dns[inst.serverid].extend([cont.dn for cont in conts.list()]) |
| 791 |
|
| 792 |
assert set(conts_dns[M1.serverid]) == set(conts_dns[M2.serverid]) |
| 793 |
|
| 794 |
user_dns_m1 = [user.dn for user in test_users_m1.list()] |
| 795 |
user_dns_m2 = [user.dn for user in test_users_m2.list()] |
| 796 |
assert set(user_dns_m1) == set(user_dns_m2) |
| 797 |
|
| 798 |
def test_conflict_attribute_multi_valued(self, topology_m2, base_m2): |
| 799 |
"""A RDN attribute being multi-valued, checks that after several operations |
| 800 |
MODRDN and MOD_REPL its RDN values are the same on both servers |
| 801 |
|
| 802 |
:id: 225b3522-8ed7-4256-96f9-5fab9b7044a5 |
| 803 |
:setup: Two supplier replication, |
| 804 |
audit log, error log for replica and access log for internal |
| 805 |
:steps: |
| 806 |
1. Create a test entry uid=user_test_1000,... |
| 807 |
2. Pause all replication agreements |
| 808 |
3. On M1 rename it into uid=foo1,... |
| 809 |
4. On M2 rename it into uid=foo2,... |
| 810 |
5. On M1 MOD_REPL uid:foo1 |
| 811 |
6. Resume all replication agreements |
| 812 |
7. Check that entry on M1 has uid=foo1, foo2 |
| 813 |
8. Check that entry on M2 has uid=foo1, foo2 |
| 814 |
9. Check that entry on M1 and M2 has the same uid values |
| 815 |
:expectedresults: |
| 816 |
1. It should pass |
| 817 |
2. It should pass |
| 818 |
3. It should pass |
| 819 |
4. It should pass |
| 820 |
5. It should pass |
| 821 |
6. It should pass |
| 822 |
7. It should pass |
| 823 |
8. It should pass |
| 824 |
9. It should pass |
| 825 |
""" |
| 826 |
|
| 827 |
M1 = topology_m2.ms["supplier1"] |
| 828 |
M2 = topology_m2.ms["supplier2"] |
| 829 |
repl = ReplicationManager(SUFFIX) |
| 830 |
|
| 831 |
# add a test user |
| 832 |
test_users_m1 = UserAccounts(M1, base_m2.dn, rdn=None) |
| 833 |
user_1 = test_users_m1.create_test_user(uid=1000) |
| 834 |
test_users_m2 = UserAccount(M2, user_1.dn) |
| 835 |
# Waiting fo the user to be replicated |
| 836 |
for i in range(0,60): |
| 837 |
time.sleep(1) |
| 838 |
if test_users_m2.exists(): |
| 839 |
break |
| 840 |
try: |
| 841 |
assert(test_users_m2.exists()) |
| 842 |
except AssertionError as e: |
| 843 |
_dump_logs(topology_m2) |
| 844 |
raise e from None |
| 845 |
|
| 846 |
# Stop replication agreements |
| 847 |
topology_m2.pause_all_replicas() |
| 848 |
|
| 849 |
# On M1 rename test entry in uid=foo1 |
| 850 |
original_dn = user_1.dn |
| 851 |
user_1.rename('uid=foo1') |
| 852 |
time.sleep(1) |
| 853 |
|
| 854 |
# On M2 rename test entry in uid=foo2 |
| 855 |
M2.rename_s(original_dn, 'uid=foo2') |
| 856 |
time.sleep(2) |
| 857 |
|
| 858 |
# on M1 MOD_REPL uid into foo1 |
| 859 |
user_1.replace('uid', 'foo1') |
| 860 |
|
| 861 |
# resume replication agreements |
| 862 |
topology_m2.resume_all_replicas() |
| 863 |
repl.test_replication_topology(topology_m2) |
| 864 |
|
| 865 |
# check that on M1, the entry 'uid' has two values 'foo1' and 'foo2' |
| 866 |
final_dn = re.sub('^.*1000,', 'uid=foo2,', original_dn) |
| 867 |
final_user_m1 = UserAccount(M1, final_dn) |
| 868 |
for val in final_user_m1.get_attr_vals_utf8('uid'): |
| 869 |
log.info("Check %s is on M1" % val) |
| 870 |
assert(val in ['foo1', 'foo2']) |
| 871 |
|
| 872 |
# check that on M2, the entry 'uid' has two values 'foo1' and 'foo2' |
| 873 |
final_user_m2 = UserAccount(M2, final_dn) |
| 874 |
for val in final_user_m2.get_attr_vals_utf8('uid'): |
| 875 |
log.info("Check %s is on M1" % val) |
| 876 |
assert(val in ['foo1', 'foo2']) |
| 877 |
|
| 878 |
# check that the entry have the same uid values |
| 879 |
for val in final_user_m1.get_attr_vals_utf8('uid'): |
| 880 |
log.info("Check M1.uid %s is also on M2" % val) |
| 881 |
assert(val in final_user_m2.get_attr_vals_utf8('uid')) |
| 882 |
|
| 883 |
for val in final_user_m2.get_attr_vals_utf8('uid'): |
| 884 |
log.info("Check M2.uid %s is also on M1" % val) |
| 885 |
assert(val in final_user_m1.get_attr_vals_utf8('uid')) |
| 886 |
|
| 887 |
def test_conflict_attribute_single_valued(self, topology_m2, base_m2): |
| 888 |
"""A RDN attribute being signle-valued, checks that after several operations |
| 889 |
MODRDN and MOD_REPL its RDN values are the same on both servers |
| 890 |
|
| 891 |
:id: c38ae613-5d1e-47cf-b051-c7284e64b817 |
| 892 |
:setup: Two supplier replication, test container for entries, enable plugin logging, |
| 893 |
audit log, error log for replica and access log for internal |
| 894 |
:steps: |
| 895 |
1. Create a test entry uid=user_test_1000,... |
| 896 |
2. Pause all replication agreements |
| 897 |
3. On M1 rename it into employeenumber=foo1,... |
| 898 |
4. On M2 rename it into employeenumber=foo2,... |
| 899 |
5. On M1 MOD_REPL employeenumber:foo1 |
| 900 |
6. Resume all replication agreements |
| 901 |
7. Check that entry on M1 has employeenumber=foo1 |
| 902 |
8. Check that entry on M2 has employeenumber=foo1 |
| 903 |
9. Check that entry on M1 and M2 has the same employeenumber values |
| 904 |
:expectedresults: |
| 905 |
1. It should pass |
| 906 |
2. It should pass |
| 907 |
3. It should pass |
| 908 |
4. It should pass |
| 909 |
5. It should pass |
| 910 |
6. It should pass |
| 911 |
7. It should pass |
| 912 |
8. It should pass |
| 913 |
9. It should pass |
| 914 |
""" |
| 915 |
|
| 916 |
M1 = topology_m2.ms["supplier1"] |
| 917 |
M2 = topology_m2.ms["supplier2"] |
| 918 |
repl = ReplicationManager(SUFFIX) |
| 919 |
|
| 920 |
# add a test user with a dummy 'uid' extra value because modrdn removes |
| 921 |
# uid that conflict with 'account' objectclass |
| 922 |
test_users_m1 = UserAccounts(M1, base_m2.dn, rdn=None) |
| 923 |
user_1 = test_users_m1.create_test_user(uid=1000) |
| 924 |
user_1.add('objectclass', 'extensibleobject') |
| 925 |
user_1.add('uid', 'dummy') |
| 926 |
test_users_m2 = UserAccount(M2, user_1.dn) |
| 927 |
|
| 928 |
# Waiting fo the user to be replicated |
| 929 |
for i in range(0,60): |
| 930 |
time.sleep(1) |
| 931 |
if test_users_m2.exists(): |
| 932 |
break |
| 933 |
try: |
| 934 |
assert(test_users_m2.exists()) |
| 935 |
except AssertionError as e: |
| 936 |
_dump_logs(topology_m2) |
| 937 |
raise e from None |
| 938 |
|
| 939 |
# Stop replication agreements |
| 940 |
topology_m2.pause_all_replicas() |
| 941 |
|
| 942 |
# On M1 rename test entry in employeenumber=foo1 |
| 943 |
original_dn = user_1.dn |
| 944 |
user_1.rename('employeenumber=foo1') |
| 945 |
time.sleep(1) |
| 946 |
|
| 947 |
# On M2 rename test entry in employeenumber=foo2 |
| 948 |
M2.rename_s(original_dn, 'employeenumber=foo2') |
| 949 |
time.sleep(2) |
| 950 |
|
| 951 |
# on M1 MOD_REPL uid into foo1 |
| 952 |
user_1.replace('employeenumber', 'foo1') |
| 953 |
|
| 954 |
# resume replication agreements |
| 955 |
topology_m2.resume_all_replicas() |
| 956 |
repl.test_replication_topology(topology_m2) |
| 957 |
|
| 958 |
# check that on M1, the entry 'employeenumber' has value 'foo1' |
| 959 |
final_dn = re.sub('^.*1000,', 'employeenumber=foo2,', original_dn) |
| 960 |
final_user_m1 = UserAccount(M1, final_dn) |
| 961 |
for val in final_user_m1.get_attr_vals_utf8('employeenumber'): |
| 962 |
log.info("Check %s is on M1" % val) |
| 963 |
assert(val in ['foo1']) |
| 964 |
|
| 965 |
# check that on M2, the entry 'employeenumber' has values 'foo1' |
| 966 |
final_user_m2 = UserAccount(M2, final_dn) |
| 967 |
for val in final_user_m2.get_attr_vals_utf8('employeenumber'): |
| 968 |
log.info("Check %s is on M2" % val) |
| 969 |
assert(val in ['foo1']) |
| 970 |
|
| 971 |
# check that the entry have the same uid values |
| 972 |
for val in final_user_m1.get_attr_vals_utf8('employeenumber'): |
| 973 |
log.info("Check M1.uid %s is also on M2" % val) |
| 974 |
assert(val in final_user_m2.get_attr_vals_utf8('employeenumber')) |
| 975 |
|
| 976 |
for val in final_user_m2.get_attr_vals_utf8('employeenumber'): |
| 977 |
log.info("Check M2.uid %s is also on M1" % val) |
| 978 |
assert(val in final_user_m1.get_attr_vals_utf8('employeenumber')) |
| 979 |
|
| 980 |
class TestThreeSuppliers: |
| 981 |
def test_nested_entries(self, topology_m3, base_m3): |
| 982 |
"""Check that conflict properly resolved for operations |
| 983 |
with nested entries with children |
| 984 |
|
| 985 |
:id: 77f09b18-03d1-45da-940b-1ad2c2908eb6 |
| 986 |
:setup: Three supplier replication, test container for entries, enable plugin logging, |
| 987 |
audit log, error log for replica and access log for internal |
| 988 |
:steps: |
| 989 |
1. Add 15 containers to m1 and wait for replication to happen |
| 990 |
2. Pause replication |
| 991 |
3. Create two child entries under each of two entries |
| 992 |
4. Create three child entries under each of three entries |
| 993 |
5. Create two parents on m1 and m2, then on m1 - create a child and delete one parent, |
| 994 |
on m2 - delete one parent and create a child |
| 995 |
6. Test a few more parent-child combinations with three instances |
| 996 |
7. Resume replication |
| 997 |
8. Check that the entries on both suppliers are the same and replication is working |
| 998 |
:expectedresults: |
| 999 |
1. It should pass |
| 1000 |
2. It should pass |
| 1001 |
3. It should pass |
| 1002 |
4. It should pass |
| 1003 |
5. It should pass |
| 1004 |
6. It should pass |
| 1005 |
7. It should pass |
| 1006 |
8. It should pass |
| 1007 |
""" |
| 1008 |
|
| 1009 |
pytest.xfail("Issue 49591 - work in progress") |
| 1010 |
|
| 1011 |
M1 = topology_m3.ms["supplier1"] |
| 1012 |
M2 = topology_m3.ms["supplier2"] |
| 1013 |
M3 = topology_m3.ms["supplier3"] |
| 1014 |
repl = ReplicationManager(SUFFIX) |
| 1015 |
|
| 1016 |
cont_list = [] |
| 1017 |
for num in range(11): |
| 1018 |
cont = _create_container(M1, base_m3.dn, 'sub{}'.format(num)) |
| 1019 |
cont_list.append(cont) |
| 1020 |
|
| 1021 |
repl.test_replication(M1, M2) |
| 1022 |
repl.test_replication(M1, M3) |
| 1023 |
|
| 1024 |
topology_m3.pause_all_replicas() |
| 1025 |
|
| 1026 |
log.info("Create two child entries under each of two entries") |
| 1027 |
cont_num = -1 |
| 1028 |
for num in range(2): |
| 1029 |
cont_num += 1 |
| 1030 |
_create_container(M1, cont_list[cont_num].dn, 'p0', sleep=True) |
| 1031 |
_create_container(M2, cont_list[cont_num].dn, 'p1', sleep=True) |
| 1032 |
|
| 1033 |
log.info("Create three child entries under each of three entries") |
| 1034 |
for num in range(3): |
| 1035 |
cont_num += 1 |
| 1036 |
_create_container(M1, cont_list[cont_num].dn, 'p0', sleep=True) |
| 1037 |
_create_container(M2, cont_list[cont_num].dn, 'p1', sleep=True) |
| 1038 |
_create_container(M3, cont_list[cont_num].dn, 'p2', sleep=True) |
| 1039 |
|
| 1040 |
log.info("Create two parents on m1 and m2, then on m1 - create a child and delete one parent," |
| 1041 |
"on m2 - delete one parent and create a child") |
| 1042 |
for inst1, inst2 in ((M1, M2), (M2, M1)): |
| 1043 |
cont_num += 1 |
| 1044 |
cont_p_m1_1 = _create_container(inst1, cont_list[cont_num].dn, 'p0') |
| 1045 |
cont_p_m1_2 = _create_container(inst1, cont_list[cont_num].dn, 'p1', sleep=True) |
| 1046 |
cont_p_m2_1 = _create_container(inst2, cont_list[cont_num].dn, 'p0') |
| 1047 |
cont_p_m2_2 = _create_container(inst2, cont_list[cont_num].dn, 'p1', sleep=True) |
| 1048 |
_create_container(inst1, cont_p_m1_1.dn, 'c0', sleep=True) |
| 1049 |
_delete_container(cont_p_m2_1, sleep=True) |
| 1050 |
_delete_container(cont_p_m1_2, sleep=True) |
| 1051 |
_create_container(inst2, cont_p_m2_2.dn, 'c0', sleep=True) |
| 1052 |
|
| 1053 |
log.info("Test a few more parent-child combinations on three instances") |
| 1054 |
for inst1, inst2, inst3 in ((M1, M2, M3), (M2, M1, M3), (M3, M1, M2)): |
| 1055 |
cont_num += 1 |
| 1056 |
cont_p_m1 = _create_container(inst1, cont_list[cont_num].dn, 'p0') |
| 1057 |
_delete_container(cont_p_m1, sleep=True) |
| 1058 |
|
| 1059 |
cont_p_m2 = _create_container(inst2, cont_list[cont_num].dn, 'p0') |
| 1060 |
cont_c_m2 = _create_container(inst2, cont_p_m2.dn, 'c0') |
| 1061 |
_delete_container(cont_c_m2) |
| 1062 |
_delete_container(cont_p_m2, sleep=True) |
| 1063 |
|
| 1064 |
cont_p_m3 = _create_container(inst3, cont_list[cont_num].dn, 'p0') |
| 1065 |
_create_container(inst3, cont_p_m3.dn, 'c0') |
| 1066 |
_create_container(inst3, cont_p_m3.dn, 'c1', sleep=True) |
| 1067 |
|
| 1068 |
topology_m3.resume_all_replicas() |
| 1069 |
|
| 1070 |
repl.test_replication_topology(topology_m3) |
| 1071 |
|
| 1072 |
conts_dns = {} |
| 1073 |
for num in range(1, 4): |
| 1074 |
inst = topology_m3.ms["supplier{}".format(num)] |
| 1075 |
conts_dns[inst.serverid] = [] |
| 1076 |
conts = nsContainers(inst, base_m3.dn) |
| 1077 |
for cont in conts.list(): |
| 1078 |
conts_p = nsContainers(inst, cont.dn) |
| 1079 |
for cont_p in conts_p.list(): |
| 1080 |
conts_c = nsContainers(inst, cont_p.dn) |
| 1081 |
conts_dns[inst.serverid].extend([cont_c.dn for cont_c in conts_c.list()]) |
| 1082 |
conts_dns[inst.serverid].extend([cont_p.dn for cont_p in conts_p.list()]) |
| 1083 |
conts_dns[inst.serverid].extend([cont.dn for cont in conts.list()]) |
| 1084 |
|
| 1085 |
for conts1, conts2 in permutations(conts_dns.values(), 2): |
| 1086 |
assert set(conts1) == set(conts2) |
| 1087 |
|
| 1088 |
|
| 1089 |
if __name__ == '__main__': |
| 1090 |
# Run isolated |
| 1091 |
# -s for DEBUG mode |
| 1092 |
CURRENT_FILE = os.path.realpath(__file__) |
| 1093 |
pytest.main("-s %s" % CURRENT_FILE) |