From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id EC6411FF13A for ; Wed, 01 Apr 2026 16:41:16 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D0AF431695; Wed, 1 Apr 2026 16:40:47 +0200 (CEST) From: Stefan Hanreich To: pve-devel@lists.proxmox.com Subject: [PATCH proxmox-ve-rs v2 16/34] ve-config: add route maps integration tests Date: Wed, 1 Apr 2026 16:39:25 +0200 Message-ID: <20260401143957.386809-17-s.hanreich@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260401143957.386809-1-s.hanreich@proxmox.com> References: <20260401143957.386809-1-s.hanreich@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1775054348932 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.708 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: JTJOL6FZG52KHSA5BZ3O3T6XSDA2BRQT X-Message-ID-Hash: JTJOL6FZG52KHSA5BZ3O3T6XSDA2BRQT X-MailFrom: s.hanreich@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Add full integration test for reading route maps configuration from a section config, parsing it and then writing a new FRR configuration from the section config file. Signed-off-by: Stefan Hanreich --- proxmox-ve-config/tests/route_maps/main.rs | 146 +++++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 proxmox-ve-config/tests/route_maps/main.rs diff --git a/proxmox-ve-config/tests/route_maps/main.rs b/proxmox-ve-config/tests/route_maps/main.rs new file mode 100644 index 0000000..081dfa5 --- /dev/null +++ b/proxmox-ve-config/tests/route_maps/main.rs @@ -0,0 +1,146 @@ +#![cfg(feature = "frr")] + +use proxmox_ve_config::sdn::route_map::{frr::build_frr_route_maps, *}; + +use proxmox_frr::ser::{serializer::dump, FrrConfig}; +use proxmox_section_config::typed::ApiSectionDataEntry; + +#[test] +fn test_build_route_map_order() -> Result<(), anyhow::Error> { + let section_config = r#" +route-map-entry: another_20 + action deny + +route-map-entry: another_50 + action deny + +route-map-entry: another_60 + action deny + +route-map-entry: another_40 + action deny + +route-map-entry: another_30 + action deny +"#; + + let config = RouteMap::parse_section_config("route-maps.cfg", section_config)?; + let mut frr_config = FrrConfig::default(); + + build_frr_route_maps( + config + .into_iter() + .map(|(_, route_map_entry)| route_map_entry), + &mut frr_config, + )?; + + assert_eq!( + dump(&frr_config)?, + r#"! +route-map another deny 20 +exit +! +route-map another deny 30 +exit +! +route-map another deny 40 +exit +! +route-map another deny 50 +exit +! +route-map another deny 60 +exit +"# + ); + + Ok(()) +} + +#[test] +fn test_build_route_map() -> Result<(), anyhow::Error> { + let section_config = r#" +route-map-entry: another_67 + action deny + match key=vni,value=313373 + match key=peer,value=some_peergroup + +route-map-entry: example_122 + action deny + match key=route-type,value=es + match key=vni,value=313373 + match key=ip-address-prefix-list,value=some_prefix_list + match key=ip-next-hop-prefix-list,value=some_other_prefix_list + match key=ip-next-hop-address,value=192.0.2.45 + match key=metric,value=8347 + match key=local-preference,value=8347 + match key=peer,value=some_interface + match key=peer,value=some_peergroup + set key=ip6-next-hop-peer-address + set key=ip6-next-hop-prefer-global + set key=ip6-next-hop,value=2001:DB8::1 + +route-map-entry: example_123 + action permit + match key=ip6-address-prefix-list,value=some_prefix_list + match key=ip6-next-hop-prefix-list,value=some_other_prefix_list + match key=ip6-next-hop-address,value=2001:DB8:cafe::BeeF + set key=ip-next-hop-peer-address + set key=ip-next-hop-unchanged + set key=ip-next-hop,value=198.51.100.3 + set key=local-preference,value=1234 + set key=tag,value=untagged + set key=weight,value=20 + set key=metric,value=+rtt +"#; + + let config = RouteMap::parse_section_config("route-maps.cfg", section_config)?; + let mut frr_config = FrrConfig::default(); + + build_frr_route_maps( + config + .into_iter() + .map(|(_, route_map_entry)| route_map_entry), + &mut frr_config, + )?; + + assert_eq!( + dump(&frr_config)?, + r#"! +route-map another deny 67 + match evpn vni 313373 + match peer some_peergroup +exit +! +route-map example deny 122 + match evpn route-type es + match evpn vni 313373 + match ip address prefix-list some_prefix_list + match ip next-hop prefix-list some_other_prefix_list + match ip next-hop address 192.0.2.45 + match metric 8347 + match local-preference 8347 + match peer some_interface + match peer some_peergroup + set ipv6 next-hop peer-address + set ipv6 next-hop prefer-global + set ipv6 next-hop global 2001:db8::1 +exit +! +route-map example permit 123 + match ipv6 address prefix-list some_prefix_list + match ipv6 next-hop prefix-list some_other_prefix_list + match ipv6 next-hop address 2001:db8:cafe::beef + set ip next-hop peer-address + set ip next-hop unchanged + set ip next-hop 198.51.100.3 + set local-preference 1234 + set tag untagged + set weight 20 + set metric +rtt +exit +"# + ); + + Ok(()) +} -- 2.47.3