Skip to content

Commit 1591d75

Browse files
authored
test(integ): fix ValidateTemplate calls by passing CustomResourceURLs (#3678)
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the Apache 2.0 License.
1 parent 2fe9ec2 commit 1591d75

File tree

2 files changed

+50
-7
lines changed

2 files changed

+50
-7
lines changed

internal/pkg/deploy/cloudformation/stack/validate_template_integration_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ func TestAutoscalingIntegration_Validate(t *testing.T) {
3838
ImageTag: imageTag,
3939
},
4040
ServiceDiscoveryEndpoint: "test.app.local",
41+
CustomResourcesURL: map[string]string{
42+
"EnvControllerFunction": "https://my-bucket.s3.us-west-2.amazonaws.com/code.zip",
43+
"DynamicDesiredCountFunction": "https://my-bucket.s3.us-west-2.amazonaws.com/code.zip",
44+
"RulePriorityFunction": "https://my-bucket.s3.us-west-2.amazonaws.com/code.zip",
45+
},
4146
},
4247
})
4348
require.NoError(t, err)
@@ -65,6 +70,9 @@ func TestScheduledJob_Validate(t *testing.T) {
6570
require.True(t, ok)
6671
serializer, err := stack.NewScheduledJob(v, envName, appName, stack.RuntimeConfig{
6772
ServiceDiscoveryEndpoint: "test.app.local",
73+
CustomResourcesURL: map[string]string{
74+
"EnvControllerFunction": "https://my-bucket.s3.us-west-2.amazonaws.com/code.zip",
75+
},
6876
})
6977

7078
tpl, err := serializer.Template()

internal/pkg/template/template_integration_test.go

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ import (
1818
)
1919

2020
func TestTemplate_ParseScheduledJob(t *testing.T) {
21+
customResources := map[string]template.S3ObjectLocation{
22+
"EnvControllerFunction": {
23+
Bucket: "my-bucket",
24+
Key: "key",
25+
},
26+
}
27+
2128
testCases := map[string]struct {
2229
opts template.WorkloadOpts
2330
}{
@@ -28,6 +35,7 @@ func TestTemplate_ParseScheduledJob(t *testing.T) {
2835
AssignPublicIP: template.EnablePublicIP,
2936
SubnetsType: template.PublicSubnetsPlacement,
3037
},
38+
CustomResources: customResources,
3139
},
3240
},
3341
"renders with timeout and no retries": {
@@ -40,6 +48,7 @@ func TestTemplate_ParseScheduledJob(t *testing.T) {
4048
SubnetsType: template.PublicSubnetsPlacement,
4149
},
4250
ServiceDiscoveryEndpoint: "test.app.local",
51+
CustomResources: customResources,
4352
},
4453
},
4554
"renders with options": {
@@ -53,6 +62,7 @@ func TestTemplate_ParseScheduledJob(t *testing.T) {
5362
SubnetsType: template.PublicSubnetsPlacement,
5463
},
5564
ServiceDiscoveryEndpoint: "test.app.local",
65+
CustomResources: customResources,
5666
},
5767
},
5868
"renders with options and addons": {
@@ -71,6 +81,7 @@ func TestTemplate_ParseScheduledJob(t *testing.T) {
7181
SubnetsType: template.PublicSubnetsPlacement,
7282
},
7383
ServiceDiscoveryEndpoint: "test.app.local",
84+
CustomResources: customResources,
7485
},
7586
},
7687
"renders with Windows platform": {
@@ -84,6 +95,7 @@ func TestTemplate_ParseScheduledJob(t *testing.T) {
8495
Arch: "x86_64",
8596
},
8697
ServiceDiscoveryEndpoint: "test.app.local",
98+
CustomResources: customResources,
8799
},
88100
},
89101
}
@@ -112,6 +124,18 @@ func TestTemplate_ParseLoadBalancedWebService(t *testing.T) {
112124
defaultHttpHealthCheck := template.HTTPHealthCheckOpts{
113125
HealthCheckPath: "/",
114126
}
127+
fakeS3Object := template.S3ObjectLocation{
128+
Bucket: "my-bucket",
129+
Key: "key",
130+
}
131+
customResources := map[string]template.S3ObjectLocation{
132+
"DynamicDesiredCountFunction": fakeS3Object,
133+
"EnvControllerFunction": fakeS3Object,
134+
"RulePriorityFunction": fakeS3Object,
135+
"NLBCustomDomainFunction": fakeS3Object,
136+
"NLBCertValidatorFunction": fakeS3Object,
137+
}
138+
115139
testCases := map[string]struct {
116140
opts template.WorkloadOpts
117141
}{
@@ -123,7 +147,8 @@ func TestTemplate_ParseLoadBalancedWebService(t *testing.T) {
123147
AssignPublicIP: template.EnablePublicIP,
124148
SubnetsType: template.PublicSubnetsPlacement,
125149
},
126-
ALBEnabled: true,
150+
ALBEnabled: true,
151+
CustomResources: customResources,
127152
},
128153
},
129154
"renders a valid grpc template by default": {
@@ -135,7 +160,8 @@ func TestTemplate_ParseLoadBalancedWebService(t *testing.T) {
135160
AssignPublicIP: template.EnablePublicIP,
136161
SubnetsType: template.PublicSubnetsPlacement,
137162
},
138-
ALBEnabled: true,
163+
ALBEnabled: true,
164+
CustomResources: customResources,
139165
},
140166
},
141167
"renders a valid template with addons with no outputs": {
@@ -150,6 +176,7 @@ func TestTemplate_ParseLoadBalancedWebService(t *testing.T) {
150176
},
151177
ServiceDiscoveryEndpoint: "test.app.local",
152178
ALBEnabled: true,
179+
CustomResources: customResources,
153180
},
154181
},
155182
"renders a valid template with addons with outputs": {
@@ -167,6 +194,7 @@ func TestTemplate_ParseLoadBalancedWebService(t *testing.T) {
167194
},
168195
ServiceDiscoveryEndpoint: "test.app.local",
169196
ALBEnabled: true,
197+
CustomResources: customResources,
170198
},
171199
},
172200
"renders a valid template with private subnet placement": {
@@ -178,6 +206,7 @@ func TestTemplate_ParseLoadBalancedWebService(t *testing.T) {
178206
},
179207
ServiceDiscoveryEndpoint: "test.app.local",
180208
ALBEnabled: true,
209+
CustomResources: customResources,
181210
},
182211
},
183212
"renders a valid template with all storage options": {
@@ -216,7 +245,8 @@ func TestTemplate_ParseLoadBalancedWebService(t *testing.T) {
216245
},
217246
},
218247
},
219-
ALBEnabled: true,
248+
ALBEnabled: true,
249+
CustomResources: customResources,
220250
},
221251
},
222252
"renders a valid template with minimal storage options": {
@@ -250,7 +280,8 @@ func TestTemplate_ParseLoadBalancedWebService(t *testing.T) {
250280
},
251281
},
252282
},
253-
ALBEnabled: true,
283+
ALBEnabled: true,
284+
CustomResources: customResources,
254285
},
255286
},
256287
"renders a valid template with ephemeral storage": {
@@ -264,7 +295,8 @@ func TestTemplate_ParseLoadBalancedWebService(t *testing.T) {
264295
Storage: &template.StorageOpts{
265296
Ephemeral: aws.Int(500),
266297
},
267-
ALBEnabled: true,
298+
ALBEnabled: true,
299+
CustomResources: customResources,
268300
},
269301
},
270302
"renders a valid template with entrypoint and command overrides": {
@@ -277,7 +309,8 @@ func TestTemplate_ParseLoadBalancedWebService(t *testing.T) {
277309
AssignPublicIP: template.EnablePublicIP,
278310
SubnetsType: template.PublicSubnetsPlacement,
279311
},
280-
ALBEnabled: true,
312+
ALBEnabled: true,
313+
CustomResources: customResources,
281314
},
282315
},
283316
"renders a valid template with additional addons parameters": {
@@ -292,7 +325,8 @@ func TestTemplate_ParseLoadBalancedWebService(t *testing.T) {
292325
DiscoveryServiceArn:
293326
Fn::GetAtt: [DiscoveryService, Arn]
294327
`,
295-
ALBEnabled: true,
328+
ALBEnabled: true,
329+
CustomResources: customResources,
296330
},
297331
},
298332
"renders a valid template with Windows platform": {
@@ -308,6 +342,7 @@ DiscoveryServiceArn:
308342
},
309343
ServiceDiscoveryEndpoint: "test.app.local",
310344
ALBEnabled: true,
345+
CustomResources: customResources,
311346
},
312347
},
313348
}

0 commit comments

Comments
 (0)