| 1 |
# --- BEGIN COPYRIGHT BLOCK --- |
| 2 |
# Copyright (C) 2019 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 threading |
| 10 |
import pytest |
| 11 |
import random |
| 12 |
from lib389 import DirSrv |
| 13 |
from lib389.tasks import * |
| 14 |
from lib389.utils import * |
| 15 |
from test389.topologies import topology_m4, topology_m2 |
| 16 |
from lib389._constants import * |
| 17 |
|
| 18 |
pytestmark = pytest.mark.tier1 |
| 19 |
|
| 20 |
@pytest.mark.skipif(ds_is_older("1.4.1.6"), reason="Not implemented") |
| 21 |
def test_max_tasks(topology_m4): |
| 22 |
"""Test we can not create more than 64 cleaning tasks |
| 23 |
|
| 24 |
This test needs to be a standalone test becuase there is no easy way to |
| 25 |
"restore" the instance after running this test |
| 26 |
|
| 27 |
:id: c34d0b40-3c3e-4f53-8656-5e4c2a310a1f |
| 28 |
:setup: Replication setup with four suppliers |
| 29 |
:steps: |
| 30 |
1. Stop suppliers 3 & 4 |
| 31 |
2. Create over 64 tasks between m1 and m2 |
| 32 |
3. Check logs to see if (>64) tasks were rejected |
| 33 |
|
| 34 |
:expectedresults: |
| 35 |
1. Success |
| 36 |
2. Success |
| 37 |
3. Success |
| 38 |
""" |
| 39 |
|
| 40 |
# Stop suppliers 3 & 4 |
| 41 |
m1 = topology_m4.ms["supplier1"] |
| 42 |
m2 = topology_m4.ms["supplier2"] |
| 43 |
m3 = topology_m4.ms["supplier3"] |
| 44 |
m4 = topology_m4.ms["supplier4"] |
| 45 |
m3.stop() |
| 46 |
m4.stop() |
| 47 |
|
| 48 |
# Add over 64 tasks between supplier1 & 2 to try to exceed the 64 task limit |
| 49 |
for i in range(1, 64): |
| 50 |
cruv_task = CleanAllRUVTask(m1) |
| 51 |
cruv_task.create(properties={ |
| 52 |
'replica-id': str(i), |
| 53 |
'replica-base-dn': DEFAULT_SUFFIX, |
| 54 |
'replica-force-cleaning': 'no', # This forces these tasks to stick around |
| 55 |
}) |
| 56 |
cruv_task = CleanAllRUVTask(m2) |
| 57 |
cruv_task.create(properties={ |
| 58 |
'replica-id': "10" + str(i), |
| 59 |
'replica-base-dn': DEFAULT_SUFFIX, |
| 60 |
'replica-force-cleaning': 'yes', # This allows the tasks to propagate |
| 61 |
}) |
| 62 |
|
| 63 |
# Check the errors log for our error message in supplier 1 |
| 64 |
assert m1.searchErrorsLog('Exceeded maximum number of active CLEANALLRUV tasks') |
| 65 |
|
| 66 |
|
| 67 |
if __name__ == '__main__': |
| 68 |
# Run isolated |
| 69 |
# -s for DEBUG mode |
| 70 |
CURRENT_FILE = os.path.realpath(__file__) |
| 71 |
pytest.main("-s %s" % CURRENT_FILE) |
| 72 |
|