-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(rds): instance identifiers and endpoints of a Cluster are blank #14394
Changes from 1 commit
7ba3f6d
956b771
bae2b64
d9d014f
50735c3
9a83757
5d88e31
b22d926
de8419f
2e4c564
d8b37f3
d46c481
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1902,6 +1902,77 @@ describe('cluster', () => { | |
DBClusterIdentifier: clusterIdentifier, | ||
}); | ||
}); | ||
|
||
test('allows accessing instanceIdentifiers', () => { | ||
// GIVEN | ||
const stack = testStack(); | ||
const vpc = new ec2.Vpc(stack, 'VPC'); | ||
|
||
// WHEN | ||
const cluster = new DatabaseCluster(stack, 'Database', { | ||
engine: DatabaseClusterEngine.aurora({ | ||
version: AuroraEngineVersion.VER_1_22_2, | ||
}), | ||
credentials: { | ||
username: 'admin', | ||
}, | ||
instanceProps: { | ||
vpc, | ||
}, | ||
instances: 1, | ||
}); | ||
|
||
// THEN | ||
expect(cluster.instanceIdentifiers).toHaveLength(1); | ||
expect(stack.resolve(cluster.instanceIdentifiers[0])).toEqual({ | ||
Ref: 'DatabaseInstance1844F58FD', | ||
}); | ||
}); | ||
|
||
test('allows accessing instanceEndpoints', () => { | ||
// GIVEN | ||
const stack = testStack(); | ||
const vpc = new ec2.Vpc(stack, 'VPC'); | ||
|
||
// WHEN | ||
const cluster = new DatabaseCluster(stack, 'Database', { | ||
engine: DatabaseClusterEngine.aurora({ | ||
version: AuroraEngineVersion.VER_1_22_2, | ||
}), | ||
credentials: { | ||
username: 'admin', | ||
}, | ||
instanceProps: { | ||
vpc, | ||
}, | ||
instances: 1, | ||
}); | ||
|
||
// THEN | ||
expect(cluster.instanceEndpoints).toHaveLength(1); | ||
expect(stack.resolve(cluster.instanceEndpoints[0])).toEqual({ | ||
hostname: { | ||
'Fn::GetAtt': ['DatabaseInstance1844F58FD', 'Endpoint.Address'], | ||
}, | ||
port: { | ||
'Fn::GetAtt': ['DatabaseB269D8BB', 'Endpoint.Port'], | ||
}, | ||
socketAddress: { | ||
'Fn::Join': [ | ||
'', | ||
[ | ||
{ | ||
'Fn::GetAtt': ['DatabaseInstance1844F58FD', 'Endpoint.Address'], | ||
}, | ||
':', | ||
{ | ||
'Fn::GetAtt': ['DatabaseB269D8BB', 'Endpoint.Port'], | ||
}, | ||
], | ||
], | ||
}, | ||
}); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is such a small change, I'm not sure it warrants an entirely separate unit test. How about adding a new assertion to existing tests? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I now included the expectations to an existing unit test that was creating a cluster with 1 db instance. But I do feel like the existing unit tests have been pretty specific on testing just a certain functionality, so it didn't fit too naturally into any existing test in my opinion. |
||
}); | ||
|
||
test.each([ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why move these? We keep members in a specific order (public, then protected, then private). Let's keep it this way here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are actually moved to the implementing classes, so they no longer exist on the
DatabaseClusterNew
class. (diff looks almost as if they were just moved a bit down inside same class, but there's actually 200 rows in between)The reason for moving them was that I could not figure out a way to keep them readonly on the base class if we needed to set them from the implementing classes.