# sonic-net/sonic-mgmt architecture

> Architecture diagram of the GitHub repository sonic-net/sonic-mgmt, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sonic-net/sonic-mgmt
- Repository: https://github.com/sonic-net/sonic-mgmt

## Overview

sonic-mgmt is SONiC’s testbed deployment, test automation, and reporting repository. A typical test run starts in SpyTest, uses testbed definitions to target switches, exercises SONiC through its API and connection layers, and produces results for reporting. Ansible provides a separate operational path for testbed setup, topology, device facts, and upgrades. Traffic generation and the Go-based PINS infrastructure are additional testing capabilities. The README establishes the product scope; the sampled sources provide concrete detail for SpyTest startup, one device API, route announcement, and report storage, so other connections are shown only where supported by the repository structure or documentation.

Main entry points: [`ansible`](https://github.com/sonic-net/sonic-mgmt/tree/master/ansible) (Ansible automation), [`spytest/spytest/framework.py`](https://github.com/sonic-net/sonic-mgmt/blob/master/spytest/spytest/framework.py) (Test framework), [`spytest/spytest/main.py`](https://github.com/sonic-net/sonic-mgmt/blob/master/spytest/spytest/main.py) (SpyTest CLI), [`test_reporting`](https://github.com/sonic-net/sonic-mgmt/tree/master/test_reporting) (Report collection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_testbed["Testbed operations"]
  node_ansible["Ansible automation"]
  node_inventory["Testbed inventory"]
  node_topology["Topology generation<br/>[generate_topo.py]"]
  node_device_facts["Device facts"]
  node_upgrade["SONiC upgrades<br/>[upgrade_sonic.py]"]
end

subgraph group_spytest["SpyTest runtime"]
  node_cli["SpyTest CLI<br/>[main.py]"]
  node_framework["Test framework<br/>[framework.py]"]
  node_testbed_model["Testbed model<br/>[testbed.py]"]
  node_test_suites["Test suites<br/>[suite.py]"]
  node_test_results["Test results<br/>[result.py]"]
end

subgraph group_device["Device and traffic"]
  node_device_apis["SONiC APIs"]
  node_connections["Device connections"]
  node_traffic_gen["Traffic generation"]
  node_route_announce["Route announcement<br/>[announce_routes.py]"]
  node_pins_tests["PINS infrastructure"]
end

subgraph group_reporting["Results and reporting"]
  node_reporting["Report collection"]
  node_report_store[("Report storage")]
  node_report_upload["Report upload<br/>[report_uploader.py]"]
end

node_engineer(("Test engineer"))
node_kusto[("Azure Kusto")]
node_pytest["Pytest"]
node_sonic["SONiC devices"]

node_engineer -->|"starts tests"| node_cli
node_cli -->|"invokes"| node_pytest
node_cli -->|"initializes"| node_framework
node_framework -->|"loads"| node_testbed_model
node_framework -->|"runs"| node_test_suites
node_framework -->|"records"| node_test_results
node_device_apis -->|"uses"| node_connections
node_connections -->|"connects"| node_sonic
node_device_apis -->|"configures and queries"| node_sonic
node_traffic_gen -->|"generates traffic for"| node_sonic
node_ansible -->|"uses"| node_inventory
node_ansible -->|"generates"| node_topology
node_ansible -->|"collects"| node_device_facts
node_ansible -->|"runs"| node_upgrade
node_ansible -->|"manages"| node_sonic
node_route_announce -->|"announces routes to"| node_sonic
node_pins_tests -->|"tests"| node_sonic
node_test_results -->|"feeds"| node_reporting
node_reporting -->|"stores reports"| node_report_store
node_report_store -.->|"ingests into"| node_kusto
node_reporting -->|"uploads"| node_report_upload

click node_ansible "https://github.com/sonic-net/sonic-mgmt/tree/master/ansible"
click node_inventory "https://github.com/sonic-net/sonic-mgmt/tree/master/ansible/devutil"
click node_topology "https://github.com/sonic-net/sonic-mgmt/blob/master/ansible/generate_topo.py"
click node_device_facts "https://github.com/sonic-net/sonic-mgmt/tree/master/ansible/library"
click node_upgrade "https://github.com/sonic-net/sonic-mgmt/blob/master/ansible/upgrade_sonic.py"
click node_cli "https://github.com/sonic-net/sonic-mgmt/blob/master/spytest/spytest/main.py"
click node_framework "https://github.com/sonic-net/sonic-mgmt/blob/master/spytest/spytest/framework.py"
click node_testbed_model "https://github.com/sonic-net/sonic-mgmt/blob/master/spytest/spytest/testbed.py"
click node_test_suites "https://github.com/sonic-net/sonic-mgmt/blob/master/spytest/spytest/suite.py"
click node_test_results "https://github.com/sonic-net/sonic-mgmt/blob/master/spytest/spytest/result.py"
click node_device_apis "https://github.com/sonic-net/sonic-mgmt/tree/master/spytest/apis"
click node_connections "https://github.com/sonic-net/sonic-mgmt/tree/master/spytest/spytest/access"
click node_traffic_gen "https://github.com/sonic-net/sonic-mgmt/tree/master/spytest/spytest/tgen"
click node_route_announce "https://github.com/sonic-net/sonic-mgmt/blob/master/ansible/library/announce_routes.py"
click node_pins_tests "https://github.com/sonic-net/sonic-mgmt/tree/master/sdn_tests/pins_ondatra/infrastructure"
click node_reporting "https://github.com/sonic-net/sonic-mgmt/tree/master/test_reporting"
click node_report_store "https://github.com/sonic-net/sonic-mgmt/blob/master/test_reporting/report_data_storage.py"
click node_report_upload "https://github.com/sonic-net/sonic-mgmt/blob/master/test_reporting/report_uploader.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_ansible,node_inventory,node_topology,node_device_facts,node_upgrade toneBlue
class node_cli,node_framework,node_testbed_model,node_test_suites,node_test_results,node_kusto toneAmber
class node_device_apis,node_connections,node_traffic_gen,node_route_announce,node_pins_tests toneMint
class node_reporting,node_report_store,node_report_upload toneRose
class node_engineer,node_pytest,node_sonic toneIndigo
```

## Components

### Testbed operations

- [Ansible automation](https://github.com/sonic-net/sonic-mgmt/tree/master/ansible): `ansible`
- [Testbed inventory](https://github.com/sonic-net/sonic-mgmt/tree/master/ansible/devutil): `ansible/devutil`
- [Topology generation](https://github.com/sonic-net/sonic-mgmt/blob/master/ansible/generate_topo.py): `ansible/generate_topo.py`
- [Device facts](https://github.com/sonic-net/sonic-mgmt/tree/master/ansible/library): `ansible/library`
- [SONiC upgrades](https://github.com/sonic-net/sonic-mgmt/blob/master/ansible/upgrade_sonic.py): `ansible/upgrade_sonic.py`

### SpyTest runtime

- [SpyTest CLI](https://github.com/sonic-net/sonic-mgmt/blob/master/spytest/spytest/main.py): `spytest/spytest/main.py`
- [Test framework](https://github.com/sonic-net/sonic-mgmt/blob/master/spytest/spytest/framework.py): `spytest/spytest/framework.py`
- [Testbed model](https://github.com/sonic-net/sonic-mgmt/blob/master/spytest/spytest/testbed.py): `spytest/spytest/testbed.py`
- [Test suites](https://github.com/sonic-net/sonic-mgmt/blob/master/spytest/spytest/suite.py): `spytest/spytest/suite.py`
- [Test results](https://github.com/sonic-net/sonic-mgmt/blob/master/spytest/spytest/result.py): `spytest/spytest/result.py`

### Device and traffic

- [SONiC APIs](https://github.com/sonic-net/sonic-mgmt/tree/master/spytest/apis): `spytest/apis`
- [Device connections](https://github.com/sonic-net/sonic-mgmt/tree/master/spytest/spytest/access): `spytest/spytest/access`
- [Traffic generation](https://github.com/sonic-net/sonic-mgmt/tree/master/spytest/spytest/tgen): `spytest/spytest/tgen`
- [Route announcement](https://github.com/sonic-net/sonic-mgmt/blob/master/ansible/library/announce_routes.py): `ansible/library/announce_routes.py`
- [PINS infrastructure](https://github.com/sonic-net/sonic-mgmt/tree/master/sdn_tests/pins_ondatra/infrastructure): `sdn_tests/pins_ondatra/infrastructure`

### Results and reporting

- [Report collection](https://github.com/sonic-net/sonic-mgmt/tree/master/test_reporting): `test_reporting`
- [Report storage](https://github.com/sonic-net/sonic-mgmt/blob/master/test_reporting/report_data_storage.py): `test_reporting/report_data_storage.py`
- [Report upload](https://github.com/sonic-net/sonic-mgmt/blob/master/test_reporting/report_uploader.py): `test_reporting/report_uploader.py`

### Other components

- **Test engineer**
- **Azure Kusto**
- **Pytest**
- **SONiC devices**

## Connections

- Test engineer → SpyTest CLI: starts tests
- SpyTest CLI → Pytest: invokes
- SpyTest CLI → Test framework: initializes
- Test framework → Testbed model: loads
- Test framework → Test suites: runs
- Test framework → Test results: records
- SONiC APIs → Device connections: uses
- Device connections → SONiC devices: connects
- SONiC APIs → SONiC devices: configures and queries
- Traffic generation → SONiC devices: generates traffic for
- Ansible automation → Testbed inventory: uses
- Ansible automation → Topology generation: generates
- Ansible automation → Device facts: collects
- Ansible automation → SONiC upgrades: runs
- Ansible automation → SONiC devices: manages
- Route announcement → SONiC devices: announces routes to
- PINS infrastructure → SONiC devices: tests
- Test results → Report collection: feeds
- Report collection → Report storage: stores reports
- Report storage → Azure Kusto: ingests into
- Report collection → Report upload: uploads
