Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: run test in parallel #490

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

ci: run test in parallel #490

wants to merge 1 commit into from

Conversation

hfudev
Copy link
Member

@hfudev hfudev commented Jan 21, 2025

No description provided.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@hfudev
Copy link
Member Author

hfudev commented Jan 21, 2025

I tried locally with a simple example and pytest-embedded should work with pytest-xdist, if there's no duplicated target-port got assigned.

For example

import pytest

from pytest_embedded_idf.dut import IdfDut


@pytest.mark.parametrize('app_path', [
    '/home/fuhanxi/esp/esp-idf/examples/get-started/hello_world',
], indirect=True)
@pytest.mark.parametrize('target,build_dir', [  # different targets, auto-detection still works
    ('esp32c6', 'build_esp32c6_default'),
    ('esp32', 'build_esp32_default'),
], indirect=True)
def test_hello_world(
    dut: IdfDut,
) -> None:
    dut.expect('Hello world!')

and here's a benchmark with xdist and without xdist, with two cases

hyperfine "pytest -n 2 test.py --embedded-services esp,idf" "pytest test.py --embedded-services esp,idf"
Benchmark 1: pytest -n 2 test.py --embedded-services esp,idf
  Time (mean ± σ):      5.121 s ±  0.346 s    [User: 0.697 s, System: 0.168 s]
  Range (min … max):    4.781 s …  6.056 s    10 runs
 
Benchmark 2: pytest test.py --embedded-services esp,idf
  Time (mean ± σ):      9.036 s ±  0.675 s    [User: 0.327 s, System: 0.093 s]
  Range (min … max):    8.542 s … 10.295 s    10 runs
 
Summary
  pytest -n 2 test.py --embedded-services esp,idf ran
    1.76 ± 0.18 times faster than pytest test.py --embedded-services esp,idf

known limitation of using pytest-xdist

  • can't trace serial output in job log. ref

cc @igrr @espzav

Copy link

Test Results

 15 files  15 suites   3m 57s ⏱️
 45 tests 14 ✅  23 💤 0 ❌ 8 🔥
330 runs  14 ✅ 308 💤 0 ❌ 8 🔥

For more details on these errors, see this check.

Results for commit 3f83e56.

@espzav
Copy link
Collaborator

espzav commented Jan 21, 2025

@hfudev Thank you very much for this solution! It seems that it can work, when we will select only one example for tests for each board. Otherwise, we will make some process to synchronize it. I will try it soon with these changes :-)

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