Skip to content

CI/CD Integration

CodeMeaning
0All assertions passed
1One or more assertions failed
2Runtime error (connection failed, etc.)

Use -o json for machine-readable output:

Terminal window
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/workflows/network-test.yml
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 --insecure
.gitlab-ci.yml
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_PASS
deploy.sh
#!/bin/bash
# Apply config changes
ansible-playbook site.yml
# Wait for convergence
sleep 30
# Validate state
netsert run -f post-change.yaml
if [ $? -ne 0 ]; then
echo "Validation failed! Rolling back..."
ansible-playbook rollback.yml
exit 1
fi
echo "Change validated successfully"
  • Typical assertion: 10-50ms
  • 100 devices with 10 workers × 5 parallel: <1 minute
  • vs sequential: 10+ minutes