77import datetime
88import itertools
99import random
10+ import secrets
1011from collections .abc import AsyncIterator , Awaitable , Callable
1112from copy import deepcopy
1213from typing import Any
@@ -1028,10 +1029,23 @@ def test_get_new_node_docker_tags(
10281029 app_settings : ApplicationSettings ,
10291030 fake_ec2_instance_data : Callable [..., EC2InstanceData ],
10301031):
1031- ec2_instance_data = fake_ec2_instance_data ()
1032+ random_ec2_type = secrets .choice (
1033+ list (app_settings .AUTOSCALING_EC2_INSTANCES .EC2_INSTANCES_ALLOWED_TYPES )
1034+ )
1035+
1036+ ec2_instance_data = fake_ec2_instance_data (type = random_ec2_type )
10321037 node_docker_tags = get_new_node_docker_tags (app_settings , ec2_instance_data )
10331038 assert node_docker_tags
10341039 assert DOCKER_TASK_EC2_INSTANCE_TYPE_PLACEMENT_CONSTRAINT_KEY in node_docker_tags
1040+ for (
1041+ key ,
1042+ value ,
1043+ ) in app_settings .AUTOSCALING_EC2_INSTANCES .EC2_INSTANCES_ALLOWED_TYPES [
1044+ random_ec2_type
1045+ ].custom_node_labels .items ():
1046+ assert key in node_docker_tags
1047+ assert node_docker_tags [key ] == value
1048+
10351049 assert app_settings .AUTOSCALING_NODES_MONITORING
10361050 for (
10371051 tag_key
@@ -1046,6 +1060,9 @@ def test_get_new_node_docker_tags(
10461060 DOCKER_TASK_EC2_INSTANCE_TYPE_PLACEMENT_CONSTRAINT_KEY ,
10471061 * app_settings .AUTOSCALING_NODES_MONITORING .NODES_MONITORING_NODE_LABELS ,
10481062 * app_settings .AUTOSCALING_NODES_MONITORING .NODES_MONITORING_NEW_NODES_LABELS ,
1063+ * app_settings .AUTOSCALING_EC2_INSTANCES .EC2_INSTANCES_ALLOWED_TYPES [
1064+ random_ec2_type
1065+ ].custom_node_labels .keys (),
10491066 ]
10501067 for tag_key in node_docker_tags :
10511068 assert tag_key in all_keys
0 commit comments