f-50: lab: scénarios E5, configuration de l'agent par hyperviseur, release 0.2.0rc003 #50

Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
GnomeZworc 2026-10-04 20:43:53 +02:00
commit 5728fdd33c
Signed by: nicolas.boufideline
GPG key ID: 4406BBBF8845D632
25 changed files with 760 additions and 27 deletions

View file

@ -262,3 +262,37 @@ func TestRoles_SwitchLoopbackIsCreatedByTheSwitchScript(t *testing.T) {
t.Errorf("lab-switch:\n%s\ndoes not end with:\n%s", script, want)
}
}
func TestRoles_HypervisorAgentConfigIsWrittenBeforeTheDeployment(t *testing.T) {
doc := strings.Replace(withRoles, "frr: hv1.conf, release: 0.2.0rc002 }", "frr: hv1.conf, release: 0.2.0rc002, agent: two.yml }", 1)
nodes, err := Render(plan(t, doc), Options{RunDir: "/srv/lab", AuthorizedKeys: []string{labKey}, FRR: frrConfigs, Agent: map[string]string{"hv1": "dhcp:\n backend: two\n"}})
if err != nil {
t.Fatalf("Render: %v", err)
}
var hv1, hv2 Node
for _, n := range nodes {
switch n.Name {
case "hv1":
hv1 = n
case "hv2":
hv2 = n
}
}
f := fileAt(t, user(t, hv1), "/etc/two/agent.yml")
if f.Content != "dhcp:\n backend: two\n" || f.Permissions != "0640" {
t.Errorf("agent.yml (%s) = %q", f.Permissions, f.Content)
}
for _, w := range user(t, hv2).WriteFiles {
if w.Path == "/etc/two/agent.yml" {
t.Error("hv2 receives an agent.yml it does not declare")
}
}
}
func TestRoles_RefusesAnUnreadAgentConfig(t *testing.T) {
doc := strings.Replace(withRoles, "frr: hv1.conf, release: 0.2.0rc002 }", "frr: hv1.conf, release: 0.2.0rc002, agent: two.yml }", 1)
_, err := Render(plan(t, doc), Options{RunDir: "/srv/lab", AuthorizedKeys: []string{labKey}, FRR: frrConfigs})
if err == nil || err.Error() != "node hv1: agent configuration two.yml was not read" {
t.Errorf("error = %v", err)
}
}