#537 Remove pdc calls, use bodhi instead
Opened 3 months ago by lenkaseg. Modified a day ago
lenkaseg/fedpkg pdc-retire  into  master

@@ -57,6 +57,7 @@ 

  # Refer to fedpkg.conf

  staging = True

  releases_service = https://bodhi.stg.fedoraproject.org/releases/%(release)s

+ url = bodhi.stg.fedoraproject.org/

  

  [fedpkg-stage.mbs]

  auth_method = oidc
@@ -73,12 +74,9 @@ 

  [fedpkg-stage.pagure]

  url = https://stg.pagure.io/

  

- [fedpkg-stage.pdc]

- url = https://pdc.stg.fedoraproject.org/

- 

  [fedpkg-stage.greenwave]

  url = https://greenwave.stg.fedoraproject.org/

  

  [fedpkg-stage.distgit]

  apibaseurl = https://src.stg.fedoraproject.org

- token = 

+ token =

file modified
+2 -4
@@ -59,6 +59,7 @@ 

  # bodhi, and production is used without providing --staging.

  staging = False

  releases_service = https://bodhi.fedoraproject.org/releases/%(release)s

+ url = https://bodhi.fedoraproject.org/

  

  [fedpkg.mbs]

  auth_method = oidc
@@ -75,12 +76,9 @@ 

  url = https://pagure.io/

  token = 

  

- [fedpkg.pdc]

- url = https://pdc.fedoraproject.org/

- 

  [fedpkg.greenwave]

  url = https://greenwave.fedoraproject.org/

  

  [fedpkg.distgit]

  apibaseurl = https://src.fedoraproject.org

- token = 

+ token =

file modified
+12 -14
@@ -1183,7 +1183,7 @@ 

          if not (branch or all_releases) and active_branch:

              branch = active_branch

  

-         pdc_url = config.get('{0}.pdc'.format(name), 'url')

+         bodhi_url = config.get('{0}.bodhi'.format(name), 'url')

          if branch:

              if is_epel(branch):

                  assert_valid_epel_package(repo_name, branch)
@@ -1196,7 +1196,7 @@ 

                          'underscores, and pluses are allowed in {0} branch '

                          'names'.format('flatpak' if ns == 'flatpaks' else 'module'))

              release_branches = list(itertools.chain(

-                 *list(get_release_branches(pdc_url).values())))

+                 *list(get_release_branches(bodhi_url).values())))

              # treat epel*-next the same as epel* release branches

              next_match = re.match(r'^(epel\d+)-next$', branch)

  
@@ -1207,14 +1207,14 @@ 

          # If service levels were provided, verify them

          if service_levels:

              sl_dict = sl_list_to_dict(service_levels)

-             verify_sls(pdc_url, sl_dict)

+             verify_sls(sl_dict)

  

          pagure_section = '{0}.pagure'.format(name)

          pagure_url = config_get_safely(config, pagure_section, 'url')

          pagure_token = config_get_safely(config, pagure_section, 'token')

          if all_releases:

              release_branches = list(itertools.chain(

-                 *list(get_release_branches(pdc_url).values())))

+                 *list(get_release_branches(bodhi_url).values())))

              branches = [b for b in release_branches

                          if re.match(r'^(f\d+)$', b)]

          else:
