Skip to content

Add before field (Breaking)#1935

Merged
fernando79513 merged 29 commits into
mainfrom
add-before-field
Jun 20, 2025
Merged

Add before field (Breaking)#1935
fernando79513 merged 29 commits into
mainfrom
add-before-field

Conversation

@fernando79513
Copy link
Copy Markdown
Collaborator

Description

This PR adds a new field called "before" to the jobs. This field allows a new type of dependency for the jobs.
The way the dependency manager sorts the jobs has not changed. Instead, the way the before flag works is by adding the current job as an after dependency of the jobs listed in the before field.

These references are added to the job object as a new attribute and included to the after_deps set when retrieving the dependency set.

Resolved issues

https://warthogs.atlassian.net/browse/CHECKBOX-1919

Documentation

The "before" flag has also been added to the corresponding section in the checkbox documentation.

Tests

Unit tests for this feature have been added In the PR

@fernando79513 fernando79513 changed the title Add before field Add before field (New) May 27, 2025
@codecov
Copy link
Copy Markdown

codecov Bot commented May 27, 2025

Codecov Report

❌ Patch coverage is 90.29126% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.56%. Comparing base (42842da) to head (569dcd5).
⚠️ Report is 125 commits behind head on main.

Files with missing lines Patch % Lines
checkbox-ng/plainbox/impl/depmgr.py 88.88% 5 Missing and 3 partials ⚠️
checkbox-ng/plainbox/impl/unit/job.py 88.23% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1935      +/-   ##
==========================================
+ Coverage   50.40%   50.56%   +0.16%     
==========================================
  Files         384      384              
  Lines       41087    41169      +82     
  Branches     6749     7421     +672     
