#50702 Issue 49761 - Fix CI test suite issues
Closed 3 years ago by spichugi. Opened 4 years ago by vashirov.
vashirov/389-ds-base test_fixes  into  master

@@ -11,6 +11,8 @@ 

  """

  

  import os

+ import ldap

+ import pytest

  from lib389.topologies import topology_m1 as topo

  from lib389.idm.organizationalunit import OrganizationalUnits

  from lib389.idm.domain import Domain
@@ -20,9 +22,8 @@ 

  from lib389.backend import Backends

  from lib389.config import Config

  from lib389._constants import DEFAULT_SUFFIX

- import ldap

- import pytest

  from lib389.idm.group import Groups, Group, UniqueGroup, nsAdminGroups, nsAdminGroup

+ from lib389.utils import ds_is_older

  

  pytestmark = pytest.mark.tier1

  
@@ -72,6 +73,11 @@ 

      """

      Will create entries with nsAdminGroup objectclass

      """

+     objectclasses = ['top', 'person', 'posixaccount', 'inetuser',

+                         'nsMemberOf', 'nsAccount', 'nsAdminGroup']

+     if ds_is_older('1.4.0'):

+         objectclasses.remove('nsAccount')

+ 

      user = nsAdminGroups(topo.ms["master1"], suffix, rdn=None).create(properties={

          'cn': user_id,

          'sn': user_id,
@@ -80,8 +86,7 @@ 

          'loginShell': '/bin/bash',

          'uidNumber': uid_no,

          'gidNumber': gid_no,

-         'objectclass': ['top', 'person', 'posixaccount', 'inetuser',

-                         'nsMemberOf', 'nsAccount', 'nsAdminGroup'],

+         'objectclass': objectclasses,

          'nsAdminGroupName': role_usr,

          'seeAlso': 'uid={},{}'.format(user_id, suffix),

          'entrydn': 'uid={},{}'.format(user_id, suffix)

@@ -624,7 +624,7 @@ 

                   (['+'], 'nsUniqueId', True),

                   (['*'], 'cn', True),

                   (['cn'], 'cn', True)]

- @pytest.mark.skipif(ds_is_older("1.4.1.6"), reason="Not implemented")

+ @pytest.mark.skipif(ds_is_older("1.4.2.0"), reason="Not implemented")

  @pytest.mark.parametrize("attrs, attr, present", search_params)

  def test_search_req_attrs(topology_st, add_test_entry, attrs, attr, present):

      """Test requested attributes in search operations.
@@ -1355,7 +1355,7 @@ 

      return inst

  

  