@@ -1404,25 +1404,23 @@ 

          :raises rpkgError: if branch is a stream branch but it is inactive.

          """

          for branch_info in stream_branches:

-             if branch_info['name'] != name:

-                 continue

-             if branch_info['active']:

+             if branch_info == name:

                  return True

-             else:

-                 raise rpkgError('Cannot build from stream branch {0} as it is '

-                                 'inactive.'.format(name))

          return False

  

      def _build(self, sets=None):

          if hasattr(self.args, 'chain') or self.args.scratch:

              return super(fedpkgClient, self)._build(sets)

  

-         server_url = self.config.get('{0}.pdc'.format(self.name), 'url')

+         server_url = self.config.get('{0}.bodhi'.format(self.name), 'url')

+         distgit_section = '{0}.distgit'.format(self.name)

+         apibaseurl = config_get_safely(self.config, distgit_section, "apibaseurl")

+         logger = self.log

  

-         stream_branches = get_stream_branches(server_url, self.cmd.repo_name)

+         stream_branches = get_stream_branches(server_url, self.cmd.repo_name, apibaseurl, logger)

          self.log.debug(

              'Package %s has stream branches: %r',

-             self.cmd.repo_name, [item['name'] for item in stream_branches])

+             self.cmd.repo_name, [item for item in stream_branches])

  

          if not self.is_stream_branch(stream_branches, self.cmd.branch_merge):

              return super(fedpkgClient, self)._build(sets)
@@ -1451,7 +1449,7 @@ 

          return task_ids

  

      def show_releases_info(self):

-         server_url = self.config.get('{0}.pdc'.format(self.name), 'url')

+         server_url = self.config.get('{0}.bodhi'.format(self.name), 'url')

          releases = get_release_branches(server_url)

  

          def _join(ln):

file modified
+45 -102
@@ -19,68 +19,29 @@ 

  from pyrpkg import rpkgError

  from requests.exceptions import ConnectionError

  from six.moves.configparser import NoOptionError, NoSectionError

- from six.moves.urllib.parse import urlencode, urlparse

+ from six.moves.urllib.parse import urlparse

  

  

- def query_pdc(server_url, endpoint, params, timeout=60):

-     api_url = '{0}/rest_api/v1/{1}/'.format(

-         server_url.rstrip('/'), endpoint.strip('/'))

-     query_args = params

-     while True:

-         try:

-             rv = requests.get(api_url, params=query_args, timeout=60)

-         except ConnectionError as error:

-             error_msg = ('The connection to PDC failed while trying to get '

-                          'the active release branches. The error was: {0}'

-                          .format(str(error)))

-             raise rpkgError(error_msg)

- 

-         if not rv.ok:

-             base_error_msg = ('The following error occurred while trying to '

-                               'get the active release branches in PDC: {0}')

-             raise rpkgError(base_error_msg.format(rv.text))

- 

-         rv_json = rv.json()

-         for item in rv_json['results']:

-             yield item

- 

-         if rv_json['next']:

-             # Clear the query_args because they are baked into the "next" URL

-             query_args = {}

-             api_url = rv_json['next']

-         else:

-             # We've gone through every page, so we can return the found

-             # branches

-             break

- 

- 

- def get_sl_type(url, sl_name):

-     """

-     Gets the service level (SL) type from PDC

-     :param url: a string of the URL to PDC

-     :param sl_name: a string of the SL name

-     :return: a dictionary representing the SL type or None

-     """

-     api_url = '{0}/rest_api/v1/component-sla-types/'.format(url.rstrip('/'))

-     api_url_w_args = '{0}?{1}'.format(api_url, urlencode({'name': sl_name}))

+ def query_bodhi(server_url, timeout=60):

+     query_arg = '/?exclude_archived=True'

+     api_url = '{0}/releases/{1}'.format(server_url.rstrip('/'), query_arg)

      try:

-         rv = requests.get(api_url_w_args, timeout=60)

+         rv = requests.get(api_url, timeout=60)

      except ConnectionError as error:

-         error_msg = ('The connection to PDC failed while trying to validate '

-                      'the passed in service level. The error was: {0}'

+         error_msg = ('The connection to BODHI failed while trying to get '

+                      'the active release branches. The error was: {0}'

                       .format(str(error)))

          raise rpkgError(error_msg)

  

      if not rv.ok:

-         base_error_msg = ('The following error occurred while validating the '

-                           'passed in service level in PDC: {0}')

+         base_error_msg = ('The following error occurred while trying to '

+                           'get the active release branches in Bodhi: {0}')

          raise rpkgError(base_error_msg.format(rv.text))

  

      rv_json = rv.json()

-     if rv_json['count'] == 1:

-         return rv_json['results'][0]

-     else:

-         return None

+     if rv_json['releases']:

+         for branch in rv_json['releases']:

+             yield branch['branch']

  

  

  def new_pagure_issue(logger, url, token, title, body, cli_name):
@@ -281,36 +242,21 @@ 

  

  def get_release_branches(server_url):

      """

-     Get the active Fedora release branches from PDC

+     Get the active Fedora release branches from Bodhi

  

-     :param  str url: a string of the URL to PDC

