Skip to content

[sonic_xcvr]: Add xcvr-emu integration tests - #758

Open
az-pz wants to merge 1 commit into
sonic-net:masterfrom
az-pz:test/xcvr-emu-integration
Open

az-pz wants to merge 1 commit into
sonic-net:masterfrom
az-pz:test/xcvr-emu-integration

Conversation

@az-pz

@az-pz az-pz commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Description

Add integration tests that run the production SONiC CMIS transceiver stack against a live xcvr-emu process instead of mocks.

The change adds:

  • A gRPC-backed SfpOptoeBase adapter and per-test emulator lifecycle management.
  • Coverage for EEPROM address translation, API discovery, identity and capability decoding, module and datapath state machines, hot plug behavior, and DOM values.
  • A deterministic CMIS emulator configuration and documentation for running or selecting the tests.
  • An integration pytest marker and a testing package extra pinned to a compatible az-pz/xcvr-emu commit.

Motivation and Context

The existing unit tests validate individual CMIS components with mocks, but they do not verify that the complete SfpOptoeBase -> XcvrApiFactory -> CmisApi stack reads and writes the intended registers through a live transport. These tests exercise those boundaries end to end and catch regressions in page/bank translation, field decoding, and state-machine control flows.

How Has This Been Tested?

Tested in a Debian 12 Bookworm container with Python 3.11 and the SONiC build dependencies installed.

  • pytest tests/sonic_xcvr/integration/test_cmis_emulator.py: 53 passed.
  • Full pytest suite: 1,916 passed, 0 failed, 0 errors, 0 skipped; 72% coverage.
  • python3 -m build -n: wheel built successfully, and its metadata contains the fork-pinned xcvr-emu dependency under the testing extra.

Additional Information (Optional)

The emulator dependency is pinned to immutable commit az-pz/xcvr-emu@3aca04f89de6dfecf33bea29509234164d917a81, which supports current SONiC gRPC versions and package-qualified protobuf imports. The integration module skips cleanly when the optional emulator dependency is unavailable.

xcvr-emu should be forked under sonic-net and that fork should be used here in the future.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI left a comment

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.

🟡 Changes recommended

The testing dependency breaks supported older Python environments, and one asynchronous state assertion is scheduling-dependent.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds live xcvr-emu integration coverage for the production CMIS transceiver stack.

Changes:

  • Adds a gRPC emulator adapter and isolated daemon fixtures.
  • Tests addressing, discovery, state machines, hot-plugging, and DOM decoding.
  • Adds emulator configuration, documentation, pytest marker, and testing dependencies.
File summaries
File Description
tests/sonic_xcvr/integration/xcvr_emu_config.yaml Defines deterministic CMIS modules.
tests/sonic_xcvr/integration/test_cmis_emulator.py Adds end-to-end CMIS tests.
tests/sonic_xcvr/integration/README.md Documents architecture and execution.
tests/sonic_xcvr/integration/emulator.py Implements daemon, client, and SFP adapter.
tests/sonic_xcvr/integration/conftest.py Provides isolated integration fixtures.
tests/sonic_xcvr/integration/__init__.py Defines the integration test package.
setup.py Adds the testing extra and emulator dependency.
pytest.ini Registers the integration marker.
Review details
  • Files reviewed: 7/8 changed files
  • Comments generated: 2
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread setup.py
Comment on lines +14 to +15
'xcvr-emu @ git+https://github.com/az-pz/'
'xcvr-emu.git@3aca04f89de6dfecf33bea29509234164d917a81',
Comment on lines +302 to +309
ready_cmis_api.decommission_all_datapaths()

assert ready_cmis_api.get_active_apsel_hostlane() == {
"ActiveAppSelLane%d" % lane: 0 for lane in range(1, 9)
}
assert ready_cmis_api.get_datapath_state() == {
"DP%dState" % lane: "DataPathDeactivated" for lane in range(1, 9)
}
Exercise the production CMIS stack against a live transceiver emulator,
including address translation, API discovery, state machines, datapath
provisioning, and DOM decoding. Add the integration marker, documentation,
and a testing extra pinned to the compatible az-pz/xcvr-emu fork.

Signed-off-by: Ariz Zubair <arizzubair@microsoft.com>
@az-pz
az-pz force-pushed the test/xcvr-emu-integration branch from 1b39b5c to 5c90960 Compare September 16, 2026 17:51
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

3 participants