Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

Commit

Permalink
ci: fix tests and re-add cancel to tuxsuite backend
Browse files Browse the repository at this point in the history
Thanks to Katie, the UI for test jobs now only display the
resubmit/cancel buttons when needed, meaning a cleaner UI.

Her patch just needed a few small fixes.

Signed-off-by: Charles Oliveira <[email protected]>
  • Loading branch information
chaws committed Apr 3, 2024
1 parent a180c53 commit 287bbe9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
6 changes: 6 additions & 0 deletions squad/ci/backend/fake.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ def listen(self):
def job_url(self, test_job):
return 'https://example.com/job/%s' % test_job.job_id

def has_resubmit(self):
return False

def has_cancel(self):
return True

def cancel(self, test_job):
return True

Expand Down
1 change: 0 additions & 1 deletion squad/ci/backend/null.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ def listen(self):
"""
raise NotImplementedError


def has_cancel(self):
"""
If the backend has a cancel method implemented, override this to
Expand Down
10 changes: 9 additions & 1 deletion squad/ci/backend/tuxsuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def has_resubmit(self):
return False

def has_cancel(self):
return False
return True

@staticmethod
def get_session():
Expand Down Expand Up @@ -413,6 +413,14 @@ def __resolve_settings__(self, test_job):
result_settings.update(ps)
return result_settings

def cancel(self, testjob):
result_type, tux_project, tux_uid = self.parse_job_id(testjob.job_id)
tux_group, tux_user = tux_project.split('@')
endpoint = f'groups/{tux_group}/projects/{tux_user}/{result_type.lower()}s/{tux_uid}/cancel'
url = urljoin(self.data.url, endpoint)
response = requests.post(url)
return response.status_code == 200

def supports_callbacks(self):
return True

Expand Down
2 changes: 1 addition & 1 deletion squad/ci/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def cancel(self):
if self.job_status == "Canceled":
return False

if self.job_id is not None and self.backend.has_cancel(self):
if self.job_id is not None and self.backend.get_implementation().has_cancel():
return self.backend.get_implementation().cancel(self)

self.fetched = True
Expand Down

0 comments on commit 287bbe9

Please sign in to comment.