Skip to content

Commit 8594fb5

Browse files
authored
Refactor e2e tests to use acktest.tags helper (#106)
Issue #, if available: aws-controllers-k8s/community#1235 Description of changes: * Use `acktest.tags` assertions in e2e tests to accurately test for ACK tags and user-defined tags * Enhance existing tag tests by checking both server-side values as well as `Spec.Tags` values * Add hook code for `Instance` and `RouteTable` so ACK tags are not populated in `Spec` By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 423e97d commit 8594fb5

22 files changed

+631
-133
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-09-21T13:36:34Z"
2+
build_date: "2022-09-27T22:29:46Z"
33
build_hash: 6e2ffbc3b16a30ac59be6719918c601c2c864064
44
go_version: go1.18.1
55
version: v0.20.1-3-g6e2ffbc
66
api_directory_checksum: 127aa0f51fbcdde596b8f42f93bcdf3b6dee8488
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.44.93
99
generator_config_info:
10-
file_checksum: 8573a89b8220023263610579bfb84b762d99f5fa
10+
file_checksum: a31177552ce6ea5ce3b624520711382f113cf05b
1111
original_file_name: generator.yaml
1212
last_modification:
1313
reason: API generation

apis/v1alpha1/generator.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ resources:
205205
hooks:
206206
sdk_create_post_build_request:
207207
template_path: hooks/instance/sdk_create_post_build_request.go.tpl
208+
sdk_create_post_set_output:
209+
template_path: hooks/instance/sdk_create_post_set_output.go.tpl
210+
sdk_read_many_post_set_output:
211+
template_path: hooks/instance/sdk_read_many_post_set_output.go.tpl
208212
sdk_delete_post_build_request:
209213
template_path: hooks/instance/sdk_delete_post_build_request.go.tpl
210214
sdk_file_end:

generator.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ resources:
205205
hooks:
206206
sdk_create_post_build_request:
207207
template_path: hooks/instance/sdk_create_post_build_request.go.tpl
208+
sdk_create_post_set_output:
209+
template_path: hooks/instance/sdk_create_post_set_output.go.tpl
210+
sdk_read_many_post_set_output:
211+
template_path: hooks/instance/sdk_read_many_post_set_output.go.tpl
208212
sdk_delete_post_build_request:
209213
template_path: hooks/instance/sdk_delete_post_build_request.go.tpl
210214
sdk_file_end:

pkg/resource/instance/sdk.go

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

pkg/resource/route_table/sdk.go

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
toAdd, toDelete := computeTagsDelta(desired.ko.Spec.Tags, ko.Spec.Tags)
2+
if len(toAdd) == 0 && len(toDelete) == 0 {
3+
// if desired tags and response tags are equal,
4+
// then assign desired tags to maintain tag order
5+
ko.Spec.Tags = desired.ko.Spec.Tags
6+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
toAdd, toDelete := computeTagsDelta(r.ko.Spec.Tags, ko.Spec.Tags)
3+
if len(toAdd) == 0 && len(toDelete) == 0 {
4+
// if resource's initial tags and response tags are equal,
5+
// then assign resource's tags to maintain tag order
6+
ko.Spec.Tags = r.ko.Spec.Tags
7+
}
8+

templates/hooks/route_table/sdk_create_post_set_output.go.tpl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,11 @@
1010
if err := rm.createRoutes(ctx, &resource{ko}); err != nil {
1111
return nil, err
1212
}
13+
}
14+
15+
toAdd, toDelete := computeTagsDelta(desired.ko.Spec.Tags, ko.Spec.Tags)
16+
if len(toAdd) == 0 && len(toDelete) == 0 {
17+
// if desired tags and response tags are equal,
18+
// then assign desired tags to maintain tag order
19+
ko.Spec.Tags = desired.ko.Spec.Tags
1320
}

templates/hooks/route_table/sdk_read_many_post_set_output.go.tpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,10 @@
22
if found {
33
rm.addRoutesToStatus(ko, resp.RouteTables[0])
44
}
5+
toAdd, toDelete := computeTagsDelta(r.ko.Spec.Tags, ko.Spec.Tags)
6+
if len(toAdd) == 0 && len(toDelete) == 0 {
7+
// if resource's initial tags and response tags are equal,
8+
// then assign resource's tags to maintain tag order
9+
ko.Spec.Tags = r.ko.Spec.Tags
10+
}
511

test/e2e/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
acktest @ git+https://github.com/aws-controllers-k8s/test-infra.git@5220331d003e3a23de4470e68d02c99b16c81989
1+
acktest @ git+https://github.com/aws-controllers-k8s/test-infra.git@73eb0d5af8ac19d17fad8787d6462d56f4e3e37d

0 commit comments

Comments
 (0)