@@ -134,42 +134,6 @@ def test_create_delete(self, ec2_client):
134
134
# Check Subnet no longer exists in AWS
135
135
ec2_validator .assert_subnet (resource_id , exists = False )
136
136
137
- def test_terminal_condition (self ):
138
- test_resource_values = REPLACEMENT_VALUES .copy ()
139
- resource_name = random_suffix_name ("subnet-fail" , 24 )
140
- test_vpc = get_bootstrap_resources ().SharedTestVPC
141
- vpc_cidr = test_vpc .vpc_cidr_block
142
-
143
- test_resource_values ["SUBNET_NAME" ] = resource_name
144
- test_resource_values ["VPC_ID" ] = "InvalidVpcId"
145
- test_resource_values ["CIDR_BLOCK" ] = vpc_cidr
146
-
147
- # Load Subnet CR
148
- resource_data = load_ec2_resource (
149
- "subnet" ,
150
- additional_replacements = test_resource_values ,
151
- )
152
- logging .debug (resource_data )
153
-
154
- # Create k8s resource
155
- ref = k8s .CustomResourceReference (
156
- CRD_GROUP , CRD_VERSION , RESOURCE_PLURAL ,
157
- resource_name , namespace = "default" ,
158
- )
159
- k8s .create_custom_resource (ref , resource_data )
160
- cr = k8s .wait_resource_consumed_by_controller (ref )
161
-
162
- assert cr is not None
163
- assert k8s .get_resource_exists (ref )
164
-
165
- expected_msg = "InvalidVpcID.NotFound: The vpc ID 'InvalidVpcId' does not exist"
166
- terminal_condition = k8s .get_resource_condition (ref , "ACK.Terminal" )
167
- # Example condition message:
168
- # InvalidVpcID.NotFound: The vpc ID 'InvalidVpcId' does not exist
169
- # status code: 400, request id: 5801fc80-67cf-465f-8b83-5e02d517d554
170
- # This check only verifies the error message; the request hash is irrelevant and therefore can be ignored.
171
- assert expected_msg in terminal_condition ['message' ]
172
-
173
137
def test_route_table_assocations (self , ec2_client , default_route_tables ):
174
138
test_resource_values = REPLACEMENT_VALUES .copy ()
175
139
resource_name = random_suffix_name ("subnet-test" , 24 )
@@ -231,4 +195,40 @@ def test_route_table_assocations(self, ec2_client, default_route_tables):
231
195
time .sleep (DELETE_WAIT_AFTER_SECONDS )
232
196
233
197
# Check Subnet no longer exists in AWS
234
- ec2_validator .assert_subnet (resource_id , exists = False )
198
+ ec2_validator .assert_subnet (resource_id , exists = False )
199
+
200
+ def test_terminal_condition_invalid_parameter_value (self ):
201
+ test_resource_values = REPLACEMENT_VALUES .copy ()
202
+ resource_name = random_suffix_name ("subnet-fail" , 24 )
203
+ test_vpc = get_bootstrap_resources ().SharedTestVPC
204
+ vpc_id = test_vpc .vpc_id
205
+
206
+ test_resource_values ["SUBNET_NAME" ] = resource_name
207
+ test_resource_values ["CIDR_BLOCK" ] = "InvalidCidrBlock"
208
+ test_resource_values ["VPC_ID" ] = vpc_id
209
+
210
+ # Load Subnet CR
211
+ resource_data = load_ec2_resource (
212
+ "subnet" ,
213
+ additional_replacements = test_resource_values ,
214
+ )
215
+ logging .debug (resource_data )
216
+
217
+ # Create k8s resource
218
+ ref = k8s .CustomResourceReference (
219
+ CRD_GROUP , CRD_VERSION , RESOURCE_PLURAL ,
220
+ resource_name , namespace = "default" ,
221
+ )
222
+ k8s .create_custom_resource (ref , resource_data )
223
+ cr = k8s .wait_resource_consumed_by_controller (ref )
224
+
225
+ assert cr is not None
226
+ assert k8s .get_resource_exists (ref )
227
+
228
+ expected_msg = "InvalidParameterValue: Value (InvalidCidrBlock) for parameter cidrBlock is invalid. This is not a valid CIDR block."
229
+ terminal_condition = k8s .get_resource_condition (ref , "ACK.Terminal" )
230
+ # Example condition message:
231
+ # An error occurred (InvalidParameterValue) when calling the CreateSubnet operation:
232
+ # Value (InvalidCidrBlock) for parameter cidrBlock is invalid.
233
+ # This is not a valid CIDR block.
234
+ assert expected_msg in terminal_condition ['message' ]
0 commit comments