Skip to content

[vpp] SAIVPP unit-test harness (docker-sai-test-vpp) + devdocs - #1950

Open
nicholasching wants to merge 45 commits into
sonic-net:masterfrom
nicholasching:vpp_ut_harness
Open

[vpp] SAIVPP unit-test harness (docker-sai-test-vpp) + devdocs#1950
nicholasching wants to merge 45 commits into
sonic-net:masterfrom
nicholasching:vpp_ut_harness

Conversation

@nicholasching

Copy link
Copy Markdown
Contributor

Description of PR

Summary:
Adds the self-contained Docker harness (docker-sai-test-vpp) that runs the upstream OCP sai_test PTF suite against the real VPP SAI backend (libsaivs) in one container — VPP + saiserver + PTF + veth/AF_PACKET topology — and produces a per-test compatibility matrix. This is test scaffolding only (everything under .azure-pipelines/docker-sai-test-vpp/); it does not touch any production/runtime code, so it cannot affect existing sonic-sairedis functionality. Reviewers can start at .azure-pipelines/docker-sai-test-vpp/README.md and run_test.sh.

Fixes # (N/A — no upstream issue)

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Documentation update
  • Test improvement

Approach

What is the motivation for this PR?

There was no in-tree way to run the OCP sai_test suite against the VPP SAI backend and track per-test coverage. This harness provides that, plus the development docs and compatibility matrices used to drive the backend fixes.

How did you do it?

Added under .azure-pipelines/docker-sai-test-vpp/:

  • Dockerfile and run_test.sh (orchestrates Redis → veth/PortChannel topology → VPP → saiserver → PTF), plus T0 config (sai.profile, lanemap.ini, port-map.ini, ptf-port-map.ini) and gen_compatibility_matrix.py.
  • Config-signature grouping: because the VPP SAI backend builds the switch once per saiserver process, run_test.sh groups tests by their setUp config signature and restarts the backend per group, so one container can run any mix of tests.
  • ISOLATE_EACH_TEST (default on): run each test in its own group with a fresh backend + own config to eliminate cross-test config-reuse contamination; set 0 for faster grouped runs.
  • L3-over-LAG forwarding (harness portion): run_test.sh assigns the DUT-side connected IPs to each LAG (be<N>) and SVI (bvi<vlan>) so routed-to-LAG/SVI traffic forwards in the standalone PTF environment (the backend portion is in the backend-fixes PR).
  • Debug hold to keep VPP/saiserver/veths alive after a --debug run for vppctl inspection.
  • devdocs/, demodocs/, and results/ compatibility matrices; .gitignore for generated artifacts.

How did you verify/test it?

Running the harness against sai_route_test/sai_rif_test/sai_neighbor_test/sai_ecmp_test produces a compatibility matrix (current state: 34 PASS, captured in devdocs//results/). The harness is self-contained and does not build or run any production code.

Any platform specific information?

VPP platform test infrastructure only; isolated under .azure-pipelines/docker-sai-test-vpp/. No impact on the sonic-sairedis build or runtime behavior.

Documentation

This PR adds the harness README.md plus rolling/dated progress notes and deep-dive debug logs under .azure-pipelines/docker-sai-test-vpp/devdocs/ and demo docs under demodocs/.

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

Signed-off-by: Nicholas Ching <nicholaslching@gmail.com>
…dog, --relax

Signed-off-by: Nicholas Ching <nicholaslching@gmail.com>
…ature and restarting backend per group

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

Signed-off-by: Nicholas Ching <nicholaslching@gmail.com>
Signed-off-by: Nicholas Ching <nicholaslching@gmail.com>
Signed-off-by: Nicholas Ching <nicholaslching@gmail.com>
Signed-off-by: Nicholas Ching <nicholaslching@gmail.com>
UT-harness portion of the L3-over-LAG forwarding fix: run_test.sh assigns the
DUT-side connected IPs to each LAG (be<N>) and SVI (bvi<vlan>) so routed-to-LAG
/SVI traffic forwards in the standalone PTF environment. The backend portion
(SwitchVppFdb.cpp) is in the VPP SAI backend PR.

Signed-off-by: Nicholas Ching <nicholaslching@gmail.com>
Signed-off-by: Nicholas Ching <nicholaslching@gmail.com>
Signed-off-by: Nicholas Ching <nicholaslching@gmail.com>
Signed-off-by: Nicholas Ching <nicholaslching@gmail.com>
Signed-off-by: Nicholas Ching <nicholaslching@gmail.com>
Signed-off-by: Nicholas Ching <nicholaslching@gmail.com>
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jun 23, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

…SER)

