[transceiver][test-plan][attribute_parser]: restructure per-category attribute JSONs into scope-rooted shards#1
Closed
mihirpat1 wants to merge 1 commit into
Closed
Conversation
…attribute JSONs into scope-rooted shards
Replace the single flat `<category>.json` file under
`ansible/files/transceiver/inventory/attributes/` with a sharded layout
where each non-category shard is rooted on disk by its scope:
attributes/<category>/
<category>.json # mandatory / defaults / dut / deployment_configurations
platforms/<PLATFORM>/<category>.json # platform body
platforms/<PLATFORM>/hwskus/<HWSKU>.json # HWSKU body
transceivers/vendors/<V>/<category>.json # vendor `defaults` body
transceivers/vendors/<V>/part_numbers/<PN>/<category>.json # per-PN body (attrs + optional firmware_overrides / platform_hwsku_overrides)
Each non-category shard's JSON contains only its scope's body; the scope
is encoded in the directory path. Because each shard owns a disjoint
subtree of the merged tree (`platforms.<P>`, `hwskus.<H>`,
`transceivers.vendors.<V>.defaults`, `transceivers.vendors.<V>.part_numbers.<PN>`),
two shards can never write the same key path - the directory IS the schema.
Loader (tests/transceiver/attribute_parser/attribute_manager.py):
- Discovers shards from the directory tree and grafts each body into the
correct slot of the merged in-memory tree.
- Validation reduced to four fail-fast checks at framework init:
1. Category top-key whitelist (mandatory / defaults / dut /
transceivers.deployment_configurations only)
2. Body-shape sanity (per-PN reserved sub-slots must be dict-of-dict)
3. Vendor / PN normalization (directory names must appear in
normalization_mappings.json when the vendor/PN owns a shard)
4. Mandatory-field resolution after merge + priority resolution
Path/payload mismatch and duplicate-leaf checks are no longer needed -
the scope-rooted layout makes them structurally impossible.
Tests (tests/transceiver/attribute_parser/transceiver_attribute_infra_test.py):
- `_shard_category` helper rewritten to emit scope-rooted bodies.
- Obsolete tests removed: path/payload mismatch (both vendor + per-PN),
vendor-shard extra slot, duplicate-leaf detection.
- Existing slot-whitelist / normalization tests rewritten for the new
body shape.
- New test: `test_loader_pn_reserved_subslot_shape` covers the dict-of-dict
check for `firmware_overrides` / `platform_hwsku_overrides`.
- Final result: 25 / 25 passing.
HLD updates (docs/testplan/transceiver/):
- `test_plan.md`: File Organization tree + shard contracts table now show
per-scope body shapes; Loader Validation reduced from 5 to 4 checks;
JSON Schema Structure section replaces wrapped templates with scope-rooted
bodies and a comment indicating where each is grafted.
- `diagrams/file_organization.md` and `diagrams/data_flow.md`: trees and
Mermaid graphs updated to reflect sharded layout; priority hierarchy
bumped from 8 to 9 levels (firmware_overrides reserved slot).
- `eeprom_test_plan.md`, `system_test_plan.md`, `dom_test_plan.md`:
pre-req / attributes sections link to the shard layout and validation
rules.
- Example inventory under `docs/testplan/transceiver/examples/inventory/`:
the flat `eeprom.json` replaced by a full scope-rooted shard tree
exercising platform / HWSKU / two vendors / two per-PN files.
Signed-off-by: Mihir Patel <patelmi@microsoft.com>
|
/azp run |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of PR
Summary:
Restructure the per-category transceiver attribute JSONs under
ansible/files/transceiver/inventory/attributes/from a single flat<category>.jsonfile into a sharded, scope-rooted layout. Every non-category shard (platform / HWSKU / vendor / per-PN) carries only its scope's body; the scope is encoded entirely in the directory path. The loader grafts each body into the correct slot of the merged in-memory tree before priority resolution.Because each shard owns a disjoint subtree of the merged tree, two shards can never write the same key path - the directory IS the schema. Path/payload mismatch and duplicate-leaf checks are no longer needed; the layout makes them structurally impossible.
Fixes # (issue) — ADO PBI link will be added in a comment.
Type of change
Back port request
Approach
What is the motivation for this PR?
The previous single-file-per-category layout did not scale to vendor onboarding and per-PN tuning. Every vendor or PN-specific tweak had to be edited into the same shared JSON, creating merge friction and making it easy to mis-place attributes. A path-mismatch or duplicate-leaf required custom loader checks to catch.
The sharded layout isolates each ownership level into its own file and uses the directory structure itself as the schema - vendor onboarding adds a vendor directory, PN-specific tuning adds a PN directory, and no two shards can collide.
How did you do it?
Loader (
tests/transceiver/attribute_parser/attribute_manager.py)mandatory,defaults,dut, andtransceivers.deployment_configurationsallowed at category-level.firmware_overrides/platform_hwsku_overridesmust be dict-of-dict.normalization_mappings.jsonwhen the vendor/PN owns a shard.mandatoryfield somewhere in the hierarchy.Tests (
tests/transceiver/attribute_parser/transceiver_attribute_infra_test.py)_shard_categoryhelper rewritten to emit scope-rooted bodies.test_loader_pn_reserved_subslot_shapecovers the dict-of-dict check.HLD updates in
docs/testplan/transceiver/:test_plan.md— File Organization (tree + shard contracts table), Loader Validation (5 → 4 checks), JSON Schema Structure (scope-rooted examples).diagrams/file_organization.mdanddiagrams/data_flow.md— trees + Mermaid graphs updated; priority hierarchy 8 → 9 levels (firmware_overrides reserved slot).eeprom_test_plan.md,system_test_plan.md,dom_test_plan.md— pre-req / attributes sections link to the shard layout and validation rules.docs/testplan/transceiver/examples/inventory/attributes/eeprom/— flateeprom.jsonreplaced by a full scope-rooted shard tree exercising platform / HWSKU / two vendors / two per-PN files.How did you verify/test it?
Any platform specific information?
None — this is framework / HLD work; no DUT runtime behavior is affected. Loader changes are exercised by the standalone unit-test runner.
Supported testbed topology if it's a new test case?
N/A — no new test cases. Framework + documentation only.
Documentation
The HLD documents in
docs/testplan/transceiver/are part of this PR. The example inventory tree underdocs/testplan/transceiver/examples/inventory/is updated to match the new layout.