+     :param  str url: a string of the URL to Bodhi

      :return: a mapping containing the active Fedora releases and EPEL branches.

      :rtype: dict

      """

-     query_args = {

-         'fields': ['short', 'version'],

-         'active': True

-     }

      releases = {}

- 

-     for product_version in query_pdc(

-             server_url, 'product-versions', params=query_args):

-         short_name = product_version['short']

-         version = product_version['version']

- 

-         # If the version is not a digit we can ignore it (e.g. rawhide)

-         if not version.isdigit():

+     for product_version in query_bodhi(

+             server_url):

+         if product_version == "rawhide":

              continue

+         short_name = "fedora" if product_version.startswith("f") else "epel"

+         releases.setdefault(short_name, set()).add(product_version)

  

-         if short_name == 'epel':

-             prefix = 'el' if version == '6' else 'epel'

-         elif short_name == 'fedora':

-             prefix = 'f'

- 

-         release = '{0}{1}'.format(prefix, version)

-         releases.setdefault(short_name, []).append(release)

- 

-     return releases

+     return {key: list(value) for key, value in releases.items()}

  

  

  def sl_list_to_dict(sls):
@@ -336,10 +282,9 @@ 

      return sl_dict

  

  

- def verify_sls(pdc_url, sl_dict):

+ def verify_sls(sl_dict):

      """

-     Verifies that the service levels are properly formatted and exist in PDC

-     :param pdc_url: a string of the URL to PDC

+     Verifies that the service levels are properly formatted

      :param sl_dict: a dictionary with the SLs of the request

      :return: None or ValidationError

      """
@@ -360,10 +305,6 @@ 

              raise rpkgError(

                  'The EOL date "{0}" is in an invalid format'.format(eol))

  

-         sl_obj = get_sl_type(pdc_url, sl)

-         if not sl_obj:

-             raise rpkgError('The SL "{0}" is not in PDC'.format(sl))

- 

  

  def is_epel(branch):

      """
@@ -494,41 +435,43 @@ 

      return '{0}://{1}'.format(parsed_url.scheme, parsed_url.netloc)

  

  

- def get_stream_branches(server_url, package_name):

+ def get_stream_branches(server_url, package_name, apibaseurl, logger):

      """Get a package's stream branches

  

-     :param str server_url: PDC server URL.

+     :param str server_url: Bodhi server URL.

      :param str package_name: package name. Generally for RPM packages, this is

          the repository name without namespace.

-     :return: a list of stream branches. Each element in the list is a dict

-         containing branch property name and active.

-     :rtype: list[dict]

+     :param str apibaseurl: Distgit url (src.fedoraproject.org)

+     :param obj logger: Log object

+     :return: a list of stream branches. Each element in the list is an active

+     release branch name.

+     :rtype: list

      """

-     query_args = {

-         'global_component': package_name,

-         'fields': ['name', 'active'],

-     }

-     branches = query_pdc(

-         server_url, 'component-branches', params=query_args)

-     # When write this method, endpoint component-branches contains not only

-     # stream branches, but also regular release branches, e.g. rawhide/main, f28.

-     # Please remember to review the data regularly, there are only stream

-     # branches, or some new replacement of PDC fixes the issue as well, it

-     # should be ok to remove if from this list.

+     active_branches = []

+     for active_branch in query_bodhi(server_url):

+         if active_branch not in active_branches:

+             active_branches.append(active_branch)

+ 

+     package_branches = get_pagure_branches(logger, apibaseurl, "rpms", package_name)

+ 

+     # Stream branches are the intersection between active releases in Bodhi

+     # (active_branches) and package_branches

+     intersection = list(set(active_branches) & set(package_branches))

+ 

      stream_branches = []

-     for item in branches:

-         if item['name'] in ('rawhide', 'main'):

+     for item in intersection:

+         if item in ('rawhide', 'main'):

              continue

-         elif re.match(r'^(f|el)\d+$', item['name']):

+         elif re.match(r'^(f|el)\d+$', item):

              continue

          # epel7 is regular release branch

          # epel8 and above should be considered a stream branch to use

          # package.cfg file in the branch.

-         elif 'epel7' == item['name']:

+         elif 'epel7' == item:

              continue

          # epel8-next and above branches should be considered as release branches

          # so that it will use epelX-next-candidate target to build.

-         elif re.match(r'^epel\d+-next$', item['name']):

+         elif re.match(r'^epel\d+-next$', item):

              continue

          else:

              stream_branches.append(item)

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

  

  [fedpkg-stage.bodhi]

  staging = True

+ url = https://bodhi.stg.example.com

  

  [fedpkg-stage.bugzilla]

  url = https://bugzilla.stg.example.com
