feat: enhance evobgp with new command-line tools for bundle management, including pull, verify, and apply functionalities. Update go.mod to include necessary dependencies and complete todos in architecture plan for improved observability and deployment practices.
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
package birdfmt
|
||||
|
||||
import (
|
||||
"net/netip"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// Ensures generator output matches the standard_layout scenario files (CI bird -p).
|
||||
func TestStandardLayout_GeneratorMatchesFixtures(t *testing.T) {
|
||||
p4 := netip.MustParsePrefix("203.0.113.0/24")
|
||||
|
||||
f4, err := RenderExportFilterIPv4("evobgp_export_v4", []netip.Prefix{p4})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assertFileEquals(t, "testdata/scenarios/standard_layout/bird.d/evobgp_filters_v4.conf", f4)
|
||||
|
||||
f6, err := RenderExportFilterIPv6("evobgp_export_v6", nil)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assertFileEquals(t, "testdata/scenarios/standard_layout/bird.d/evobgp_filters_v6.conf", f6)
|
||||
|
||||
staticV4 := RenderStaticIPv4Protocol("evobgp_prefixes_v4", []netip.Prefix{p4})
|
||||
assertFileEquals(t, "testdata/scenarios/standard_layout/bird.d/evobgp_prefixes_v4.conf", staticV4)
|
||||
|
||||
staticV6 := RenderStaticIPv6Protocol("evobgp_prefixes_v6", nil)
|
||||
assertFileEquals(t, "testdata/scenarios/standard_layout/bird.d/evobgp_prefixes_v6.conf", staticV6)
|
||||
|
||||
peer, err := RenderProtocolBGPIPv4(BGPPeerIPv4Options{
|
||||
ProtocolName: "evobgp_peer_ci",
|
||||
LocalIP: "192.0.2.1",
|
||||
LocalASN: 65001,
|
||||
NeighborIP: "192.0.2.2",
|
||||
NeighborASN: 65002,
|
||||
ExportFilter: "evobgp_export_v4",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
assertFileEquals(t, "testdata/scenarios/standard_layout/bird.d/evobgp_peers.conf", peer)
|
||||
|
||||
main, err := RenderMainBirdConf(MainBirdConfOptions{
|
||||
RouterID: "192.0.2.1",
|
||||
Includes: StandardIncludeFragments(),
|
||||
Preamble: "tags: layout, include, filter, peer\nStandard EvoBGP layout: main skeleton + bird.d fragments (matches StandardIncludeFragments).",
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// Fixture has two header comment lines; RenderMainBirdConf adds # per line.
|
||||
wantMain, err := os.ReadFile("testdata/scenarios/standard_layout/bird.conf")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if strings.TrimSpace(main) != strings.TrimSpace(string(wantMain)) {
|
||||
t.Fatalf("main bird.conf mismatch\n--- got ---\n%s\n--- want ---\n%s", main, wantMain)
|
||||
}
|
||||
}
|
||||
|
||||
func assertFileEquals(t *testing.T, path, content string) {
|
||||
t.Helper()
|
||||
want, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if strings.TrimSpace(content) != strings.TrimSpace(string(want)) {
|
||||
t.Fatalf("%s mismatch\n--- got ---\n%s\n--- want ---\n%s", path, content, string(want))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user