Skip to content

Commit

Permalink
vmi ctrl: fix invtsc and hyperv tests
Browse files Browse the repository at this point in the history
Both invtsc and hyperv tests expect a pod creation
when topoloty hints is going to be set, but actually
this pod creation does not occur (it can occur in the
subsequent reconcile cycle).

Remove also `runController` function since it does not
add anything.

Signed-off-by: fossedihelm <ffossemo@redhat.com>
  • Loading branch information
fossedihelm committed Apr 19, 2024
1 parent 6b76e42 commit 7d24f58
Showing 1 changed file with 14 additions and 19 deletions.
33 changes: 14 additions & 19 deletions pkg/virt-controller/watch/vmi_test.go
Expand Up @@ -3206,16 +3206,10 @@ var _ = Describe("VirtualMachineInstance watcher", func() {
}

Context("needs to be set when", func() {

runController := func(vmi *virtv1.VirtualMachineInstance) {
addVirtualMachine(vmi)
controller.Execute()
expectMatchingPodCreation(vmi)
}

It("invtsc feature exists", func() {
vmi := getVmiWithInvTsc()
runController(vmi)
addVirtualMachine(vmi)
controller.Execute()
expectTopologyHintsDefined(vmi, BeTrue())
})

Expand All @@ -3228,7 +3222,8 @@ var _ = Describe("VirtualMachineInstance watcher", func() {

When("TSC frequency is exposed", func() {
It("topology hints need to be set", func() {
runController(vmi)
addVirtualMachine(vmi)
controller.Execute()
expectTopologyHintsDefined(vmi, BeTrue())
})
})
Expand All @@ -3244,9 +3239,10 @@ var _ = Describe("VirtualMachineInstance watcher", func() {
It("topology hints don't need to be set and VMI needs to be non-migratable", func() {
unexposeTscFrequency(topology.RequiredForMigration)
// Make sure no update occurs
runController(vmi)
expectMatchingPodCreation(vmi)
addVirtualMachine(vmi)
controller.Execute()
expectTopologyHintsDefined(vmi, BeFalse())
expectMatchingPodCreation(vmi)
testutils.ExpectEvent(recorder, SuccessfulCreatePodReason)
})
})
Expand All @@ -3257,32 +3253,31 @@ var _ = Describe("VirtualMachineInstance watcher", func() {

Context("pod creation", func() {

runController := func(vmi *virtv1.VirtualMachineInstance) {
addVirtualMachine(vmi)
controller.Execute()
}

It("does not need to happen if tsc requiredment is of type RequiredForBoot", func() {
vmi := getVmiWithInvTsc()
Expect(topology.GetTscFrequencyRequirement(vmi).Type).To(Equal(topology.RequiredForBoot))

runController(vmi)
addVirtualMachine(vmi)
controller.Execute()
expectTopologyHintsDefined(vmi, BeTrue())
})

It("does not need to happen if tsc requiredment is of type RequiredForMigration", func() {
vmi := getVmiWithReenlightenment()
Expect(topology.GetTscFrequencyRequirement(vmi).Type).To(Equal(topology.RequiredForMigration))
addVirtualMachine(vmi)

runController(vmi)
controller.Execute()
expectTopologyHintsDefined(vmi, BeTrue())
})

It("does not need to happen if tsc requiredment is of type NotRequired", func() {
vmi := NewPendingVirtualMachine("testvmi")
Expect(topology.GetTscFrequencyRequirement(vmi).Type).To(Equal(topology.NotRequired))
addVirtualMachine(vmi)

controller.Execute()

runController(vmi)
testutils.ExpectEvent(recorder, SuccessfulCreatePodReason)
expectMatchingPodCreation(vmi)
})
Expand Down

0 comments on commit 7d24f58

Please sign in to comment.