forked from kubevirt/kubevirt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
expose_test.go
473 lines (399 loc) · 19.8 KB
/
expose_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
package tests_test
import (
"flag"
"fmt"
"strconv"
"time"
expect "github.com/google/goexpect"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
k8sv1 "k8s.io/api/core/v1"
k8smetav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "kubevirt.io/kubevirt/pkg/api/v1"
"kubevirt.io/kubevirt/pkg/kubecli"
"kubevirt.io/kubevirt/pkg/virtctl/expose"
"kubevirt.io/kubevirt/tests"
)
func newLabeledVM(label string, virtClient kubecli.KubevirtClient) (vmi *v1.VirtualMachineInstance) {
ports := []v1.Port{{Name: "http", Port: 80}, {Name: "udp", Port: 82, Protocol: "UDP"}}
vmi = tests.NewRandomVMIWithBridgeInterfaceEphemeralDiskAndUserdata(tests.ContainerDiskFor(tests.ContainerDiskCirros), "#!/bin/bash\necho 'hello'\n", ports)
vmi.Labels = map[string]string{"expose": label}
vmi, err := virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Create(vmi)
Expect(err).ToNot(HaveOccurred())
tests.WaitForSuccessfulVMIStartIgnoreWarnings(vmi)
vmi, err = virtClient.VirtualMachineInstance(tests.NamespaceTestDefault).Get(vmi.ObjectMeta.Name, &k8smetav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
return
}
func generateHelloWorldServer(vmi *v1.VirtualMachineInstance, virtClient kubecli.KubevirtClient, testPort int, protocol string) {
expecter, err := tests.LoggedInCirrosExpecter(vmi)
Expect(err).ToNot(HaveOccurred())
defer expecter.Close()
serverCommand := fmt.Sprintf("screen -d -m sudo nc -klp %d -e echo -e 'Hello World!'\n", testPort)
if protocol == "udp" {
// nc has to be in a while loop in case of UDP, since it exists after one message
serverCommand = fmt.Sprintf("screen -d -m sh -c \"while true\n do nc -uklp %d -e echo -e 'Hello UDP World!'\ndone\n\"\n", testPort)
}
_, err = expecter.ExpectBatch([]expect.Batcher{
&expect.BSnd{S: serverCommand},
&expect.BExp{R: "\\$ "},
&expect.BSnd{S: "echo $?\n"},
&expect.BExp{R: "0"},
}, 60*time.Second)
Expect(err).ToNot(HaveOccurred())
}
var _ = Describe("Expose", func() {
flag.Parse()
virtClient, err := kubecli.GetKubevirtClient()
tests.PanicOnError(err)
const testPort = 1500
Context("[rfe_id:253][crit:medium][vendor:[email protected]][level:component]Expose service on a VM", func() {
var tcpVM *v1.VirtualMachineInstance
tests.BeforeAll(func() {
tcpVM = newLabeledVM("vm", virtClient)
generateHelloWorldServer(tcpVM, virtClient, testPort, "tcp")
})
Context("Expose ClusterIP service", func() {
const servicePort = "27017"
const serviceName = "cluster-ip-vmi"
It("[test_id:1531]Should expose a Cluster IP service on a VMI and connect to it", func() {
By("Exposing the service via virtctl command")
virtctl := tests.NewRepeatableVirtctlCommand(expose.COMMAND_EXPOSE, "virtualmachineinstance", "--namespace",
tcpVM.Namespace, tcpVM.Name, "--port", servicePort, "--name", serviceName, "--target-port", strconv.Itoa(testPort))
err := virtctl()
Expect(err).ToNot(HaveOccurred())
By("Getting back the cluster IP given for the service")
svc, err := virtClient.CoreV1().Services(tcpVM.Namespace).Get(serviceName, k8smetav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
serviceIP := svc.Spec.ClusterIP
By("Starting a pod which tries to reach the VMI via ClusterIP")
job := tests.NewHelloWorldJob(serviceIP, servicePort)
job, err = virtClient.CoreV1().Pods(tcpVM.Namespace).Create(job)
Expect(err).ToNot(HaveOccurred())
By("Waiting for the pod to report a successful connection attempt")
getStatus := func() k8sv1.PodPhase {
pod, err := virtClient.CoreV1().Pods(job.Namespace).Get(job.Name, k8smetav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
return pod.Status.Phase
}
Eventually(getStatus, 60, 1).Should(Equal(k8sv1.PodSucceeded))
})
})
Context("Expose ClusterIP service with string target-port", func() {
const servicePort = "27017"
const serviceName = "cluster-ip-target-vmi"
It("[test_id:1532]Should expose a ClusterIP service and connect to the vm on port 80", func() {
virtctl := tests.NewRepeatableVirtctlCommand(expose.COMMAND_EXPOSE, "virtualmachineinstance", "--namespace",
tcpVM.Namespace, tcpVM.Name, "--port", servicePort, "--name", serviceName, "--target-port", "http")
err := virtctl()
Expect(err).ToNot(HaveOccurred())
By("Waiting for kubernetes to create the relevant endpoint")
getEndpoint := func() error {
_, err := virtClient.CoreV1().Endpoints(tests.NamespaceTestDefault).Get(serviceName, k8smetav1.GetOptions{})
return err
}
Eventually(getEndpoint, 60, 1).Should(BeNil())
endpoints, err := virtClient.CoreV1().Endpoints(tests.NamespaceTestDefault).Get(serviceName, k8smetav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
Expect(len(endpoints.Subsets)).To(Equal(1))
endpoint := endpoints.Subsets[0]
Expect(len(endpoint.Ports)).To(Equal(1))
Expect(endpoint.Ports[0].Port).To(Equal(int32(80)))
})
})
Context("Expose ClusterIP service wiht ports on the vmi defined", func() {
const serviceName = "cluster-ip-target-multiple-ports-vmi"
It("[test_id:1533]Should expose a ClusterIP service and connect to all ports defined on the vmi", func() {
virtctl := tests.NewRepeatableVirtctlCommand(expose.COMMAND_EXPOSE, "virtualmachineinstance", "--namespace",
tcpVM.Namespace, tcpVM.Name, "--name", serviceName)
err := virtctl()
Expect(err).ToNot(HaveOccurred())
By("Waiting for kubernetes to create the relevant endpoint")
getEndpoint := func() error {
_, err := virtClient.CoreV1().Endpoints(tests.NamespaceTestDefault).Get(serviceName, k8smetav1.GetOptions{})
return err
}
Eventually(getEndpoint, 60, 1).Should(BeNil())
endpoints, err := virtClient.CoreV1().Endpoints(tests.NamespaceTestDefault).Get(serviceName, k8smetav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
Expect(len(endpoints.Subsets)).To(Equal(1))
endpoint := endpoints.Subsets[0]
Expect(len(endpoint.Ports)).To(Equal(2))
Expect(endpoint.Ports).To(ContainElement(k8sv1.EndpointPort{Name: "port-1", Port: 80, Protocol: "TCP"}))
Expect(endpoint.Ports).To(ContainElement(k8sv1.EndpointPort{Name: "port-2", Port: 82, Protocol: "UDP"}))
})
})
Context("Expose NodePort service", func() {
const servicePort = "27017"
const serviceName = "node-port-vmi"
It("[test_id:1534]Should expose a NodePort service on a VMI and connect to it", func() {
By("Exposing the service via virtctl command")
virtctl := tests.NewRepeatableVirtctlCommand(expose.COMMAND_EXPOSE, "virtualmachineinstance", "--namespace",
tcpVM.Namespace, tcpVM.Name, "--port", servicePort, "--name", serviceName, "--target-port", strconv.Itoa(testPort),
"--type", "NodePort")
err := virtctl()
Expect(err).ToNot(HaveOccurred())
By("Getting back the the service")
svc, err := virtClient.CoreV1().Services(tcpVM.Namespace).Get(serviceName, k8smetav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
nodePort := svc.Spec.Ports[0].NodePort
Expect(nodePort).To(BeNumerically(">", 0))
By("Getting the node IP from all nodes")
nodes, err := virtClient.CoreV1().Nodes().List(k8smetav1.ListOptions{})
Expect(err).ToNot(HaveOccurred())
Expect(nodes.Items).ToNot(BeEmpty())
for _, node := range nodes.Items {
Expect(node.Status.Addresses).ToNot(BeEmpty())
nodeIP := node.Status.Addresses[0].Address
By("Starting a pod which tries to reach the VMI via NodePort")
job := tests.NewHelloWorldJob(nodeIP, strconv.Itoa(int(nodePort)))
job, err = virtClient.CoreV1().Pods(tcpVM.Namespace).Create(job)
Expect(err).ToNot(HaveOccurred())
By("Waiting for the pod to report a successful connection attempt")
getStatus := func() k8sv1.PodPhase {
pod, err := virtClient.CoreV1().Pods(job.Namespace).Get(job.Name, k8smetav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
return pod.Status.Phase
}
Eventually(getStatus, 60, 1).Should(Equal(k8sv1.PodSucceeded))
}
})
})
})
Context("Expose UDP service on a VMI", func() {
var udpVM *v1.VirtualMachineInstance
tests.BeforeAll(func() {
udpVM = newLabeledVM("udp-vm", virtClient)
generateHelloWorldServer(udpVM, virtClient, testPort, "udp")
})
Context("Expose ClusterIP UDP service", func() {
const servicePort = "28017"
const serviceName = "cluster-ip-udp-vmi"
It("[test_id:1535]Should expose a ClusterIP service on a VMI and connect to it", func() {
By("Exposing the service via virtctl command")
virtctl := tests.NewRepeatableVirtctlCommand(expose.COMMAND_EXPOSE, "virtualmachineinstance", "--namespace",
udpVM.Namespace, udpVM.Name, "--port", servicePort, "--name", serviceName, "--target-port", strconv.Itoa(testPort),
"--protocol", "UDP")
err := virtctl()
Expect(err).ToNot(HaveOccurred())
By("Getting back the cluster IP given for the service")
svc, err := virtClient.CoreV1().Services(udpVM.Namespace).Get(serviceName, k8smetav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
serviceIP := svc.Spec.ClusterIP
By("Starting a pod which tries to reach the VMI via ClusterIP")
job := tests.NewHelloWorldJobUDP(serviceIP, servicePort)
job, err = virtClient.CoreV1().Pods(udpVM.Namespace).Create(job)
Expect(err).ToNot(HaveOccurred())
By("Waiting for the pod to report a successful connection attempt")
getStatus := func() k8sv1.PodPhase {
pod, err := virtClient.CoreV1().Pods(job.Namespace).Get(job.Name, k8smetav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
return pod.Status.Phase
}
Eventually(getStatus, 60, 1).Should(Equal(k8sv1.PodSucceeded))
})
})
Context("Expose NodePort UDP service", func() {
const servicePort = "29017"
const serviceName = "node-port-udp-vmi"
It("[test_id:1536]Should expose a NodePort service on a VMI and connect to it", func() {
By("Exposing the service via virtctl command")
virtctl := tests.NewRepeatableVirtctlCommand(expose.COMMAND_EXPOSE, "virtualmachineinstance", "--namespace",
udpVM.Namespace, udpVM.Name, "--port", servicePort, "--name", serviceName, "--target-port", strconv.Itoa(testPort),
"--type", "NodePort", "--protocol", "UDP")
err := virtctl()
Expect(err).ToNot(HaveOccurred())
By("Getting back the cluster IP given for the service")
svc, err := virtClient.CoreV1().Services(udpVM.Namespace).Get(serviceName, k8smetav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
serviceIP := svc.Spec.ClusterIP
nodePort := svc.Spec.Ports[0].NodePort
Expect(nodePort).To(BeNumerically(">", 0))
By("Starting a pod which tries to reach the VMI via ClusterIP")
job := tests.NewHelloWorldJobUDP(serviceIP, servicePort)
job, err = virtClient.CoreV1().Pods(udpVM.Namespace).Create(job)
Expect(err).ToNot(HaveOccurred())
By("Getting the node IP from all nodes")
nodes, err := virtClient.CoreV1().Nodes().List(k8smetav1.ListOptions{})
Expect(err).ToNot(HaveOccurred())
Expect(nodes.Items).ToNot(BeEmpty())
for _, node := range nodes.Items {
Expect(node.Status.Addresses).ToNot(BeEmpty())
nodeIP := node.Status.Addresses[0].Address
By("Starting a pod which tries to reach the VMI via NodePort")
job := tests.NewHelloWorldJobUDP(nodeIP, strconv.Itoa(int(nodePort)))
job, err = virtClient.CoreV1().Pods(udpVM.Namespace).Create(job)
Expect(err).ToNot(HaveOccurred())
By("Waiting for the pod to report a successful connection attempt")
getStatus := func() k8sv1.PodPhase {
pod, err := virtClient.CoreV1().Pods(job.Namespace).Get(job.Name, k8smetav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
return pod.Status.Phase
}
Eventually(getStatus, 60, 1).Should(Equal(k8sv1.PodSucceeded))
}
})
})
})
Context("Expose service on a VMI replica set", func() {
var vmrs *v1.VirtualMachineInstanceReplicaSet
tests.BeforeAll(func() {
By("Creating a VMRS object with 2 replicas")
const numberOfVMs = 2
template := tests.NewRandomVMIWithEphemeralDiskAndUserdata(tests.ContainerDiskFor(tests.ContainerDiskCirros), "#!/bin/bash\necho 'hello'\n")
vmrs = tests.NewRandomReplicaSetFromVMI(template, int32(numberOfVMs))
vmrs.Labels = map[string]string{"expose": "vmirs"}
By("Start the replica set")
vmrs, err = virtClient.ReplicaSet(tests.NamespaceTestDefault).Create(vmrs)
Expect(err).ToNot(HaveOccurred())
By("Checking the number of ready replicas")
Eventually(func() int {
rs, err := virtClient.ReplicaSet(tests.NamespaceTestDefault).Get(vmrs.ObjectMeta.Name, k8smetav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
return int(rs.Status.ReadyReplicas)
}, 120*time.Second, 1*time.Second).Should(Equal(numberOfVMs))
By("Add an 'hello world' server on each VMI in the replica set")
// TODO: add label to list options
// check size of list
// remove check for owner
vms, err := virtClient.VirtualMachineInstance(vmrs.ObjectMeta.Namespace).List(&k8smetav1.ListOptions{})
Expect(err).ToNot(HaveOccurred())
for _, vm := range vms.Items {
if vm.OwnerReferences != nil {
generateHelloWorldServer(&vm, virtClient, testPort, "tcp")
}
}
})
Context("Expose ClusterIP service", func() {
const servicePort = "27017"
const serviceName = "cluster-ip-vmirs"
It("[test_id:1537]Should create a ClusterIP service on VMRS and connect to it", func() {
By("Expose a service on the VMRS using virtctl")
virtctl := tests.NewRepeatableVirtctlCommand(expose.COMMAND_EXPOSE, "vmirs", "--namespace",
vmrs.Namespace, vmrs.Name, "--port", servicePort, "--name", serviceName, "--target-port", strconv.Itoa(testPort))
err = virtctl()
Expect(err).ToNot(HaveOccurred())
By("Getting back the cluster IP given for the service")
svc, err := virtClient.CoreV1().Services(vmrs.Namespace).Get(serviceName, k8smetav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
serviceIP := svc.Spec.ClusterIP
By("Starting a pod which tries to reach the VMI via ClusterIP")
job := tests.NewHelloWorldJob(serviceIP, servicePort)
job, err = virtClient.CoreV1().Pods(vmrs.Namespace).Create(job)
Expect(err).ToNot(HaveOccurred())
By("Waiting for the pod to report a successful connection attempt")
getStatus := func() k8sv1.PodPhase {
pod, err := virtClient.CoreV1().Pods(job.Namespace).Get(job.Name, k8smetav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
return pod.Status.Phase
}
Eventually(getStatus, 60, 1).Should(Equal(k8sv1.PodSucceeded))
})
})
})
Context("[rfe_id:253][crit:high][vendor:[email protected]][level:component]Expose a VM as a service.", func() {
const servicePort = "27017"
const serviceName = "cluster-ip-vm"
var vm *v1.VirtualMachine
tests.BeforeAll(func() {
By("Creating an VM object")
template := tests.NewRandomVMIWithEphemeralDiskAndUserdata(tests.ContainerDiskFor(tests.ContainerDiskCirros), "#!/bin/bash\necho 'hello'\n")
template.Labels = map[string]string{"expose": "vm"}
vm = NewRandomVirtualMachine(template, false)
By("Creating the VM")
_, err := virtClient.VirtualMachine(tests.NamespaceTestDefault).Create(vm)
Expect(err).ToNot(HaveOccurred())
By("Exposing a service to the VM using virtctl")
virtctl := tests.NewRepeatableVirtctlCommand(expose.COMMAND_EXPOSE, "virtualmachine", "--namespace",
vm.Namespace, vm.Name, "--port", servicePort, "--name", serviceName, "--target-port", strconv.Itoa(testPort))
err = virtctl()
Expect(err).ToNot(HaveOccurred())
By("Calling the start command")
virtctl = tests.NewRepeatableVirtctlCommand("start", "--namespace", vm.Namespace, vm.Name)
err = virtctl()
Expect(err).ToNot(HaveOccurred())
By("Getting the status of the VMI")
Eventually(func() bool {
vm, err = virtClient.VirtualMachine(vm.Namespace).Get(vm.Name, &k8smetav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
return vm.Status.Ready
}, 120*time.Second, 1*time.Second).Should(BeTrue())
By("Getting the running VMI")
var vmi *v1.VirtualMachineInstance
Eventually(func() bool {
vmi, err = virtClient.VirtualMachineInstance(vm.Namespace).Get(vm.Name, &k8smetav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
return vmi.Status.Phase == v1.Running
}, 120*time.Second, 1*time.Second).Should(BeTrue())
generateHelloWorldServer(vmi, virtClient, testPort, "tcp")
})
Context("Expose a VM as a ClusterIP service.", func() {
It("[test_id:1538]Connect to ClusterIP services that was set when VM was offline", func() {
By("Getting back the cluster IP given for the service")
svc, err := virtClient.CoreV1().Services(vm.Namespace).Get(serviceName, k8smetav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
serviceIP := svc.Spec.ClusterIP
By("Starting a pod which tries to reach the VMI via ClusterIP")
job := tests.NewHelloWorldJob(serviceIP, servicePort)
job, err = virtClient.CoreV1().Pods(vm.Namespace).Create(job)
Expect(err).ToNot(HaveOccurred())
By("Waiting for the pod to report a successful connection attempt")
getStatus := func() k8sv1.PodPhase {
pod, err := virtClient.CoreV1().Pods(job.Namespace).Get(job.Name, k8smetav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
return pod.Status.Phase
}
Eventually(getStatus, 60, 1).Should(Equal(k8sv1.PodSucceeded))
})
It("[test_id:345]Should verify the exposed service is functional before and after VM restart.", func() {
vmObj := vm
By("Getting back the service's allocated cluster IP.")
svc, err := virtClient.CoreV1().Services(vmObj.Namespace).Get(serviceName, k8smetav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
serviceIP := svc.Spec.ClusterIP
By("Starting a pod which tries to reach the VMI via ClusterIP.")
job := tests.NewHelloWorldJob(serviceIP, servicePort)
job, err = virtClient.CoreV1().Pods(vmObj.Namespace).Create(job)
Expect(err).ToNot(HaveOccurred())
By("Waiting for the pod to report a successful connection attempt.")
getStatus := func() k8sv1.PodPhase {
pod, err := virtClient.CoreV1().Pods(job.Namespace).Get(job.Name, k8smetav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
return pod.Status.Phase
}
Eventually(getStatus, 60, 1).Should(Equal(k8sv1.PodSucceeded))
// Retrieve the current VMI UID, to be compared with the new UID after restart.
var vmi *v1.VirtualMachineInstance
vmi, err = virtClient.VirtualMachineInstance(vmObj.Namespace).Get(vmObj.Name, &k8smetav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
vmiUIdBeforeRestart := vmi.GetObjectMeta().GetUID()
By("Restarting the running VM.")
virtctl := tests.NewRepeatableVirtctlCommand("restart", "--namespace", vmObj.Namespace, vmObj.Name)
err = virtctl()
Expect(err).ToNot(HaveOccurred())
By("Verifying the VMI is back up AFTER restart (in Running status with new UID).")
Eventually(func() bool {
vmi, err = virtClient.VirtualMachineInstance(vmObj.Namespace).Get(vmObj.Name, &k8smetav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
vmiUIdAfterRestart := vmi.GetObjectMeta().GetUID()
newUId := (vmiUIdAfterRestart != vmiUIdBeforeRestart)
return ((vmi.Status.Phase == v1.Running) && (newUId))
}, 120*time.Second, 1*time.Second).Should(BeTrue())
By("Creating a TCP server on the VM.")
generateHelloWorldServer(vmi, virtClient, testPort, "tcp")
By("Repeating the sequence as prior to restarting the VM: Connect to exposed ClusterIP service.")
By("Starting a pod which tries to reach the VMI via ClusterIP.")
job = tests.NewHelloWorldJob(serviceIP, servicePort)
job, err = virtClient.CoreV1().Pods(vmObj.Namespace).Create(job)
Expect(err).ToNot(HaveOccurred())
By("Waiting for the pod to report a successful connection attempt.")
getStatus = func() k8sv1.PodPhase {
pod, err := virtClient.CoreV1().Pods(job.Namespace).Get(job.Name, k8smetav1.GetOptions{})
Expect(err).ToNot(HaveOccurred())
return pod.Status.Phase
}
Eventually(getStatus, 60, 1).Should(Equal(k8sv1.PodSucceeded))
})
})
})
})