Migrate slirp func tests from contexts to tables
@@ -27,6 +27,7 @@ import (
expect "github.com/google/goexpect"
. "github.com/onsi/ginkgo"
+ "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
"kubevirt.io/kubevirt/pkg/api/v1"
@@ -59,8 +60,8 @@ var _ = Describe("Slirp", func() {
}
})
- declareTestCases := func(vmiRef **v1.VirtualMachineInstance) {
- It("should start the virtual machine with slirp interface", func() {
+ table.DescribeTable("should be able to", func(vmiRef **v1.VirtualMachineInstance) {
+ By("start the virtual machine with slirp interface")
vmi := *vmiRef
vmiPod := tests.GetRunningPodByLabel(vmi.Name, v1.DomainLabel, tests.NamespaceTestDefault)
output, err := tests.ExecuteCommandOnPod(
@@ -72,11 +73,9 @@ var _ = Describe("Slirp", func() {
log.Log.Infof("%v", output)
Expect(err).ToNot(HaveOccurred())
Expect(strings.Contains(output, "0.0.0.0:80")).To(BeTrue())
- })
- It("should return \"Hello World!\" when connecting to localhost on port 80", func() {
- vmi := *vmiRef
- vmiPod := tests.GetRunningPodByLabel(vmi.Name, v1.DomainLabel, tests.NamespaceTestDefault)
- output, err := tests.ExecuteCommandOnPod(
+
+ By("return \"Hello World!\" when connecting to localhost on port 80")
+ output, err = tests.ExecuteCommandOnPod(
virtClient,
vmiPod,
vmiPod.Spec.Containers[1].Name,
@@ -86,11 +85,9 @@ var _ = Describe("Slirp", func() {
log.Log.Infof("%v", output)
Expect(err).ToNot(HaveOccurred())
Expect(strings.Contains(output, "Hello World!")).To(BeTrue())
- })
- It("should reject connecting to localhost and port different than 80", func() {
- vmi := *vmiRef
- vmiPod := tests.GetRunningPodByLabel(vmi.Name, v1.DomainLabel, tests.NamespaceTestDefault)
- output, err := tests.ExecuteCommandOnPod(
+
+ By("reject connecting to localhost and port different than 80")
+ output, err = tests.ExecuteCommandOnPod(
virtClient,
vmiPod,
vmiPod.Spec.Containers[1].Name,
@@ -98,9 +95,8 @@ var _ = Describe("Slirp", func() {
)
log.Log.Infof("%v", output)
Expect(err).To(HaveOccurred())
- })
- It("should be able to communicate with the outside world", func() {
- vmi := *vmiRef
+
+ By("communicate with the outside world")
expecter, _, err := tests.NewConsoleExpecter(virtClient, vmi, 10*time.Second)
defer expecter.Close()
Expect(err).ToNot(HaveOccurred())
@@ -113,13 +109,8 @@ var _ = Describe("Slirp", func() {
}, 180*time.Second)
log.Log.Infof("%v", out)
Expect(err).ToNot(HaveOccurred())
- })
- }
-
- Context("VirtualMachineInstance with slirp interface", func() {
- declareTestCases(&genericVmi)
- })
- Context("VirtualMachineInstance with slirp interface with custom MAC address", func() {
- declareTestCases(&deadbeafVmi)
- })
+ },
+ table.Entry("VirtualMachineInstance with slirp interface", &genericVmi),
+ table.Entry("VirtualMachineInstance with slirp interface with custom MAC address", &deadbeafVmi),
+ )
})
