f-41: config, frr: base BGP pilotée par l'agent au démarrage #41

Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
GnomeZworc 2026-10-11 19:52:46 +02:00
commit bf0e83862f
Signed by: nicolas.boufideline
GPG key ID: 4406BBBF8845D632
12 changed files with 331 additions and 18 deletions

View file

@ -10,6 +10,8 @@ import (
"testing"
"time"
configuration "git.g3e.fr/syonad/two/internal/config/agent"
"git.g3e.fr/syonad/two/internal/frr"
"git.g3e.fr/syonad/two/pkg/worker"
)
@ -96,3 +98,22 @@ func TestShutdown_SansServeur(t *testing.T) {
t.Fatal("l'absence de serveur ne doit pas empêcher un arrêt propre")
}
}
type fakeBase struct{ called bool }
func (f *fakeBase) ApplyBase(frr.Base) error {
f.called = true
return nil
}
func TestApplyBGPBase_RefusesAnInvalidSectionBeforeTouchingFRR(t *testing.T) {
cfg := &configuration.Config{}
cfg.BGP.RouteReflectors = []string{"10.255.255.1"}
f := &fakeBase{}
if err := applyBGPBase(cfg, f); err == nil || !strings.Contains(err.Error(), "bgp.asn must be set") {
t.Errorf("erreur %v", err)
}
if f.called {
t.Error("ApplyBase appelé avec une section bgp invalide")
}
}