@@ -34,6 +34,7 @@ import (
3434 "github.com/deckhouse/virtualization-controller/pkg/controller/reconciler"
3535 vmservice "github.com/deckhouse/virtualization-controller/pkg/controller/vm/internal/service"
3636 "github.com/deckhouse/virtualization-controller/pkg/controller/vm/internal/state"
37+ "github.com/deckhouse/virtualization-controller/pkg/controller/vmchange"
3738 "github.com/deckhouse/virtualization-controller/pkg/eventrecord"
3839 "github.com/deckhouse/virtualization/api/core/v1alpha2"
3940 "github.com/deckhouse/virtualization/api/core/v1alpha2/vmcondition"
@@ -319,4 +320,19 @@ var _ = Describe("SyncKvvmHandler", func() {
319320 Entry ("Pending phase with changes applied, condition should not exist" , v1alpha2 .MachinePending , false , metav1 .ConditionUnknown , false ),
320321 Entry ("Pending phase with changes not applied, condition should not exist" , v1alpha2 .MachinePending , true , metav1 .ConditionUnknown , false ),
321322 )
323+
324+ DescribeTable ("isPlacementPolicyChanged" ,
325+ func (path string , expected bool ) {
326+ h := & SyncKvvmHandler {}
327+ changes := vmchange.SpecChanges {}
328+ changes .Add (vmchange.FieldChange {Path : path , CurrentValue : "old" , DesiredValue : "new" })
329+
330+ Expect (h .isPlacementPolicyChanged (changes )).To (Equal (expected ))
331+ },
332+ Entry ("vm tolerations change" , "tolerations" , true ),
333+ Entry ("vmclass tolerations change" , "VirtualMachineClass:spec.tolerations" , true ),
334+ Entry ("vmclass nodeSelector change" , "VirtualMachineClass:spec.nodeSelector" , true ),
335+ Entry ("vmclass name change" , "virtualMachineClassName" , true ),
336+ Entry ("cpu change is not a placement policy" , "cpu.cores" , false ),
337+ )
322338})
0 commit comments