forked from 389ds/389-ds-base
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue 6470 - Some replication status data are reset upon a restart
Bug description: The replication agreement contains operational attributes related to the total init: nsds5replicaLastInitStart, nsds5replicaLastInitEnd, nsds5replicaLastInitStatus. Those attributes are reset at restart Fix description: When reading the replication agreement from config (agmt_new_from_entry) restore the attributes into the in-memory RA. Updates the RA config entry from the in-memory RA during shutdown/cleanallruv/enable_ra fixes: 389ds#6470 Reviewed by:
- Loading branch information
Showing
6 changed files
with
270 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
from lib389.idm.user import UserAccounts, TEST_USER_PROPERTIES | ||
|
||
from lib389.replica import ReplicationManager, Replicas | ||
from lib389.agreement import Agreements | ||
from lib389.backend import Backends | ||
|
||
from lib389.topologies import topology_m1c1 as topo_r # Replication | ||
|
@@ -156,6 +157,136 @@ def test_lastupdate_attr_before_init(topo_nr): | |
json_obj = json.loads(json_status) | ||
log.debug("JSON status message: {}".format(json_obj)) | ||
|
||
def test_total_init_operational_attr(topo_r): | ||
"""Check that operation attributes nsds5replicaLastInitStatus | ||
nsds5replicaLastInitStart and nsds5replicaLastInitEnd | ||
are preserved between restart | ||
:id: 6ba00bb1-87c0-47dd-86e0-ccf892b3985b | ||
:customerscenario: True | ||
:setup: Replication setup with supplier and consumer instances, | ||
test user on supplier | ||
:steps: | ||
1. Check that user was replicated to consumer | ||
2. Trigger a first total init | ||
3. Check status/start/end values are set on the supplier | ||
4. Restart supplier | ||
5. Check previous status/start/end values are preserved | ||
6. Trigger a second total init | ||
7. Check status/start/end values are set on the supplier | ||
8. Restart supplier | ||
9. Check previous status/start/end values are preserved | ||
10. Check status/start/end values are different between | ||
first and second total init | ||
:expectedresults: | ||
1. The user should be replicated to consumer | ||
2. Total init should be successful | ||
3. It must exist a values | ||
4. Operation should be successful | ||
5. Check values are identical before/after restart | ||
6. Total init should be successful | ||
7. It must exist a values | ||
8. Operation should be successful | ||
9. Check values are identical before/after restart | ||
10. values must differ between first/second total init | ||
""" | ||
|
||
supplier = topo_r.ms["supplier1"] | ||
consumer = topo_r.cs["consumer1"] | ||
repl = ReplicationManager(DEFAULT_SUFFIX) | ||
|
||
# Create a test user | ||
m_users = UserAccounts(topo_r.ms["supplier1"], DEFAULT_SUFFIX) | ||
m_user = m_users.ensure_state(properties=TEST_USER_PROPERTIES) | ||
m_user.ensure_present('mail', '[email protected]') | ||
|
||
# Then check it is replicated | ||
log.info("Check that replication is working") | ||
repl.wait_for_replication(supplier, consumer) | ||
c_users = UserAccounts(topo_r.cs["consumer1"], DEFAULT_SUFFIX) | ||
c_user = c_users.get('testuser') | ||
assert c_user | ||
|
||
# Retrieve the replication agreement S1->C1 | ||
replica_supplier = Replicas(supplier).get(DEFAULT_SUFFIX) | ||
agmts_supplier = Agreements(supplier, replica_supplier.dn) | ||
supplier_consumer = None | ||
for agmt in agmts_supplier.list(): | ||
if (agmt.get_attr_val_utf8('nsDS5ReplicaPort') == str(consumer.port) and | ||
agmt.get_attr_val_utf8('nsDS5ReplicaHost') == consumer.host): | ||
supplier_consumer = agmt | ||
break | ||
assert supplier_consumer | ||
|
||
|
||
# Trigger a first total init and check that | ||
# start/end/status is updated AND preserved during a restart | ||
log.info("First total init") | ||
supplier_consumer.begin_reinit() | ||
(done, error) = supplier_consumer.wait_reinit() | ||
assert done is True | ||
|
||
status_1 = supplier_consumer.get_attr_val_utf8("nsds5replicaLastInitStatus") | ||
assert status_1 | ||
|
||
initStart_1 = supplier_consumer.get_attr_val_utf8("nsds5replicaLastInitStart") | ||
assert initStart_1 | ||
|
||
initEnd_1 = supplier_consumer.get_attr_val_utf8("nsds5replicaLastInitEnd") | ||
assert initEnd_1 | ||
|
||
log.info("Check values from first total init are preserved") | ||
supplier.restart() | ||
post_restart_status_1 = supplier_consumer.get_attr_val_utf8("nsds5replicaLastInitStatus") | ||
assert post_restart_status_1 | ||
assert post_restart_status_1 == status_1 | ||
|
||
post_restart_initStart_1 = supplier_consumer.get_attr_val_utf8("nsds5replicaLastInitStart") | ||
assert post_restart_initStart_1 | ||
assert post_restart_initStart_1 == initStart_1 | ||
|
||
post_restart_initEnd_1 = supplier_consumer.get_attr_val_utf8("nsds5replicaLastInitEnd") | ||
assert post_restart_initEnd_1 == initEnd_1 | ||
|
||
# Trigger a second total init and check that | ||
# start/end/status is updated (differ from previous values) | ||
# AND new values are preserved during a restart | ||
time.sleep(1) | ||
log.info("Second total init") | ||
supplier_consumer.begin_reinit() | ||
(done, error) = supplier_consumer.wait_reinit() | ||
assert done is True | ||
|
||
status_2 = supplier_consumer.get_attr_val_utf8("nsds5replicaLastInitStatus") | ||
assert status_2 | ||
|
||
initStart_2 = supplier_consumer.get_attr_val_utf8("nsds5replicaLastInitStart") | ||
assert initStart_2 | ||
|
||
initEnd_2 = supplier_consumer.get_attr_val_utf8("nsds5replicaLastInitEnd") | ||
assert initEnd_2 | ||
|
||
log.info("Check values from second total init are preserved") | ||
supplier.restart() | ||
post_restart_status_2 = supplier_consumer.get_attr_val_utf8("nsds5replicaLastInitStatus") | ||
assert post_restart_status_2 | ||
assert post_restart_status_2 == status_2 | ||
|
||
post_restart_initStart_2 = supplier_consumer.get_attr_val_utf8("nsds5replicaLastInitStart") | ||
assert post_restart_initStart_2 | ||
assert post_restart_initStart_2 == initStart_2 | ||
|
||
post_restart_initEnd_2 = supplier_consumer.get_attr_val_utf8("nsds5replicaLastInitEnd") | ||
assert post_restart_initEnd_2 == initEnd_2 | ||
|
||
# Check that values are updated by total init | ||
log.info("Check values from first/second total init are different") | ||
assert status_2 == status_1 | ||
assert initStart_2 != initStart_1 | ||
assert initEnd_2 != initEnd_1 | ||
|
||
|
||
|
||
if __name__ == '__main__': | ||
# Run isolated | ||
# -s for DEBUG mode | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters