From 7cd055590c617603d835a26c8d6b37e6dcca10ac Mon Sep 17 00:00:00 2001 From: Thomas Carmet <8408330+tcarmet@users.noreply.github.com> Date: Fri, 9 Aug 2024 18:23:01 +0000 Subject: [PATCH] fix some cases and tests --- bert_e/lib/versions.py | 8 ++++ bert_e/server/status.py | 5 +-- bert_e/tests/test_bert_e.py | 20 +++++++++- bert_e/tests/test_server.py | 32 +++++++++++----- bert_e/tests/unit/test_sorted.py | 15 ++++++++ bert_e/workflow/gitwaterflow/branches.py | 48 ++++++++++++------------ 6 files changed, 92 insertions(+), 36 deletions(-) create mode 100644 bert_e/lib/versions.py diff --git a/bert_e/lib/versions.py b/bert_e/lib/versions.py new file mode 100644 index 00000000..2904c826 --- /dev/null +++ b/bert_e/lib/versions.py @@ -0,0 +1,8 @@ + + +def version_key(version): + """Key function to sort versions in descending order.""" + parts = version.split('.') + parts = tuple(int(part) for part in parts) + # Convert parts to integers and fill missing parts with float('inf') + return parts + (float('inf'),) * (4 - len(parts)) diff --git a/bert_e/server/status.py b/bert_e/server/status.py index 5d81e93f..907b2599 100644 --- a/bert_e/server/status.py +++ b/bert_e/server/status.py @@ -15,6 +15,7 @@ """This module defines the server status page.""" import logging from flask import Blueprint, current_app, render_template, request +from bert_e.lib.versions import version_key from ..git_host.cache import BUILD_STATUS_CACHE @@ -44,9 +45,7 @@ def display(): for version, _ in queued_commits: versions.add(version) - # TODO: check the display of the queue - versions = sorted(versions, reverse=True) - + versions = sorted(versions, key=version_key, reverse=True) for pr_id, queued_commits in queue_data.items(): if int(pr_id) in [i['id'] for i in merged_prs]: continue diff --git a/bert_e/tests/test_bert_e.py b/bert_e/tests/test_bert_e.py index 73f08418..bd25bc5b 100644 --- a/bert_e/tests/test_bert_e.py +++ b/bert_e/tests/test_bert_e.py @@ -346,7 +346,9 @@ def finalize_cascade(self, branches, tags, destination, c.add_branch(branch, my_dst) for tag in tags: - c.update_micro(tag) + c.update_versions(tag) + + c._update_major_versions() # check merge_paths now (finalize not required) if merge_paths: @@ -726,6 +728,22 @@ def test_major_development_branch(self): }) self.finalize_cascade(branches, tags, destination, fixver) + def test_major_development_branch_no_tag_bump(self): + destination = 'development/4.3' + branches = OrderedDict({ + 1: {'name': 'stabilization/4.3.18', 'ignore': True}, + 2: {'name': 'development/4.3', 'ignore': False}, + 3: {'name': 'development/4', 'ignore': False}, + 4: {'name': 'stabilization/5.1.4', 'ignore': True}, + 5: {'name': 'development/5.1', 'ignore': False}, + 6: {'name': 'development/10.0', 'ignore': False}, + 7: {'name': 'development/10', 'ignore': False} + }) + tags = ['4.3.16', '4.3.17', '4.3.18_rc1', + 'v5.1.3', 'v5.1.4_rc1'] + fixver = ['4.3.19', '4.4.0', '5.1.5', '10.0.0', '10.1.0'] + self.finalize_cascade(branches, tags, destination, fixver) + def test_retry_handler(self): class DummyError(Exception): pass diff --git a/bert_e/tests/test_server.py b/bert_e/tests/test_server.py index 2358dd80..31edf0da 100644 --- a/bert_e/tests/test_server.py +++ b/bert_e/tests/test_server.py @@ -236,45 +236,54 @@ def set_status_cache(self, sha1, state, url, def test_merge_queue_print(self): server.BERTE.status['merge queue'] = OrderedDict([ (4472, [ + ('6', '4472/6'), ('6.4', '4472/6.4'), ('6.3', '4472/6.3'), ('6.2', '4472/6.2')]), ('5773', [ + ('6', '5773/6'), ('6.4', '5773/6.4')]), ('6050', [ + ('6', '6050/6'), ('6.4', '6050/6.4')]), ('6086', [ + ('6', '6086/6'), ('6.4', '6086/6.4'), ('6.3.0', '6086/6.3.0'), ('6.3', '6086/6.3')]), ('5095', [ + ('6', '5095/6'), ('6.4', '5095/6.4')]), ]) + self.set_status_cache('4472/6', 'SUCCESSFUL', '4472/6_url') self.set_status_cache('4472/6.4', 'SUCCESSFUL', '4472/6.4_url') self.set_status_cache('4472/6.3', 'SUCCESSFUL', '4472/6.3_url') self.set_status_cache('4472/6.2', 'INPROGRESS', '4472/6.2_url') + self.set_status_cache('5773/6', 'FAILED', '5773/6_url') self.set_status_cache('5773/6.4', 'FAILED', '5773/6.4_url') + self.set_status_cache('6050/6', 'SUCCESSFUL', '6050/6_url') self.set_status_cache('6050/6.4', 'SUCCESSFUL', '6050/6.4_url') + self.set_status_cache('6086/6', 'FAILED', '6086/6_url') self.set_status_cache('6086/6.4', 'FAILED', '6086/6.4_url') self.set_status_cache('6086/6.3.0', 'SUCCESSFUL', '6086/6.3.0_url') self.set_status_cache('6086/6.3', 'SUCCESSFUL', '6086/6.3_url') + self.set_status_cache('5095/6', 'SUCCESSFUL', '5095/6_urltoto') self.set_status_cache('5095/6.4', 'SUCCESSFUL', '5095/6.4_urltoto') expected = ( 'Merge queue status:', - ' 6.4 6.3.0 6.3 6.2', - ' #4472 SUCCESSFUL SUCCESSFUL INPROGRESS \n', # noqa - ' #5773 FAILED \n', # noqa - ' #6050 SUCCESSFUL \n', # noqa - ' #6086 FAILED SUCCESSFUL SUCCESSFUL \n', # noqa - ' #5095 SUCCESSFUL' # noqa + ' 6 6.4 6.3 6.3.0 6.2 \n', # noqa + ' #4472 SUCCESSFUL SUCCESSFUL SUCCESSFUL INPROGRESS \n', # noqa + ' #5773 FAILED FAILED \n', # noqa + ' #6050 SUCCESSFUL SUCCESSFUL \n', # noqa + ' #6086 FAILED FAILED SUCCESSFUL SUCCESSFUL \n', # noqa + ' #5095 SUCCESSFUL SUCCESSFUL' # noqa ) client = self.test_client() res = client.get('/?output=txt') data = res.data.decode() - for exp in expected: self.assertIn(exp, data) @@ -287,17 +296,22 @@ def test_merge_queue_print(self): ' \n' ' \n' '