Skip to content

Commit

Permalink
tests, ping: Use tests.PingFromVMConsole directly
Browse files Browse the repository at this point in the history
Use `tests.PingFromVMConsole` instead of `pingVirtualMachine`

Signed-off-by: Edward Haas <[email protected]>
  • Loading branch information
EdDev committed Aug 10, 2020
1 parent 36de964 commit 59503ed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
22 changes: 9 additions & 13 deletions tests/vmi_multus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ var _ = Describe("Multus", func() {
Expect(err).ToNot(HaveOccurred())
tests.WaitUntilVMIReady(detachedVMI, tests.LoggedInCirrosExpecter)

pingVirtualMachine(detachedVMI, "10.1.1.1", "\\$ ")
Expect(tests.PingFromVMConsole(detachedVMI, "10.1.1.1", "\\$ ")).To(Succeed())
})

It("[test_id:1752]should create a virtual machine with one interface with network definition from different namespace", func() {
Expand All @@ -186,7 +186,7 @@ var _ = Describe("Multus", func() {
Expect(err).ToNot(HaveOccurred())
tests.WaitUntilVMIReady(detachedVMI, tests.LoggedInCirrosExpecter)

pingVirtualMachine(detachedVMI, "10.1.1.1", "\\$ ")
Expect(tests.PingFromVMConsole(detachedVMI, "10.1.1.1", "\\$ ")).To(Succeed())
})

It("[test_id:1753]should create a virtual machine with two interfaces", func() {
Expand Down Expand Up @@ -222,7 +222,7 @@ var _ = Describe("Multus", func() {
checkInterface(detachedVMI, "eth0", "\\$ ")
checkInterface(detachedVMI, "eth1", "\\$ ")

pingVirtualMachine(detachedVMI, "10.1.1.1", "\\$ ")
Expect(tests.PingFromVMConsole(detachedVMI, "10.1.1.1", "\\$ ")).To(Succeed())
})
})

Expand All @@ -244,7 +244,7 @@ var _ = Describe("Multus", func() {
tests.WaitUntilVMIReady(detachedVMI, tests.LoggedInCirrosExpecter)

By("checking virtual machine instance can ping 10.1.1.1 using ptp cni plugin")
pingVirtualMachine(detachedVMI, "10.1.1.1", "\\$ ")
Expect(tests.PingFromVMConsole(detachedVMI, "10.1.1.1", "\\$ ")).To(Succeed())

By("checking virtual machine instance only has one interface")
// lo0, eth0
Expand Down Expand Up @@ -336,7 +336,7 @@ var _ = Describe("Multus", func() {
checkInterface(vmiTwo, "eth0", "localhost:~#")

By("ping between virtual machines")
pingVirtualMachine(vmiOne, "10.1.1.2", "localhost:~#")
Expect(tests.PingFromVMConsole(vmiOne, "10.1.1.2", "localhost:~#")).To(Succeed())
})

It("[test_id:1578]should create two virtual machines with two interfaces", func() {
Expand Down Expand Up @@ -365,7 +365,7 @@ var _ = Describe("Multus", func() {
checkInterface(vmiTwo, "eth1", "localhost:~#")

By("ping between virtual machines")
pingVirtualMachine(vmiOne, "10.1.1.2", "localhost:~#")
Expect(tests.PingFromVMConsole(vmiOne, "10.1.1.2", "localhost:~#")).To(Succeed())
})
})

Expand Down Expand Up @@ -409,7 +409,7 @@ var _ = Describe("Multus", func() {
Expect(strings.Contains(out, customMacAddress)).To(BeFalse())

By("Ping from the VM with the custom MAC to the other VM.")
pingVirtualMachine(vmiOne, "10.1.1.2", "localhost:~#")
Expect(tests.PingFromVMConsole(vmiOne, "10.1.1.2", "localhost:~#")).To(Succeed())
})
})
Context("Single VirtualMachineInstance with Linux bridge CNI plugin interface", func() {
Expand Down Expand Up @@ -864,8 +864,8 @@ var _ = Describe("SRIOV", func() {
configInterface(vmi2, "eth1", cidrB, "#")

// now check ICMP goes both ways
pingVirtualMachine(vmi1, cidrToIP(cidrB), "#")
pingVirtualMachine(vmi2, cidrToIP(cidrA), "#")
Expect(tests.PingFromVMConsole(vmi1, cidrToIP(cidrB), "#")).To(Succeed())
Expect(tests.PingFromVMConsole(vmi2, cidrToIP(cidrA), "#")).To(Succeed())
}

It("[test_id:3956]should connect to another machine with sriov interface over IPv4", func() {
Expand Down Expand Up @@ -935,10 +935,6 @@ func checkMacAddress(vmi *v1.VirtualMachineInstance, interfaceName, macAddress s
Expect(err).ToNot(HaveOccurred(), "MAC %q was not found in the VMI %s within the given timeout", macAddress, vmi.Name)
}

func pingVirtualMachine(vmi *v1.VirtualMachineInstance, ipAddr, prompt string) {
Expect(tests.PingFromVMConsole(vmi, ipAddr, prompt)).To(Succeed())
}

// Tests in Multus suite are expecting a Linux bridge to be available on each node, with iptables allowing
// traffic to go through. This function creates a Daemon Set on the cluster (if not exists yet), this Daemon
// Set creates a linux bridge and configures the firewall. We use iptables-compat in order to work with
Expand Down
7 changes: 4 additions & 3 deletions tests/vmi_networking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -766,11 +766,12 @@ var _ = Describe("[rfe_id:694][crit:medium][vendor:[email protected]][level:comp
ipv4NetworkCIDR = api.DefaultVMCIDR
}
By("Checking ping to gateway")
pingVirtualMachine(serverVMI, gatewayIPFromCIDR(ipv4NetworkCIDR), "\\$ ")
ipAddr := gatewayIPFromCIDR(ipv4NetworkCIDR)
Expect(tests.PingFromVMConsole(serverVMI, ipAddr, "\\$ ")).To(Succeed())

By("Checking ping to google")
pingVirtualMachine(serverVMI, "8.8.8.8", "\\$ ")
pingVirtualMachine(clientVMI, "google.com", "\\$ ")
Expect(tests.PingFromVMConsole(serverVMI, "8.8.8.8", "\\$ ")).To(Succeed())
Expect(tests.PingFromVMConsole(clientVMI, "google.com", "\\$ ")).To(Succeed())
}

By("starting a tcp server")
Expand Down

0 comments on commit 59503ed

Please sign in to comment.