Skip to content

Commit 808d2e9

Browse files
authored
Add async handling and e2e tests for VPCLink resource (#29)
Description of changes: * Add async handling for VPCLink resource * Add e2e tests for VPCLink resource * Update the test-infra dependency in e2e tests * Assert for ACK.ResourceSynced condition in all e2e tests * I did not create a new Lambda function Bootstrapable Resource because there are multiple ways to input handler code inside a lambda function and I did not want to handle all the complexity as part of this PR. By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent b36c2cb commit 808d2e9

File tree

17 files changed

+287
-146
lines changed

17 files changed

+287
-146
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-03-02T21:33:14Z"
2+
build_date: "2022-03-03T00:08:42Z"
33
build_hash: ade2429bb444ab635916395ea5773d141ba135e1
44
go_version: go1.17.5
55
version: v0.17.2
66
api_directory_checksum: b98cf468e3704663b922b51293db3aab00e16cbc
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.42.0
99
generator_config_info:
10-
file_checksum: 851121fe11436e5c8584a366cb634e2dcdc7766a
10+
file_checksum: 21136a68fd8323e233a0f579b52126998a12e378
1111
original_file_name: generator.yaml
1212
last_modification:
1313
reason: API generation

apis/v1alpha1/generator.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,15 @@ resources:
3535
hooks:
3636
sdk_update_post_build_request:
3737
template_path: hooks/stage/sdk_update_post_build_request.go.tpl
38+
VpcLink:
39+
hooks:
40+
sdk_update_pre_build_request:
41+
template_path: hooks/vpc_link/sdk_update_pre_build_request.go.tpl
42+
synced:
43+
when:
44+
- path: Status.VPCLinkStatus
45+
in:
46+
- AVAILABLE
3847
operations:
3948
CreateApi:
4049
custom_implementation: customCreateApi
41-

generator.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,15 @@ resources:
3535
hooks:
3636
sdk_update_post_build_request:
3737
template_path: hooks/stage/sdk_update_post_build_request.go.tpl
38+
VpcLink:
39+
hooks:
40+
sdk_update_pre_build_request:
41+
template_path: hooks/vpc_link/sdk_update_pre_build_request.go.tpl
42+
synced:
43+
when:
44+
- path: Status.VPCLinkStatus
45+
in:
46+
- AVAILABLE
3847
operations:
3948
CreateApi:
4049
custom_implementation: customCreateApi
41-

olm/olmconfig.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,8 @@ samples:
3939
spec: '{}'
4040
- kind: Deployment
4141
spec: '{}'
42-
- kind: IntegrationResponse
43-
spec: '{}'
4442
- kind: Integration
4543
spec: '{}'
46-
- kind: Model
47-
spec: '{}'
48-
- kind: RouteResponse
49-
spec: '{}'
5044
- kind: Route
5145
spec: '{}'
5246
- kind: Stage

pkg/resource/vpc_link/hook.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License"). You may
4+
// not use this file except in compliance with the License. A copy of the
5+
// License is located at
6+
//
7+
// http://aws.amazon.com/apache2.0/
8+
//
9+
// or in the "license" file accompanying this file. This file is distributed
10+
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11+
// express or implied. See the License for the specific language governing
12+
// permissions and limitations under the License.
13+
14+
package vpc_link
15+
16+
import (
17+
"fmt"
18+
19+
ackrequeue "github.com/aws-controllers-k8s/runtime/pkg/requeue"
20+
svcsdk "github.com/aws/aws-sdk-go/service/apigatewayv2"
21+
)
22+
23+
var (
24+
waitForAvailableRequeue = ackrequeue.NeededAfter(
25+
fmt.Errorf("VPCLink not in '%s' state, cannot be modified",
26+
svcsdk.VpcLinkStatusAvailable),
27+
ackrequeue.DefaultRequeueAfterDuration,
28+
)
29+
)

pkg/resource/vpc_link/manager.go

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

pkg/resource/vpc_link/sdk.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
if latest.ko.Status.VPCLinkStatus != nil && *latest.ko.Status.VPCLinkStatus != svcsdk.VpcLinkStatusAvailable {
2+
return nil, waitForAvailableRequeue
3+
}

test/e2e/bootstrap_resources.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,24 @@
1616
"""
1717

1818
from dataclasses import dataclass
19-
from pathlib import Path
20-
from acktest.resources import read_bootstrap_config
19+
from acktest.bootstrapping import Resources
20+
from acktest.bootstrapping.iam import Role
21+
from acktest.bootstrapping.vpc import VPC
2122
from e2e import bootstrap_directory
2223

2324
@dataclass
24-
class TestBootstrapResources:
25-
AuthorizerRoleName: str
26-
AuthorizerPolicyArn: str
27-
AuthorizerRoleArn: str
28-
AuthorizerFunctionName: str
29-
AuthorizerFunctionArn: str
25+
class BootstrapResources(Resources):
26+
AuthorizerRole: Role
27+
VPC: VPC
28+
AuthorizerFunctionName: str = ""
29+
AuthorizerFunctionArn: str = ""
3030

3131

3232
_bootstrap_resources = None
3333

3434

35-
def get_bootstrap_resources(bootstrap_file_name: str = "bootstrap.yaml"):
35+
def get_bootstrap_resources(bootstrap_file_name: str = "bootstrap.pkl") -> BootstrapResources:
3636
global _bootstrap_resources
3737
if _bootstrap_resources is None:
38-
_bootstrap_resources = TestBootstrapResources(
39-
**read_bootstrap_config(bootstrap_directory, bootstrap_file_name=bootstrap_file_name),
40-
)
38+
_bootstrap_resources = BootstrapResources.deserialize(bootstrap_directory, bootstrap_file_name=bootstrap_file_name)
4139
return _bootstrap_resources

test/e2e/replacement_values.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,9 @@
3131
"INTEGRATION_ID": "integration_id",
3232
"AUTHORIZER_ID": "authorizer_id",
3333
"STAGE_NAME": "test",
34-
"STAGE_DESCRIPTION": "ack-test-stage"
34+
"STAGE_DESCRIPTION": "ack-test-stage",
35+
"VPC_LINK_RES_NAME": "ack-test",
36+
"VPC_LINK_NAME": "ack-test",
37+
"SUBNET_ID_1": "subnet-id-1",
38+
"SUBNET_ID_2": "subnet-id-2"
3539
}

0 commit comments

Comments
 (0)