Skip to content

feat: Add integration test framework and fix embedded vrf field#71

Merged
azryve merged 4 commits into
mainfrom
feature/integration-tests
May 8, 2026
Merged

feat: Add integration test framework and fix embedded vrf field#71
azryve merged 4 commits into
mainfrom
feature/integration-tests

Conversation

@azryve

@azryve azryve commented May 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Implements an integration testing infrastructure for the Netbox API versions.
  • Fixes found issues with embedded vrf field.

Integration Test Framework

Test Infrastructure

  • YAML-based test definitions with per-test version targeting
  • VCR.py for recording/replaying HTTP interactions (deterministic, no live Netbox needed)
  • Single compose.yaml with 3 Netbox versions
  • Shared postgres + redis infrastructure
  • Automatic database creation and demo data loading
  • netbox-demo-data as git submodule

Developer Workflow

  • make test # Run all tests
  • make lint # Run linter
  • make docker # Start all Netbox versions
  • make fixtures # Generate test fixtures from live instances

Structure

  • tests/integration/definitions.yaml - Shared test definitions
  • tests/integration/fixtures/vXX/ - Per-version cassettes + expected outputs
  • tests/integration/test_declarative.py - API behavior tests
  • tests/integration/test_consistency.py - Fixture integrity validation

Known limitations

  • v24 is not supported in tests due to netbox-demo-data missing demo data for this version
  • depends on specific local ports being available to expose netbox: localhost:{8037,8041,8042}

Bug Fixes

Model Updates (v3.7, v4.1, v4.2)

  • Fixed embedded VRF field: Vrf → VrfBrief
  • Removed deprecated description field from VRF models

Misc

  • Updated GitHub Actions to use make commands
  • New AGENTS.md with development guidelines

azryve and others added 4 commits May 7, 2026 13:23
Implement comprehensive integration testing infrastructure for Netbox
API client with support for multiple Netbox versions and reproducible
test execution without requiring live Netbox instances.

Key components:
- Declarative test definitions in YAML with version targeting
- VCR.py-based HTTP recording/replay for deterministic tests
- Tamper detection via lock files
- Automated fixture generation from live Netbox instances
- Multi-version Docker Compose setup (shared postgres/redis)
- Consistency validation tests for fixture integrity

Test workflow:
1. Define tests in tests/integration/definitions.yaml with target versions
2. Generate fixtures: `make fixtures` (requires Docker)
3. Run tests: `make test` (no Docker needed, uses recorded cassettes)

Structure:
- tests/integration/definitions.yaml - Shared test definitions
- tests/integration/fixtures/vXX/ - Per-version cassettes and expected outputs
- tests/integration/helpers.py - Utilities (lock files, version discovery)
- tests/integration/generate_fixtures.py - Fixture generator
- tests/integration/test_declarative.py - API behavior tests
- tests/integration/test_consistency.py - Fixture integrity validation
- compose.yaml - Multi-version Netbox setup with demo data

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
ipam_vlans() is not defined for the clients version other than v42.
% make docker
docker compose up -d --wait --wait-timeout 120
[+] up 8/8
 ✔ Container annetbox-redis-1           Healthy
 ✔ Container annetbox-postgres-1        Healthy
 ✔ Container annetbox-netbox-v37-1      Healthy
 ✔ Container annetbox-netbox-v41-1      Healthy
 ✔ Container annetbox-netbox-v42-1      Healthy
 ✔ Container annetbox-netbox-init-v41-1 Exited
 ✔ Container annetbox-netbox-init-v37-1 Exited
 ✔ Container annetbox-netbox-init-v42-1 Exited

% make fixtures
python -m tests.integration.generate_fixtures
Processing v37/
        Ok: 9 Failed: 0
Processing v41/
        Ok: 9 Failed: 0
Processing v42/
        Ok: 10 Failed: 0
Problem summary:
    * v42 there are two Vrf classes.
    * v37 does not return description for Vrf.

Change summary:
v37:
    * rename embedded vrf: Vrf -> VrfBrief
    * remove description field from VrfBrief

v41:
    * rename embedded vrf: Vrf -> VrfBrief

v42:
    * rename embedded vrf: Vrf -> VrfBrief
@azryve azryve marked this pull request as ready for review May 7, 2026 11:31
@azryve azryve merged commit c09b712 into main May 8, 2026
3 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.

2 participants