コード例 #1
0
def test_replace_secondary_same_port(uptane_repo, secondary, aktualizr, **kwargs):
    '''Test replacing a Secondary that reuses the same port'''

    port = IPSecondary.get_free_port()
    with IPSecondary(output_logs=False, id=('hwid1', 'serial2'), port=port) as secondary2:
        # Why is this necessary? The Primary waiting works outside of this test.
        time.sleep(5)
        aktualizr.add_secondary(secondary2)
        with aktualizr:
            aktualizr.wait_for_completion()

    if not aktualizr.is_ecu_registered(secondary.id) or not aktualizr.is_ecu_registered(secondary2.id):
        logger.error("Secondary ECU is not registered.")
        return False

    aktualizr.remove_secondary(secondary2)

    with IPSecondary(output_logs=False, id=('hwid1', 'serial3'), port=port) as secondary3:
        # Why is this necessary? The Primary waiting works outside of this test.
        time.sleep(5)
        aktualizr.add_secondary(secondary3)
        with aktualizr:
            aktualizr.wait_for_completion()

    if not aktualizr.is_ecu_registered(secondary.id) or not aktualizr.is_ecu_registered(secondary3.id):
        logger.error("Secondary ECU is not registered.")
        return False
    if aktualizr.is_ecu_registered(secondary2.id):
        logger.error("Secondary ECU is unexpectedly still registered.")
        return False

    return True
コード例 #2
0
ファイル: ipsecondary_test.py プロジェクト: uptane/aktualizr
def test_change_secondary_port(uptane_repo, secondary, aktualizr, **kwargs):
    '''Test changing a Secondary's port but not the ECU serial'''

    with IPSecondary(output_logs=False, id=('hwid1', 'serial2')) as secondary2:
        # Why is this necessary? The Primary waiting works outside of this test.
        time.sleep(5)
        aktualizr.add_secondary(secondary2)
        with aktualizr:
            aktualizr.wait_for_completion()

    if not aktualizr.is_ecu_registered(
            secondary.id) or not aktualizr.is_ecu_registered(secondary2.id):
        logger.error("Secondary ECU is not registered.")
        return False

    aktualizr.remove_secondary(secondary2)

    with IPSecondary(output_logs=False, id=('hwid1', 'serial2')) as secondary3:
        # Why is this necessary? The Primary waiting works outside of this test.
        time.sleep(5)
        aktualizr.add_secondary(secondary3)
        with aktualizr:
            aktualizr.wait_for_completion()

    if secondary2.port == secondary3.port:
        logger.error("Secondary ECU port unexpectedly did not change!")
        return False

    if not aktualizr.is_ecu_registered(
            secondary.id) or not aktualizr.is_ecu_registered(secondary3.id):
        logger.error("Secondary ECU is not registered.")
        return False

    return True
コード例 #3
0
def test_add_secondary(uptane_repo, secondary, aktualizr, **kwargs):
    '''Test adding a Secondary after registration'''

    with aktualizr:
        aktualizr.wait_for_completion()

    if not aktualizr.is_ecu_registered(secondary.id):
        logger.error("Secondary ECU is not registered.")
        return False

    with IPSecondary(output_logs=False, id=('hwid1', 'serial2')) as secondary2:
        # Why is this necessary? The Primary waiting works outside of this test.
        time.sleep(5)
        aktualizr.add_secondary(secondary2)
        with aktualizr:
            aktualizr.wait_for_completion()

    if not aktualizr.is_ecu_registered(secondary.id) or not aktualizr.is_ecu_registered(secondary2.id):
        logger.error("Secondary ECU is not registered.")
        return False

    return True