tests: loopback DEL
This commit is contained in:
parent
80ab40470c
commit
4a5426b77a
@ -19,30 +19,21 @@ var _ = Describe("Loopback", func() {
|
||||
networkNS string
|
||||
containerID string
|
||||
command *exec.Cmd
|
||||
environ []string
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
command = exec.Command(pathToLoPlugin)
|
||||
|
||||
environ := os.Environ()
|
||||
|
||||
containerID = "some-container-id"
|
||||
networkNS = makeNetworkNS(containerID)
|
||||
|
||||
cniEnvVars := []string{
|
||||
fmt.Sprintf("CNI_COMMAND=%s", "ADD"),
|
||||
environ = []string{
|
||||
fmt.Sprintf("CNI_CONTAINERID=%s", containerID),
|
||||
fmt.Sprintf("CNI_NETNS=%s", networkNS),
|
||||
fmt.Sprintf("CNI_IFNAME=%s", "this is ignored"),
|
||||
fmt.Sprintf("CNI_ARGS=%s", "none"),
|
||||
fmt.Sprintf("CNI_PATH=%s", "/some/test/path"),
|
||||
}
|
||||
|
||||
for _, v := range cniEnvVars {
|
||||
environ = append(environ, v)
|
||||
}
|
||||
|
||||
command.Env = environ
|
||||
command.Stdin = strings.NewReader("this doesn't matter")
|
||||
})
|
||||
|
||||
@ -52,6 +43,8 @@ var _ = Describe("Loopback", func() {
|
||||
|
||||
Context("when given a network namespace", func() {
|
||||
It("sets the lo device to UP", func() {
|
||||
command.Env = append(environ, fmt.Sprintf("CNI_COMMAND=%s", "ADD"))
|
||||
|
||||
session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
@ -68,5 +61,25 @@ var _ = Describe("Loopback", func() {
|
||||
|
||||
Expect(lo.Flags & net.FlagUp).To(Equal(net.FlagUp))
|
||||
})
|
||||
|
||||
It("sets the lo device to DOWN", func() {
|
||||
command.Env = append(environ, fmt.Sprintf("CNI_COMMAND=%s", "DEL"))
|
||||
|
||||
session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
Eventually(session).Should(gbytes.Say(``))
|
||||
Eventually(session).Should(gexec.Exit(0))
|
||||
|
||||
var lo *net.Interface
|
||||
err = ns.WithNetNSPath(networkNS, true, func(hostNS *os.File) error {
|
||||
var err error
|
||||
lo, err = net.InterfaceByName("lo")
|
||||
return err
|
||||
})
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
Expect(lo.Flags & net.FlagUp).NotTo(Equal(net.FlagUp))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user