@@ -19,8 +20,6 @@ 

  [fedpkg-stage.pagure]

  url = https://pagure.stg.example.com/

  

- [fedpkg-stage.pdc]

- url = https://pdc.stg.example.com/

- 

  [fedpkg-stage.distgit]

  apibaseurl = https://src.example.com

+ token = aabbccdd

file modified
+1 -3
@@ -13,6 +13,7 @@ 

  [fedpkg.bodhi]

  staging = False

  releases_service = https://bodhi.fedoraproject.org/releases/%(release)s

+ url = https://bodhi.example.org

  

  [fedpkg.bugzilla]

  url = https://bugzilla.example.com
@@ -20,9 +21,6 @@ 

  [fedpkg.pagure]

  url = https://pagure.example.com/

  

- [fedpkg.pdc]

- url = https://pdc.example.com/

- 

  [fedpkg.distgit]

  apibaseurl = https://src.example.com

  token = notsecretatall

file modified
+3 -12
@@ -2326,21 +2326,12 @@ 

              'f28')

          self.assertFalse(result)

  

-     def test_stream_branch_is_inactive(self):

-         with patch('sys.argv', new=self.fake_cmd):

-             cli = self.new_cli()

- 

-         six.assertRaisesRegex(

-             self, rpkgError, 'Cannot build from stream branch',

-             cli.is_stream_branch, [{'name': '10', 'active': False}], '10')

- 

      def test_branch_is_stream_branch(self):

          with patch('sys.argv', new=self.fake_cmd):

              cli = self.new_cli()

  

          result = cli.is_stream_branch(

-             [{'name': '8', 'active': True}, {'name': '10', 'active': True}],

-             '8')

+             ['epel8', 'epel9'], 'epel8')

          self.assertTrue(result)

  

  
@@ -2418,9 +2409,9 @@ 

              _build):

          get_release_branches.return_value = {

              'fedora': ['f28', 'f27'],

-             'epel': ['el6', 'epel7'],

+             'epel': ['epel7', 'epel8', 'epel9'],

          }

-         get_stream_branches.return_value = [{'name': '8', 'active': True}]

+         get_stream_branches.return_value = ['8', 'epel9']

          _build.side_effect = [1, 2]

          self.checkout_branch(git.Repo(self.cloned_repo_path), '8')

  

file modified
+76 -147
@@ -30,67 +30,22 @@ 

  class TestUtils(unittest.TestCase):

      """Test functions in fedpkg.utils"""

  

-     @patch('requests.get')

-     def test_get_sl_type(self, mock_get):

-         """Test get_sl_type"""

-         sl_type = {

-             'id': 1,

-             'name': 'security_fixes',

-             'description': 'security_fixes',

-         }

-         mock_rv = Mock()

-         mock_rv.ok = True

-         mock_rv.json.return_value = {

-             'count': 1,

-             'results': [sl_type]

-         }

-         mock_get.return_value = mock_rv

-         rv = utils.get_sl_type('http://pdc.local/', 'securty_fixes')

-         self.assertEqual(rv, sl_type)

- 

-     @patch('requests.get')

-     def test_get_sl_type_pdc_error(self, mock_request_get):

-         """Test get_sl_type when PDC errors"""

-         mock_rv = Mock()

-         mock_rv.ok = False

-         mock_rv.text = 'Some error'

-         mock_request_get.return_value = mock_rv

-         try:

-             utils.get_sl_type('http://pdc.local/', 'securty_fixes')

-             assert False, 'rpkgError not raised'

-         except rpkgError as error:

-             expected_error = ('The following error occurred while validating '

-                               'the passed in service level in PDC: Some error')

-             self.assertEqual(str(error), expected_error)

- 

-     @patch('fedpkg.utils.get_sl_type')

-     def test_verify_sls(self, mock_get_sl_type):

+     def test_verify_sls(self):

          """Test verify_sls"""

-         mock_get_sl_type.return_value = {

-             'id': 1,

-             'name': 'security_fixes',

-             'description': 'security_fixes',

-         }

-         sls = {'security_fixes': '2222-12-01'}

+         sls = {"security_fixes": "2222-12-01"}

          # If it's invalid, an rpkgError will be raised

          try:

-             utils.verify_sls('http://pdc.local/', sls)

+             utils.verify_sls(sls)

          except rpkgError:

              assert False, 'An rpkgError exception was raised but not expected'

  

