#50419 Issue 49761 - Fix CI test suite issues
Closed 3 years ago by spichugi. Opened 4 years ago by vashirov.
vashirov/389-ds-base fix-tests-on-rhel7  into  master

@@ -128,24 +128,42 @@ 

  

      ds_replcheck_path = os.path.join(m1.ds_paths.bin_dir, 'ds-replcheck')

  

-     replcheck_cmd = [[ds_replcheck_path, 'online', '-b', DEFAULT_SUFFIX, '-D', DN_DM, '-w', PW_DM, '-l', '1',

-                       '-m', 'ldap://{}:{}'.format(m1.host, m1.port), '--conflicts',

-                       '-r', 'ldap://{}:{}'.format(m2.host, m2.port)],

-                      [ds_replcheck_path, 'online', '-b', DEFAULT_SUFFIX, '-D', DN_DM, '-w', PW_DM, '-l', '1',

-                       '-m', 'ldaps://{}:{}'.format(m1.host, m1.sslport), '--conflicts',

-                       '-r', 'ldaps://{}:{}'.format(m2.host, m2.sslport)],

-                      [ds_replcheck_path, 'online', '-b', DEFAULT_SUFFIX, '-D', DN_DM, '-w', PW_DM, '-l', '1',

-                       '-m', 'ldap://{}:{}'.format(m1.host, m1.port), '-Z', m1.get_ssca_dir(),

-                       '-r', 'ldap://{}:{}'.format(m2.host, m2.port), '--conflicts'],

-                      [ds_replcheck_path, 'online', '-b', DEFAULT_SUFFIX, '-D', DN_DM, '-w', PW_DM, '-l', '1',

-                       '-m', 'ldapi://%2fvar%2frun%2fslapd-{}.socket'.format(m1.serverid), '--conflict',

-                       '-r', 'ldapi://%2fvar%2frun%2fslapd-{}.socket'.format(m2.serverid)],

-                      [ds_replcheck_path, 'offline', '-b', DEFAULT_SUFFIX, '--conflicts', '--rid', '1',

-                       '-m', '/tmp/export_{}.ldif'.format(m1.serverid),

-                       '-r', '/tmp/export_{}.ldif'.format(m2.serverid)]]

-     return replcheck_cmd

+     if ds_is_newer("1.4.1.2"):

+         replcheck_cmd = [[ds_replcheck_path, 'online', '-b', DEFAULT_SUFFIX, '-D', DN_DM, '-w', PW_DM, '-l', '1',

+                           '-m', 'ldap://{}:{}'.format(m1.host, m1.port), '--conflicts',

+                           '-r', 'ldap://{}:{}'.format(m2.host, m2.port)],

+                          [ds_replcheck_path, 'online', '-b', DEFAULT_SUFFIX, '-D', DN_DM, '-w', PW_DM, '-l', '1',

+                           '-m', 'ldaps://{}:{}'.format(m1.host, m1.sslport), '--conflicts',

+                           '-r', 'ldaps://{}:{}'.format(m2.host, m2.sslport)],

+                          [ds_replcheck_path, 'online', '-b', DEFAULT_SUFFIX, '-D', DN_DM, '-w', PW_DM, '-l', '1',

+                           '-m', 'ldap://{}:{}'.format(m1.host, m1.port), '-Z', m1.get_ssca_dir(),

+                           '-r', 'ldap://{}:{}'.format(m2.host, m2.port), '--conflicts'],

+                          [ds_replcheck_path, 'online', '-b', DEFAULT_SUFFIX, '-D', DN_DM, '-w', PW_DM, '-l', '1',

+                           '-m', 'ldapi://%2fvar%2frun%2fslapd-{}.socket'.format(m1.serverid), '--conflict',

+                           '-r', 'ldapi://%2fvar%2frun%2fslapd-{}.socket'.format(m2.serverid)],

+                          [ds_replcheck_path, 'offline', '-b', DEFAULT_SUFFIX, '--conflicts', '--rid', '1',

+                           '-m', '/tmp/export_{}.ldif'.format(m1.serverid),

+                           '-r', '/tmp/export_{}.ldif'.format(m2.serverid)]]

+     else:

