3434DELETE_WAIT_AFTER_SECONDS = 180
3535MAX_WAIT_FOR_SYNCED_SECONDS = 180
3636MODIFY_WAIT_AFTER_SECONDS = 30
37+ WAIT_PERIOD = 30
3738
3839@pytest .fixture (scope = "module" )
39- def simple_tgw_attachment (request ):
40+ def simple_tgw_attachment (request , ec2_client ):
4041 test_resource_values = REPLACEMENT_VALUES .copy ()
4142 resource_name = random_suffix_name ("tgw-attachment-test" , 24 )
4243
4344 test_vpc = get_bootstrap_resources ().SharedTestVPC
4445 test_tgw = get_bootstrap_resources ().TestTransitGateway
46+
47+ tgw_id = test_tgw .transit_gateway_id
48+
49+ ec2_validator = EC2Validator (ec2_client )
50+ is_available = ec2_validator .wait_transit_gateway_state (tgw_id = tgw_id , state = 'available' )
51+ assert is_available
4552
4653 test_resource_values ["TGWVA_NAME" ] = resource_name
4754 test_resource_values ["VPC_ID" ] = test_vpc .vpc_id
@@ -96,7 +103,7 @@ def test_crud_tags(self, ec2_client, simple_tgw_attachment):
96103 ref ,
97104 "ACK.ResourceSynced" ,
98105 "True" ,
99- wait_periods = MAX_WAIT_FOR_SYNCED_SECONDS ,
106+ wait_periods = WAIT_PERIOD ,
100107 )
101108
102109 time .sleep (CREATE_WAIT_AFTER_SECONDS )
@@ -143,20 +150,6 @@ def test_crud_tags(self, ec2_client, simple_tgw_attachment):
143150 actual = attachment ["Tags" ],
144151 )
145152
146- @pytest .mark .resource_data ({'tag_key' : 'initialtagkey' , 'tag_value' : 'initialtagvalue' })
147- def test_update_options (self , ec2_client , simple_tgw_attachment ):
148- (ref , cr ) = simple_tgw_attachment
149-
150-
151- assert k8s .wait_on_condition (
152- ref ,
153- "ACK.ResourceSynced" ,
154- "True" ,
155- wait_periods = MAX_WAIT_FOR_SYNCED_SECONDS ,
156- )
157-
158- attachment_id = cr ["status" ]["id" ]
159-
160153 # Update options
161154 updates = {
162155 "spec" : {
@@ -171,7 +164,7 @@ def test_update_options(self, ec2_client, simple_tgw_attachment):
171164 time .sleep (MODIFY_WAIT_AFTER_SECONDS )
172165
173166 # Check resource synced successfully
174- assert k8s .wait_on_condition (ref , "ACK.ResourceSynced" , "True" , wait_periods = 5 )
167+ assert k8s .wait_on_condition (ref , "ACK.ResourceSynced" , "True" , wait_periods = WAIT_PERIOD )
175168
176169 # Verify the update in AWS
177170 ec2_validator = EC2Validator (ec2_client )
@@ -180,20 +173,6 @@ def test_update_options(self, ec2_client, simple_tgw_attachment):
180173 assert attachment ["Options" ]["DnsSupport" ] == "disable"
181174 assert attachment ["Options" ]["Ipv6Support" ] == "enable"
182175
183- @pytest .mark .resource_data ({'tag_key' : 'initialtagkey' , 'tag_value' : 'initialtagvalue' })
184- def test_update_subnet_ids (self , ec2_client , simple_tgw_attachment ):
185- (ref , cr ) = simple_tgw_attachment
186-
187-
188- assert k8s .wait_on_condition (
189- ref ,
190- "ACK.ResourceSynced" ,
191- "True" ,
192- wait_periods = MAX_WAIT_FOR_SYNCED_SECONDS ,
193- )
194-
195- attachment_id = cr ["status" ]["id" ]
196-
197176 # Update subnet ids
198177 test_vpc = get_bootstrap_resources ().SharedTestVPC
199178 updates = {
@@ -206,10 +185,10 @@ def test_update_subnet_ids(self, ec2_client, simple_tgw_attachment):
206185 time .sleep (MODIFY_WAIT_AFTER_SECONDS )
207186
208187 # Check resource synced successfully
209- assert k8s .wait_on_condition (ref , "ACK.ResourceSynced" , "True" , wait_periods = 5 )
188+ assert k8s .wait_on_condition (ref , "ACK.ResourceSynced" , "True" , wait_periods = WAIT_PERIOD )
210189
211190 # Verify the update in AWS
212191 ec2_validator = EC2Validator (ec2_client )
213192 attachment = ec2_validator .get_transit_gateway_vpc_attachment (attachment_id )
214193
215- assert attachment ["SubnetIds" ] == test_vpc .public_subnets .subnet_ids
194+ assert set ( attachment ["SubnetIds" ]) == set ( test_vpc .public_subnets .subnet_ids )
0 commit comments