- gen_compatibility_matrix.py: prefer defusedxml for parsing PTF JUnit XML
  (XXE-hardened), with a stdlib fallback; input is our own local test output.
- Dockerfile: annotate the root entrypoint with a nosemgrep justification — the
  --privileged harness must run as root to start VPP/Redis/saiserver and manage
  veth/AF_PACKET; it is a disposable test container, never a deployed service.

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

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

Satisfy tests/checkwhitespace.sh (Azure Build amd64 gate).

Signed-off-by: Nicholas Ching <nicholaslching@gmail.com>
Copilot AI review requested due to automatic review settings August 5, 2026 17:59
@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.

Pull request overview

Copilot reviewed 14 out of 15 changed files in this pull request and generated no new comments.

Suppressed comments (4)

vslib/vpp/SwitchVppRif.cpp:359

  • getPortHwifNameFromLane uses a fixed 8-entry buffer for SAI_PORT_ATTR_HW_LANE_LIST and treats any non-success as “lane list unavailable”. If the port ever reports more lanes than fit, the call will typically fail with SAI_STATUS_BUFFER_OVERFLOW, and this path will silently fall back to TAP mapping (or fail later) without a clear error. Handle BUFFER_OVERFLOW explicitly and include the status code in the debug log so failures are diagnosable.
    uint32_t lanes[8] = {};
    sai_attribute_t attr = {};
    attr.id = SAI_PORT_ATTR_HW_LANE_LIST;
    attr.value.u32list.count = sizeof(lanes) / sizeof(lanes[0]);
    attr.value.u32list.list = lanes;

.azure-pipelines/docker-sai-test-vpp/run_test.sh:1012

  • run_one_ptf hard-codes the "Turn up ports..." marker string instead of using the LINK_UP_TRIGGER variable defined near the top of the script. This makes LINK_UP_TRIGGER effectively dead configuration and can confuse readers expecting it to work.
        case "$ptf_line" in
            *"Turn up ports..."*)
                bring_up_veths
                ;;
        esac

.azure-pipelines/docker-sai-test-vpp/run_test.sh:566

  • enumerate_test_classes() is currently defined but never called (planning uses plan_test_groups() instead). Keeping an unused discovery implementation in a large script makes future maintenance harder (two code paths to keep consistent).
# Enumerate every test class under $SAI_TEST_DIR as "module.Class" selectors so
# each can run as its own config-reuse ptf invocation. Best-effort: on any
# failure prints nothing and the caller falls back to a single invocation.
enumerate_test_classes()
{

vslib/vpp/SwitchVppRif.cpp:346

  • PR description states the change is “test scaffolding only (everything under .azure-pipelines/docker-sai-test-vpp/)” and “does not touch any production/runtime code”, but this PR also modifies vslib/vpp (e.g., adds lane-based interface resolution in SwitchVppRif.cpp / SwitchVpp.h). Please update the description to reflect the vslib runtime change, or split runtime changes into a separate PR if the intent is to keep this PR harness-only.
bool SwitchVpp::getPortHwifNameFromLane(
      _In_ sai_object_id_t port_id,
      _Out_ std::string& if_name)
{
    SWSS_LOG_ENTER();

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

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

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

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

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

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

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

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

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

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

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

Comment thread vslib/vpp/SwitchVppRif.cpp Outdated

if (get(SAI_OBJECT_TYPE_PORT, port_id, 1, &attr) != SAI_STATUS_SUCCESS)
{
SWSS_LOG_DEBUG("lane list unavailable for port %s",

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.

LANE_LIST is mandatory in PORT. This should be an error message. Same for all the DEBUG message in the returning false case in this function.

Comment thread vslib/vpp/SwitchVppRif.cpp Outdated
}

if_name = mapped_hwifname;
SWSS_LOG_DEBUG("resolved port %s lane set to %s/%s",

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.

use INFO. DEBUG level is overwhelmed in syncd due to SWSS_LOG_ENTER in every function.

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

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

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

@nicholasching

Copy link
Copy Markdown
Contributor Author

/azpw run

@mssonicbld

Copy link
Copy Markdown
Collaborator

⚠️ Notice: /azpw run only runs failed jobs now. If you want to trigger a whole pipline run, please rebase your branch or close and reopen the PR.
💡 Tip: You can also use /azpw retry to retry failed jobs directly.

Retrying failed(or canceled) jobs...

@mssonicbld

Copy link
Copy Markdown
Collaborator

Retrying failed(or canceled) stages in build 1187084:

✅Stage BuildAsan:

  • Job amd64: retried.

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.

5 participants