CI/CD Integration
Exit codes
Section titled “Exit codes”| Code | Meaning |
|---|---|
0 | All assertions passed |
1 | One or more assertions failed |
2 | Runtime error (connection failed, etc.) |
JSON output
Section titled “JSON output”Use -o json for machine-readable output:
netsert run -f assertions.yaml -o json{ "summary": { "total": 10, "passed": 9, "failed": 1 }, "results": [ { "target": "spine1:6030", "path": "interfaces[Ethernet1]/state/oper-status", "expected": "UP", "actual": "UP", "passed": true } ]}GitHub Actions
Section titled “GitHub Actions”name: Network Tests
on: push: branches: [main]
jobs: test: runs-on: self-hosted steps: - uses: actions/checkout@v4
- name: Setup Go uses: actions/setup-go@v5 with: go-version: '1.22'
- name: Install netsert run: go install github.com/ndtobs/netsert/cmd/netsert@latest
- name: Run assertions env: NETSERT_USERNAME: ${{ secrets.NETWORK_USER }} NETSERT_PASSWORD: ${{ secrets.NETWORK_PASS }} run: netsert run -f assertions.yaml --insecureGitLab CI
Section titled “GitLab CI”network-test: image: golang:1.22 stage: test before_script: - go install github.com/ndtobs/netsert/cmd/netsert@latest script: - netsert run -f assertions.yaml --insecure variables: NETSERT_USERNAME: $NETWORK_USER NETSERT_PASSWORD: $NETWORK_PASSPost-change validation
Section titled “Post-change validation”#!/bin/bash# Apply config changesansible-playbook site.yml
# Wait for convergencesleep 30
# Validate statenetsert run -f post-change.yamlif [ $? -ne 0 ]; then echo "Validation failed! Rolling back..." ansible-playbook rollback.yml exit 1fi
echo "Change validated successfully"Performance
Section titled “Performance”- Typical assertion: 10-50ms
- 100 devices with 10 workers × 5 parallel: <1 minute
- vs sequential: 10+ minutes