all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Gabriel Goller <g.goller@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH pve-network 10/10] test: add test for frr.conf.local merging
Date: Tue,  3 Feb 2026 17:01:28 +0100	[thread overview]
Message-ID: <20260203160246.353351-22-g.goller@proxmox.com> (raw)
In-Reply-To: <20260203160246.353351-1-g.goller@proxmox.com>

Add a test that tests the frr.conf.local merging. This should ensure we
do not run into further regressions. The test also "succeeds" with the
pre-templates version, there are just some whitespace and "!" issues.
Also the route-maps are merged instead of pushed with higher sequence
number. This shouldn't change anything.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 src/test/run_test_zones.pl                    | 16 ++++-
 .../expected_controller_config                | 61 +++++++++++++++++++
 .../frr_local_merge/expected_sdn_interfaces   | 42 +++++++++++++
 .../zones/evpn/frr_local_merge/frr.conf.local | 30 +++++++++
 .../zones/evpn/frr_local_merge/interfaces     |  7 +++
 .../zones/evpn/frr_local_merge/sdn_config     | 24 ++++++++
 6 files changed, 177 insertions(+), 3 deletions(-)
 create mode 100644 src/test/zones/evpn/frr_local_merge/expected_controller_config
 create mode 100644 src/test/zones/evpn/frr_local_merge/expected_sdn_interfaces
 create mode 100644 src/test/zones/evpn/frr_local_merge/frr.conf.local
 create mode 100644 src/test/zones/evpn/frr_local_merge/interfaces
 create mode 100644 src/test/zones/evpn/frr_local_merge/sdn_config

diff --git a/src/test/run_test_zones.pl b/src/test/run_test_zones.pl
index 905b2f42e1dc..806225735e6b 100755
--- a/src/test/run_test_zones.pl
+++ b/src/test/run_test_zones.pl
@@ -126,12 +126,22 @@ foreach my $test (@tests) {
             reload_controller => sub {
                 return;
             },
-            read_local_frr_config => sub {
-                return;
-            },
         );
     }
 
+    # Mock read_local_frr_config in PVE::Network::SDN::Frr to support testing frr.conf.local merging
+    my $frr_local_config;
+    my $frr_local_path = "./$test/frr.conf.local";
+    if (-e $frr_local_path) {
+        $frr_local_config = read_file($frr_local_path);
+    }
+    my $mocked_frr = Test::MockModule->new('PVE::Network::SDN::Frr');
+    $mocked_frr->mock(
+        read_local_frr_config => sub {
+            return $frr_local_config;
+        },
+    );
+
     my $name = $test;
     my $expected = read_file("./$test/expected_sdn_interfaces");
 
