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

Add firmware_update phase #40

Closed
wants to merge 2 commits into from
Closed

Conversation

nancyc12
Copy link

@nancyc12 nancyc12 commented Oct 12, 2023

Description

Base on CR033 - Firmware updates for regression testing, introduce a new optional phase firmware_update after provision phase to handle request for firmware update on the device. As in the spec, this new phase is implemented in DefaultDevice, so it won't need any change on existing DeviceConnector codes.

To trigger firmware_update phase, the following section needs to be provided in job.yaml. If the firmware_update_data section is missing from the job, this phase will not run.

firmware_update_data:
  version: < latest >
  ignore_failure: < false | true >

Variables in firmware_update_data:

  • version: The desired firmware level on the device. Currently it only supports latest (upgrading all components in the device with the latest firmware release). More options are planned to be implemented in the future once we gathering data for working firmware baseline on devices.
  • ignore_failure: When set to false, Testflinger Agent will suspend the job if firmware_update phase return a status other than 0, which implies there's a failure during firmware_update phase. If set to true, the job will continue regardless the status of firmware_update phase.

Code changes

Add firmware_update phase in job.py and agent.py.
Update schema.py to handle the phase with firmware_update_command.

Important

For each Testflinger agent instance, firmware_update_command needs to be specified in testflinger-agent.conf, giving firmware_update as its phase name.

In order to make it work as a whole, there're also PRs raised in testflinger and snappy-device-agents.

Resolved issues

N/A

Documentation

README.rst is updated for the new phase.

Tests

It's tested by building a dev testflinger server with docker along with modified testflinger-agent and snappy-device-agents.

  • Unit tests
(env) ubuntu@juju-ee0bf9-0:/srv/testflinger-agent/dell-optiplex3070-c26629/testflinger-agent$ sudo  /srv/testflinger-agent/dell-optiplex3070-c26629/env/bin/python3 -m coverage run -m pytest .
============================================== test session starts ==============================================
platform linux -- Python 3.8.10, pytest-7.4.2, pluggy-1.3.0
rootdir: /srv/testflinger-agent/dell-optiplex3070-c26629/testflinger-agent
plugins: requests-mock-1.11.0
collected 20 items                                                                                              

testflinger_agent/tests/test_agent.py 
.......                                                             [ 35%]
testflinger_agent/tests/test_client.py ..                                                                 [ 45%]
testflinger_agent/tests/test_config.py ..                                                                 [ 55%]
testflinger_agent/tests/test_job.py .........                                                             [100%]

=============================================== warnings summary ================================================
testflinger_agent/tests/test_job.py:155
  /srv/testflinger-agent/dell-optiplex3070-c26629/testflinger-agent/testflinger_agent/tests/test_job.py:155: PytestUnknownMarkWarning: Unknown pytest.mark.timeout - is this a typo?  You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html
    @pytest.mark.timeout(1)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=================================== 20 passed, 1 warning in 80.27s (0:01:20) ====================================

  • Testflinger Server is able to accept job.yaml with firmware_update_data section and assign to Testflinger Agents
  • Testflinger Agent is able to work with Testflinger Device Connector (tested with noprovision) to run firmware_update phase

Copy link
Collaborator

@plars plars left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice and straightforward, thanks!

@plars
Copy link
Collaborator

plars commented Oct 20, 2023

@nancyc12 We'll need to redo this against https://github.com/canonical/testflinger, let me know if you need any help from me on that.

@nancyc12
Copy link
Author

Move the changes to #141

@nancyc12 nancyc12 closed this Oct 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants