Skip to content

Commit d9b6c57

Browse files
Terminal codes for DhcpOptions (#60)
Issue #, if available: [1362](aws-controllers-k8s/community#1362) Description of changes: - Mapped terminal codes for **DhcpOptions** resource. - Added integration tests for the terminal codes mapped. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 63f2ec7 commit d9b6c57

File tree

5 files changed

+59
-5
lines changed

5 files changed

+59
-5
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
ack_generate_info:
2-
build_date: "2022-07-13T18:52:15Z"
2+
build_date: "2022-07-21T17:09:05Z"
33
build_hash: 208b1e15257d57c46729698f47a40fd59441ecbd
44
go_version: go1.18.3
55
version: v0.19.2-1-g208b1e1
66
api_directory_checksum: 8c35bdcab21768638dfaa277896e05fdd8a11969
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.42.0
99
generator_config_info:
10-
file_checksum: b8c9656298e66891b1a4ecf1c915423499795c6c
10+
file_checksum: 2d139419a1025deea1337589c5831061d23499bb
1111
original_file_name: generator.yaml
1212
last_modification:
1313
reason: API generation

apis/v1alpha1/generator.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ operations:
156156
resource_name: Instance
157157
resources:
158158
DhcpOptions:
159+
exceptions:
160+
terminal_codes:
161+
- InvalidParameterValue
159162
fields:
160163
DHCPConfigurations.Values:
161164
set:

generator.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ operations:
156156
resource_name: Instance
157157
resources:
158158
DhcpOptions:
159+
exceptions:
160+
terminal_codes:
161+
- InvalidParameterValue
159162
fields:
160163
DHCPConfigurations.Values:
161164
set:

pkg/resource/dhcp_options/sdk.go

Lines changed: 13 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/e2e/tests/test_dhcp_options.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,41 @@ def test_create_delete(self, ec2_client):
7878
time.sleep(DELETE_WAIT_AFTER_SECONDS)
7979

8080
# Check DHCP Options no longer exists in AWS
81-
ec2_validator.assert_dhcp_options(resource_id, exists=False)
81+
ec2_validator.assert_dhcp_options(resource_id, exists=False)
82+
83+
def test_terminal_condition_invalid_parameter_value(self):
84+
test_resource_values = REPLACEMENT_VALUES.copy()
85+
resource_name = random_suffix_name("dhcp-opts-fail", 24)
86+
87+
test_resource_values["DHCP_OPTIONS_NAME"] = resource_name
88+
test_resource_values["DHCP_KEY_1"] = "InvalidValue"
89+
test_resource_values["DHCP_VAL_1"] = "ack-example.com"
90+
test_resource_values["DHCP_KEY_2"] = "domain-name-servers"
91+
test_resource_values["DHCP_VAL_2_1"] = "10.2.5.1"
92+
test_resource_values["DHCP_VAL_2_2"] = "10.2.5.2"
93+
94+
# Load DHCP Options CR
95+
resource_data = load_ec2_resource(
96+
"dhcp_options",
97+
additional_replacements=test_resource_values,
98+
)
99+
logging.debug(resource_data)
100+
101+
# Create k8s resource
102+
ref = k8s.CustomResourceReference(
103+
CRD_GROUP, CRD_VERSION, RESOURCE_PLURAL,
104+
resource_name, namespace="default",
105+
)
106+
k8s.create_custom_resource(ref, resource_data)
107+
cr = k8s.wait_resource_consumed_by_controller(ref)
108+
109+
assert cr is not None
110+
assert k8s.get_resource_exists(ref)
111+
112+
expected_msg = "InvalidParameterValue: Value (InvalidValue) for parameter name is invalid. Unknown DHCP option"
113+
terminal_condition = k8s.get_resource_condition(ref, "ACK.Terminal")
114+
# Example condition message:
115+
# An error occurred (InvalidParameterValue) when calling the CreateDhcpOptions operation:
116+
# Value (InvalidValue) for parameter value is invalid.
117+
# Unknown DHCP option
118+
assert expected_msg in terminal_condition['message']

0 commit comments

Comments
 (0)