Skip to content

Commit

Permalink
plugins/ptp: test for valid data in Interfaces field
Browse files Browse the repository at this point in the history
  • Loading branch information
Casey Callendrello committed Apr 11, 2018
1 parent 13e6a4b commit 26dafaa
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion plugins/main/ptp/ptp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,14 @@ var _ = Describe("ptp Operations", func() {
// Make sure ptp link exists in the target namespace
// Then, ping the gateway
seenIPs := 0

wantMac := ""
err = targetNs.Do(func(ns.NetNS) error {
defer GinkgoRecover()

link, err := netlink.LinkByName(IFNAME)
Expect(err).NotTo(HaveOccurred())
Expect(link.Attrs().Name).To(Equal(IFNAME))
wantMac = link.Attrs().HardwareAddr.String()

for _, ipc := range res.IPs {
if *ipc.Interface != 1 {
Expand All @@ -105,6 +107,17 @@ var _ = Describe("ptp Operations", func() {

Expect(seenIPs).To(Equal(numIPs))

// make sure the interfaces are correct
Expect(res.Interfaces).To(HaveLen(2))

Expect(res.Interfaces[0].Name).To(HavePrefix("veth"))
Expect(res.Interfaces[0].Mac).To(HaveLen(17))
Expect(res.Interfaces[0].Sandbox).To(BeEmpty())

Expect(res.Interfaces[1].Name).To(Equal(IFNAME))
Expect(res.Interfaces[1].Mac).To(Equal(wantMac))
Expect(res.Interfaces[1].Sandbox).To(Equal(targetNs.Path()))

// Call the plugins with the DEL command, deleting the veth endpoints
err = originalNS.Do(func(ns.NetNS) error {
defer GinkgoRecover()
Expand Down

0 comments on commit 26dafaa

Please sign in to comment.