+         replcheck_cmd = [[ds_replcheck_path, '-b', DEFAULT_SUFFIX, '-D', DN_DM, '-w', PW_DM, '-l', '1',

+                           '-m', 'ldap://{}:{}'.format(m1.host, m1.port), '--conflicts',

+                           '-r', 'ldap://{}:{}'.format(m2.host, m2.port)],

+                          [ds_replcheck_path, '-b', DEFAULT_SUFFIX, '-D', DN_DM, '-w', PW_DM, '-l', '1',

+                           '-m', 'ldaps://{}:{}'.format(m1.host, m1.sslport), '--conflicts',

+                           '-r', 'ldaps://{}:{}'.format(m2.host, m2.sslport)],

+                          [ds_replcheck_path, '-b', DEFAULT_SUFFIX, '-D', DN_DM, '-w', PW_DM, '-l', '1',

+                           '-m', 'ldap://{}:{}'.format(m1.host, m1.port), '-Z', m1.get_ssca_dir(),

+                           '-r', 'ldap://{}:{}'.format(m2.host, m2.port), '--conflicts'],

+                          [ds_replcheck_path, '-b', DEFAULT_SUFFIX, '-D', DN_DM, '-w', PW_DM, '-l', '1',

+                           '-m', 'ldapi://%2fvar%2frun%2fslapd-{}.socket'.format(m1.serverid), '--conflict',

+                           '-r', 'ldapi://%2fvar%2frun%2fslapd-{}.socket'.format(m2.serverid)],

+                          [ds_replcheck_path, '-b', DEFAULT_SUFFIX, '-D', DN_DM, '-w', PW_DM, '--conflicts',

+                           '-M', '/tmp/export_{}.ldif'.format(m1.serverid),

+                           '-R', '/tmp/export_{}.ldif'.format(m2.serverid)]]

  

+     return replcheck_cmd

  

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

  def test_state(topo_tls_ldapi):

      """Check "state" report

  
@@ -367,7 +385,7 @@ 

              assert attr_m1 in result

              assert attr_m2 in result

              assert attr_m1_only in result

-             if ds_is_newer("1.4.1.2"):

+             if ds_is_newer("1.3.9.1", "1.4.1.2"):

                  assert attr_first not in result

                  assert attr_second not in result

              # Ignore some attributes and check the output
@@ -376,7 +394,7 @@ 

              assert attr_m1 not in result

              assert attr_m2 not in result

              assert attr_m1_only not in result

-             if ds_is_newer("1.4.1.2"):

+             if ds_is_newer("1.3.9.1", "1.4.1.2"):

                  assert attr_first not in result

                  assert attr_second not in result

  

file modified
+26 -6
@@ -36,6 +36,7 @@ 

  import pwd

  import six

  import shlex

+ import operator

  import subprocess

  from socket import getfqdn

  from ldapurl import LDAPUrl
@@ -1055,14 +1056,33 @@ 

      return p.version

  

  

- def ds_is_older(ver):

-     """Return True if current version of ns-slapd is older than provided

-     version"""

-     return get_ds_version() < ver

+ def ds_is_related(relation, *ver):

+     """

+     Return a result of a comparison between the current version of ns-slapd and a provided version.

+     """

+     ops = {'older': operator.lt,

+            'newer': operator.ge}

+     ds_ver = get_ds_version()

+     if len(ver) > 1:

+         for cmp_ver in ver:

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

+                 return ops[relation](ds_ver,cmp_ver)

+     else:

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

  

  

- def ds_is_newer(ver):

-     return get_ds_version() >= ver

+ def ds_is_older(*ver):

+     """

+     Return True if the current version of ns-slapd is older than a provided version

+     """

+     return ds_is_related('older', *ver)

+ 

+ 

+ def ds_is_newer(*ver):

+     """

+     Return True if the current version of ns-slapd is newer than a provided version

+     """

+     return ds_is_related('newer', *ver)

  

  

  def getDateTime():

Bug Description:
ds_is_older() and ds_is_newer() accept only one value. This becomes tricky
when we need to compare current DS version to a number of versions
across different branches where a feature was implemented or a bug was
fixed.

Fix Description:
Add a generic function that accepts either string or multiple strings
containing versions. If a single version string is passed, it is
compared only to that string. If multiple version strings are passed,
the comparison happens only in a related branch, i.e. '1.3.9.1' is
compared only to '1.3.x', but not to '1.4.x'.

Update replcheck_test.py to use different parameters for ds-replcheck
depending on the version.

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

Reviewed by: ???

rebased onto 73cdeb7

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/3477

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