top-level integration test for bridge + bandwidth
This commit is contained in:
parent
2793dd11cb
commit
d5bdfe4cbd
@ -27,10 +27,10 @@ import (
|
|||||||
|
|
||||||
var _ = Describe("Basic PTP using cnitool", func() {
|
var _ = Describe("Basic PTP using cnitool", func() {
|
||||||
var (
|
var (
|
||||||
env TestEnv
|
env TestEnv
|
||||||
nsShortName string
|
hostNS NSShortName
|
||||||
nsLongName string
|
contNS NSShortName
|
||||||
cnitoolBin string
|
cnitoolBin string
|
||||||
)
|
)
|
||||||
|
|
||||||
BeforeEach(func() {
|
BeforeEach(func() {
|
||||||
@ -47,32 +47,37 @@ var _ = Describe("Basic PTP using cnitool", func() {
|
|||||||
"PATH=" + os.Getenv("PATH"),
|
"PATH=" + os.Getenv("PATH"),
|
||||||
})
|
})
|
||||||
|
|
||||||
nsShortName = fmt.Sprintf("cni-test-%x", rand.Int31())
|
hostNS = NSShortName(fmt.Sprintf("cni-test-host-%x", rand.Int31()))
|
||||||
nsLongName = fmt.Sprintf("/var/run/netns/" + nsShortName)
|
hostNS.Add()
|
||||||
|
|
||||||
|
contNS = NSShortName(fmt.Sprintf("cni-test-cont-%x", rand.Int31()))
|
||||||
|
contNS.Add()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
AfterEach(func() {
|
||||||
|
contNS.Del()
|
||||||
|
hostNS.Del()
|
||||||
|
})
|
||||||
|
|
||||||
|
basicAssertion := func(netName, expectedIPPrefix string) {
|
||||||
|
env.runInNS(hostNS, cnitoolBin, "add", netName, contNS.LongName())
|
||||||
|
|
||||||
|
addrOutput := env.runInNS(contNS, "ip", "addr")
|
||||||
|
Expect(addrOutput).To(ContainSubstring(expectedIPPrefix))
|
||||||
|
|
||||||
|
env.runInNS(hostNS, cnitoolBin, "del", netName, contNS.LongName())
|
||||||
|
}
|
||||||
|
|
||||||
It("supports basic network add and del operations", func() {
|
It("supports basic network add and del operations", func() {
|
||||||
env.run("ip", "netns", "add", nsShortName)
|
basicAssertion("basic-ptp", "10.1.2.")
|
||||||
defer env.run("ip", "netns", "del", nsShortName)
|
|
||||||
|
|
||||||
env.run(cnitoolBin, "add", "basic-ptp", nsLongName)
|
|
||||||
|
|
||||||
addrOutput := env.run("ip", "netns", "exec", nsShortName, "ip", "addr")
|
|
||||||
Expect(addrOutput).To(ContainSubstring("10.1.2."))
|
|
||||||
|
|
||||||
env.run(cnitoolBin, "del", "basic-ptp", nsLongName)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
It("supports add and del with chained plugins", func() {
|
It("supports add and del with ptp + bandwidth", func() {
|
||||||
env.run("ip", "netns", "add", nsShortName)
|
basicAssertion("chained-ptp-bandwidth", "10.9.2.")
|
||||||
defer env.run("ip", "netns", "del", nsShortName)
|
})
|
||||||
|
|
||||||
env.run(cnitoolBin, "add", "chained-ptp-bandwidth", nsLongName)
|
It("supports add and del with bridge + bandwidth", func() {
|
||||||
|
basicAssertion("chained-bridge-bandwidth", "10.11.2.")
|
||||||
addrOutput := env.run("ip", "netns", "exec", nsShortName, "ip", "addr")
|
|
||||||
Expect(addrOutput).To(ContainSubstring("10.9.2."))
|
|
||||||
|
|
||||||
env.run(cnitoolBin, "del", "chained-ptp-bandwidth", nsLongName)
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -86,3 +91,22 @@ func (e TestEnv) run(bin string, args ...string) string {
|
|||||||
Eventually(session, "5s").Should(gexec.Exit(0))
|
Eventually(session, "5s").Should(gexec.Exit(0))
|
||||||
return string(session.Out.Contents())
|
return string(session.Out.Contents())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (e TestEnv) runInNS(nsShortName NSShortName, bin string, args ...string) string {
|
||||||
|
a := append([]string{"netns", "exec", string(nsShortName), bin}, args...)
|
||||||
|
return e.run("ip", a...)
|
||||||
|
}
|
||||||
|
|
||||||
|
type NSShortName string
|
||||||
|
|
||||||
|
func (n NSShortName) LongName() string {
|
||||||
|
return fmt.Sprintf("/var/run/netns/%s", n)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n NSShortName) Add() {
|
||||||
|
(TestEnv{}).run("ip", "netns", "add", string(n))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (n NSShortName) Del() {
|
||||||
|
(TestEnv{}).run("ip", "netns", "del", string(n))
|
||||||
|
}
|
||||||
|
20
integration/testdata/chained-bridge-bandwidth.conflist
vendored
Normal file
20
integration/testdata/chained-bridge-bandwidth.conflist
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"cniVersion": "0.3.1",
|
||||||
|
"name": "chained-bridge-bandwidth",
|
||||||
|
"plugins": [
|
||||||
|
{
|
||||||
|
"type": "bridge",
|
||||||
|
"ipam": {
|
||||||
|
"type": "host-local",
|
||||||
|
"subnet": "10.11.2.0/24"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "bandwidth",
|
||||||
|
"ingressRate": 800,
|
||||||
|
"ingressBurst": 200,
|
||||||
|
"egressRate": 800,
|
||||||
|
"egressBurst": 200
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user