diff options
author | Petr Vobornik <pvoborni@redhat.com> | 2015-03-25 13:39:43 +0100 |
---|---|---|
committer | Petr Vobornik <pvoborni@redhat.com> | 2015-04-14 19:31:54 +0200 |
commit | 11bd9d96f191066f7ba760549f00179c128a9787 (patch) | |
tree | 3d20a02cae3af4600793c6a339a2ceeceb9a6a03 /ipatests/test_ipapython | |
parent | 0a1a3d73120bdf20ae05bcf663f14ca1a8b02c25 (diff) | |
download | freeipa-11bd9d96f191066f7ba760549f00179c128a9787.tar.gz freeipa-11bd9d96f191066f7ba760549f00179c128a9787.tar.xz freeipa-11bd9d96f191066f7ba760549f00179c128a9787.zip |
performance: faster DN implementation
DN code was optimized to be faster if DNs are created from string. This is
the major use case, since most DNs come from LDAP.
With this patch, DN creation is almost 8-10x faster (with 30K-100K DNs).
Second mojor use case - deepcopy in LDAPEntry is about 20x faster - done by
custom __deepcopy__ function.
The major change is that DN is no longer internally composed of RDNs and
AVAs but it rather keeps the data in open ldap format - the same as output
of str2dn function. Therefore, for immutable DNs, no other transformations
are required on instantiation.
The format is:
DN: [RDN, RDN,...]
RDN: [AVA, AVA,...]
AVA: ['utf-8 encoded str - attr', 'utf-8 encode str -value', FLAG]
FLAG: int
Further indexing of DN object constructs an RDN which is just an encapsulation
of the RDN part of open ldap representation. Indexing of RDN constructs AVA in
the same fashion.
Obtained EditableAVA, EditableRDN from EditableDN shares the respected lists
of the open ldap repr. so that the change of value or attr is reflected in
parent object.
Reviewed-By: Petr Viktorin <pviktori@redhat.com>
Diffstat (limited to 'ipatests/test_ipapython')
-rw-r--r-- | ipatests/test_ipapython/test_dn.py | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/ipatests/test_ipapython/test_dn.py b/ipatests/test_ipapython/test_dn.py index 60802b70c..77e35eb47 100644 --- a/ipatests/test_ipapython/test_dn.py +++ b/ipatests/test_ipapython/test_dn.py @@ -129,9 +129,9 @@ class TestAVA(unittest.TestCase): with self.assertRaises(TypeError): AVA_class() - # Create with more than 2 args should fail + # Create with more than 3 args should fail with self.assertRaises(TypeError): - AVA_class(self.attr1, self.value1, self.attr1) + AVA_class(self.attr1, self.value1, self.attr1, self.attr1) # Create with 1 arg which is not string should fail with self.assertRaises(TypeError): @@ -164,11 +164,14 @@ class TestAVA(unittest.TestCase): self.assertEqual(ava1[self.attr1], self.value1) + self.assertEqual(ava1[0], self.attr1) + self.assertEqual(ava1[1], self.value1) + with self.assertRaises(KeyError): ava1['foo'] - with self.assertRaises(TypeError): - ava1[0] + with self.assertRaises(KeyError): + ava1[3] def test_properties(self): for AVA_class in (AVA, EditableAVA): @@ -1413,7 +1416,7 @@ class TestDN(unittest.TestCase): dn3 = DN_class(self.dn3) self.assertEqual(len(dn1), 1) - self.assertEqual(dn1[:], [self.rdn1]) + self.assertEqual(dn1[:], self.rdn1) for i, ava in enumerate(dn1): if i == 0: self.assertEqual(ava, self.rdn1) @@ -1421,7 +1424,7 @@ class TestDN(unittest.TestCase): self.fail("got iteration index %d, but len=%d" % (i, len(self.rdn1))) self.assertEqual(len(dn2), 1) - self.assertEqual(dn2[:], [self.rdn2]) + self.assertEqual(dn2[:], self.rdn2) for i, ava in enumerate(dn2): if i == 0: self.assertEqual(ava, self.rdn2) @@ -1429,7 +1432,7 @@ class TestDN(unittest.TestCase): self.fail("got iteration index %d, but len=%d" % (i, len(self.rdn2))) self.assertEqual(len(dn3), 2) - self.assertEqual(dn3[:], [self.rdn1, self.rdn2]) + self.assertEqual(dn3[:], DN_class(self.rdn1, self.rdn2)) for i, ava in enumerate(dn3): if i == 0: self.assertEqual(ava, self.rdn1) |