==========================================
+ Hits        20709    20817     +108     
+ Misses      19637    19605      -32     
- Partials      741      747       +6     
Flag Coverage Δ
checkbox-ng 70.32% <90.29%> (+0.29%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

pieqq
pieqq previously approved these changes Jun 4, 2025
Copy link
Copy Markdown
Collaborator

@pieqq pieqq left a comment

Choose a reason for hiding this comment

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

I tested it locally by butchering jobs in the client-cert-desktop-24-04-automated test plan and seeing what was happening, and it works as expected in my quick test.

If possible, add more warnings in the documentation about this field.

Comment thread checkbox-ng/plainbox/impl/ctrl.py Outdated
Comment thread checkbox-ng/plainbox/impl/ctrl.py
Comment thread checkbox-ng/plainbox/impl/unit/job.py
Comment thread docs/reference/units/job.rst Outdated
Comment thread docs/reference/units/job.rst
Copy link
Copy Markdown
Collaborator

@Hook25 Hook25 left a comment

Choose a reason for hiding this comment

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

See below, please consider not failing on missing job

Comment thread metabox/metabox/scenarios/basic/ordering.py
Comment thread metabox/metabox/scenarios/basic/ordering.py Outdated
Comment thread metabox/metabox/scenarios/basic/ordering.py
Comment thread metabox/metabox/metabox-provider/units/ordering.pxu
Comment thread docs/tutorial/using-checkbox/advanced-commands.rst Outdated
Comment thread docs/reference/units/job.rst Outdated
Comment thread checkbox-ng/plainbox/impl/unit/job.py
Comment thread checkbox-ng/plainbox/impl/ctrl.py Outdated
Copy link
Copy Markdown
Collaborator

@pieqq pieqq left a comment

Choose a reason for hiding this comment

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

two little suggestions

Comment thread checkbox-ng/plainbox/impl/depmgr.py
Comment thread checkbox-ng/plainbox/impl/depmgr.py Outdated
Hook25
Hook25 previously approved these changes Jun 18, 2025
Copy link
Copy Markdown
Collaborator

@Hook25 Hook25 left a comment

Choose a reason for hiding this comment

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

+1, wait for @pieqq to give a look as well but this looks good to me. Adjusting the title, this is a breaking change!

@Hook25 Hook25 changed the title Add before field (New) Add before field (Breaking) Jun 18, 2025
pieqq
pieqq previously approved these changes Jun 18, 2025
Copy link
Copy Markdown
Collaborator

@pieqq pieqq left a comment

Choose a reason for hiding this comment

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

I left some inline comments regarding the documentation. It would be good if you took a look at it, but otherwise I think the feature works as expected.

I've done the following test, since we have an issue with debsum being run after a wireless test that modifies netplan config:

  1. Moved the misc-client-cert-automated nested part in the client-cert-desktop-24-04-automated test plan to the very end. This nested part includes miscellanea/debsums.
  2. Ran checkbox-cli list-bootstrapped "com.canonical.certification::client-cert-desktop-24-04-automated" > /var/tmp/misc_np_at_the_end
  3. Looked at the result, and indeed the jobs from that nested part are all towards the end, including the debsum job.
  4. Edited the miscellanea/debsums job to add before: wireless/detect
  5. Ran checkbox-cli list-bootstrapped "com.canonical.certification::client-cert-desktop-24-04-automated" > /var/tmp/misc_np_at_the_end_before_field_added

Compared the two, and sure enough, all the jobs from the misc-client-cert-automated nested part are still at the end of the list, except miscellanea/debsums which sits just before wireless/detect. (this should fix our problem, so it means the feature works great! :)

Comment thread docs/reference/units/job.rst Outdated
@fernando79513 fernando79513 dismissed stale reviews from pieqq and Hook25 via 569dcd5 June 19, 2025 07:17
@fernando79513 fernando79513 merged commit 2305e2c into main Jun 20, 2025
37 of 38 checks passed
@fernando79513 fernando79513 deleted the add-before-field branch June 20, 2025 07:41
pieqq added a commit that referenced this pull request Jun 23, 2025
Because of a bug in netplan[1], the miscellanea/debsums will fail if
it's run after any of the wireless tests.

Checkbox now supports the before field for job units[2].

Since wireless/detect is a dependency for all of the wireless tests,
using it ensures the miscellanea/debsums job will be called before any
wireless tests happen.

[1]: https://bugs.launchpad.net/ubuntu/+source/netplan.io/+bug/2078759
[2]: #1935

Fix https://warthogs.atlassian.net/browse/CHECKBOX-1916
mreed8855 pushed a commit that referenced this pull request Jul 30, 2025
* First implementation of the before flag

* Added DependencyMissingError

* Added unit tests and made docstrings more clear

* renamed before_references

* Added test for multiple dependencies

* Updated documentation

* Fixed wrong arrow replacement

* Added unittests for coverage

* Fixed test typo

* Added ordering metabox tests

* Added after-suspend ordering test

* updated documentation

* Updated docstring

* Some changes

* Ignoring before and after refs for pulling

* Moved dep types out of the error

* Draft solution for Dep solver

* Renamed color graph

* Modified implementation

* Refactored the dep manager

* Apply suggestions from code review

Co-authored-by: Pierre Equoy <pierre.equoy@canonical.com>

* Fixed PR issues

* Fixed error type for deps

* Clarifying "before" behavior with after suspend flag

* Added documentation changes

* Update checkbox-ng/plainbox/impl/depmgr.py

Co-authored-by: Pierre Equoy <pierre.equoy@canonical.com>

* Added better debug for the ordering phase

* Updated the documentation

---------

Co-authored-by: Pierre Equoy <pierre.equoy@canonical.com>
mreed8855 pushed a commit that referenced this pull request Jul 31, 2025
* First implementation of the before flag

* Added DependencyMissingError

* Added unit tests and made docstrings more clear

* renamed before_references

* Added test for multiple dependencies

* Updated documentation

* Fixed wrong arrow replacement

* Added unittests for coverage

* Fixed test typo

* Added ordering metabox tests

* Added after-suspend ordering test

* updated documentation

* Updated docstring

* Some changes

* Ignoring before and after refs for pulling

* Moved dep types out of the error

* Draft solution for Dep solver

* Renamed color graph

* Modified implementation

* Refactored the dep manager

* Apply suggestions from code review

Co-authored-by: Pierre Equoy <pierre.equoy@canonical.com>

* Fixed PR issues

* Fixed error type for deps

* Clarifying "before" behavior with after suspend flag

* Added documentation changes

* Update checkbox-ng/plainbox/impl/depmgr.py

Co-authored-by: Pierre Equoy <pierre.equoy@canonical.com>

* Added better debug for the ordering phase

* Updated the documentation

---------

Co-authored-by: Pierre Equoy <pierre.equoy@canonical.com>
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.

3 participants