Skip to content

Migrate idle suspend test cases from manual to semi-auto(DC) and auto(AC) (New)#2483

Open
hanhsuan wants to merge 7 commits into
mainfrom
migrate_idle_suspend_to_auto
Open

Migrate idle suspend test cases from manual to semi-auto(DC) and auto(AC) (New)#2483
hanhsuan wants to merge 7 commits into
mainfrom
migrate_idle_suspend_to_auto

Conversation

@hanhsuan
Copy link
Copy Markdown
Contributor

@hanhsuan hanhsuan commented Apr 20, 2026

Description

This PR is going to migrate the manual test cases to semi-auto and auto:

  1. id: power-management/suspend-on-AC-power to Auto test case
  2. id: power-management/suspend-on-battery-power to semi-auto test case

The new test groups three test cases

  1. setup: for setting dbus configurations of idle to suspend behavior and backup the configurations
  2. test:
    2.1. Set the rtc wake for full auto AC test only
    2.2. Ensure the system is in the correct power supply mode. (DC/AC)
    2.3. Verifying the suspend is starting at the right timing or not
  3. teardown: restore the configurations

At this point, the tolerance is higher for collecting more data to fine tune the gate in the future.

Resolved issues

Documentation

Tests

Test
laptop: https://certification.canonical.com/hardware/202001-27667/submission/484162/
desktop: https://certification.canonical.com/hardware/202603-38566/submission/486631/

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 20, 2026

Codecov Report

❌ Patch coverage is 99.07407% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 58.99%. Comparing base (20ba9cd) to head (7fd9876).
⚠️ Report is 20 commits behind head on main.

Files with missing lines Patch % Lines
providers/base/bin/idle_suspend.py 99.07% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2483      +/-   ##
==========================================
+ Coverage   58.87%   58.99%   +0.12%     
==========================================
  Files         476      477       +1     
  Lines       48004    48112     +108     
  Branches     8568     8586      +18     
==========================================
+ Hits        28260    28383     +123     
+ Misses      18850    18837      -13     
+ Partials      894      892       -2     
Flag Coverage Δ
provider-base 34.51% <99.07%> (+0.50%) ⬆️

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.

@hanhsuan hanhsuan marked this pull request as ready for review April 21, 2026 01:16
Copy link
Copy Markdown
Contributor

@tomli380576 tomli380576 left a comment

Choose a reason for hiding this comment

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

please see the inline comments, the main thing are the possible None values

Comment thread providers/base/bin/idle_suspend.py Outdated
Comment thread providers/base/bin/idle_suspend.py Outdated
Comment thread providers/base/bin/idle_suspend.py Outdated
Comment thread providers/base/bin/idle_suspend.py Outdated
@hanhsuan hanhsuan requested a review from tomli380576 May 7, 2026 02:24
Copy link
Copy Markdown
Contributor

@tomli380576 tomli380576 left a comment

Choose a reason for hiding this comment

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

the main thing is the timestamp regex, everything else looks ok


def parse_journal_suspend_times(
journal_output: str,
) -> ("datetime | None", "datetime | None"):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

optional: python doesn't reject this but the correct syntax is:

def parse_journal_suspend_times(
    journal_output: str,
) -> "tuple[datetime | None, datetime | None]":

(basically wrap the entire python3.10 version in strings)


Returns None on parse failure.
"""
normalized = re.sub(r"([+-]\d{2}):(\d{2})$", r"\1\2", ts_str)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could you add a comment for this regex? looks like it removes the last colon from the string

Comment on lines +137 to +139
ts_re = re.compile(
r"^(\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{2}:\d{2})"
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This doesn't match the timestamp in journalctl --since today --no-pager -o short-iso for 22.04 and below, because they don't have the final colon in the timezone:

# doesn't match this
'2026-05-07T11:12:53+0800'
# but this will match
'2026-05-07T11:20:15+08:00'

I think the easier way to do this is to just take the 1st word of each line in the journal

for line in journal_output.splitlines():
    words = line.strip().split()
    if len(words) < 1:
        continue
    ts = _parse_ts(words[0])

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.

2 participants