@@ -380,6 +380,10 @@ class LibvirtVifTestCase(test.NoDBTestCase):
380
380
uuid = 'f0000000-0000-0000-0000-000000000001' ,
381
381
project_id = 723 )
382
382
383
+ flavor_1vcpu = objects .Flavor (vcpus = 1 , memory = 512 , root_gb = 1 )
384
+
385
+ flavor_2vcpu = objects .Flavor (vcpus = 2 , memory = 512 , root_gb = 1 )
386
+
383
387
bandwidth = {
384
388
'quota:vif_inbound_peak' : '200' ,
385
389
'quota:vif_outbound_peak' : '20' ,
@@ -1048,32 +1052,50 @@ def test_tap_ethernet_vif_driver(self):
1048
1052
@mock .patch ('nova.privsep.linux_net.device_exists' , return_value = True )
1049
1053
@mock .patch ('nova.privsep.linux_net.set_device_mtu' )
1050
1054
@mock .patch ('nova.privsep.linux_net.create_tap_dev' )
1051
- def test_plug_tap_kvm_virtio (self , mock_create_tap_dev , mock_set_mtu ,
1052
- mock_device_exists ):
1055
+ def test_plug_tap_kvm_virtio (
1056
+ self , mock_create_tap_dev , mock_set_mtu , mock_device_exists ):
1053
1057
1054
1058
d1 = vif .LibvirtGenericVIFDriver ()
1055
1059
ins = objects .Instance (
1056
1060
id = 1 , uuid = 'f0000000-0000-0000-0000-000000000001' ,
1057
- image_ref = uuids .image_ref ,
1061
+ image_ref = uuids .image_ref , flavor = self . flavor_2vcpu ,
1058
1062
project_id = 723 , system_metadata = {}
1059
1063
)
1060
1064
d1 .plug (ins , self .vif_tap )
1061
- mock_create_tap_dev .assert_called_once_with ('tap-xxx-yyy-zzz' , None ,
1062
- multiqueue = False )
1065
+ mock_create_tap_dev .assert_called_once_with (
1066
+ 'tap-xxx-yyy-zzz' , None , multiqueue = False )
1063
1067
1064
1068
mock_create_tap_dev .reset_mock ()
1065
1069
1066
1070
d2 = vif .LibvirtGenericVIFDriver ()
1067
1071
mq_ins = objects .Instance (
1068
1072
id = 1 , uuid = 'f0000000-0000-0000-0000-000000000001' ,
1069
- image_ref = uuids .image_ref ,
1073
+ image_ref = uuids .image_ref , flavor = self . flavor_2vcpu ,
1070
1074
project_id = 723 , system_metadata = {
1071
1075
'image_hw_vif_multiqueue_enabled' : 'True'
1072
1076
}
1073
1077
)
1074
1078
d2 .plug (mq_ins , self .vif_tap )
1075
- mock_create_tap_dev .assert_called_once_with ('tap-xxx-yyy-zzz' , None ,
1076
- multiqueue = True )
1079
+ mock_create_tap_dev .assert_called_once_with (
1080
+ 'tap-xxx-yyy-zzz' , None , multiqueue = True )
1081
+
1082
+ @mock .patch ('nova.privsep.linux_net.device_exists' , return_value = True )
1083
+ @mock .patch ('nova.privsep.linux_net.set_device_mtu' )
1084
+ @mock .patch ('nova.privsep.linux_net.create_tap_dev' )
1085
+ def test_plug_tap_mq_ignored_1vcpu (
1086
+ self , mock_create_tap_dev , mock_set_mtu , mock_device_exists ):
1087
+
1088
+ d1 = vif .LibvirtGenericVIFDriver ()
1089
+ mq_ins = objects .Instance (
1090
+ id = 1 , uuid = 'f0000000-0000-0000-0000-000000000001' ,
1091
+ image_ref = uuids .image_ref , flavor = self .flavor_1vcpu ,
1092
+ project_id = 723 , system_metadata = {
1093
+ 'image_hw_vif_multiqueue_enabled' : 'True' ,
1094
+ }
1095
+ )
1096
+ d1 .plug (mq_ins , self .vif_tap )
1097
+ mock_create_tap_dev .assert_called_once_with (
1098
+ 'tap-xxx-yyy-zzz' , None , multiqueue = False )
1077
1099
1078
1100
@mock .patch ('nova.privsep.linux_net.device_exists' , return_value = True )
1079
1101
@mock .patch ('nova.privsep.linux_net.set_device_mtu' )
@@ -1088,15 +1110,14 @@ def test_plug_tap_mq_ignored_virt_type(
1088
1110
d1 = vif .LibvirtGenericVIFDriver ()
1089
1111
ins = objects .Instance (
1090
1112
id = 1 , uuid = 'f0000000-0000-0000-0000-000000000001' ,
1091
- image_ref = uuids .image_ref ,
1113
+ image_ref = uuids .image_ref , flavor = self . flavor_2vcpu ,
1092
1114
project_id = 723 , system_metadata = {
1093
1115
'image_hw_vif_multiqueue_enabled' : 'True'
1094
1116
}
1095
1117
)
1096
1118
d1 .plug (ins , self .vif_tap )
1097
- mock_create_tap_dev .assert_called_once_with ('tap-xxx-yyy-zzz' ,
1098
- None ,
1099
- multiqueue = False )
1119
+ mock_create_tap_dev .assert_called_once_with (
1120
+ 'tap-xxx-yyy-zzz' , None , multiqueue = False )
1100
1121
1101
1122
@mock .patch ('nova.privsep.linux_net.device_exists' , return_value = True )
1102
1123
@mock .patch ('nova.privsep.linux_net.set_device_mtu' )
@@ -1107,16 +1128,15 @@ def test_plug_tap_mq_ignored_vif_model(
1107
1128
d1 = vif .LibvirtGenericVIFDriver ()
1108
1129
ins = objects .Instance (
1109
1130
id = 1 , uuid = 'f0000000-0000-0000-0000-000000000001' ,
1110
- image_ref = uuids .image_ref ,
1131
+ image_ref = uuids .image_ref , flavor = self . flavor_2vcpu ,
1111
1132
project_id = 723 , system_metadata = {
1112
1133
'image_hw_vif_multiqueue_enabled' : 'True' ,
1113
1134
'image_hw_vif_model' : 'e1000' ,
1114
1135
}
1115
1136
)
1116
1137
d1 .plug (ins , self .vif_tap )
1117
- mock_create_tap_dev .assert_called_once_with ('tap-xxx-yyy-zzz' ,
1118
- None ,
1119
- multiqueue = False )
1138
+ mock_create_tap_dev .assert_called_once_with (
1139
+ 'tap-xxx-yyy-zzz' , None , multiqueue = False )
1120
1140
1121
1141
def test_unplug_tap (self ):
1122
1142
d = vif .LibvirtGenericVIFDriver ()
0 commit comments