Skip to content

Conversation

eugene-yujinwu
Copy link
Contributor

@eugene-yujinwu eugene-yujinwu commented Mar 24, 2025

Description

This is a clone PR of #1686.
The 1686 was not reviewed by Cert team, and it was reverted and this PR was re-submitted for review.
Please refer more detailed info in the #1686.
Thank you.

We would like to automate the wake-on-LAN test instead of running manual tests for it.
Please refer to wake-on-LAN-automatic-tests.md in the commit for more details

Resolved issues

Make the Wake-on-LAN test from manual to automatic.

Documentation

https://github.com/canonical/checkbox/pull/1819/files#diff-cb60a2a6986f9c704b5a299f24f29bbfc64064adc94aec85d4fa75c167ccbb01

Tests

"[wol_S3_auto] Both success": https://certification.canonical.com/submissions/status/300209

"[wol_S3_auto] Cannot connect to the WOL server" : https://certification.canonical.com/submissions/status/300211

"[wol_S3_auto] One of the WOL disabled" : https://certification.canonical.com/submissions/status/300210

"[wol_auto_test] One of NIC has wake-on-LAN issue" : https://certification.canonical.com/submissions/status/300212

"[wake-on-Lan] test for one NIC": https://certification.canonical.com/hardware/202406-34088/submission/408713/

Copy link

codecov bot commented Mar 24, 2025

Codecov Report

❌ Patch coverage is 95.45455% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.53%. Comparing base (560ff50) to head (a63674d).

Files with missing lines Patch % Lines
providers/base/bin/wol_client.py 93.02% 8 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1819      +/-   ##
==========================================
+ Coverage   52.33%   52.53%   +0.20%     
==========================================
  Files         392      394       +2     
  Lines       42070    42268     +198     
  Branches     7796     7824      +28     
==========================================
+ Hits        22018    22207     +189     
- Misses      19275    19283       +8     
- Partials      777      778       +1     
Flag Coverage Δ
provider-base 29.33% <95.45%> (+0.81%) ⬆️
provider-certification-client 57.14% <ø> (ø)

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.

@eugene-yujinwu eugene-yujinwu changed the title Automate wake-on-LAN tests (New) Automate wake-on-LAN tests (New) Mar 24, 2025
@stanley31huang
Copy link
Collaborator

@eugene-yujinwu
is it possible to provide how user could get the wol_server.py scripts in the README? as we need it be run in another client to make this test works.

@eugene-yujinwu
Copy link
Contributor Author

@eugene-yujinwu is it possible to provide how user could get the wol_server.py scripts in the README? as we need it be run in another client to make this test works.

@stanley31huang A link to the wol_server.py was added. Thank you.

stanley31huang
stanley31huang previously approved these changes Jul 11, 2025
Copy link
Collaborator

@stanley31huang stanley31huang left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
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'm sorry this review took so long! It looks like a sensible change, and the different examples you provided from C3 are really helpful to see it in action!

I left a few comments below, please check them out and let me know if you have questions.

req = urllib.request.Request(url, data=data_encoded, headers=headers)

attempts = 0
while attempts < retry:
Copy link
Collaborator

Choose a reason for hiding this comment

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

In checkbox_support, we have a retry helper that can be used to re-run a given function a certain number of times. See this example for how to use it, and check if it could be a good use case for here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using a retry decorator appears more elegant, but the current approach is easier to understand and read, and it doesn’t require modifying the unit tests. If it be deemed necessary, I will make the corresponding changes.

In checkbox_support, we have a retry helper that can be used to re-run a given function a certain number of times. See this example for how to use it, and check if it could be a good use case for here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

For us, it's easier to maintain if new tests use the same retry mechanism, so please use it for your test. For the unit test, you can use mock_retry which was implemented to make it easier to write unit tests for scripts that make use of @retry. Please check test_eth_hotplugging.py for instance.

Copy link
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.

Thanks for the changes, I added a few more comments.

req = urllib.request.Request(url, data=data_encoded, headers=headers)

attempts = 0
while attempts < retry:
Copy link
Collaborator

Choose a reason for hiding this comment

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

For us, it's easier to maintain if new tests use the same retry mechanism, so please use it for your test. For the unit test, you can use mock_retry which was implemented to make it easier to write unit tests for scripts that make use of @retry. Please check test_eth_hotplugging.py for instance.

eugene-yujinwu and others added 12 commits September 28, 2025 16:33
please refer to wake-on-LAN-automatic-tests.md for more details

Co-authored-by: hanhsuan <[email protected]>
… checkbox. This is because it's not directly called by checkbox and introduces an unnecessary dependency on FastAPI.
…ues on some older python versions.

Fix some issues per Stanley's review
Add the related unit tests after code changes
Move inline function out of get_ip_mac per Stanley's comments
use more specific 4xx or 5xx status code from wol_server

Co-authored-by: stanley31huang <[email protected]>
Check the return value when get the timestamp to prevent unexpected exception
Update related unit tests
@eugene-yujinwu eugene-yujinwu force-pushed the automate_wake-on-lan branch 2 times, most recently from f0bb3ed to 43ea23c Compare September 28, 2025 09:12
@eugene-yujinwu
Copy link
Contributor Author

@pieqq Thank you for the review. New commit was pushed.

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