Skip to content

Commit

Permalink
further improvements
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Büchse <[email protected]>
  • Loading branch information
mbuechse committed Nov 20, 2024
1 parent 1baa82c commit 2e1587f
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions Tests/kaas/sonobuoy_handler/sonobuoy_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ def __init__(
self.check_name = check_name
logger.debug(f"kubeconfig: {kubeconfig} ")
if kubeconfig is None:
raise Exception("No kubeconfig provided")
else:
self.kubeconfig_path = kubeconfig
raise RuntimeError("No kubeconfig provided")
self.kubeconfig_path = kubeconfig
self.working_directory = os.getcwd()
self.result_dir_name = result_dir_name
self.sonobuoy = shutil.which('sonobuoy')
Expand Down Expand Up @@ -63,14 +62,14 @@ def _sonobuoy_status_result(self):
return counter

def _eval_result(self, counter):
"""evaluate test results and return return code"""
result_str = ', '.join(f"{counter[key]} {key}" for key in ('passed', 'failed', 'skipped'))
result_message = f"sonobuoy reports {result_str}"
if counter['failed']:
logger.error(result_message)
self.return_code = 3
else:
logger.info(result_message)
self.return_code = 0
return 3
logger.info(result_message)
return 0

def _preflight_check(self):
"""
Expand Down Expand Up @@ -117,15 +116,18 @@ def run(self):
This method is to be called to run the plugin
"""
logger.info(f"running sonobuoy for testcase {self.check_name}")
self.return_code = 11
self._preflight_check()
self._sonobuoy_run()
self._eval_result(self._sonobuoy_status_result())

# ERROR: currently disabled do to: "error retrieving results: unexpected EOF"
# might be related to following bug: https://github.com/vmware-tanzu/sonobuoy/issues/1633
# self._sonobuoy_retrieve_result(self)

self._sonobuoy_delete()
print(self.check_name + ": " + ("PASS", "FAIL")[min(1, self.return_code)])
return self.return_code
try:
self._sonobuoy_run()
return_code = self._eval_result(self._sonobuoy_status_result())
print(self.check_name + ": " + ("PASS", "FAIL")[min(1, return_code)])
return return_code

# ERROR: currently disabled due to: "error retrieving results: unexpected EOF"
# might be related to following bug: https://github.com/vmware-tanzu/sonobuoy/issues/1633
# self._sonobuoy_retrieve_result(self)
except BaseException:
logger.exception("something went wrong")
return 112
finally:
self._sonobuoy_delete()

0 comments on commit 2e1587f

Please sign in to comment.