diff --git a/src/test/zones/evpn/frr_local_merge/expected_controller_config b/src/test/zones/evpn/frr_local_merge/expected_controller_config
new file mode 100644
index 000000000000..9d47e080bf7a
--- /dev/null
+++ b/src/test/zones/evpn/frr_local_merge/expected_controller_config
@@ -0,0 +1,61 @@
+frr version 10.4.1
+frr defaults datacenter
+hostname localhost
+log syslog informational
+service integrated-vtysh-config
+!
+vrf vrf_myzone
+ vni 1000
+exit-vrf
+!
+router bgp 65000
+ bgp router-id 192.168.0.1
+ no bgp hard-administrative-reset
+ no bgp default ipv4-unicast
+ coalesce-time 1000
+ no bgp graceful-restart notification
+ neighbor VTEP peer-group
+ neighbor VTEP remote-as 65000
+ neighbor VTEP bfd
+ neighbor 192.168.0.2 peer-group VTEP
+ neighbor 192.168.0.3 peer-group VTEP
+ neighbor 192.168.1.1 remote-as 65001
+ neighbor 192.168.1.1 description "External Peer"
+ address-family ipv4 unicast
+  neighbor VTEP activate
+ exit-address-family
+ !
+ address-family l2vpn evpn
+  neighbor VTEP activate
+  neighbor VTEP route-map MAP_VTEP_IN in
+  neighbor VTEP route-map MAP_VTEP_OUT out
+  advertise-svi-ip
+  advertise-all-vni
+ exit-address-family
+exit
+!
+router bgp 65000 vrf vrf_myzone
+ bgp router-id 192.168.0.1
+ no bgp hard-administrative-reset
+ no bgp graceful-restart notification
+exit
+!
+route-map MAP_VTEP_IN permit 1
+exit
+!
+route-map MAP_VTEP_OUT permit 1
+ set community 65000:100
+exit
+route-map MAP_VTEP_IN permit 2
+ set community 65000:200
+exit
+!
+ip prefix-list PL_ALLOW seq 10 permit 10.0.0.0/8 le 24
+route-map CUSTOM_MAP permit 10
+ match ip address prefix-list PL_ALLOW
+exit
+!
+bgp community-list standard CL_LOCAL permit 65000:200
+!
+line vty
+!
diff --git a/src/test/zones/evpn/frr_local_merge/expected_sdn_interfaces b/src/test/zones/evpn/frr_local_merge/expected_sdn_interfaces
new file mode 100644
index 000000000000..9d1c64c0f3fa
--- /dev/null
+++ b/src/test/zones/evpn/frr_local_merge/expected_sdn_interfaces
@@ -0,0 +1,42 @@
+#version:1
+
+auto myvnet
+iface myvnet
+	address 10.0.0.1/24
+	hwaddress A2:1D:CB:1A:C0:8B
+	bridge_ports vxlan_myvnet
+	bridge_stp off
+	bridge_fd 0
+	mtu 1450
+	ip-forward on
+	arp-accept on
+	vrf vrf_myzone
+
+auto vrf_myzone
+iface vrf_myzone
+	vrf-table auto
+	post-up ip route add vrf vrf_myzone unreachable default metric 4278198272
+
+auto vrfbr_myzone
+iface vrfbr_myzone
+	bridge-ports vrfvx_myzone
+	bridge_stp off
+	bridge_fd 0
+	mtu 1450
+	vrf vrf_myzone
+
+auto vrfvx_myzone
+iface vrfvx_myzone
+	vxlan-id 1000
+	vxlan-local-tunnelip 192.168.0.1
+	bridge-learning off
+	bridge-arp-nd-suppress on
+	mtu 1450
+
+auto vxlan_myvnet
+iface vxlan_myvnet
+	vxlan-id 100
+	vxlan-local-tunnelip 192.168.0.1
+	bridge-learning off
+	bridge-arp-nd-suppress on
+	mtu 1450
diff --git a/src/test/zones/evpn/frr_local_merge/frr.conf.local b/src/test/zones/evpn/frr_local_merge/frr.conf.local
new file mode 100644
index 000000000000..a08f805cdabc
--- /dev/null
+++ b/src/test/zones/evpn/frr_local_merge/frr.conf.local
@@ -0,0 +1,30 @@
+!
+! Custom FRR configuration to be merged
+!
+router bgp 65000
+ neighbor 192.168.1.1 remote-as 65001
+ neighbor 192.168.1.1 description "External Peer"
+ address-family l2vpn evpn
+  advertise-svi-ip
+ exit-address-family
+ address-family ipv4 unicast
+  neighbor VTEP activate
+ exit-address-family
+exit
+!
+route-map MAP_VTEP_OUT permit 1
+ set community 65000:100
+exit
+!
+route-map MAP_VTEP_IN permit 2
+ set community 65000:200
+exit
+!
+ip prefix-list PL_ALLOW seq 10 permit 10.0.0.0/8 le 24
+!
+route-map CUSTOM_MAP permit 10
+ match ip address prefix-list PL_ALLOW
+exit
+!
+bgp community-list standard CL_LOCAL permit 65000:200
+!
diff --git a/src/test/zones/evpn/frr_local_merge/interfaces b/src/test/zones/evpn/frr_local_merge/interfaces
new file mode 100644
index 000000000000..66bb826a44b3
--- /dev/null
+++ b/src/test/zones/evpn/frr_local_merge/interfaces
@@ -0,0 +1,7 @@
+auto vmbr0
+iface vmbr0 inet static
+	address 192.168.0.1/24
+	gateway 192.168.0.254
+        bridge-ports eth0
+        bridge-stp off
+        bridge-fd 0
diff --git a/src/test/zones/evpn/frr_local_merge/sdn_config b/src/test/zones/evpn/frr_local_merge/sdn_config
new file mode 100644
index 000000000000..d6e44b7593c2
--- /dev/null
+++ b/src/test/zones/evpn/frr_local_merge/sdn_config
@@ -0,0 +1,24 @@
+{
+    version => 1,
+            vnets   => {
+                ids => {
+                    myvnet => { tag => "100", type => "vnet", zone => "myzone" },
+                },
+            },
+
+            zones   => {
+                ids => { myzone => { ipam => "pve", type => "evpn", controller => "evpnctl", 'vrf-vxlan' => 1000, 'mac' => 'A2:1D:CB:1A:C0:8B' } },
+            },
+            controllers  => {
+                ids => { evpnctl => { type => "evpn", 'peers' => '192.168.0.1,192.168.0.2,192.168.0.3', asn => "65000" } },
+            },
+
+            subnets => {
+                ids => { 'myzone-10.0.0.0-24' => {
+                    'type' => 'subnet',
+                    'vnet' => 'myvnet',
+                    'gateway' => '10.0.0.1',
+                }
+                }
+            }
+}
-- 
2.47.3





  parent reply	other threads:[~2026-02-03 16:05 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-03 16:01 [PATCH docs/manager/network/proxmox{-ve-rs,-perl-rs} 00/23] Generate frr config using jinja templates and rust types Gabriel Goller
2026-02-03 16:01 ` [PATCH proxmox-ve-rs 1/9] ve-config: firewall: cargo fmt Gabriel Goller
2026-02-03 16:01 ` [PATCH proxmox-ve-rs 2/9] frr: add proxmox-frr-templates package that contains templates Gabriel Goller
2026-02-03 16:01 ` [PATCH proxmox-ve-rs 3/9] ve-config: remove FrrConfigBuilder struct Gabriel Goller
2026-02-03 16:01 ` [PATCH proxmox-ve-rs 4/9] sdn-types: support variable-length NET identifier Gabriel Goller
2026-02-03 16:01 ` [PATCH proxmox-ve-rs 5/9] frr: add template serializer and serialize fabrics using templates Gabriel Goller
2026-02-03 16:01 ` [PATCH proxmox-ve-rs 6/9] frr: add isis configuration and templates Gabriel Goller
2026-02-03 16:01 ` [PATCH proxmox-ve-rs 7/9] frr: support custom frr configuration lines Gabriel Goller
2026-02-03 16:01 ` [PATCH proxmox-ve-rs 8/9] frr: add bgp support with templates and serialization Gabriel Goller
2026-02-03 16:01 ` [PATCH proxmox-ve-rs 9/9] frr: store frr template content as a const map Gabriel Goller
2026-02-03 16:01 ` [PATCH proxmox-perl-rs 1/2] sdn: add function to generate the frr config for all daemons Gabriel Goller
2026-02-03 16:01 ` [PATCH proxmox-perl-rs 2/2] sdn: add method to get a frr template Gabriel Goller
2026-02-03 16:01 ` [PATCH pve-network 01/10] sdn: remove duplicate comment line '!' in frr config Gabriel Goller
2026-02-03 16:01 ` [PATCH pve-network 02/10] sdn: tests: add missing comment " Gabriel Goller
2026-02-03 16:01 ` [PATCH pve-network 03/10] tests: use Test::Differences to make test assertions Gabriel Goller
2026-02-03 16:01 ` [PATCH pve-network 04/10] sdn: write structured frr config that can be rendered using templates Gabriel Goller
2026-02-03 16:01 ` [PATCH pve-network 05/10] tests: rearrange some statements in the frr config Gabriel Goller
2026-02-03 16:01 ` [PATCH pve-network 06/10] sdn: adjust frr.conf.local merging to rust template types Gabriel Goller
2026-02-03 16:01 ` [PATCH pve-network 07/10] cli: add pvesdn cli tool for managing frr template overrides Gabriel Goller
2026-02-03 16:01 ` [PATCH pve-network 08/10] debian: handle user modifications to FRR templates via ucf Gabriel Goller
2026-02-03 16:01 ` [PATCH pve-network 09/10] api: add dry-run endpoint for sdn apply to preview changes Gabriel Goller
2026-02-03 16:01 ` Gabriel Goller [this message]
2026-02-03 16:01 ` [PATCH pve-manager 1/1] sdn: add dry-run view for sdn apply Gabriel Goller
2026-02-03 16:01 ` [PATCH pve-docs 1/1] docs: add man page for the `pvesdn` cli Gabriel Goller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260203160246.353351-22-g.goller@proxmox.com \
    --to=g.goller@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal