6 from os
import getcwd, chdir
7 from test_fixtures
import KeyStore, with_uptane_backend, with_path, with_director, with_aktualizr,\
8 with_install_manager, with_imagerepo, TestRunner, \
9 DownloadInterruptionHandler, MalformedJsonHandler, DownloadInterruptionHandler
11 logger = logging.getLogger(__file__)
15 Verifies whether aktualizr is updatable after director metadata download failure
16 with follow-up successful metadata download.
18 Currently, it's tested against two types of metadata download/parsing failure:
19 - download interruption - metadata file download is interrupted once|three times, after that it's successful
20 - malformed json - aktualizr receives malformed json/metadata as a response to the first request for metadata,
21 a response to subsequent request is successful
23 Note: Aktualizr doesn't send any installation report in manifest in case of metadata download failure
24 https://saeljira.it.here.com/browse/OTA-3730
26 @with_uptane_backend(start_generic_server=
True)
27 @with_path(paths=[
'/1.root.json',
'/targets.json'])
28 @with_director(handlers=[
29 DownloadInterruptionHandler(number_of_failures=1),
30 MalformedJsonHandler(number_of_failures=1),
31 DownloadInterruptionHandler(number_of_failures=3),
33 @with_aktualizr(start=
False, run_mode=
'full')
34 @with_install_manager()
35 def test_director_update_after_metadata_download_failure(install_mngr, director,
39 install_result = director.wait_for_install()
40 install_result = install_result
and install_mngr.are_images_installed()
45 Verifies whether an update fails if director metadata download fails or they are malformed
46 - download is interrupted three times
47 - malformed json is received
49 @with_uptane_backend(start_generic_server=
True)
50 @with_path(paths=[
'/1.root.json',
'/targets.json'])
52 @with_director(handlers=[
53 DownloadInterruptionHandler(number_of_failures=3),
54 MalformedJsonHandler(number_of_failures=1),
56 @with_aktualizr(run_mode=
'once')
57 @with_install_manager()
58 def test_director_unsuccessful_download(install_mngr, aktualizr,
60 aktualizr.wait_for_completion()
61 return not (director.get_install_result()
or install_mngr.are_images_installed())
64 if __name__ ==
"__main__":
65 logging.basicConfig(level=logging.INFO)
67 parser = argparse.ArgumentParser(description=
'Test backend failure')
68 parser.add_argument(
'-b',
'--build-dir', help=
'build directory', default=
'build')
69 parser.add_argument(
'-s',
'--src-dir', help=
'source directory', default=
'.')
70 input_params = parser.parse_args()
72 KeyStore.base_dir = input_params.src_dir
73 initial_cwd = getcwd()
74 chdir(input_params.build_dir)
77 test_director_update_after_metadata_download_failure,
78 test_director_unsuccessful_download
81 with TestRunner(test_suite)
as runner:
82 test_suite_run_result = runner.run()
85 exit(0
if test_suite_run_result
else 1)