Skip to content

[ci]: Make pure package validation deterministic#719

Merged
hdwhdw merged 2 commits into
sonic-net:masterfrom
hdwhdw:ci/fix-pure-package-validation
Jul 18, 2026
Merged

[ci]: Make pure package validation deterministic#719
hdwhdw merged 2 commits into
sonic-net:masterfrom
hdwhdw:ci/fix-pure-package-validation

Conversation

@hdwhdw

@hdwhdw hdwhdw commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Why I did it

Pure-package validation could report false-green results:

  • pkg/exec behavior tests skipped when privileged nsenter was unavailable
  • looped pure.mk targets could return success after an earlier command failed
  • gNOI file tests assumed TMPDIR was under the production path allowlist
  • the hand-maintained package list could omit nested canonical packages from hosted tests

How I did it

  • made looped validation targets stop on the first command failure
  • added an internal command-construction seam so pkg/exec tests run deterministically without namespace privileges
  • reused the existing host-root test seam so TransferToRemote tests use allowed logical paths with isolated physical storage
  • derived pure packages mechanically from internal/, pkg/, and cmd/
  • changed loop targets to validate each discovered package exactly once
  • aligned JUnit compiler flags with gomonkey-based tests

How to verify it

  • make -f pure.mk ci
  • make -f pure.mk junit-xml
  • make -f pure.mk list-packages
  • verify injected command failures return nonzero from looped validation targets

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012
  • 202106
  • 202111

Description for the changelog

Make pure-package validation deterministic, complete, and failure-sensitive.

Link to config_db schema for YANG module changes

N/A

A picture of a cute animal (not mandatory but encouraged)

Propagate failures from looped pure.mk targets, replace privileged nsenter tests with a deterministic command seam, and keep file tests portable across TMPDIR settings.

The previous workflow could skip command behavior or return the status of a later successful shell command, producing false-green validation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Dawei Huang <daweihuang@microsoft.com>
Copilot AI review requested due to automatic review settings July 13, 2026 19:13
@mssonicbld

Copy link
Copy Markdown
Contributor

/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

This PR improves determinism and failure propagation in the “pure package” CI flow, while making unit tests for pkg/exec and gNOI file handling more reliable across environments (no privileged nsenter requirements and less dependence on process-level TMPDIR).

Changes:

  • Make pure.mk looped targets fail fast by enabling set -e and avoiding error-masking patterns.
  • Refactor pkg/exec tests to validate RunHostCommand* behavior via an in-test helper process, without requiring real nsenter.
  • Update gNOI file transfer tests to use a temp “host root” mapping and validate results via the physical on-disk path.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
pure.mk Ensures looped validation targets fail deterministically and clean up coverage conversion artifacts reliably.
pkg/gnoi/file/file_test.go Makes file transfer tests use a host-root-mapped temp path so file assertions don’t depend on process TMPDIR.
pkg/exec/command.go Adds an injectable command-construction hook to enable deterministic tests of nsenter execution paths.
pkg/exec/command_test.go Replaces privileged/skip-based nsenter testing with a helper-process approach that validates stdout/stderr/exit behavior deterministically.

Derive the pure package set from internal, pkg, and cmd so new canonical packages cannot be omitted. Run each package exactly once and align the JUnit compiler flags with the gomonkey-based tests now included.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Dawei Huang <daweihuang@microsoft.com>
@mssonicbld

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

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

@hdwhdw
hdwhdw merged commit 698e2ea into sonic-net:master Jul 18, 2026
13 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.

4 participants