Skip to content

Commit

Permalink
- Can validate AtRestEncryptionEnabled in Observe tests now.
Browse files Browse the repository at this point in the history
- Revert unintentional change to SuccessfulObserveAfterCreationCompleted
- In Observe test successfulObserveAfterCreationFailed, make mock object as close to what AWS served us as possible when we encountered issue 1838.
  • Loading branch information
dee0sap committed Aug 24, 2023
1 parent 0404e79 commit d500748
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions pkg/controller/cache/managed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ func withNumNodeGroups(n int) replicationGroupModifier {
return func(r *v1beta1.ReplicationGroup) { r.Spec.ForProvider.NumNodeGroups = &n }
}

func withAtRestEncryptionEnabled(b bool) replicationGroupModifier {
return func(r *v1beta1.ReplicationGroup) { r.Spec.ForProvider.AtRestEncryptionEnabled = &b }
}

func withNumCacheClusters(n int) replicationGroupModifier {
return func(r *v1beta1.ReplicationGroup) { r.Spec.ForProvider.NumCacheClusters = &n }
}
Expand Down Expand Up @@ -231,9 +235,9 @@ func TestObserve(t *testing.T) {
*p = t
return p
}
// var makeArn = func(id string) *string {
// return makeStringPtr("arn:aws:elasticache:eu-central-1:976748029054:replicationgroup:" + id)
// }
var makeArn = func(id string) *string {
return makeStringPtr("arn:aws:elasticache:eu-central-1:1001001ESOES:replicationgroup:" + id)
}
var makeDescription = func(id string) *string {
return makeStringPtr("Redis Group:" + id)
}
Expand Down Expand Up @@ -318,7 +322,6 @@ func TestObserve(t *testing.T) {
withReplicationGroupID(name),
withConditions(xpv1.Creating()),
withClusterEnabled(true),
withNumNodeGroups(2),
),
want: replicationGroup(
withReplicationGroupID(name),
Expand All @@ -336,9 +339,9 @@ func TestObserve(t *testing.T) {
MockDescribeReplicationGroups: func(ctx context.Context, _ *elasticache.DescribeReplicationGroupsInput, opts []func(*elasticache.Options)) (*elasticache.DescribeReplicationGroupsOutput, error) {
return &elasticache.DescribeReplicationGroupsOutput{
ReplicationGroups: []types.ReplicationGroup{{
// ARN: makeArn(successfulObserveAfterCreationFailed),
// AtRestEncryptionEnabled: makeBoolPtr(true),
// AuthTokenEnabled: makeBoolPtr(true),
ARN: makeArn(successfulObserveAfterCreationFailed),
AtRestEncryptionEnabled: makeBoolPtr(true),
AuthTokenEnabled: makeBoolPtr(true),
AutomaticFailover: types.AutomaticFailoverStatusEnabled,
AuthTokenLastModifiedDate: makeTimePtr(time.Date(2023, 6, 15, 12, 21, 05, 0, time.UTC)),
DataTiering: types.DataTieringStatusDisabled,
Expand Down Expand Up @@ -368,6 +371,8 @@ func TestObserve(t *testing.T) {
withConditions(xpv1.Creating()),
withClusterEnabled(true),
withNumNodeGroups(2),
withAtRestEncryptionEnabled(true),
withAuthEnabled(true),
),
want: replicationGroup(
withReplicationGroupID(name),
Expand All @@ -379,6 +384,8 @@ func TestObserve(t *testing.T) {
{NodeGroupID: "0001", Status: v1beta1.StatusCreateFailed},
{NodeGroupID: "0002", Status: v1beta1.StatusCreateFailed},
}),
withAtRestEncryptionEnabled(true),
withAuthEnabled(true),
),
tokenCreated: false,
},
Expand Down Expand Up @@ -488,9 +495,6 @@ func TestObserve(t *testing.T) {
}

for _, tc := range cases {
if tc.name != "SuccessfulObserveAfterCreationFailed" {
continue
}
t.Run(tc.name, func(t *testing.T) {
observation, err := tc.e.Observe(ctx, tc.r)
if tc.returnsErr != (err != nil) {
Expand Down

0 comments on commit d500748

Please sign in to comment.