Files
EvoBGP/internal/pipeline/speaker_overlay_test.go
Denozordec 927e27640a
quality / commitlint (push) Skipped
quality / changes (push) Successful in 8s
quality / docker-check (push) Skipped
quality / openapi (push) Successful in 26s
quality / web (push) Successful in 1m27s
quality / go (push) Successful in 1m18s
quality / bird2 (push) Successful in 16s
CD / quality (push) Successful in 3m43s
CD / publish (push) Successful in 3m11s
feat(docs): update speaker installation instructions and logging details
- Enhanced the speaker installation documentation to clarify the use of TCP port 179 and the logging commands for monitoring BIRD and evobgp-agent.
- Updated the speaker form dialog to include additional information about MikroTik connections and logging commands.
- Modified the BIRD configuration to include logging to stderr for better visibility during operations.
- Adjusted the Docker Compose configuration to ensure proper network settings and sysctl configurations for BGP functionality.
2026-08-21 16:11:28 +07:00

88 lines
2.5 KiB
Go

package pipeline_test
import (
"strings"
"testing"
"evobgp/internal/pipeline"
"evobgp/internal/store"
)
func TestOverlayFragmentsForSpeaker_differentRouterID(t *testing.T) {
m := store.NewMemory()
m.SeedDemo()
tenant, _, _, _, _ := m.DemoIDs()
sp1, _ := m.CreateSpeaker(tenant, &store.Speaker{
Role: "replica",
Endpoint: "https://203.0.113.1",
MetaJSON: `{"bird_bgp_source_ipv4":"203.0.113.1"}`,
})
sp2, _ := m.CreateSpeaker(tenant, &store.Speaker{
Role: "replica",
Endpoint: "https://203.0.113.2",
MetaJSON: `{"bird_bgp_source_ipv4":"203.0.113.2"}`,
})
base := map[string]string{
"bird.conf": "router id 192.0.2.1;\n# EvoBGP tenant aggregate config (trigger module mod) revision rev1",
}
out1, err := pipeline.OverlayFragmentsForSpeaker(m, tenant, sp1.ID, "rev1", base)
if err != nil {
t.Fatal(err)
}
out2, err := pipeline.OverlayFragmentsForSpeaker(m, tenant, sp2.ID, "rev1", base)
if err != nil {
t.Fatal(err)
}
if !strings.Contains(out1["bird.conf"], "203.0.113.1") {
t.Fatalf("sp1 router: %s", out1["bird.conf"])
}
if !strings.Contains(out2["bird.conf"], "203.0.113.2") {
t.Fatalf("sp2 router: %s", out2["bird.conf"])
}
}
func TestOverlayFragmentsForSpeaker_nodeIPv4Fallback(t *testing.T) {
m := store.NewMemory()
m.SeedDemo()
tenant, _, _, _, _ := m.DemoIDs()
sp, err := m.CreateSpeaker(tenant, &store.Speaker{
Role: "replica",
Endpoint: "https://node.example.com",
MetaJSON: `{"node_ipv4":"198.51.100.9"}`,
})
if err != nil {
t.Fatal(err)
}
out, err := pipeline.OverlayFragmentsForSpeaker(m, tenant, sp.ID, "rev1", nil)
if err != nil {
t.Fatal(err)
}
if !strings.Contains(out["bird.conf"], "198.51.100.9") {
t.Fatalf("expected node_ipv4 as router id, got: %s", out["bird.conf"])
}
}
func TestOverlayFragmentsForSpeaker_sourceOverridesNodeIPv4(t *testing.T) {
m := store.NewMemory()
m.SeedDemo()
tenant, _, _, _, _ := m.DemoIDs()
sp, err := m.CreateSpeaker(tenant, &store.Speaker{
Role: "replica",
Endpoint: "https://node.example.com",
MetaJSON: `{"node_ipv4":"198.51.100.9","bird_bgp_source_ipv4":"203.0.113.40"}`,
})
if err != nil {
t.Fatal(err)
}
out, err := pipeline.OverlayFragmentsForSpeaker(m, tenant, sp.ID, "rev1", map[string]string{})
if err != nil {
t.Fatal(err)
}
if !strings.Contains(out["bird.conf"], "203.0.113.40") {
t.Fatalf("source should win: %s", out["bird.conf"])
}
if strings.Contains(out["bird.conf"], "198.51.100.9") {
t.Fatalf("node_ipv4 should not win over source: %s", out["bird.conf"])
}
}