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

Test sonic-xcvr with xcvr-emu #530

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

ishidawataru
Copy link

@ishidawataru ishidawataru commented Jan 17, 2025

Description

This PR adds sonic-xcvr testing platform that uses xcvr-emu.

Also, this PR includes a fix for a possible bug found by the test with xcvr-emu. (edit. It seems the current behavior is intentional. I reverted the fix.)

assert decoded == "2021-10-20 \0\0"

This PR mainly aims to show how xcvr-emu can be integrated into the sonic-platform-common CI pipeline.

Motivation and Context

sonic-net/SONiC#1849

How Has This Been Tested?

Run make test_sonic_xcvr_with_emu at the top directory of this repo.

$ make test_sonic_xcvr_with_emu 
docker build -f docker/Dockerfile -t sonic-xcvr .                                                                                                            
[+] Building 0.0s (11/11) FINISHED                                                                                                      docker:desktop-linux
 => [internal] load build definition from Dockerfile                                                                                                    0.0s
 => => transferring dockerfile: 360B                                                                                                                    0.0s
 => [internal] load metadata for ghcr.io/ishidawataru/xcvr-emu:main                                                                                     0.0s
 => [internal] load .dockerignore                                                                                                                       0.0s
 => => transferring context: 2B                                                                                                                         0.0s
 => [stage-0 1/6] FROM ghcr.io/ishidawataru/xcvr-emu:main                                                                                               0.0s
 => [internal] load build context                                                                                                                       0.0s  => => transferring context: 360B                                                                                                                       0.0s
 => CACHED [stage-0 2/6] WORKDIR /sonic_platform_base                                                                                                   0.0s  => CACHED [stage-0 3/6] RUN --mount=type=bind,source=docker/sonic_py_common,target=/sonic_py_common,rw     cd /sonic_py_common && pip install .        0.0s  => CACHED [stage-0 4/6] RUN mkdir sonic_platform_base && touch sonic_platform_base/__init__.py                                                         0.0s
 => CACHED [stage-0 5/6] COPY docker/pyproject.toml .                                                                                                   0.0s
 => CACHED [stage-0 6/6] RUN pip install '.[dev]'                                                                                                       0.0s
 => exporting to image                                                                                                                                  0.0s 
 => => exporting layers                                                                                                                                 0.0s
 => => writing image sha256:882ddc798bca7515e3941f96c61424921cd2fee074f567b5c2ecaf7eab85e3ea                                                            0.0s
 => => naming to docker.io/library/sonic-xcvr  
docker run -it \
        -v `pwd`/docker/pyproject.toml:/sonic_platform_base/pyproject.toml \
        -v `pwd`/sonic_platform_base:/sonic_platform_base/sonic_platform_base \
        -v `pwd`/docker/tests:/sonic_platform_base/tests \
        -w /sonic_platform_base \
        sonic-xcvr \
        python -m pytest -v .
/usr/local/lib/python3.11/site-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset.
The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session"

  warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET))
==================================================================== test session starts ====================================================================
platform linux -- Python 3.11.11, pytest-8.3.4, pluggy-1.5.0 -- /usr/local/bin/python
cachedir: .pytest_cache
rootdir: /sonic_platform_base
configfile: pyproject.toml
plugins: asyncio-0.25.2
asyncio: mode=Mode.STRICT, asyncio_default_fixture_loop_scope=None
collected 2 items                                                                                                                                           

tests/sonic_xcvr_with_emu/test_cmis.py::test_get_model[1234567890-1234567890] PASSED                                                                  [ 50%]
tests/sonic_xcvr_with_emu/test_cmis.py::test_get_model[ABCD-ABCD] PASSED                                                                              [100%]
$

Additional Information (Optional)

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ishidawataru ishidawataru changed the title Test sonic xcvr with emu Test sonic-xcvr with xcvr-emu Jan 17, 2025
@ishidawataru
Copy link
Author

@prgeor PTAL

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

…tringRegField"

This reverts commit df1852d.

It seems leaving the traling null characters is intentional.
@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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