Creating replicas with a new Replicas/Replica object is failing now. We need to have at least a simple test for every method (some of them are not functioning now).
Also, it has a few typos in the variables and some docstrings are absent.
The docstring of 'delete()' method mentions 'it also deletes the changelog associated to that replica' but it is not true now. I think we need handle it.
The 'get_dn()' method does the same what DSLdapObject method 'dn()' does. Should it be consistent?
Metadata Update from @spichugi: - Issue assigned to spichugi
Metadata Update from @spichugi: - Assignee reset
Metadata Update from @spichugi: - Custom field Origin adjusted to None - Custom field Review Status adjusted to None
Move tests for ReplicaLegacy to replicaLegacy_test.py module. Add a new test suite for Replicas(DSLdapObject). Fix or change:
- Agreement.create() - if property is None, define the dict object; - Changelog.list() - make it consistent and return empry list if nothing is found; - Replica: - Replace hard coded values with variables if possibe; - Fix get_role() functions so it will return right result; - Fix deleteAgreements. It now doesn't have suffix param; - Fix typos on variables; - Make promote() and demote() methods more explicit; - Rename Replicas.delete() to Replicas.disable because it coveres changelog and agreements deletion too; - Make docstring format consistent;
Metadata Update from @spichugi: - Custom field Review Status adjusted to review (was: None)
@spichugi I'm starting to review this now, but it may take me a while.
Tiny change on line 778. Let's replace 'master' and 'hub' with their corresponding constants?
Btw, do the REPLICAROLE_MASTER, etc. constants really need to be strings?
@ilias95 thanks! I agree with you and I've applied your suggestions.
Thanks! Tbh, I was thinking of using an enum as well for this. Unfortunately it's p3 only (but also backported in pypi), and William said that we still need py2 compatibility.
However, we can easily create our own enums as shown here: https://stackoverflow.com/a/1695250/1069389
IE.
def enum(*sequential, **named): enums = dict(zip(sequential, range(len(sequential))), **named) return type('Enum', (), enums) >>> Numbers = enum('ZERO', 'ONE', 'TWO') >>> Numbers.ZERO 0 >>> Numbers.ONE 1
It all looks good but:
1468 + # 1469 + # MASTER (suffix/backend) 1470 + # 1471 + backendEntry = topology.master.backend.create(suffix=NEW_SUFFIX_4, 1472 + properties={BACKEND_NAME: 1473 + NEW_BACKEND_4}) 1474 + 1475 + ents = topology.master.mappingtree.list() 1476 + master_nb_mappingtree = len(ents) 1477 + 1478 + # create a first additional mapping tree 1479 + topology.master.mappingtree.create(NEW_SUFFIX_4, bename=NEW_BACKEND_4) 1480 + ents = topology.master.mappingtree.list() 1481 + assert len(ents) == (master_nb_mappingtree + 1) 1482 + topology.master.add_s(Entry((NEW_SUFFIX_4, 1483 + {'objectclass': "top organizationalunit".split(), 1484 + 'ou': NEW_SUFFIX_4.split('=', 1)[1]})))
Why do you make an extra MT here? The backend create already makes the MT you need for this? You should only need to retrieve it I think....
We have another option though. It was backported as enum34 in pypi. Sorry for not mentioning that... https://pypi.python.org/pypi/enum34
Also, RHEL 7 repo has python-enum34, but I think we are good if we will add enum34 to the requirements. @firstyear what do you think?
@firstyear
If I haven't missed anything, BackendLegacy(object) doesn't have the feature you are talking of... And I've just moved replica_test.py to replicaLegacy_test.py, and I made no changes to that...
Ohhhh I see. I assumed you were using the new backend. That makes sense now.
I'm happy with adding enum provided you are: I really only care about python 3 now, but I know that python 2 affects you in QE @spichugi
Add enum34 to requirements.txt for py2 compatibility
Is enum34 available in an rpm? Without that we can't add it .... .:( Because else we won't have working fedora rpms. :(
Yes, it is. https://www.rpmfind.net/linux/rpm2html/search.php?query=python-enum34
Is enum34 available in an rpm? Without that we can't add it .... .:( Because else we won't have working fedora rpms. :( Yes, it is. https://www.rpmfind.net/linux/rpm2html/search.php?query=python-enum34
I don't trust rpmfind.net, since it contains a lot of outdated garbage.
The official rpms for Fedora are located in koji: https://koji.fedoraproject.org/koji/packageinfo?packageID=18278 RHEL7/CentOS7 have python-enum34 is official repos as well (not in EPEL). And for RHEL6 we will need to install from pip.
Ok, thanks, I didn't know that.
If it's available as a dep in el7/fedora lets put that into the lib389 specfile, and then I'm happy to ack this :)
Added. Package python-enum34 exists by that name in both RHEL7 and Fedora.
Rebased version of the patch:
================ test session starts ================ platform linux2 -- Python 2.7.5, pytest-3.2.1, py-1.4.34, pluggy-0.4.0 -- /usr/bin/python cachedir: .cache metadata: {'Python': '2.7.5', 'Platform': 'Linux-3.10.0-693.el7.x86_64-x86_64-with-redhat-7.4-Maipo', 'Packages': {'py': '1.4.34', 'pytest': '3.2.1', 'pluggy': '0.4.0'}, 'Plugins': {'beakerlib': '0.7.1', 'html': '1.15.1', 'cov': '2.5.1', 'metadata': '1.5.0'}} DS build: 1.3.6.1 389-ds-base: 1.3.6.1-16.el7 nss: 3.28.4-8.el7 nspr: 4.13.1-1.0.el7_3 openldap: 2.4.44-5.el7 svrcore: 4.1.3-2.el7
rootdir: /mnt/tests/rhds/tests/upstream/src/lib389, inifile: plugins: metadata-1.5.0, html-1.15.1, cov-2.5.1, beakerlib-0.7.1 collected 23 items
lib389/tests/replicaLegacy_test.py::test_create PASSED lib389/tests/replicaLegacy_test.py::test_list PASSED lib389/tests/replicaLegacy_test.py::test_create_repl_manager PASSED lib389/tests/replicaLegacy_test.py::test_enableReplication PASSED lib389/tests/replicaLegacy_test.py::test_disableReplication PASSED lib389/tests/replicaLegacy_test.py::test_setProperties PASSED lib389/tests/replicaLegacy_test.py::test_getProperties PASSED lib389/tests/replica_test.py::test_delete_agreements PASSED lib389/tests/replica_test.py::test_get_ruv_entry PASSED lib389/tests/replica_test.py::test_get_role PASSED lib389/tests/replica_test.py::test_basic PASSED lib389/tests/replica_test.py::test_promote[Replica role.CONSUMER-Replica role.HUB] PASSED lib389/tests/replica_test.py::test_promote[Replica role.CONSUMER-Replica role.MASTER] PASSED lib389/tests/replica_test.py::test_promote[Replica role.HUB-Replica role.MASTER] PASSED lib389/tests/replica_test.py::test_demote[Replica role.MASTER-Replica role.HUB] PASSED lib389/tests/replica_test.py::test_demote[Replica role.MASTER-Replica role.CONSUMER] PASSED lib389/tests/replica_test.py::test_demote[Replica role.HUB-Replica role.CONSUMER] PASSED lib389/tests/replica_test.py::test_promote_fail[Replica role.MASTER] PASSED lib389/tests/replica_test.py::test_promote_fail[Replica role.HUB] PASSED lib389/tests/replica_test.py::test_promote_fail[Replica role.CONSUMER] PASSED lib389/tests/replica_test.py::test_demote_fail[Replica role.MASTER] PASSED lib389/tests/replica_test.py::test_demote_fail[Replica role.HUB] PASSED lib389/tests/replica_test.py::test_demote_fail[Replica role.CONSUMER] PASSED
================ 23 passed in 273.58 seconds ================
Metadata Update from @firstyear: - Custom field Review Status adjusted to ack (was: review)
commit 3342c118fb034f7262f10470e055911ea3848b1c Author: Simon Pichugin spichugi@redhat.com Date: Fri Jul 21 17:32:46 2017 +0200
Metadata Update from @spichugi: - Issue close_status updated to: Fixed - Issue status updated to: Closed (was: Open)