Skip to content

sai_test: add opt-in SIMULATE_SONIC to emulate SONiC teamd/IntfMgr netdevs for standalone benches#2316

Merged
kcudnik merged 3 commits into
opencomputeproject:masterfrom
nicholasching:simulate_sonic
Jul 14, 2026
Merged

sai_test: add opt-in SIMULATE_SONIC to emulate SONiC teamd/IntfMgr netdevs for standalone benches#2316
kcudnik merged 3 commits into
opencomputeproject:masterfrom
nicholasching:simulate_sonic

Conversation

@nicholasching

Copy link
Copy Markdown
Contributor

Context / motivation
Part of the SAIVPP unit-test framework (see the sonic-sairedis docker-sai-test-vpp harness). When the OCP sai_test T0 suite runs against a SAI backend on a standalone bench with no SONiC control plane, there is no teamd to create PortChannel netdevs and no IntfMgr to assign LAG/SVI interface IPs — which some backends (e.g. the VPP virtual switch) rely on for LAG bring-up and routed-to-LAG/SVI forwarding. This adds an opt-in way for the test setup to emulate that.

What this change does

  • test/sai_test/config/simulate_sonic.py (new). Opt-in helper, active only when SIMULATE_SONIC=1; every entry point is a no-op otherwise.
  • test/sai_test/config/lag_configer.pycreate_lag(). When enabled, create the PortChannel<N> netdev teamd would provide, before the SAI LAG create.
  • test/sai_test/config/route_configer.pycreate_router_interface(). When enabled, assign the connected IPs IntfMgr would set on a LAG or VLAN(SVI) router interface.
  • Vendor-neutral by construction. PortChannel netdevs use generic Linux ip … type bond; LAG RIF IPs use ip addr add. A VLAN SVI has no host-interface netdev to mirror from, so its address is programmed via command templates supplied by the caller (SVI_RIF_SET_IP_CMD / SVI_RIF_PROBE_CMD, with {ifname}/{addr} placeholders) — no backend-specific tooling is hardcoded in sai_test. All interface-name prefixes and address patterns are env-overridable.

Scope / risk

  • 3 files (one new module + two setUp-path hooks) — test-config helpers only; no change to SAI/backend code or packet semantics.
  • Fully opt-in with default-off: with SIMULATE_SONIC unset, all entry points no-op, so real-HW and other OCP consumers are unchanged unless they opt in.

Dependencies
None. Independent of #2299 / #2300 / #2301 (edits different functions); targets master.

…s in sai_test

Signed-off-by: Nicholas Ching <nicholaslching@gmail.com>
@nicholasching

Copy link
Copy Markdown
Contributor Author

@kcudnik, could you please invoke azure pipelines to run checks, please. I do not have the permissions to do so.

@kcudnik

kcudnik commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

Comment thread test/sai_test/config/simulate_sonic.py Outdated
@@ -0,0 +1,157 @@
# Copyright (c) 2021 Microsoft Open Technologies, Inc.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Update the year to 2026

Comment thread test/sai_test/config/simulate_sonic.py Outdated


def _run(cmd, check=False):
return subprocess.run(cmd, check=check, capture_output=True, text=True)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Add a warning or error log message when _run fails

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

All done! Warnings/errors now log using logger module.

Signed-off-by: Nicholas Ching <nicholaslching@gmail.com>
Signed-off-by: Nicholas Ching <nicholaslching@gmail.com>
@nicholasching

Copy link
Copy Markdown
Contributor Author

Thanks @dypet!

@kcudnik, thank you for your help on #2299 and #2300 this morning. I know there is still #2301 open right now; when you get a chance, please kindly invoke PR checks / take a quick look at this PR as well to prepare for merge into master. Thanks!

@kcudnik

kcudnik commented Jul 13, 2026

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

@nicholasching

nicholasching commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

Hi @kcudnik, looks like the changes in this PR are passing checks and have been reviewed by @dypet. When you have a chance, could you please take a quick look and help us merge into master for upstream feature in sonic-sairedis? Thanks!

@kcudnik
kcudnik merged commit cd70272 into opencomputeproject:master Jul 14, 2026
3 checks passed
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