#49798 Issue 49073 - Add py3 support for tickets
Closed 3 years ago by spichugi. Opened 5 years ago by amsharma.
amsharma/389-ds-base feature  into  master

@@ -2,7 +2,6 @@ 

  from lib389.tasks import *

  from lib389.utils import *

  from lib389.topologies import topology_m2

- 

  from lib389._constants import (PLUGIN_MEMBER_OF, DEFAULT_SUFFIX, SUFFIX, HOST_MASTER_2,

                                PORT_MASTER_2)

  
@@ -37,7 +36,7 @@ 

              topology_m2.ms["master1"].modify_s(GROUP_DN,

                                        [(ldap.MOD_ADD,

                                          'member',

-                                         MEMBER_VAL)])

+                                         ensure_bytes(MEMBER_VAL))])

          except ldap.LDAPError as e:

              log.fatal('Failed to update group: member (%s) - error: %s' %

                        (MEMBER_VAL, e.message['desc']))
@@ -51,7 +50,7 @@ 

              USER_DN = ("uid=member%d,%s" % (idx, DEFAULT_SUFFIX))

              ent = master.getEntry(USER_DN, ldap.SCOPE_BASE, "(objectclass=*)")

              if presence_flag:

-                 assert ent.hasAttr('memberof') and ent.getValue('memberof') == GROUP_DN

+                 assert ent.hasAttr('memberof') and ensure_str(ent.getValue('memberof')) == GROUP_DN

              else:

                  assert not ent.hasAttr('memberof')

          except ldap.LDAPError as e:
@@ -96,10 +95,10 @@ 

      topology_m2.ms["master1"].modify_s(ents[0].dn,

                                [(ldap.MOD_REPLACE,

                                  'nsDS5ReplicatedAttributeListTotal',

-                                 '(objectclass=*) $ EXCLUDE '),

+                                b'(objectclass=*) $ EXCLUDE '),

                                 (ldap.MOD_REPLACE,

                                  'nsDS5ReplicatedAttributeList',

-                                 '(objectclass=*) $ EXCLUDE memberOf')])

+                                b'(objectclass=*) $ EXCLUDE memberOf')])

      topology_m2.ms["master1"].restart(timeout=10)

  

      #
@@ -131,7 +130,7 @@ 

      topology_m2.ms["master1"].agreement.init(SUFFIX, HOST_MASTER_2, PORT_MASTER_2)

      topology_m2.ms["master1"].waitForReplInit(ents[0].dn)

  

-     # Check that for total update  memberof was on both side 

+     # Check that for total update  memberof was on both side

      # because memberof is NOT excluded from total init

      time.sleep(5)

      _check_memberof(topology_m2.ms["master1"], True)
@@ -147,3 +146,4 @@ 

      # -s for DEBUG mode

      CURRENT_FILE = os.path.realpath(__file__)

      pytest.main("-s %s" % CURRENT_FILE)

+ 

Description: Added py3 support by explicitly changing strings to bytes.

https://pagure.io/389-ds-base/issue/49588

Reviewed by: ??

This test fails for me with error:

E           lib389.exceptions.NoSuchEntryError: no such entry for [('cn=replica,cn=dc\\3Dexample\\2Cdc\\3Dcom,cn=mapping tree,cn=config', 1, '(&(objectclass=nsds5replicationagreement)(nsds5replicahost=localhost)(nsds5replicaport=39002)(nsds5replicaroot=dc=example,dc=com))')]

Full error log:
https://paste.fedoraproject.org/paste/AoPEN6osp0sovjHh8NKyMw

I think this is the wrong approach. If you have a bytes error it's because you are using the raw entry api, instead of converting to lib389 wrappers. It may be better to rearchitect the test to use the proper lib389 types instead, because one day I would like to remove Entry from lib389 as it's a horrible horrible hack.

We have other tests/tickets ported to Python 3 in the same maner so I think we can merge it like this.

But the test case is really small and should be easy to port. If it is not a big trouble, @amsharma or other collegues, could you please check it?
And please, ask questions if you'll face any issues.

It is very basic UserAccounts test.

Closing this, work will be done in a different PR.

Pull-Request has been closed by vashirov

3 years ago

389-ds-base is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in 389-ds-base's github repository.

This pull request has been cloned to Github as issue and is available here:
- https://github.com/389ds/389-ds-base/issues/2857

If you want to continue to work on the PR, please navigate to the github issue,
download the patch from the attachments and file a new pull request.

Thank you for understanding. We apologize for all inconvenience.

Pull-Request has been closed by spichugi

3 years ago
Metadata