-     @patch('fedpkg.utils.get_sl_type')

-     def test_verify_sls_eol_expired(self, mock_get_sl_type):

+     def test_verify_sls_eol_expired(self):

          """Test verify_sls raises an exception when an EOL is expired"""

-         mock_get_sl_type.return_value = {

-             'id': 1,

-             'name': 'security_fixes',

-             'description': 'security_fixes',

-         }

-         sls = {'security_fixes': '2001-12-01'}

+         sls = {"security_fixes": "2001-12-01"}

  

          try:

-             utils.verify_sls('http://pdc.local/', sls)

-             assert False, 'An rpkgError exception was not raised'

+             utils.verify_sls(sls)

+             assert False, "An rpkgError exception was not raised"

          except rpkgError as e:

              self.assertEqual(str(e), 'The SL "2001-12-01" is already expired')

  
@@ -118,9 +73,9 @@ 

          """

          for eol in ['2030-01-01', '2030-12-25']:

              try:

-                 sls = {'security_fixes': eol, 'bug_fixes': eol}

-                 utils.verify_sls('http://pdc.example.com/', sls)

-                 assert False, 'An rpkgError exception was not raised'

+                 sls = {"security_fixes": eol, "bug_fixes": eol}

+                 utils.verify_sls(sls)

+                 assert False, "An rpkgError exception was not raised"

              except rpkgError as e:

                  assert str(e) == ('The SL "{0}" must expire on June 1st or '

                                    'December 1st'.format(eol))
@@ -132,29 +87,33 @@ 

          """

          mock_rv = Mock()

          mock_rv.ok = True

-         # This abbreviated data returned from the product-versions PDC API

-         mock_rv.json.return_value = {

-             'count': 7,

-             'next': None,

-             'previous': None,

-             'results': [

-                 {'short': 'epel', 'version': '6'},

-                 {'short': 'epel', 'version': '7'},

-                 {'short': 'fedora', 'version': '25'},

-                 {'short': 'fedora', 'version': '26'},

-                 {'short': 'fedora', 'version': '27'},

-                 {'short': 'fedora', 'version': '28'},

-                 {'short': 'fedora', 'version': 'rawhide'}

-             ]

-         }

+         # This abbreviated data returned from the Bodhi API active releases

+         mock_rv.json.return_value = {'releases': [

+             {'name': 'EPEL-7', 'branch': 'epel7'},

+             {'name': 'EPEL-8', 'branch': 'epel8'},

+             {'name': 'EPEL-8N',

+              'long_name': 'Fedora EPEL 8 Next',

+              'version': '8',

+              'id_prefix': 'FEDORA-EPEL-NEXT',

+              'branch': 'epel8-next'},

+             {'name': 'EPEL-9', 'branch': 'epel9'},

+             {'name': 'EPEL-9N', 'branch': 'epel9-next'},

+             {'name': 'F38', 'branch': 'f38'},

+             {'name': 'F38C', 'branch': 'f38'},

+             {'name': 'F38F', 'branch': 'f38'},

+             {'name': 'F38M', 'branch': 'f38m'},

+             {'name': 'F39', 'branch': 'f39'},

+             {'name': 'F39C', 'branch': 'f39'},

+             {'name': 'F39F', 'branch': 'f39'},

+             ], 'page': 1, 'pages': 1, 'rows_per_page': 20, 'total': 12}

          mock_request_get.return_value = mock_rv

-         expected = set(['el6', 'epel7', 'f25', 'f26', 'f27', 'f28'])

          expected = {

-             'epel': ['el6', 'epel7'],

-             'fedora': ['f25', 'f26', 'f27', 'f28'],

+             'epel': ['epel7', 'epel8', 'epel8-next', 'epel9', 'epel9-next'],

+             'fedora': ['f38', 'f38m', 'f39'],

          }

-         actual = utils.get_release_branches('http://pdc.local')

-         self.assertEqual(expected, actual)

+         actual = utils.get_release_branches('http://src.local')

+         actual_sorted = {key: sorted(value) for key, value in sorted(actual.items())}

+         self.assertDictEqual(expected, actual_sorted)

  

  

  @patch('requests.get')
@@ -207,54 +166,20 @@ 

                                utils.config_get_safely, config, 'fedpkg.pagure', 'token')

  

  

- @patch('requests.get')

