Skip to content

Commit f388234

Browse files
Add unit test for build_launch_network_interfaces
Signed-off-by: Francesco Giordano <[email protected]>
1 parent 8e970b7 commit f388234

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

cli/tests/pcluster/validators/test_cluster_validators.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,6 +1116,75 @@ def test_generate_tag_specifications(input_tags):
11161116
assert_that(_LaunchTemplateValidator._generate_tag_specifications(input_tags)).is_equal_to(expected_output_tags)
11171117

11181118

1119+
@pytest.mark.parametrize(
1120+
"network_interfaces_count, use_efa, security_group_ids, subnet, use_public_ips, expected_result",
1121+
[
1122+
[
1123+
1,
1124+
False,
1125+
"sg-1",
1126+
"subnet-1",
1127+
False,
1128+
[
1129+
{
1130+
"DeviceIndex": 0,
1131+
"NetworkCardIndex": 0,
1132+
"InterfaceType": "interface",
1133+
"Groups": "sg-1",
1134+
"SubnetId": "subnet-1",
1135+
}
1136+
],
1137+
],
1138+
[
1139+
4,
1140+
True,
1141+
"sg-2",
1142+
"subnet-2",
1143+
True,
1144+
[
1145+
{
1146+
"DeviceIndex": 0,
1147+
"NetworkCardIndex": 0,
1148+
"InterfaceType": "efa",
1149+
"Groups": "sg-2",
1150+
"SubnetId": "subnet-2",
1151+
"AssociatePublicIpAddress": True,
1152+
},
1153+
{
1154+
"DeviceIndex": 0,
1155+
"NetworkCardIndex": 1,
1156+
"InterfaceType": "efa",
1157+
"Groups": "sg-2",
1158+
"SubnetId": "subnet-2",
1159+
},
1160+
{
1161+
"DeviceIndex": 0,
1162+
"NetworkCardIndex": 2,
1163+
"InterfaceType": "efa",
1164+
"Groups": "sg-2",
1165+
"SubnetId": "subnet-2",
1166+
},
1167+
{
1168+
"DeviceIndex": 0,
1169+
"NetworkCardIndex": 3,
1170+
"InterfaceType": "efa",
1171+
"Groups": "sg-2",
1172+
"SubnetId": "subnet-2",
1173+
},
1174+
],
1175+
],
1176+
],
1177+
)
1178+
def test_build_launch_network_interfaces(
1179+
network_interfaces_count, use_efa, security_group_ids, subnet, use_public_ips, expected_result
1180+
):
1181+
"""Verify function to build network interfaces for dry runs of RunInstances works as expected."""
1182+
lt_network_interfaces = _LaunchTemplateValidator._build_launch_network_interfaces(
1183+
network_interfaces_count, use_efa, security_group_ids, subnet, use_public_ips
1184+
)
1185+
assert_that(lt_network_interfaces).is_equal_to(expected_result)
1186+
1187+
11191188
@pytest.mark.parametrize(
11201189
"head_node_security_groups, queues, expect_warning",
11211190
[

0 commit comments

Comments
 (0)