@@ -34,6 +34,23 @@ def vm(request, cluster_cpu_model_scope_function, unprivileged_client, namespace
3434 yield vm
3535
3636
37+ @pytest .fixture ()
38+ def vm_with_non_default_machine_type (
39+ request , cluster_cpu_model_scope_function , unprivileged_client , namespace , non_default_machine_type
40+ ):
41+ name = f"vm-{ request .param ['vm_name' ]} -machine-type"
42+
43+ with VirtualMachineForTests (
44+ name = name ,
45+ namespace = namespace .name ,
46+ body = fedora_vm_body (name = name ),
47+ client = unprivileged_client ,
48+ machine_type = non_default_machine_type ,
49+ ) as vm :
50+ running_vm (vm = vm , check_ssh_connectivity = False )
51+ yield vm
52+
53+
3754@pytest .fixture ()
3855def updated_kubevirt_config_machine_type (
3956 request ,
@@ -84,39 +101,22 @@ def migrated_vm(vm, machine_type_from_kubevirt_config):
84101 indirect = True ,
85102)
86103def test_default_machine_type (machine_type_from_kubevirt_config , vm ):
87- # Workaround for s390x (https://github.com/kubevirt/kubevirt/issues/14953), as machine type missing in config and
88- # hardcoded to s390_ccw_virtio in kubevirt code.
89- if machine_type_from_kubevirt_config == MachineTypesNames .s390_ccw_virtio :
90- expected_libvirt_machine_type = MachineTypesNames .s390_ccw_virtio_rhel9_6
91- else :
92- expected_libvirt_machine_type = machine_type_from_kubevirt_config
93- validate_machine_type (
94- vm = vm ,
95- expected_machine_type = machine_type_from_kubevirt_config ,
96- expected_libvirt_machine_type = expected_libvirt_machine_type ,
97- )
104+ validate_machine_type (vm = vm , expected_machine_type = machine_type_from_kubevirt_config )
98105
99106
100107@pytest .mark .parametrize (
101- "vm, expected, expected_libvirt " ,
108+ "vm_with_non_default_machine_type " ,
102109 [
103110 pytest .param (
104- {"vm_name" : "pc-q35" , "machine_type" : MachineTypesNames .pc_q35_rhel7_6 },
105- MachineTypesNames .pc_q35_rhel7_6 ,
106- MachineTypesNames .pc_q35_rhel7_6 ,
107- marks = [pytest .mark .polarion ("CNV-3311" ), pytest .mark .x86_64 ()],
108- ),
109- pytest .param (
110- {"vm_name" : "s390-ccw-virtio" , "machine_type" : MachineTypesNames .s390_ccw_virtio },
111- MachineTypesNames .s390_ccw_virtio ,
112- MachineTypesNames .s390_ccw_virtio_rhel9_6 ,
113- marks = [pytest .mark .s390x ()],
114- ),
111+ {"vm_name" : "custom-machine-type" },
112+ marks = [pytest .mark .polarion ("CNV-3311" )],
113+ )
115114 ],
116- indirect = ["vm " ],
115+ indirect = ["vm_with_non_default_machine_type " ],
117116)
118- def test_vm_machine_type (vm , expected , expected_libvirt ):
119- validate_machine_type (vm = vm , expected_machine_type = expected , expected_libvirt_machine_type = expected_libvirt )
117+ @pytest .mark .s390x
118+ def test_vm_machine_type (vm_with_non_default_machine_type , non_default_machine_type ):
119+ validate_machine_type (vm = vm_with_non_default_machine_type , expected_machine_type = non_default_machine_type )
120120
121121
122122@pytest .mark .parametrize (
@@ -138,15 +138,9 @@ def test_vm_machine_type(vm, expected, expected_libvirt):
138138def test_migrate_vm (machine_type_from_kubevirt_config , vm ):
139139 """Migrate VM and check machine type is same"""
140140 migrate_vm_and_verify (vm = vm )
141- # s390x: machine type missing in config (GH#14953). Same as above.
142- if machine_type_from_kubevirt_config == MachineTypesNames .s390_ccw_virtio :
143- expected_libvirt_machine_type = MachineTypesNames .s390_ccw_virtio_rhel9_6
144- else :
145- expected_libvirt_machine_type = machine_type_from_kubevirt_config
146141 validate_machine_type (
147142 vm = vm ,
148143 expected_machine_type = machine_type_from_kubevirt_config ,
149- expected_libvirt_machine_type = expected_libvirt_machine_type ,
150144 )
151145
152146
0 commit comments