Skip to content

Conversation

@rene-oromtz
Copy link
Contributor

@rene-oromtz rene-oromtz commented Dec 16, 2025

Description

This PR fixes a bug when filtering polling by phase. Currently, it will wait for the whole job to complete which defeats the purpose of polling by phase.

With this modification:

  1. get_status() now returns job_state and each phase status if any (sent by agent in feat(agent): send phase status code upon phase completion #846 )
  2. This also refactors the order of the print statement, it will first print the log (if any) and then, do any other check.
  3. If no log, it will show that cli is still waiting for an output (every 90 seconds)
  4. if filter by phase, it will show all logs related to that phase and exit upon job completion.
  5. When exit, it will indicate the next fragment in case there is a need to continue polling.

Resolved issues[

CERTTF-779

Documentation

Web service API changes

Tests

Edited one unit test to match the current get_status expectation
Added one unit test to match this new behavior

Tests on staging

Submit and then poll

uv run testflinger-cli --server=https://testflinger-staging.canonical.com submit ~/Desktop/staging.yaml 
Job submitted successfully!
job_id: 758cad9c-a324-40ed-95c5-6c5b289b1349
uv run testflinger-cli --server=https://testflinger-staging.canonical.com poll 758cad9c-a324-40ed-95c5-6c5b289b1349
**********************************************
* Starting testflinger setup phase on audino *
**********************************************

Poll by phase (will wait for output until it starts test phase)

uv run testflinger-cli --server=https://testflinger-staging.canonical.com poll 758cad9c-a324-40ed-95c5-6c5b289b1349 --phase test
Waiting on output...
Waiting on output...
...
*********************************************
* Starting testflinger test phase on audino *
*********************************************
....
Phase 'test' completed with exit code: 0
Use 'testflinger poll 758cad9c-a324-40ed-95c5-6c5b289b1349 --start_fragment 31' to continue polling.
Job state: reserve

Poll by next fragment number specified in output (no test related logs):

uv run testflinger-cli --server=https://testflinger-staging.canonical.com poll 758cad9c-a324-40ed-95c5-6c5b289b1349 --start_fragment 31
************************************************
* Starting testflinger reserve phase on audino *
************************************************
2025-12-16 22:27:29,236 audino INFO: DEVICE CONNECTOR: BEGIN reservation

@codecov
Copy link

codecov bot commented Dec 16, 2025

Codecov Report

❌ Patch coverage is 97.43590% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 71.38%. Comparing base (e8f6add) to head (97fb488).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #851      +/-   ##
==========================================
+ Coverage   71.31%   71.38%   +0.06%     
==========================================
  Files         108      108              
  Lines        9651     9674      +23     
  Branches      858      860       +2     
==========================================
+ Hits         6883     6906      +23     
  Misses       2595     2595              
  Partials      173      173              
Flag Coverage Δ *Carryforward flag
agent 72.85% <ø> (ø) Carriedforward from 013a57a
cli 87.90% <97.43%> (+0.11%) ⬆️
device 55.21% <ø> (ø) Carriedforward from 013a57a
server 87.71% <ø> (ø) Carriedforward from 013a57a

*This pull request uses carry forward flags. Click here to find out more.

Components Coverage Δ
Agent 72.85% <ø> (ø)
CLI 87.90% <97.43%> (+0.11%) ⬆️
Common ∅ <ø> (∅)
Device Connectors 55.21% <ø> (ø)
Server 87.71% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rene-oromtz rene-oromtz marked this pull request as ready for review December 16, 2025 23:12
Copy link
Collaborator

@pedro-avalos pedro-avalos left a comment

Choose a reason for hiding this comment

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

Thanks for fixing this! I have left some suggestions regarding new/changed outputs

@rene-oromtz rene-oromtz merged commit accf330 into main Dec 19, 2025
14 checks passed
@rene-oromtz rene-oromtz deleted the fix-phase-poll branch December 19, 2025 17:52
tang-mm pushed a commit that referenced this pull request Dec 31, 2025
* fix(cli): end polling if filtered by phase and phase completes

* add suggestions made by reviewer

* fix test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants