6 from os
import getcwd, chdir
8 from test_fixtures
import KeyStore, with_aktualizr, with_uptane_backend, with_secondary, with_director, with_imagerepo,\
9 with_sysroot, with_treehub
12 logger = logging.getLogger(__file__)
16 Test update of Primary and Secondary if their package manager differs, `ostree` and `fake` respectively
18 Aktualizr/Primary's package manager is set to `ostree`
19 Secondary's package manager is set to `fake`
20 Primary goal is to verify whether aktualizr succeeds with a binary/fake update of secondary
21 while aktualizr/primary is configured with ostree package manager
23 @with_uptane_backend(start_generic_server=
True)
24 @with_secondary(start=
True)
28 @with_aktualizr(start=
False, run_mode=
'once', output_logs=
True)
29 def test_primary_ostree_secondary_fake_updates(uptane_repo, secondary, aktualizr, director,
30 uptane_server, sysroot, treehub):
31 target_rev = treehub.revision
33 uptane_repo.add_ostree_target(aktualizr.id, target_rev)
35 secondary_update_hash = uptane_repo.add_image(secondary.id,
"secondary-update.bin")
38 aktualizr.wait_for_completion()
41 pending_rev = aktualizr.get_primary_pending_version()
42 if pending_rev != target_rev:
43 logger.error(
"Pending version {} != the target version {}".format(pending_rev, target_rev))
47 current_secondary_image_hash = aktualizr.get_current_image_info(secondary.id)
48 if current_secondary_image_hash != secondary_update_hash:
49 logger.error(
"Current secondary image {} != expected image {}".format(current_secondary_image_hash,
50 secondary_update_hash))
54 sysroot.update_revision(pending_rev)
55 aktualizr.emulate_reboot()
58 aktualizr.wait_for_completion()
61 result = director.get_install_result()
and (target_rev == aktualizr.get_current_primary_image_info())
65 if __name__ ==
"__main__":
66 logging.basicConfig(level=logging.INFO)
68 parser = argparse.ArgumentParser(description=
'Test backend failure')
69 parser.add_argument(
'-b',
'--build-dir', help=
'build directory', default=
'build')
70 parser.add_argument(
'-s',
'--src-dir', help=
'source directory', default=
'.')
72 input_params = parser.parse_args()
74 KeyStore.base_dir = input_params.src_dir
75 initial_cwd = getcwd()
76 chdir(input_params.build_dir)
79 test_primary_ostree_secondary_fake_updates
82 test_suite_run_result =
True
83 for test
in test_suite:
84 logger.info(
'>>> Running {}...'.format(test.__name__))
85 test_run_result = test()
86 logger.info(
'>>> {}: {}\n'.format(
'OK' if test_run_result
else 'FAILED', test.__name__))
87 test_suite_run_result = test_suite_run_result
and test_run_result
90 exit(0
if test_suite_run_result
else 1)