- class TestGetServiceLevelType(unittest.TestCase):

-     """Test get_sl_type"""

- 

-     def test_raise_error_if_connection_error_to_pdc(self, get):

-         get.side_effect = ConnectionError

- 

-         six.assertRaisesRegex(

-             self, rpkgError, 'The connection to PDC failed',

-             utils.get_sl_type, 'http://localhost/', 'bug_fixes:2020-12-01')

- 

-     def test_sl_type_not_exist(self, get):

-         rv = Mock(ok=True)

-         rv.json.return_value = {'count': 0}

-         get.return_value = rv

- 

-         sl_type = utils.get_sl_type('http://localhost/',

-                                     'bug_fixes:2020-12-01')

-         self.assertIsNone(sl_type)

- 

-     def test_raise_error_if_response_not_ok(self, get):

-         get.return_value = Mock(ok=False)

- 

-         six.assertRaisesRegex(

-             self, rpkgError, 'The following error occurred',

-             utils.get_sl_type, 'http://localhost/', 'bug_fixes:2020-12-01')

- 

- 

  class TestVerifySLS(unittest.TestCase):

      """Test verify_sls"""

  

      def test_sl_date_format_is_invalid(self):

          six.assertRaisesRegex(

-             self, rpkgError, 'The EOL date .+ is in an invalid format',

-             utils.verify_sls, 'http://localhost/', {'bug_fixes': '2018/7/21'})

- 

-     @freeze_time('2018-01-01')

-     @patch('requests.get')

-     def test_sl_not_exist(self, get):

-         rv = Mock(ok=True)

-         rv.json.return_value = {'count': 0}

- 

-         six.assertRaisesRegex(

-             self, rpkgError, 'The SL .+ is not in PDC',

-             utils.verify_sls, 'http://localhost/', {'some_sl': '2018-06-01'})

+             self,

+             rpkgError,

+             "The EOL date .+ is in an invalid format",

+             utils.verify_sls,

+             {"bug_fixes": "2018/7/21"},

+         )

  

-     @freeze_time('2018-01-01')

-     @patch('requests.get')

+     @freeze_time("2018-01-01")

+     @patch("requests.get")

      def test_keep_quiet_if_service_levels_are_ok(self, get):

          rv = Mock(ok=True)

          rv.json.side_effect = [
@@ -278,11 +203,8 @@ 

          get.return_value = rv

  

          utils.verify_sls(

-             'http://localhost/',

-             {

-                 'bug_fixes': '2018-06-01',

-                 'security_fixes': '2018-12-01'

-             })

+             {"bug_fixes": "2018-06-01", "security_fixes": "2018-12-01"},

+         )

  

  

  @patch('requests.get')
@@ -434,22 +356,22 @@ 

          )

  

  

- @patch('requests.get')

- class TestQueryPDC(unittest.TestCase):

-     """Test utils.query_pdc"""

+ @patch("requests.get")

+ class TestQueryBodhi(unittest.TestCase):

+     """Test utils.query_bodhi"""

  

      def test_connection_error(self, get):

          get.side_effect = ConnectionError

  

-         result = utils.query_pdc('http://localhost/', 'endpoint', {})

+         result = utils.query_bodhi('http://localhost/')

          six.assertRaisesRegex(

-             self, rpkgError, 'The connection to PDC failed',

+             self, rpkgError, 'The connection to BODHI failed',

              list, result)

  

      def test_response_not_ok(self, get):

          get.return_value.ok = False

  

-         result = utils.query_pdc('http://localhost/', 'endpoint', {})

+         result = utils.query_bodhi('http://localhost/')

          six.assertRaisesRegex(

              self, rpkgError, 'The following error occurred',

              list, result)
@@ -458,37 +380,44 @@ 

          rv = Mock()

          rv.ok = True

          rv.json.side_effect = [

-             {'results': ['item1', 'item2'],

-              'next': 'http://localhost/?page=2'},

-             {'results': ['item3'], 'next': None}

+             {'releases': [

+                 {'name': 'item1', 'branch': 'item2'},

+                 {'name': 'item5', 'branch': 'item6'},

+                 {'name': 'item3', 'branch': 'item4'},

+                 ]}

          ]

          get.return_value = rv

  

-         result = utils.query_pdc('http://localhost/', 'endpoint', {})

-         self.assertEqual(['item1', 'item2', 'item3'], list(result))

