Skip to content

controller: extend unknown peer removal unit test to cover multi-VRF #3633

@nikw9944

Description

@nikw9944

Summary

The render_peer_removal_successful unit test in controlplane/controller/internal/controller/render_test.go only tests unknown BGP peer removal with a single VRF. The template (tunnel.tmpl) iterates UnknownBgpPeers inside each VRF block, but that code path is never exercised with multiple VRFs in the test suite.

What to change

render_test.go — In the render_peer_removal_successful test case:

  • Change UnicastVrfs: []uint16{1} to []uint16{1, 2}
  • Assign some tunnels to VrfId: 2 (e.g., keep tunnel 500 in VRF 1, move 501/502 to VRF 2)

fixtures/unknown.peer.removal.tmpl — Update the golden file to reflect multi-VRF output:

  • Add vrf instance vrf2 and ip routing vrf vrf2
  • Move affected tunnel interface declarations to vrf vrf2
  • Add a vrf vrf2 BGP section with the appropriate neighbors and no neighbor cleanup lines for the unknown peer

Why

The tunnel.tmpl template applies unknown peer removal inside each VRF iteration (lines 300–302):

{{- range $vrfId := .UnicastVrfs }}
   vrf vrf{{ $vrfId }}
      ...
      {{- range $.UnknownBgpPeers }}
      no neighbor {{ . }}
      {{- end }}
{{- end }}

Today, this is only tested with one VRF. A regression in multi-VRF unknown peer removal would go undetected by the unit test suite. The existing multi.vrf.tunnel.tmpl fixture tests multi-VRF rendering but uses UnknownBgpPeers: nil, so it doesn't cover this case.

Scope

Small change — roughly 15 lines in the test data and 20–30 lines in the fixture. No new test infrastructure needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions