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

Commit

Permalink
Test for primary waiting for secondary at install
Browse files Browse the repository at this point in the history
And fix some other test after changes

Signed-off-by: Laurent Bonnans <laurent.bonnans@here.com>
  • Loading branch information
lbonn committed Feb 12, 2020
1 parent 7e0a8ef commit 16091a2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
33 changes: 30 additions & 3 deletions tests/ipsecondary_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/usr/bin/env python3

import logging
import argparse
import logging
import threading
import time

from os import getcwd, chdir, path

Expand Down Expand Up @@ -168,6 +170,32 @@ def test_primary_timeout_during_first_run(uptane_repo, secondary, aktualizr, **k
return not_provisioned and not aktualizr.is_ecu_registered(secondary.id)


@with_uptane_backend()
@with_director()
@with_secondary(start=False)
@with_aktualizr(start=False, output_logs=True)
def test_primary_wait_secondary_install(uptane_repo, secondary, aktualizr, director, **kwargs):
"""Test that Primary waits for Secondary to connect before installing"""

# provision device with a secondary
with secondary, aktualizr:
aktualizr.wait_for_completion()

secondary_image_filename = "secondary_image_filename.img"
secondary_image_hash = uptane_repo.add_image(id=secondary.id, image_filename=secondary_image_filename)

with aktualizr:
time.sleep(10)
with secondary:
aktualizr.wait_for_completion()

if not director.get_install_result():
logger.error("Installation result is not successful")
return False

return True


@with_uptane_backend()
@with_secondary(start=False)
@with_aktualizr(start=False, output_logs=False)
Expand Down Expand Up @@ -201,8 +229,7 @@ def test_primary_timeout_after_device_is_registered(uptane_repo, secondary, aktu
with aktualizr:
aktualizr.wait_for_completion()

return (aktualizr.get_current_primary_image_info() == primary_image_hash)\
and not aktualizr.is_ecu_registered(secondary.id)
return aktualizr.get_current_primary_image_info() == primary_image_hash


# test suit runner
Expand Down
2 changes: 1 addition & 1 deletion tests/test_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def get_info(self, retry=15):
return None

# 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)
# or aktualizr-info had output status/info in a structured way (e.g. json)
def is_ecu_registered(self, ecu_id):
device_status = self.get_info()
if not ((device_status.find(ecu_id[0]) != -1) and (device_status.find(ecu_id[1]) != -1)):
Expand Down

0 comments on commit 16091a2

Please sign in to comment.