Skip to content

Commit

Permalink
Merge pull request kubevirt#10611 from xpivarc/cpu-hotplug-fix
Browse files Browse the repository at this point in the history
Improve cpu hotplug test
  • Loading branch information
kubevirt-bot authored Oct 27, 2023
2 parents 5cbe630 + 9eb2e19 commit d7371fe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 30 deletions.
25 changes: 6 additions & 19 deletions tests/hotplug/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ var _ = Describe("[sig-compute][Serial]CPU Hotplug", decorators.SigCompute, deco
patchData, err := patch.GenerateTestReplacePatch("/spec/template/spec/domain/cpu/sockets", 1, 2)
Expect(err).NotTo(HaveOccurred())
_, err = virtClient.VirtualMachine(vm.Namespace).Patch(context.Background(), vm.Name, types.JSONPatchType, patchData, &k8smetav1.PatchOptions{})
Expect(err).To(HaveOccurred())
Expect(err).To(MatchError(ContainSubstring("cannot update while VMI migration is in progress")))

libmigration.ExpectMigrationToSucceedWithDefaultTimeout(virtClient, migration)

Expand All @@ -251,24 +251,11 @@ var _ = Describe("[sig-compute][Serial]CPU Hotplug", decorators.SigCompute, deco
// Need to wait for the hotplug to begin.
Eventually(ThisVMI(vmi), 1*time.Minute, 2*time.Second).Should(HaveConditionTrue(v1.VirtualMachineInstanceVCPUChange))

By("Ensuring live-migration started")
Eventually(func() bool {
migrations, err := virtClient.VirtualMachineInstanceMigration(vm.Namespace).List(&k8smetav1.ListOptions{})
Expect(err).ToNot(HaveOccurred())
for _, mig := range migrations.Items {
match := 0
if mig.Spec.VMIName == vmi.Name {
match++
if !migration.IsFinal() || match == 2 {
migration = mig.DeepCopy()
return true
}
}
}
return false
}, 30*time.Second, time.Second).Should(BeTrue())
libmigration.ExpectMigrationToSucceedWithDefaultTimeout(virtClient, migration)
libmigration.ConfirmVMIPostMigration(virtClient, vmi, migration)
By("Ensuring hotplug ended")
Eventually(ThisVMI(vmi), 1*time.Minute, 2*time.Second).ShouldNot(SatisfyAny(
HaveConditionTrue(v1.VirtualMachineInstanceVCPUChange),
HaveConditionFalse(v1.VirtualMachineInstanceVCPUChange),
))

By("Ensuring the libvirt domain has 4 enabled cores")
Eventually(func() cpuCount {
Expand Down
15 changes: 4 additions & 11 deletions tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,17 +468,10 @@ func GetRunningPodByLabel(label string, labelType string, namespace string, node

var readyPod *k8sv1.Pod
for _, pod := range pods.Items {
ready := true
for _, status := range pod.Status.ContainerStatuses {
if status.Name == "kubevirt-infra" {
ready = status.Ready
break
}
}
if ready {
readyPod = &pod
break
}
// TODO: This needs to be reworked.
// During migration there can be more than one pod
readyPod = &pod
break
}
if readyPod == nil {
return nil, fmt.Errorf("no ready pods with the label %s", label)
Expand Down

0 comments on commit d7371fe

Please sign in to comment.