Skip to content

Commit

Permalink
watch: unit test for replacement volume strategy
Browse files Browse the repository at this point in the history
Signed-off-by: Alice Frosi <[email protected]>
  • Loading branch information
alicefr committed May 6, 2024
1 parent 68882b0 commit 45695b6
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions pkg/virt-controller/watch/vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import (
virtcontroller "kubevirt.io/kubevirt/pkg/controller"
"kubevirt.io/kubevirt/pkg/instancetype"
kvpointer "kubevirt.io/kubevirt/pkg/pointer"
virtpointer "kubevirt.io/kubevirt/pkg/pointer"
"kubevirt.io/kubevirt/pkg/testutils"
virtconfig "kubevirt.io/kubevirt/pkg/virt-config"
watchutil "kubevirt.io/kubevirt/pkg/virt-controller/watch/util"
Expand Down Expand Up @@ -5467,6 +5468,37 @@ var _ = Describe("VirtualMachine", func() {
})

})

Context("Volumes", func() {
DescribeTable("should set the restart condition", func(strategy *v1.UpdateVolumesStrategy) {
testutils.UpdateFakeKubeVirtClusterConfig(kvInformer, &v1.KubeVirt{
Spec: v1.KubeVirtSpec{
Configuration: v1.KubeVirtConfiguration{
VMRolloutStrategy: &liveUpdate,
DeveloperConfiguration: &v1.DeveloperConfiguration{
FeatureGates: []string{
virtconfig.VMLiveUpdateFeaturesGate,
virtconfig.VolumesUpdateStrategy,
},
},
},
},
})
vm, vmi := DefaultVirtualMachine(true)
vm.Spec.Template.Spec.Volumes = append(vm.Spec.Template.Spec.Volumes, v1.Volume{
Name: "vol1"})
vmi.Spec.Volumes = append(vmi.Spec.Volumes, v1.Volume{Name: "vol2"})
controller.handleVolumeUpdateRequest(vm, vmi)
cond := virtcontroller.NewVirtualMachineConditionManager().GetCondition(vm, v1.VirtualMachineRestartRequired)
Expect(cond).ToNot(BeNil())
Expect(cond.Status).To(Equal(k8score.ConditionTrue))
Expect(cond.Message).To(Equal("the volumes replacement is effective only after restart"))
},
Entry("without the updateVolumeStrategy field", nil),
Entry("with the replacement updateVolumeStrategy",
virtpointer.P(v1.UpdateVolumesStrategyReplacement)),
)
})
})

Context("CPU topology", func() {
Expand Down

0 comments on commit 45695b6

Please sign in to comment.