+         result = utils.query_bodhi('http://localhost/')

+         v = next(result)

+         self.assertEqual('item2', v)

+         v = next(result)

+         self.assertEqual('item6', v)

+         v = next(result)

+         self.assertEqual('item4', v)

  

  

  class TestGetStreamBranches(unittest.TestCase):

      """Test get_stream_branches"""

  

+     @patch('fedpkg.utils.get_pagure_branches')

      @patch('requests.get')

-     def test_fedora_and_epel_branches_are_filtered_out(self, get):

+     def test_fedora_and_epel_branches_are_filtered_out(self, get, pagure_branches):

+         logger = Mock()

+         apibaseurl = "https://bodhiurl"

          rv = Mock(ok=True)

-         rv.json.return_value = {

-             'results': [

-                 {'name': '8'},

-                 {'name': '10'},

-                 {'name': 'f28'},

-                 {'name': 'epel7'},

-                 {'name': 'rawhide'},

-                 {'name': 'epel8'},

-             ],

-             'next': None

-         }

+         rv.json.return_value = {'releases': [

+             {'name': 'ELN', 'branch': 'eln'},

+             {'name': 'F40', 'branch': 'rawhide'},

+             {'name': 'F40C', 'branch': 'f40'},

+             {'name': 'epel8', 'branch': 'epel8'},

+             ], 'page': 1, 'pages': 1, 'rows_per_page': 20, 'total': 3}

+         {'releases': [], 'page': 1, 'pages': 0, 'rows_per_page': 20, 'total': 0}

          get.return_value = rv

+         pagure_branches.return_value = ["epel7", "epel8", "epel9", "f38", "f39"]

  

-         result = utils.get_stream_branches('http://localhost/', 'pkg')

-         self.assertEqual([{'name': '8'}, {'name': '10'}, {'name': 'epel8'}], list(result))

+         result = utils.get_stream_branches('http://localhost/', 'pkg', apibaseurl, logger)

+         self.assertEqual(['epel8'], list(result))

  

  

  class TestExpandRelease(unittest.TestCase):

Since PDC is going to be dismissed, we need to redirect all pdc call to other APIs, for example bodhi.

Related to issue #535

Signed-off-by: Lenka Segura lsegura@redhat.com

Because the output of the bodhi API is different than the one from pdc, the get_stream_branches does not return list of dicts, but a list (of active releases).get_stream_branches now uses get_pagure_branches to get the package active branches
get_release_branches should keep returning the same as before, a dict.

rebased onto 3fa0476

3 months ago

1 new commit added

  • Style changes
3 months ago

2 new commits added

  • Style changes
  • Remove pdc calls, use bodhi instead
3 months ago

1 new commit added

  • Remove function get_sl_type, no longer needed
3 months ago

3 new commits added

  • Remove function get_sl_type, no longer needed
  • Style changes
  • Remove pdc calls, use bodhi instead
3 months ago

1 new commit added

  • Remove traces of PDC in docstrings
3 months ago

3 new commits added

  • Remove traces of PDC in docstrings
  • Remove function get_sl_type, no longer needed
  • Remove pdc calls, use bodhi instead
a month ago

3 new commits added

  • Remove traces of PDC in docstrings
  • Remove function get_sl_type, no longer needed
  • Remove pdc calls, use bodhi instead
a month ago

3 new commits added

  • Remove traces of PDC in docstrings
  • Remove function get_sl_type, no longer needed
  • Remove pdc calls, use bodhi instead
a month ago

3 new commits added

  • Remove traces of PDC in docstrings
  • Remove function get_sl_type, no longer needed
  • Remove pdc calls, use bodhi instead
a month ago

Finally flake8 gave up and let me be, phew!

rebased onto c27efc9

a month ago

One little change added, no need to loop through active releases since we can exclude the archived.

rebased onto f2b313d

a month ago

@onosek would you be the right person to review these changes?

Hello, I am sorry for the delay. Initially, I started reviewing the PR, but later I was assigned to a project with higher priority. I am back now so I can focus on this again.
I will look at it once more, because I forgot the details since then.

In the past, I tried to search for "service_levels" (sls) among old branch requests. I didn't find any usage. I don't know whether it still has some purpose. I would say it doesn't. But the safer approach is just to strip the PRC (like you did) and keep the rest.

pretty please pagure-ci rebuild

a day ago