- @pytest.mark.skipif(not get_user_is_root() or not default_paths.perl_enabled or ds_is_older('1.4.0.0'),

+ @pytest.mark.skipif(not get_user_is_root() or not default_paths.perl_enabled or ds_is_older('1.4.2.0'),

                      reason="This test is only required with new admin cli, and requires root.")

  @pytest.mark.bz1748016

  @pytest.mark.ds50581

@@ -124,11 +124,17 @@ 

  

      cachesize = '33333333'

  

-     dbcachesize_val = bdb_config_ldbm.get_attr_val('nsslapd-dbcachesize')

+     if ds_is_older('1.4.2'):

+         dbcachesize_val = config_ldbm.get_attr_val('nsslapd-dbcachesize')

+         autosize_val = config_ldbm.get_attr_val('nsslapd-cache-autosize')

+         autosize_split_val = config_ldbm.get_attr_val('nsslapd-cache-autosize-split')

+     else:

+         dbcachesize_val = bdb_config_ldbm.get_attr_val('nsslapd-dbcachesize')

+         autosize_val = bdb_config_ldbm.get_attr_val('nsslapd-cache-autosize')

+         autosize_split_val = bdb_config_ldbm.get_attr_val('nsslapd-cache-autosize-split')

+ 

      cachenensize_val = userroot_ldbm.get_attr_val('nsslapd-cachememsize')

      dncachenensize_val = userroot_ldbm.get_attr_val('nsslapd-dncachememsize')

-     autosize_val = bdb_config_ldbm.get_attr_val('nsslapd-cache-autosize')

-     autosize_split_val = bdb_config_ldbm.get_attr_val('nsslapd-cache-autosize-split')

  

      log.info("Check nsslapd-dbcachesize and nsslapd-cachememsize before the test")

      log.info("nsslapd-dbcachesize == {}".format(dbcachesize_val))
@@ -165,11 +171,17 @@ 

          config_ldbm.set('nsslapd-dbcachesize ', cachesize)

      topo.standalone.restart()

  

-     dbcachesize_val = bdb_config_ldbm.get_attr_val('nsslapd-dbcachesize')

+     if ds_is_older('1.4.2'):

+         dbcachesize_val = config_ldbm.get_attr_val('nsslapd-dbcachesize')

+         autosize_val = config_ldbm.get_attr_val('nsslapd-cache-autosize')

+         autosize_split_val = config_ldbm.get_attr_val('nsslapd-cache-autosize-split')

+     else:

+         dbcachesize_val = bdb_config_ldbm.get_attr_val('nsslapd-dbcachesize')

+         autosize_val = bdb_config_ldbm.get_attr_val('nsslapd-cache-autosize')

+         autosize_split_val = bdb_config_ldbm.get_attr_val('nsslapd-cache-autosize-split')

+ 

      cachenensize_val = userroot_ldbm.get_attr_val('nsslapd-cachememsize')

      dncachenensize_val = userroot_ldbm.get_attr_val('nsslapd-dncachememsize')

-     autosize_val = bdb_config_ldbm.get_attr_val('nsslapd-cache-autosize')

-     autosize_split_val = bdb_config_ldbm.get_attr_val('nsslapd-cache-autosize-split')

  

      log.info("Check nsslapd-dbcachesize and nsslapd-cachememsize in the appropriate range.")

      log.info("nsslapd-dbcachesize == {}".format(dbcachesize_val))
@@ -215,11 +227,17 @@ 

  

      # Test with caches with both real values and 0

      for cachesize in ('0', '33333333'):

-         dbcachesize_val = bdb_config_ldbm.get_attr_val('nsslapd-dbcachesize')

+         if ds_is_older('1.4.2'):

+             dbcachesize_val = config_ldbm.get_attr_val('nsslapd-dbcachesize')

+             autosize_val = config_ldbm.get_attr_val('nsslapd-cache-autosize')

+             autosize_split_val = config_ldbm.get_attr_val('nsslapd-cache-autosize-split')

+         else:

+             dbcachesize_val = bdb_config_ldbm.get_attr_val('nsslapd-dbcachesize')

+             autosize_val = bdb_config_ldbm.get_attr_val('nsslapd-cache-autosize')

+             autosize_split_val = bdb_config_ldbm.get_attr_val('nsslapd-cache-autosize-split')

+ 

          cachenensize_val = userroot_ldbm.get_attr_val('nsslapd-cachememsize')

          dncachenensize_val = userroot_ldbm.get_attr_val('nsslapd-dncachememsize')

-         autosize_val = bdb_config_ldbm.get_attr_val('nsslapd-cache-autosize')

-         autosize_split_val = bdb_config_ldbm.get_attr_val('nsslapd-cache-autosize-split')

  

          log.info("Check nsslapd-dbcachesize and nsslapd-cachememsize before the test")

          log.info("nsslapd-dbcachesize == {}".format(dbcachesize_val))
@@ -243,11 +261,17 @@ 

          userroot_ldbm.set('nsslapd-cachememsize', cachesize)

          topo.standalone.restart()

  

-         dbcachesize_val = bdb_config_ldbm.get_attr_val('nsslapd-dbcachesize')

+         if ds_is_older('1.4.2'):

+             dbcachesize_val = config_ldbm.get_attr_val('nsslapd-dbcachesize')

+             autosize_val = config_ldbm.get_attr_val('nsslapd-cache-autosize')

+             autosize_split_val = config_ldbm.get_attr_val('nsslapd-cache-autosize-split')

+         else:

+             dbcachesize_val = bdb_config_ldbm.get_attr_val('nsslapd-dbcachesize')

+             autosize_val = bdb_config_ldbm.get_attr_val('nsslapd-cache-autosize')

+             autosize_split_val = bdb_config_ldbm.get_attr_val('nsslapd-cache-autosize-split')

+ 

          cachenensize_val = userroot_ldbm.get_attr_val('nsslapd-cachememsize')

          dncachenensize_val = userroot_ldbm.get_attr_val('nsslapd-dncachememsize')

-         autosize_val = bdb_config_ldbm.get_attr_val('nsslapd-cache-autosize')

-         autosize_split_val = bdb_config_ldbm.get_attr_val('nsslapd-cache-autosize-split')

  

          log.info("Check nsslapd-dbcachesize and nsslapd-cachememsize in the appropriate range.")

          log.info("nsslapd-dbcachesize == {}".format(dbcachesize_val))
@@ -280,8 +304,12 @@ 

  

      config_ldbm = DSLdapObject(topo.standalone, DN_CONFIG_LDBM)

      bdb_config_ldbm = DSLdapObject(topo.standalone, DN_CONFIG_LDBM_BDB)

-     autosize_val = bdb_config_ldbm.get_attr_val('nsslapd-cache-autosize')

-     autosize_split_val = bdb_config_ldbm.get_attr_val('nsslapd-cache-autosize-split')

+     if ds_is_older('1.4.2'):

+         autosize_val = config_ldbm.get_attr_val('nsslapd-cache-autosize')

+         autosize_split_val = config_ldbm.get_attr_val('nsslapd-cache-autosize-split')

+     else:

+         autosize_val = bdb_config_ldbm.get_attr_val('nsslapd-cache-autosize')

+         autosize_split_val = bdb_config_ldbm.get_attr_val('nsslapd-cache-autosize-split')

  

      log.info("Set nsslapd-cache-autosize-split to {}".format(invalid_value))

      with pytest.raises(ldap.UNWILLING_TO_PERFORM):

@@ -146,13 +146,21 @@ 

      ldbmconfig = LDBMConfig(topology_m2.ms["master1"])

      bdbconfig = BDB_LDBMConfig(topology_m2.ms["master1"])

  

-     deadlock_policy = bdbconfig.get_attr_val_bytes('nsslapd-db-deadlock-policy')

+     if ds_is_older('1.4.2'):

+         deadlock_policy = ldbmconfig.get_attr_val_bytes('nsslapd-db-deadlock-policy')

+     else:

+         deadlock_policy = bdbconfig.get_attr_val_bytes('nsslapd-db-deadlock-policy')

+ 

      assert deadlock_policy == default_val

  

      # Try a range of valid values

      for val in (b'0', b'5', b'9'):

          ldbmconfig.replace('nsslapd-db-deadlock-policy', val)

-         deadlock_policy = bdbconfig.get_attr_val_bytes('nsslapd-db-deadlock-policy')

+         if ds_is_older('1.4.2'):

+             deadlock_policy = ldbmconfig.get_attr_val_bytes('nsslapd-db-deadlock-policy')

+         else:

+             deadlock_policy = bdbconfig.get_attr_val_bytes('nsslapd-db-deadlock-policy')

+ 

          assert deadlock_policy == val

  

      # Try a range of invalid values

@@ -641,7 +641,7 @@ 

      assert topo.ds_access_log.match(r'.*conn=Internal\([0-9]+\) op=[0-9]+\([0-9]+\)\([0-9]+\).*')

  

  

- @pytest.mark.skipif(ds_is_older('1.4.1.4'), reason="Not implemented")

+ @pytest.mark.skipif(ds_is_older('1.4.2.0'), reason="Not implemented")

  @pytest.mark.bz1358706

  @pytest.mark.ds49232

  def test_access_log_truncated_search_message(topology_st, clean_access_logs):
@@ -678,7 +678,7 @@ 

  

  

  

- @pytest.mark.xfail(ds_is_older('1.4.1.6'), reason="May fail because of bug 1732053")

+ @pytest.mark.xfail(ds_is_older('1.4.2.0'), reason="May fail because of bug 1732053")

  @pytest.mark.bz1732053

  @pytest.mark.ds50510

  def test_etime_at_border_of_second(topology_st, clean_access_logs):

@@ -18,6 +18,7 @@ 

  

  pytestmark = pytest.mark.tier1

  

+ @pytest.mark.skipif(ds_is_older("1.4.0.0"), reason="Not implemented")

  def test_referral_during_tot(topology_m2):

  

      master1 = topology_m2.ms["master1"]

@@ -9,9 +9,11 @@ 

  import pytest

  from lib389.topologies import topology_st

  from lib389.password_plugins import PBKDF2Plugin

+ from lib389.utils import ds_is_older

  

  pytestmark = pytest.mark.tier1

  

+ @pytest.mark.skipif(ds_is_older('1.4.1'), reason="Not implemented")

  def test_pbkdf2_upgrade(topology_st):

      """On upgrade pbkdf2 doesn't ship. We need to be able to

      provide this on upgrade to make sure default hashes work.

@@ -12,7 +12,7 @@ 

  from lib389 import Entry

  from lib389.topologies import topology_m1 as topo_master

  from lib389.idm.user import UserAccounts

- from lib389.utils import ldap, os, logging, ensure_bytes

+ from lib389.utils import ldap, os, logging, ensure_bytes, ds_is_newer

  from lib389.topologies import topology_st as topo

  from lib389.idm.organizationalunit import OrganizationalUnits

  
@@ -40,7 +40,7 @@ 

      'CN12pwtest31', 'SN3pwtest231', 'UID1pwtest123', 'MAIL2pwtest12@redhat.com', '2GN1pwtest123', 'People123')

  

  def _check_unhashed_userpw(inst, user_dn, is_present=False):

-     """Check if unhashed#user#password attribute is present of not in the changelog"""

+     """Check if unhashed#user#password attribute is present or not in the changelog"""

      unhashed_pwd_attribute = 'unhashed#user#password'

  

      changelog_dbdir = os.path.join(os.path.dirname(inst.dbdir), DEFAULT_CHANGELOG_DB)
@@ -274,13 +274,16 @@ 

              log.fatal('Failed to add user (%s): error %s' % (USER_DN, e.message['desc']))

              assert False

  

-     # Check default is that unhashed#user#password is not logged

+     # Check default is that unhashed#user#password is not logged on 1.4.1.6+

      user = "uid=member1,%s" % (PEOPLE_DN)

      inst.modify_s(user, [(ldap.MOD_REPLACE,

                                            'userpassword',

                                            PASSWORD.encode())])

      inst.stop()

-     _check_unhashed_userpw(inst, user, is_present=False)

+     if ds_is_newer('1.4.1.6'):

+         _check_unhashed_userpw(inst, user, is_present=False)

+     else:

+         _check_unhashed_userpw(inst, user, is_present=True)

  

      #  Check with nolog that unhashed#user#password is not logged

      inst.modify_s(DN_CONFIG,

@@ -15,7 +15,7 @@ 

  

  FD_ATTR = "nsslapd-maxdescriptors"

  GLOBAL_LIMIT = resource.getrlimit(resource.RLIMIT_NOFILE)[1]

- SYSTEMD_LIMIT = ensure_str(check_output("systemctl show --value -p LimitNOFILE dirsrv@standalone1".split(" ")).strip())

+ SYSTEMD_LIMIT = ensure_str(check_output("systemctl show -p LimitNOFILE dirsrv@standalone1".split(" ")).strip()).split('=')[1]

  CUSTOM_VAL = str(int(SYSTEMD_LIMIT) - 10)

  TOO_HIGH_VAL = str(GLOBAL_LIMIT * 2)

  TOO_HIGH_VAL2 = str(int(SYSTEMD_LIMIT) * 2)

file modified
+3 -2
@@ -39,6 +39,7 @@ 

  import shlex

  import operator

  import subprocess

+ from packaging import version

  from socket import getfqdn

  from ldapurl import LDAPUrl

  from contextlib import closing
@@ -1075,9 +1076,9 @@ 

      if len(ver) > 1:

          for cmp_ver in ver:

              if cmp_ver.startswith(ds_ver[:3]):

-                 return ops[relation](ds_ver,cmp_ver)

+                 return ops[relation](version.parse(ds_ver),version.parse(cmp_ver))

      else:

-         return ops[relation](ds_ver, ver[0])

+         return ops[relation](version.parse(ds_ver), version.parse(ver[0]))

  

  

  def ds_is_older(*ver):

Description:

Fix various test issues on RHEL7 and RHEL8:

  • systemd on RHEL7 doesn't have --value option.
    Drop --value option and parse the output manually.

  • Use newer BDB config only on 1.4.2+.

  • Skip tests/suites/password/pbkdf2_upgrade_plugin_test.py on <1.4.1.

  • Unhashed passwords are not logged by default only on 1.4.1.6+.

  • String literal comparison doesn't work with double digits,
    i.e. '1.3.10.1' > '1.3.2.1' returns False.
    Use packaging.version to compare versions.

  • Don't use nsAccount objectClass on versions <=1.4.x.

  • Update skipif/xfail version to match downstream versions too.

Relates: https://pagure.io/389-ds-base/issue/49761

All looks pretty good to me :) ack

rebased onto 8510fce5ff0a1207041831e184d17474705cb624

4 years ago

rebased onto 15789e8

4 years ago

Pull-Request has been merged by vashirov

4 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/3757

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