labctl: segments sur des bridges de l'hôte, routeurs et passerelle VRRP #2
All checks were successful
Tests / test (push) Successful in 3m46s
All checks were successful
Tests / test (push) Successful in 3m46s
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
e0de56a64f
commit
e9a0c19b72
24 changed files with 1766 additions and 578 deletions
|
|
@ -11,9 +11,9 @@ import (
|
|||
|
||||
const withRoles = header + `
|
||||
segments:
|
||||
underlay: { switch: sw1, cidr: 192.168.14.0/24 }
|
||||
underlay: { routers: [sw1], cidr: 192.168.14.0/24 }
|
||||
nodes:
|
||||
sw1: { role: switch, image: deb, cpus: 2, memory: 1024, secondary: { underlay: [169.254.0.1/28] }, frr: frr/sw1.conf }
|
||||
sw1: { role: router, image: deb, cpus: 2, memory: 1024, segments: [underlay], secondary: { underlay: [169.254.0.1/28] }, frr: frr/sw1.conf }
|
||||
rr1: { role: rr, image: deb, cpus: 1, memory: 1024, segments: [underlay], secondary: { underlay: [169.254.0.3/28] }, loopback: 10.255.255.1/32, frr: frr/rr1.conf }
|
||||
hv1: { role: host, image: deb, cpus: 4, memory: 16384, segments: [underlay], frr: /etc/lab/hv1.conf, provision: provision/hv.sh, post_provision: /opt/lab/post.sh, files: { agent.yml: agent/two.yml, deploy.sh: /opt/deploy.sh }, services: [agent.service] }
|
||||
`
|
||||
|
|
@ -95,10 +95,10 @@ func TestValidate_RoleFieldRejections(t *testing.T) {
|
|||
t.Run(name, func(t *testing.T) {
|
||||
doc := header + `
|
||||
segments:
|
||||
red: { switch: sw, cidr: 10.1.0.0/24 }
|
||||
blue: { switch: sw, cidr: 10.2.0.0/24 }
|
||||
red: { routers: [sw], cidr: 10.1.0.0/24 }
|
||||
blue: { routers: [sw], cidr: 10.2.0.0/24 }
|
||||
nodes:
|
||||
sw: { role: switch, image: deb, cpus: 1, memory: 512 }
|
||||
sw: { role: router, image: deb, cpus: 1, memory: 512, segments: [red, blue] }
|
||||
hv: { role: host, image: deb, cpus: 1, memory: 512, segments: [red, blue] }
|
||||
` + c.node + `
|
||||
`
|
||||
|
|
@ -107,29 +107,29 @@ nodes:
|
|||
}
|
||||
}
|
||||
|
||||
func TestValidate_SwitchSecondaryOnlyOnItsOwnSegments(t *testing.T) {
|
||||
func TestValidate_RouterSecondaryOnlyOnItsOwnSegments(t *testing.T) {
|
||||
doc := header + `
|
||||
segments:
|
||||
red: { switch: sw, cidr: 10.1.0.0/24 }
|
||||
blue: { switch: other, cidr: 10.2.0.0/24 }
|
||||
red: { routers: [sw], cidr: 10.1.0.0/24 }
|
||||
blue: { routers: [other], cidr: 10.2.0.0/24 }
|
||||
nodes:
|
||||
sw: { role: switch, image: deb, cpus: 1, memory: 512, secondary: { red: [169.254.0.1/28], blue: [169.254.1.1/28] } }
|
||||
other: { role: switch, image: deb, cpus: 1, memory: 512 }
|
||||
sw: { role: router, image: deb, cpus: 1, memory: 512, segments: [red], secondary: { red: [169.254.0.1/28], blue: [169.254.1.1/28] } }
|
||||
other: { role: router, image: deb, cpus: 1, memory: 512, segments: [blue] }
|
||||
hv: { role: host, image: deb, cpus: 1, memory: 512, segments: [red, blue] }
|
||||
`
|
||||
msg := validationError(t, doc)
|
||||
requireContains(t, msg, "node sw: secondary address given for segment blue it is not attached to")
|
||||
if bytes.Contains([]byte(msg), []byte("segment red")) {
|
||||
t.Errorf("the switch's own segment was refused:\n%s", msg)
|
||||
t.Errorf("the router's own segment was refused:\n%s", msg)
|
||||
}
|
||||
}
|
||||
|
||||
func TestValidate_LoopbackInterfaceNameIsReserved(t *testing.T) {
|
||||
doc := header + `
|
||||
segments:
|
||||
lo1: { switch: sw, cidr: 10.1.0.0/24 }
|
||||
lo1: { routers: [sw], cidr: 10.1.0.0/24 }
|
||||
nodes:
|
||||
sw: { role: switch, image: deb, cpus: 1, memory: 512 }
|
||||
sw: { role: router, image: deb, cpus: 1, memory: 512, segments: [lo1] }
|
||||
hv: { role: host, image: deb, cpus: 1, memory: 512, segments: [lo1] }
|
||||
`
|
||||
requireContains(t, validationError(t, doc), "segment lo1: name is reserved for the loopback interface")
|
||||
|
|
@ -156,9 +156,9 @@ func TestWrite_NoRolesSectionWithoutRoleFields(t *testing.T) {
|
|||
var buf bytes.Buffer
|
||||
doc := header + `
|
||||
segments:
|
||||
underlay: { switch: sw1, cidr: 10.250.0.0/24 }
|
||||
underlay: { routers: [sw1], cidr: 10.250.0.0/24 }
|
||||
nodes:
|
||||
sw1: { role: switch, image: deb, cpus: 1, memory: 512 }
|
||||
sw1: { role: router, image: deb, cpus: 1, memory: 512, segments: [underlay] }
|
||||
rr1: { role: rr, image: deb, cpus: 1, memory: 512, segments: [underlay] }
|
||||
`
|
||||
if err := compute(t, doc).Write(&buf); err != nil {
|
||||
|
|
@ -176,7 +176,7 @@ func TestValidate_ProvisionRejections(t *testing.T) {
|
|||
}{
|
||||
"the hypervisor role is gone": {
|
||||
`hv: { role: hypervisor, image: deb, cpus: 1, memory: 512, segments: [red] }`,
|
||||
`node hv: role "hypervisor" must be one of switch, rr, host`,
|
||||
`node hv: role "hypervisor" must be one of router, rr, host`,
|
||||
},
|
||||
"file name leaving the files directory": {
|
||||
`hv: { role: host, image: deb, cpus: 1, memory: 512, segments: [red], files: { ../etc/passwd: a.yml } }`,
|
||||
|
|
@ -203,9 +203,9 @@ func TestValidate_ProvisionRejections(t *testing.T) {
|
|||
t.Run(name, func(t *testing.T) {
|
||||
doc := header + `
|
||||
segments:
|
||||
red: { switch: sw, cidr: 10.1.0.0/24 }
|
||||
red: { routers: [sw], cidr: 10.1.0.0/24 }
|
||||
nodes:
|
||||
sw: { role: switch, image: deb, cpus: 1, memory: 512 }
|
||||
sw: { role: router, image: deb, cpus: 1, memory: 512, segments: [red] }
|
||||
` + c.node + `
|
||||
`
|
||||
requireContains(t, validationError(t, doc), c.want)
|
||||
|
|
@ -216,9 +216,9 @@ nodes:
|
|||
func TestValidate_ProvisionIsAllowedOnEveryRole(t *testing.T) {
|
||||
doc := header + `
|
||||
segments:
|
||||
red: { switch: sw, cidr: 10.1.0.0/24 }
|
||||
red: { routers: [sw], cidr: 10.1.0.0/24 }
|
||||
nodes:
|
||||
sw: { role: switch, image: deb, cpus: 1, memory: 512, provision: sw.sh, files: { a.conf: a.conf }, services: [lab-switch.service] }
|
||||
sw: { role: router, image: deb, cpus: 1, memory: 512, segments: [red], provision: sw.sh, files: { a.conf: a.conf }, services: [lab-router.service] }
|
||||
rr: { role: rr, image: deb, cpus: 1, memory: 512, segments: [red], provision: rr.sh, post_provision: rr-post.sh }
|
||||
hv: { role: host, image: deb, cpus: 1, memory: 512, segments: [red], files: { agent.yml: agent.yml }, services: [agent.service] }
|
||||
`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue