From 8bc45833e9c4a179075ebb68858395c40479251f Mon Sep 17 00:00:00 2001 From: Mykhaylo Sul Date: Thu, 21 Nov 2019 12:30:50 +0200 Subject: [PATCH] Try harder while getting aktualizr status/info Signed-off-by: Mykhaylo Sul --- tests/test_fixtures.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/test_fixtures.py b/tests/test_fixtures.py index b88502a8dc..9871c8dc83 100644 --- a/tests/test_fixtures.py +++ b/tests/test_fixtures.py @@ -139,7 +139,7 @@ def run(self, run_mode): subprocess.run([self._aktualizr_primary_exe, '-c', self._config_file, '--run-mode', run_mode], check=True, env=self._run_env) - def get_info(self, retry=10): + def get_info(self, retry=15): info_exe_res = None for ii in range(0, retry): info_exe_res = subprocess.run([self._aktualizr_info_exe, '-c', self._config_file], @@ -151,6 +151,7 @@ def get_info(self, retry=10): if info_exe_res and info_exe_res.returncode == 0: return str(info_exe_res.stdout) else: + logger.error(str(info_exe_res.stderr)) return None # ugly stuff that could be removed if Aktualizr had exposed API to check status @@ -197,9 +198,13 @@ def _get_current_image_info(self, ecu_id): def get_current_primary_image_info(self): primary_hash_field = 'Current primary ecu running version: ' aktualizr_status = self.get_info() - start = aktualizr_status.find(primary_hash_field) - end = aktualizr_status.find('\\n', start) - return aktualizr_status[start + len(primary_hash_field):end] + if aktualizr_status: + start = aktualizr_status.find(primary_hash_field) + end = aktualizr_status.find('\\n', start) + return aktualizr_status[start + len(primary_hash_field):end] + else: + logger.error("Failed to get aktualizr info/status") + return "" # ugly stuff that could be removed if Aktualizr had exposed API to check status # or aktializr-info had output status/info in a structured way (e.g. json)