Skip to content

Commit a8a4416

Browse files
committed
Use DNS delegated
1 parent 2f7c620 commit a8a4416

File tree

2 files changed

+40
-56
lines changed

2 files changed

+40
-56
lines changed

test/component_test.go

Lines changed: 31 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -54,33 +54,12 @@ func TestComponent(t *testing.T) {
5454

5555
// Setup phase: Create DNS zones for testing
5656
suite.Setup(t, func(t *testing.T, atm *helper.Atmos) {
57-
randomID := suite.GetRandomIdentifier()
58-
domainName := fmt.Sprintf("example-%s.net", randomID)
59-
60-
// Deploy the primary DNS zone
61-
inputs := map[string]interface{}{
62-
"domain_names": []string{domainName},
63-
}
64-
65-
primaryDnsComponent := helper.NewAtmosComponent("dns-primary", "default-test", inputs)
66-
atm.Deploy(primaryDnsComponent)
67-
68-
primaryZones := map[string]zone{}
69-
atm.OutputStruct(primaryDnsComponent, "zones", &primaryZones)
70-
71-
primaryDomains := make([]string, 0, len(primaryZones))
72-
for k := range primaryZones {
73-
primaryDomains = append(primaryDomains, k)
74-
}
75-
76-
primaryDomainName := primaryDomains[0]
77-
7857
// Deploy the delegated DNS zone
79-
inputs = map[string]interface{}{
58+
inputs := map[string]interface{}{
8059
"zone_config": []map[string]interface{}{
8160
{
82-
"subdomain": randomID,
83-
"zone_name": primaryDomainName,
61+
"subdomain": suite.GetRandomIdentifier(),
62+
"zone_name": "components.cptest.test-automation.app",
8463
},
8564
},
8665
}
@@ -89,31 +68,16 @@ func TestComponent(t *testing.T) {
8968

9069
// Teardown phase: Destroy the DNS zones created during setup
9170
suite.TearDown(t, func(t *testing.T, atm *helper.Atmos) {
92-
dnsPrimaryComponent := helper.NewAtmosComponent("dns-primary", "default-test", map[string]interface{}{})
93-
94-
primaryZones := map[string]zone{}
95-
atm.OutputStruct(dnsPrimaryComponent, "zones", &primaryZones)
96-
97-
primaryDomains := make([]string, 0, len(primaryZones))
98-
for k := range primaryZones {
99-
primaryDomains = append(primaryDomains, k)
100-
}
101-
102-
primaryDomainName := primaryDomains[0]
103-
104-
randomID := suite.GetRandomIdentifier()
105-
71+
// Deploy the delegated DNS zone
10672
inputs := map[string]interface{}{
10773
"zone_config": []map[string]interface{}{
10874
{
109-
"subdomain": randomID,
110-
"zone_name": primaryDomainName,
75+
"subdomain": suite.GetRandomIdentifier(),
76+
"zone_name": "components.cptest.test-automation.app",
11177
},
11278
},
11379
}
114-
115-
atm.GetAndDestroy("dns-delegated", "default-test", inputs)
116-
atm.GetAndDestroy("dns-primary", "default-test", map[string]interface{}{})
80+
atm.GetAndDeploy("dns-delegated", "default-test", inputs)
11781
})
11882

11983
// Test phase: Validate the functionality of the ALB component
@@ -194,6 +158,12 @@ func TestComponent(t *testing.T) {
194158

195159
schemaExistsInRdsInstance := aws.GetWhetherSchemaExistsInRdsPostgresInstance(t, dbUrl, int32(dbPort), adminUsername, adminUserPassword, databaseName)
196160
assert.True(t, schemaExistsInRdsInstance)
161+
162+
schemaExistsInRdsInstance = aws.GetWhetherSchemaExistsInRdsPostgresInstance(t, masterHostname, int32(dbPort), adminUsername, adminUserPassword, databaseName)
163+
assert.True(t, schemaExistsInRdsInstance)
164+
165+
schemaExistsInRdsInstance = aws.GetWhetherSchemaExistsInRdsPostgresInstance(t, replicasHostname, int32(dbPort), adminUsername, adminUserPassword, databaseName)
166+
assert.True(t, schemaExistsInRdsInstance)
197167
})
198168

199169
// Test phase: Validate the functionality of the ALB component
@@ -232,7 +202,7 @@ func TestComponent(t *testing.T) {
232202
assert.Equal(t, expectedMasterHostname, masterHostname)
233203

234204
ssmKeyPaths := atm.OutputList(component, "ssm_key_paths")
235-
assert.Equal(t, 6, len(ssmKeyPaths))
205+
assert.Equal(t, 7, len(ssmKeyPaths))
236206

237207
kmsKeyArn := atm.Output(component, "kms_key_arn")
238208
assert.NotEmpty(t, kmsKeyArn)
@@ -253,6 +223,23 @@ func TestComponent(t *testing.T) {
253223

254224
masterHostnameDNSRecord := aws.GetRoute53Record(t, delegatedDomainNZoneId, masterHostname, "CNAME", awsRegion)
255225
assert.Equal(t, *masterHostnameDNSRecord.ResourceRecords[0].Value, configMap["endpoint"])
226+
227+
passwordSSMKey, ok := configMap["password_ssm_key"].(string)
228+
assert.True(t, ok, "password_ssm_key should be a string")
229+
230+
adminUserPassword := aws.GetParameter(t, awsRegion, passwordSSMKey)
231+
232+
dbUrl, ok := configMap["endpoint"].(string)
233+
assert.True(t, ok, "endpoint should be a string")
234+
235+
dbPort, ok := inputs["database_port"].(int)
236+
assert.True(t, ok, "database_port should be an int")
237+
238+
schemaExistsInRdsInstance := aws.GetWhetherSchemaExistsInRdsPostgresInstance(t, dbUrl, int32(dbPort), adminUsername, adminUserPassword, databaseName)
239+
assert.True(t, schemaExistsInRdsInstance)
240+
241+
schemaExistsInRdsInstance = aws.GetWhetherSchemaExistsInRdsPostgresInstance(t, masterHostname, int32(dbPort), adminUsername, adminUserPassword, databaseName)
242+
assert.True(t, schemaExistsInRdsInstance)
256243
})
257244
})
258245
}

test/fixtures/stacks/catalog/usecase/serverless.yaml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,16 @@ components:
1717

1818
dns_gbl_delegated_environment_name: "ue2"
1919

20-
# Serverless v1 configuration
21-
engine_mode: serverless
22-
instance_type: "" # serverless engine_mode ignores `var.instance_type`
23-
engine_version: "13.12" # Latest supported version as of 08/28/2023
20+
# Serverless v2 configuration
21+
engine_mode: provisioned
22+
instance_type: "db.serverless" # serverless engine_mode ignores `var.instance_type`
23+
engine_version: "13.15" # Latest supported version as of 08/28/2023
2424
cluster_family: aurora-postgresql13
25-
cluster_size: 0 # serverless
26-
scaling_configuration:
27-
- auto_pause: true
28-
max_capacity: 4
29-
min_capacity: 2
30-
seconds_until_auto_pause: 300
31-
timeout_action: null
32-
25+
cluster_size: 1
26+
# serverless
27+
serverlessv2_scaling_configuration:
28+
min_capacity: 2
29+
max_capacity: 4
3330
admin_user: postgres
3431
admin_password: "" # generate random password
3532
database_name: postgres

0 commit comments

Comments
 (0)